Skip to content

Commit 7cff7a0

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Mark hosts response version fields as nullable (#1261)
* handle nested nullable items * Regenerate client from commit 37d94b14 of spec repo Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent e59f2c0 commit 7cff7a0

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2022-12-19 10:28:53.334299",
8-
"spec_repo_commit": "45a3d9c9"
7+
"regenerated": "2022-12-19 15:44:19.631812",
8+
"spec_repo_commit": "37d94b14"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2022-12-19 10:28:53.345908",
13-
"spec_repo_commit": "45a3d9c9"
12+
"regenerated": "2022-12-19 15:44:19.647393",
13+
"spec_repo_commit": "37d94b14"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,6 +3419,7 @@ components:
34193419
items:
34203420
description: The version name.
34213421
example: FreeBSD
3422+
nullable: true
34223423
type: string
34233424
type: array
34243425
gohai:
@@ -3434,6 +3435,7 @@ components:
34343435
items:
34353436
description: Version name.
34363437
example: Mac
3438+
nullable: true
34373439
type: string
34383440
type: array
34393441
machine:
@@ -3445,6 +3447,7 @@ components:
34453447
items:
34463448
description: Version name.
34473449
example: Ubuntu
3450+
nullable: true
34483451
type: string
34493452
type: array
34503453
platform:
@@ -3472,6 +3475,7 @@ components:
34723475
items:
34733476
description: Version name.
34743477
example: Windows
3478+
nullable: true
34753479
type: string
34763480
type: array
34773481
type: object

.generator/src/generator/openapi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def type_to_python_helper(type_, schema, alternative_name=None, in_list=False):
3737
elif type_ == "boolean":
3838
return "bool"
3939
elif type_ == "array":
40-
return "[{}]".format(type_to_python(schema["items"], in_list=True))
40+
subtype = type_to_python(schema["items"], in_list=True)
41+
if schema["items"].get("nullable"):
42+
subtype += ", none_type"
43+
return "[{}]".format(subtype)
4144
elif type_ == "object":
4245
if "additionalProperties" in schema:
4346
nested_schema = schema["additionalProperties"]

src/datadog_api_client/v1/model/host_meta.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from datadog_api_client.model_utils import (
99
ModelNormal,
1010
cached_property,
11+
none_type,
1112
unset,
1213
UnsetType,
1314
)
@@ -28,18 +29,18 @@ def openapi_types(_):
2829
"agent_checks": ([AgentCheck],),
2930
"agent_version": (str,),
3031
"cpu_cores": (int,),
31-
"fbsd_v": ([str],),
32+
"fbsd_v": ([str, none_type],),
3233
"gohai": (str,),
3334
"install_method": (HostMetaInstallMethod,),
34-
"mac_v": ([str],),
35+
"mac_v": ([str, none_type],),
3536
"machine": (str,),
36-
"nix_v": ([str],),
37+
"nix_v": ([str, none_type],),
3738
"platform": (str,),
3839
"processor": (str,),
3940
"python_v": (str,),
4041
"socket_fqdn": (str,),
4142
"socket_hostname": (str,),
42-
"win_v": ([str],),
43+
"win_v": ([str, none_type],),
4344
}
4445

4546
attribute_map = {
@@ -92,7 +93,7 @@ def __init__(
9293
:type cpu_cores: int, optional
9394
9495
:param fbsd_v: An array of Mac versions.
95-
:type fbsd_v: [str], optional
96+
:type fbsd_v: [str, none_type], optional
9697
9798
:param gohai: JSON string containing system information.
9899
:type gohai: str, optional
@@ -101,13 +102,13 @@ def __init__(
101102
:type install_method: HostMetaInstallMethod, optional
102103
103104
:param mac_v: An array of Mac versions.
104-
:type mac_v: [str], optional
105+
:type mac_v: [str, none_type], optional
105106
106107
:param machine: The machine architecture.
107108
:type machine: str, optional
108109
109110
:param nix_v: Array of Unix versions.
110-
:type nix_v: [str], optional
111+
:type nix_v: [str, none_type], optional
111112
112113
:param platform: The OS platform.
113114
:type platform: str, optional
@@ -125,7 +126,7 @@ def __init__(
125126
:type socket_hostname: str, optional
126127
127128
:param win_v: An array of Windows versions.
128-
:type win_v: [str], optional
129+
:type win_v: [str, none_type], optional
129130
"""
130131
if agent_checks is not unset:
131132
kwargs["agent_checks"] = agent_checks

src/datadog_api_client/v1/model/metrics_query_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def openapi_types(_):
4545
"scope": (str,),
4646
"start": (int,),
4747
"tag_set": ([str],),
48-
"unit": ([MetricsQueryUnit],),
48+
"unit": ([MetricsQueryUnit, none_type],),
4949
}
5050

5151
attribute_map = {
@@ -138,7 +138,7 @@ def __init__(
138138
:param unit: Detailed information about the metric unit.
139139
First element describes the "primary unit" (for example, ``bytes`` in ``bytes per second`` ),
140140
second describes the "per unit" (for example, ``second`` in ``bytes per second`` ).
141-
:type unit: [MetricsQueryUnit], optional
141+
:type unit: [MetricsQueryUnit, none_type], optional
142142
"""
143143
if aggr is not unset:
144144
kwargs["aggr"] = aggr

src/datadog_api_client/v1/model/slo_history_metrics_series_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def openapi_types(_):
3131
"metric": (str,),
3232
"query_index": (int,),
3333
"scope": (str,),
34-
"unit": ([SLOHistoryMetricsSeriesMetadataUnit], none_type),
34+
"unit": ([SLOHistoryMetricsSeriesMetadataUnit, none_type], none_type),
3535
}
3636

3737
attribute_map = {
@@ -74,7 +74,7 @@ def __init__(
7474
:param unit: An array of metric units that contains up to two unit objects.
7575
For example, bytes represents one unit object and bytes per second represents two unit objects.
7676
If a metric query only has one unit object, the second array element is null.
77-
:type unit: [SLOHistoryMetricsSeriesMetadataUnit], none_type, optional
77+
:type unit: [SLOHistoryMetricsSeriesMetadataUnit, none_type], none_type, optional
7878
"""
7979
if aggr is not unset:
8080
kwargs["aggr"] = aggr

tests/v1/cassettes/test_scenarios/test_get_all_hosts_with_metadata_deserializes_successfully.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interactions:
88
uri: https://api.datadoghq.com/api/v1/hosts?include_hosts_metadata=true
99
response:
1010
body:
11-
string: '{"exact_total_matching":true,"total_returned":1,"host_list":[{"last_reported_time":1640288946,"name":"vagrant","is_muted":false,"mute_timeout":null,"apps":["ntp","agent"],"tags_by_source":{"Datadog":["host:vagrant"]},"up":true,"metrics":{"load":0.031666666,"iowait":0.0434962,"cpu":0.6632819},"sources":["agent"],"meta":{"socket-hostname":"vagrant","nixV":["ubuntu","18.04",""],"pythonV":"3.8.11","macV":["","",""],"cpuCores":1,"agent_flavor":"agent","platform":"linux","timezones":["UTC"],"winV":["","",""],"machine":"amd64","install_method":{"tool":"install_script","installer_version":"install_script-1.7.1","tool_version":"install_script"},"fbsdV":["","",""],"gohai":"{\"cpu\":{\"cache_size\":\"8192
11+
string: '{"exact_total_matching":true,"total_returned":1,"host_list":[{"last_reported_time":1640288946,"name":"vagrant","is_muted":false,"mute_timeout":null,"apps":["ntp","agent"],"tags_by_source":{"Datadog":["host:vagrant"]},"up":true,"metrics":{"load":0.031666666,"iowait":0.0434962,"cpu":0.6632819},"sources":["agent"],"meta":{"socket-hostname":"vagrant","nixV":["ubuntu","18.04",""],"pythonV":"3.8.11","macV":["","",""],"cpuCores":1,"agent_flavor":"agent","platform":"linux","timezones":["UTC"],"winV":[null,null,null],"machine":"amd64","install_method":{"tool":"install_script","installer_version":"install_script-1.7.1","tool_version":"install_script"},"fbsdV":["","",""],"gohai":"{\"cpu\":{\"cache_size\":\"8192
1212
KB\",\"cpu_cores\":\"1\",\"cpu_logical_processors\":\"1\",\"family\":\"6\",\"mhz\":\"2711.998\",\"model\":\"142\",\"model_name\":\"Intel(R)
1313
Core(TM) i7-8559U CPU @ 2.70GHz\",\"stepping\":\"10\",\"vendor_id\":\"GenuineIntel\"},\"filesystem\":[{\"kb_size\":\"3966892\",\"mounted_on\":\"/dev\",\"name\":\"udev\"},{\"kb_size\":\"797396\",\"mounted_on\":\"/run\",\"name\":\"tmpfs\"},{\"kb_size\":\"64800356\",\"mounted_on\":\"/\",\"name\":\"/dev/mapper/vagrant--vg-root\"},{\"kb_size\":\"3986968\",\"mounted_on\":\"/dev/shm\",\"name\":\"tmpfs\"},{\"kb_size\":\"5120\",\"mounted_on\":\"/run/lock\",\"name\":\"tmpfs\"},{\"kb_size\":\"3986968\",\"mounted_on\":\"/sys/fs/cgroup\",\"name\":\"tmpfs\"},{\"kb_size\":\"488245288\",\"mounted_on\":\"/vagrant\",\"name\":\"/vagrant\"},{\"kb_size\":\"797392\",\"mounted_on\":\"/run/user/1000\",\"name\":\"tmpfs\"}],\"memory\":{\"swap_total\":\"1003516kB\",\"total\":\"7973940kB\"},\"network\":{\"interfaces\":[{\"ipv4\":\"10.0.2.15\",\"ipv4-network\":\"10.0.2.0/24\",\"ipv6\":\"fe80::a00:27ff:fec2:be11\",\"ipv6-network\":\"fe80::/64\",\"macaddress\":\"08:00:27:c2:be:11\",\"name\":\"eth0\"},{\"ipv4\":\"192.168.122.1\",\"ipv4-network\":\"192.168.122.0/24\",\"macaddress\":\"52:54:00:6f:1c:bf\",\"name\":\"virbr0\"}],\"ipaddress\":\"10.0.2.15\",\"ipaddressv6\":\"fe80::a00:27ff:fec2:be11\",\"macaddress\":\"08:00:27:c2:be:11\"},\"platform\":{\"GOOARCH\":\"amd64\",\"GOOS\":\"linux\",\"goV\":\"1.16.7\",\"hardware_platform\":\"x86_64\",\"hostname\":\"vagrant\",\"kernel_name\":\"Linux\",\"kernel_release\":\"4.15.0-29-generic\",\"kernel_version\":\"#31-Ubuntu
1414
SMP Tue Jul 17 15:39:52 UTC 2018\",\"machine\":\"x86_64\",\"os\":\"GNU/Linux\",\"processor\":\"x86_64\",\"pythonV\":\"2.7.15rc1\"}}","network":null,"logs_agent":{"transport":""},"host_id":1036078308,"agent_version":"7.32.3","processor":"Intel(R)

0 commit comments

Comments
 (0)