Skip to content

Commit dce1052

Browse files
api-clients-generation-pipeline[bot]fpighici.datadog-api-spec
authored
Fix DORA deployment and incident read responses to use date-time timestamps (#3746)
* tests: match request bodies with equivalent datetime timezone notations The Python client serializes tz-aware datetimes via datetime.isoformat(), producing a "+00:00" UTC offset, while recorded cassettes use "Z". Both denote the same instant, but the VCR replay body matcher compared them as differing strings, so replay-only scenarios that send a datetime in the request body (e.g. DORA ListDORADeployments) fail to match their cassette. The matcher also only recognized "text/json", so "application/json" bodies skipped JSON-aware comparison entirely and fell back to a raw byte compare. * Regenerate client from commit dcda436 of spec repo --------- Co-authored-by: Francesco Pighi <francesco.pighi@datadoghq.com> Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d4e3e28 commit dce1052

8 files changed

Lines changed: 137 additions & 60 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28815,12 +28815,12 @@ components:
2881528815
- "department:engineering"
2881628816
- "region:us-east-1"
2881728817
env: "production"
28818-
finished_at: 1693491984000000000
28818+
finished_at: "2023-08-31T14:26:24Z"
2881928819
git:
2882028820
commit_sha: "66adc9350f2cc9b250b69abddab733dd55e1a588"
2882128821
repository_id: "github.com/organization/example-repository"
2882228822
service: "shopist"
28823-
started_at: 1693491974000000000
28823+
started_at: "2023-08-31T14:26:14Z"
2882428824
team: "backend"
2882528825
version: "v1.12.07"
2882628826
id: "4242fcdd31586083"
@@ -28844,21 +28844,21 @@ components:
2884428844
example: production
2884528845
type: string
2884628846
finished_at:
28847-
description: Unix timestamp when the deployment finished.
28848-
example: 1693491984000000000
28849-
format: int64
28850-
type: integer
28847+
description: The time when the deployment finished.
28848+
example: "2023-08-31T14:26:24Z"
28849+
format: date-time
28850+
type: string
2885128851
git:
2885228852
$ref: "#/components/schemas/DORAGitInfoResponse"
2885328853
service:
2885428854
description: Service name.
2885528855
example: shopist
2885628856
type: string
2885728857
started_at:
28858-
description: Unix timestamp when the deployment started.
28859-
example: 1693491974000000000
28860-
format: int64
28861-
type: integer
28858+
description: The time when the deployment started.
28859+
example: "2023-08-31T14:26:14Z"
28860+
format: date-time
28861+
type: string
2886228862
team:
2886328863
description: Name of the team owning the deployed service.
2886428864
example: backend
@@ -28870,7 +28870,6 @@ components:
2887028870
required:
2887128871
- service
2887228872
- started_at
28873-
- finished_at
2887428873
type: object
2887528874
DORADeploymentPatchRemediation:
2887628875
description: Remediation details for the deployment. Optional, but required to calculate failed deployment recovery time.
@@ -29048,12 +29047,12 @@ components:
2904829047
- "department:engineering"
2904929048
- "region:us-east-1"
2905029049
env: "production"
29051-
finished_at: 1693491984000000000
29050+
finished_at: "2023-08-31T14:26:24Z"
2905229051
git:
2905329052
commit_sha: "66adc9350f2cc9b250b69abddab733dd55e1a588"
2905429053
repository_id: "github.com/organization/example-repository"
2905529054
service: "shopist"
29056-
started_at: 1693491974000000000
29055+
started_at: "2023-08-31T14:26:14Z"
2905729056
team: "backend"
2905829057
version: "v1.12.07"
2905929058
id: "4242fcdd31586083"
@@ -29063,12 +29062,12 @@ components:
2906329062
- "language:go"
2906429063
- "department:platform"
2906529064
env: "production"
29066-
finished_at: 1693492084000000000
29065+
finished_at: "2023-08-31T14:28:04Z"
2906729066
git:
2906829067
commit_sha: "77bdc9350f2cc9b250b69abddab733dd55e1a599"
2906929068
repository_id: "github.com/organization/api-service"
2907029069
service: "api-service"
29071-
started_at: 1693492074000000000
29070+
started_at: "2023-08-31T14:27:54Z"
2907229071
team: "backend"
2907329072
version: "v2.1.0"
2907429073
id: "4242fcdd31586084"
@@ -29190,12 +29189,12 @@ components:
2919029189
- "incident_type:database"
2919129190
- "department:engineering"
2919229191
env: "production"
29193-
finished_at: 1693492274000000000
29192+
finished_at: "2023-08-31T14:31:14Z"
2919429193
name: "Database outage"
2919529194
services:
2919629195
- "shopist"
2919729196
severity: "SEV-1"
29198-
started_at: 1693492174000000000
29197+
started_at: "2023-08-31T14:29:34Z"
2919929198
team: "backend"
2920029199
id: "4242fcdd31586085"
2920129200
type: "dora_incident"
@@ -29204,13 +29203,13 @@ components:
2920429203
- "incident_type:service_down"
2920529204
- "department:platform"
2920629205
env: "production"
29207-
finished_at: 1693492474000000000
29206+
finished_at: "2023-08-31T14:34:34Z"
2920829207
name: "API service outage"
2920929208
services:
2921029209
- "api-service"
2921129210
- "payment-service"
2921229211
severity: "SEV-2"
29213-
started_at: 1693492374000000000
29212+
started_at: "2023-08-31T14:32:54Z"
2921429213
team: "backend"
2921529214
id: "4242fcdd31586086"
2921629215
type: "dora_incident"
@@ -29251,15 +29250,15 @@ components:
2925129250
- "incident_type:database"
2925229251
- "department:engineering"
2925329252
env: "production"
29254-
finished_at: 1693492274000000000
29253+
finished_at: "2023-08-31T14:31:14Z"
2925529254
git:
2925629255
commit_sha: "66adc9350f2cc9b250b69abddab733dd55e1a588"
2925729256
repository_url: "https://github.com/organization/example-repository"
2925829257
name: "Database outage"
2925929258
services:
2926029259
- "shopist"
2926129260
severity: "SEV-1"
29262-
started_at: 1693492174000000000
29261+
started_at: "2023-08-31T14:29:34Z"
2926329262
team: "backend"
2926429263
id: "4242fcdd31586085"
2926529264
type: "dora_incident"
@@ -29282,10 +29281,10 @@ components:
2928229281
example: production
2928329282
type: string
2928429283
finished_at:
29285-
description: Unix timestamp when the incident finished.
29286-
example: 1693491984000000000
29287-
format: int64
29288-
type: integer
29284+
description: The time when the incident finished.
29285+
example: "2023-08-31T14:26:24Z"
29286+
format: date-time
29287+
type: string
2928929288
git:
2929029289
$ref: "#/components/schemas/DORAGitInfo"
2929129290
name:
@@ -29304,10 +29303,10 @@ components:
2930429303
example: SEV-1
2930529304
type: string
2930629305
started_at:
29307-
description: Unix timestamp when the incident started.
29308-
example: 1693491974000000000
29309-
format: int64
29310-
type: integer
29306+
description: The time when the incident started.
29307+
example: "2023-08-31T14:26:14Z"
29308+
format: date-time
29309+
type: string
2931129310
team:
2931229311
description: Name of the team owning the services impacted.
2931329312
example: backend
@@ -29316,8 +29315,6 @@ components:
2931629315
description: Version to correlate with APM Deployment Tracking.
2931729316
example: v1.12.07
2931829317
type: string
29319-
required:
29320-
- started_at
2932129318
type: object
2932229319
DORAListDeploymentsRequest:
2932329320
description: Request to get a list of deployments.
@@ -132589,9 +132586,9 @@ paths:
132589132586
data:
132590132587
- attributes:
132591132588
env: production
132592-
finished_at: 1693491984000000000
132589+
finished_at: "2023-08-31T14:26:24Z"
132593132590
service: test-service
132594-
started_at: 1693491974000000000
132591+
started_at: "2023-08-31T14:26:14Z"
132595132592
team: backend
132596132593
id: abc-123
132597132594
type: dora_deployment
@@ -132640,9 +132637,9 @@ paths:
132640132637
data:
132641132638
attributes:
132642132639
env: production
132643-
finished_at: 1693491984000000000
132640+
finished_at: "2023-08-31T14:26:24Z"
132644132641
service: test-service
132645-
started_at: 1693491974000000000
132642+
started_at: "2023-08-31T14:26:14Z"
132646132643
team: backend
132647132644
id: abc-123
132648132645
type: dora_deployment
@@ -132863,7 +132860,7 @@ paths:
132863132860
services:
132864132861
- test-service
132865132862
severity: SEV-1
132866-
started_at: 1693492174000000000
132863+
started_at: "2023-08-31T14:29:34Z"
132867132864
team: backend
132868132865
id: abc-123
132869132866
type: dora_failure
@@ -132916,7 +132913,7 @@ paths:
132916132913
services:
132917132914
- test-service
132918132915
severity: SEV-1
132919-
started_at: 1693492174000000000
132916+
started_at: "2023-08-31T14:29:34Z"
132920132917
team: backend
132921132918
id: abc-123
132922132919
type: dora_failure
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Get a list of deployment events returns deployments with date-time timestamps
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.dora_metrics_api import DORAMetricsApi
7+
from datadog_api_client.v2.model.dora_list_deployments_request import DORAListDeploymentsRequest
8+
from datadog_api_client.v2.model.dora_list_deployments_request_attributes import DORAListDeploymentsRequestAttributes
9+
from datadog_api_client.v2.model.dora_list_deployments_request_data import DORAListDeploymentsRequestData
10+
from datadog_api_client.v2.model.dora_list_deployments_request_data_type import DORAListDeploymentsRequestDataType
11+
from datetime import datetime
12+
from dateutil.tz import tzutc
13+
14+
body = DORAListDeploymentsRequest(
15+
data=DORAListDeploymentsRequestData(
16+
attributes=DORAListDeploymentsRequestAttributes(
17+
_from=datetime(2023, 8, 31, 0, 0, tzinfo=tzutc()),
18+
to=datetime(2023, 9, 1, 0, 0, tzinfo=tzutc()),
19+
),
20+
type=DORAListDeploymentsRequestDataType.DORA_DEPLOYMENTS_LIST_REQUEST,
21+
),
22+
)
23+
24+
configuration = Configuration()
25+
with ApiClient(configuration) as api_client:
26+
api_instance = DORAMetricsApi(api_client)
27+
response = api_instance.list_dora_deployments(body=body)
28+
29+
print(response)

src/datadog_api_client/v2/model/dora_deployment_object_attributes.py

Lines changed: 11 additions & 9 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+
datetime,
1112
none_type,
1213
unset,
1314
UnsetType,
@@ -26,10 +27,10 @@ def openapi_types(_):
2627
return {
2728
"custom_tags": ([str],),
2829
"env": (str,),
29-
"finished_at": (int,),
30+
"finished_at": (datetime,),
3031
"git": (DORAGitInfoResponse,),
3132
"service": (str,),
32-
"started_at": (int,),
33+
"started_at": (datetime,),
3334
"team": (str,),
3435
"version": (str,),
3536
}
@@ -47,11 +48,11 @@ def openapi_types(_):
4748

4849
def __init__(
4950
self_,
50-
finished_at: int,
5151
service: str,
52-
started_at: int,
52+
started_at: datetime,
5353
custom_tags: Union[List[str], none_type, UnsetType] = unset,
5454
env: Union[str, UnsetType] = unset,
55+
finished_at: Union[datetime, UnsetType] = unset,
5556
git: Union[DORAGitInfoResponse, UnsetType] = unset,
5657
team: Union[str, UnsetType] = unset,
5758
version: Union[str, UnsetType] = unset,
@@ -66,17 +67,17 @@ def __init__(
6667
:param env: Environment name to where the service was deployed.
6768
:type env: str, optional
6869
69-
:param finished_at: Unix timestamp when the deployment finished.
70-
:type finished_at: int
70+
:param finished_at: The time when the deployment finished.
71+
:type finished_at: datetime, optional
7172
7273
:param git: Git info returned by DORA Metrics events.
7374
:type git: DORAGitInfoResponse, optional
7475
7576
:param service: Service name.
7677
:type service: str
7778
78-
:param started_at: Unix timestamp when the deployment started.
79-
:type started_at: int
79+
:param started_at: The time when the deployment started.
80+
:type started_at: datetime
8081
8182
:param team: Name of the team owning the deployed service.
8283
:type team: str, optional
@@ -88,6 +89,8 @@ def __init__(
8889
kwargs["custom_tags"] = custom_tags
8990
if env is not unset:
9091
kwargs["env"] = env
92+
if finished_at is not unset:
93+
kwargs["finished_at"] = finished_at
9194
if git is not unset:
9295
kwargs["git"] = git
9396
if team is not unset:
@@ -96,6 +99,5 @@ def __init__(
9699
kwargs["version"] = version
97100
super().__init__(kwargs)
98101

99-
self_.finished_at = finished_at
100102
self_.service = service
101103
self_.started_at = started_at

src/datadog_api_client/v2/model/dora_incident_object_attributes.py

Lines changed: 11 additions & 10 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+
datetime,
1112
none_type,
1213
unset,
1314
UnsetType,
@@ -26,12 +27,12 @@ def openapi_types(_):
2627
return {
2728
"custom_tags": ([str],),
2829
"env": (str,),
29-
"finished_at": (int,),
30+
"finished_at": (datetime,),
3031
"git": (DORAGitInfo,),
3132
"name": (str,),
3233
"services": ([str],),
3334
"severity": (str,),
34-
"started_at": (int,),
35+
"started_at": (datetime,),
3536
"team": (str,),
3637
"version": (str,),
3738
}
@@ -51,14 +52,14 @@ def openapi_types(_):
5152

5253
def __init__(
5354
self_,
54-
started_at: int,
5555
custom_tags: Union[List[str], none_type, UnsetType] = unset,
5656
env: Union[str, UnsetType] = unset,
57-
finished_at: Union[int, UnsetType] = unset,
57+
finished_at: Union[datetime, UnsetType] = unset,
5858
git: Union[DORAGitInfo, UnsetType] = unset,
5959
name: Union[str, UnsetType] = unset,
6060
services: Union[List[str], UnsetType] = unset,
6161
severity: Union[str, UnsetType] = unset,
62+
started_at: Union[datetime, UnsetType] = unset,
6263
team: Union[str, UnsetType] = unset,
6364
version: Union[str, UnsetType] = unset,
6465
**kwargs,
@@ -72,8 +73,8 @@ def __init__(
7273
:param env: Environment name that was impacted by the incident.
7374
:type env: str, optional
7475
75-
:param finished_at: Unix timestamp when the incident finished.
76-
:type finished_at: int, optional
76+
:param finished_at: The time when the incident finished.
77+
:type finished_at: datetime, optional
7778
7879
:param git: Git info for DORA Metrics events.
7980
:type git: DORAGitInfo, optional
@@ -87,8 +88,8 @@ def __init__(
8788
:param severity: Incident severity.
8889
:type severity: str, optional
8990
90-
:param started_at: Unix timestamp when the incident started.
91-
:type started_at: int
91+
:param started_at: The time when the incident started.
92+
:type started_at: datetime, optional
9293
9394
:param team: Name of the team owning the services impacted.
9495
:type team: str, optional
@@ -110,10 +111,10 @@ def __init__(
110111
kwargs["services"] = services
111112
if severity is not unset:
112113
kwargs["severity"] = severity
114+
if started_at is not unset:
115+
kwargs["started_at"] = started_at
113116
if team is not unset:
114117
kwargs["team"] = team
115118
if version is not unset:
116119
kwargs["version"] = version
117120
super().__init__(kwargs)
118-
119-
self_.started_at = started_at

0 commit comments

Comments
 (0)