Skip to content

Commit

Permalink
validate models
Browse files Browse the repository at this point in the history
  • Loading branch information
djova committed May 17, 2021
1 parent 99737c8 commit 68a7eca
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tls/datadog_checks/tls/config_models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def instance_seconds_warning(field, value):
return get_default_field_value(field, value)


def instance_send_cert_duration(field, value):
return False


def instance_server_hostname(field, value):
return get_default_field_value(field, value)

Expand Down
1 change: 1 addition & 0 deletions tls/datadog_checks/tls/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Config:
port: Optional[int]
seconds_critical: Optional[int]
seconds_warning: Optional[int]
send_cert_duration: Optional[bool]
server: str
server_hostname: Optional[str]
service: Optional[str]
Expand Down
8 changes: 8 additions & 0 deletions vsphere/datadog_checks/vsphere/config_models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from datadog_checks.base.utils.models.fields import get_default_field_value


def shared_rest_api_options(field, value):
return get_default_field_value(field, value)


def shared_service(field, value):
return get_default_field_value(field, value)

Expand Down Expand Up @@ -84,6 +88,10 @@ def instance_resource_filters(field, value):
return get_default_field_value(field, value)


def instance_rest_api_options(field, value):
return get_default_field_value(field, value)


def instance_service(field, value):
return get_default_field_value(field, value)

Expand Down
57 changes: 56 additions & 1 deletion vsphere/datadog_checks/vsphere/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from __future__ import annotations

from typing import Optional, Sequence
from typing import Any, Mapping, Optional, Sequence

from pydantic import BaseModel, root_validator, validator

Expand Down Expand Up @@ -44,6 +44,60 @@ class Config:
type: Optional[str]


class AuthToken(BaseModel):
class Config:
allow_mutation = False

reader: Optional[Mapping[str, Any]]
writer: Optional[Mapping[str, Any]]


class Proxy(BaseModel):
class Config:
allow_mutation = False

http: Optional[str]
https: Optional[str]
no_proxy: Optional[Sequence[str]]


class RestApiOptions(BaseModel):
class Config:
allow_mutation = False

auth_token: Optional[AuthToken]
auth_type: Optional[str]
aws_host: Optional[str]
aws_region: Optional[str]
aws_service: Optional[str]
connect_timeout: Optional[float]
extra_headers: Optional[Mapping[str, Any]]
headers: Optional[Mapping[str, Any]]
kerberos_auth: Optional[str]
kerberos_cache: Optional[str]
kerberos_delegate: Optional[bool]
kerberos_force_initiate: Optional[bool]
kerberos_hostname: Optional[str]
kerberos_keytab: Optional[str]
kerberos_principal: Optional[str]
log_requests: Optional[bool]
ntlm_domain: Optional[str]
password: Optional[str]
persist_connections: Optional[bool]
proxy: Optional[Proxy]
read_timeout: Optional[float]
skip_proxy: Optional[bool]
timeout: Optional[float]
tls_ca_cert: Optional[str]
tls_cert: Optional[str]
tls_ignore_warning: Optional[bool]
tls_private_key: Optional[str]
tls_use_host_header: Optional[bool]
tls_verify: Optional[bool]
use_legacy_auth_encoding: Optional[bool]
username: Optional[str]


class InstanceConfig(BaseModel):
class Config:
allow_mutation = False
Expand All @@ -70,6 +124,7 @@ class Config:
refresh_infrastructure_cache_interval: Optional[int]
refresh_metrics_metadata_cache_interval: Optional[int]
resource_filters: Optional[Sequence[ResourceFilter]]
rest_api_options: Optional[RestApiOptions]
service: Optional[str]
ssl_capath: Optional[str]
ssl_verify: Optional[bool]
Expand Down
21 changes: 20 additions & 1 deletion vsphere/datadog_checks/vsphere/config_models/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from __future__ import annotations

from typing import Optional
from typing import Optional, Sequence

from pydantic import BaseModel, root_validator, validator

Expand All @@ -13,10 +13,29 @@
from . import defaults, validators


class Proxy(BaseModel):
class Config:
allow_mutation = False

http: Optional[str]
https: Optional[str]
no_proxy: Optional[Sequence[str]]


class RestApiOptions(BaseModel):
class Config:
allow_mutation = False

proxy: Optional[Proxy]
skip_proxy: Optional[bool]
timeout: Optional[float]


class SharedConfig(BaseModel):
class Config:
allow_mutation = False

rest_api_options: Optional[RestApiOptions]
service: Optional[str]

@root_validator(pre=True)
Expand Down

0 comments on commit 68a7eca

Please sign in to comment.