Skip to content

Commit ca49e00

Browse files
api-clients-generation-pipeline[bot]therveci.datadog-api-spec
authored
Handle null in query metrics unit (#486)
* Handle None in model_to_dict * Update cassettes * Regenerate client from commit 3efd10d of spec repo Co-authored-by: Thomas Hervé <[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 7950ece commit ca49e00

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
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.4.1.dev8",
7-
"regenerated": "2021-06-17 09:50:27.972538",
8-
"spec_repo_commit": "4951cff"
7+
"regenerated": "2021-06-17 12:46:48.192991",
8+
"spec_repo_commit": "3efd10d"
99
},
1010
"v2": {
1111
"apigentools_version": "1.4.1.dev8",
12-
"regenerated": "2021-06-17 09:50:52.322016",
13-
"spec_repo_commit": "4951cff"
12+
"regenerated": "2021-06-17 12:47:17.170607",
13+
"spec_repo_commit": "3efd10d"
1414
}
1515
}
1616
}

.generator/templates/model_utils.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ def model_to_dict(model_instance, serialize=True):
12251225
elif isinstance(value[0], ModelSimple):
12261226
result[attr] = [x.value for x in value]
12271227
else:
1228-
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
1228+
result[attr] = [model_to_dict(x, serialize=serialize) if x is not None else None for x in value]
12291229
elif isinstance(value, dict):
12301230
result[attr] = dict(map(
12311231
lambda item: (item[0],

src/datadog_api_client/v1/model/metrics_query_unit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class MetricsQueryUnit(ModelNormal):
5252

5353
additional_properties_type = None
5454

55-
_nullable = False
55+
_nullable = True
5656

5757
@cached_property
5858
def openapi_types():

src/datadog_api_client/v1/model_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ def model_to_dict(model_instance, serialize=True):
14171417
elif isinstance(value[0], ModelSimple):
14181418
result[attr] = [x.value for x in value]
14191419
else:
1420-
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
1420+
result[attr] = [model_to_dict(x, serialize=serialize) if x is not None else None for x in value]
14211421
elif isinstance(value, dict):
14221422
result[attr] = dict(
14231423
map(

src/datadog_api_client/v1/openapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,6 +4816,7 @@ components:
48164816
MetricsQueryUnit:
48174817
description: Object containing the metric unit family, scale factor, name, and
48184818
short name.
4819+
nullable: true
48194820
properties:
48204821
family:
48214822
description: Unit family, allows for conversion between units of the same

src/datadog_api_client/v2/model_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ def model_to_dict(model_instance, serialize=True):
14171417
elif isinstance(value[0], ModelSimple):
14181418
result[attr] = [x.value for x in value]
14191419
else:
1420-
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
1420+
result[attr] = [model_to_dict(x, serialize=serialize) if x is not None else None for x in value]
14211421
elif isinstance(value, dict):
14221422
result[attr] = dict(
14231423
map(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2021-04-23T10:02:02.688685+02:00
1+
2021-06-17T14:40:01.472790+02:00

tests/v1/cassettes/test_scenarios/test_submit_metrics_returns_payload_accepted_response.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
interactions:
22
- request:
3-
body: '{"series": [{"metric": "system.load.1", "type": "gauge", "points": [[1600348600,
4-
1.1]], "tags": ["test:TestSubmitmetricsreturnsPayloadacceptedresponse1619164922"]}]}'
3+
body: '{"series": [{"metric": "system.load.1", "type": "gauge", "points": [[1623933601,
4+
1.1]], "tags": ["test:TestSubmitmetricsreturnsPayloadacceptedresponse1623933601"]}]}'
55
headers:
66
Accept:
77
- application/json
@@ -10,7 +10,7 @@ interactions:
1010
Dd-Operation-Id:
1111
- SubmitMetrics
1212
User-Agent:
13-
- datadog-api-client-python/1.0.0b9.dev1+dirty (python 3.8.8; os Darwin; arch
13+
- datadog-api-client-python/1.1.1.dev7+dirty (python 3.8.10; os Darwin; arch
1414
x86_64)
1515
method: POST
1616
uri: https://api.datadoghq.com/api/v1/series
@@ -25,7 +25,7 @@ interactions:
2525
Content-Type:
2626
- text/json
2727
Date:
28-
- Fri, 23 Apr 2021 08:02:03 GMT
28+
- Thu, 17 Jun 2021 12:40:02 GMT
2929
content-security-policy:
3030
- frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report
3131
strict-transport-security:

tests/v1/features/metrics.feature

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,13 @@ Feature: Metrics
7777
When the request is sent
7878
Then the response status is 400 Bad Request
7979

80-
@generated @skip
80+
@skip-python
8181
Scenario: Query timeseries points returns "OK" response
8282
Given a valid "appKeyAuth" key in the system
8383
And new "QueryMetrics" request
84+
And request contains "from" parameter with value {{ timestamp("now - 1d") }}
85+
And request contains "to" parameter with value {{ timestamp("now") }}
86+
And request contains "query" parameter with value "system.cpu.idle{*}"
8487
When the request is sent
8588
Then the response status is 200 OK
8689

@@ -107,7 +110,7 @@ Feature: Metrics
107110

108111
Scenario: Submit metrics returns "Payload accepted" response
109112
Given new "SubmitMetrics" request
110-
And body with value {"series": [{"metric": "system.load.1", "type": "gauge", "points": [[1600348600, 1.1]], "tags": ["test:{{ unique_alnum }}"]}]}
113+
And body with value {"series": [{"metric": "system.load.1", "type": "gauge", "points": [[{{ timestamp("now") }}, 1.1]], "tags": ["test:{{ unique_alnum }}"]}]}
111114
When the request is sent
112115
Then the response status is 202 Payload accepted
113116

0 commit comments

Comments
 (0)