Skip to content

Commit 593ab97

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Add Synthetics endpoint to fetch uptimes in API spec (#2140)
* add support for top level indexing * Regenerate client from commit 3b4747f4 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 1629497 commit 593ab97

16 files changed

+506
-4
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.6",
7-
"regenerated": "2024-10-02 13:39:19.776742",
8-
"spec_repo_commit": "e02e4f4c"
7+
"regenerated": "2024-10-02 14:33:47.623313",
8+
"spec_repo_commit": "3b4747f4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-10-02 13:39:19.791012",
13-
"spec_repo_commit": "e02e4f4c"
12+
"regenerated": "2024-10-02 14:33:47.636722",
13+
"spec_repo_commit": "3b4747f4"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15194,6 +15194,32 @@ components:
1519415194
- EDGE_LAPTOP_LARGE
1519515195
- EDGE_TABLET
1519615196
- EDGE_MOBILE_SMALL
15197+
SyntheticsFetchUptimesPayload:
15198+
description: Object containing IDs of Synthetic tests and a timeframe.
15199+
properties:
15200+
from_ts:
15201+
description: Timestamp in seconds (Unix epoch) for the start of uptime.
15202+
example: 0
15203+
format: int64
15204+
type: integer
15205+
public_ids:
15206+
description: An array of Synthetic test IDs you want to delete.
15207+
example: []
15208+
items:
15209+
description: A Synthetic test ID.
15210+
example: abc-def-123
15211+
type: string
15212+
type: array
15213+
to_ts:
15214+
description: Timestamp in seconds (Unix epoch) for the end of uptime.
15215+
example: 0
15216+
format: int64
15217+
type: integer
15218+
required:
15219+
- from_ts
15220+
- to_ts
15221+
- public_ids
15222+
type: object
1519715223
SyntheticsGetAPITestLatestResultsResponse:
1519815224
description: Object with the latest Synthetic API test run.
1519915225
properties:
@@ -17283,6 +17309,24 @@ components:
1728317309
description: String Port number to use when performing the test. Supports templated
1728417310
variables.
1728517311
type: string
17312+
SyntheticsTestUptime:
17313+
description: Object containing the uptime for a Synthetic test ID.
17314+
properties:
17315+
from_ts:
17316+
description: Timestamp in seconds for the start of uptime.
17317+
format: int64
17318+
type: integer
17319+
overall:
17320+
$ref: '#/components/schemas/SyntheticsUptime'
17321+
public_id:
17322+
description: A Synthetic test ID.
17323+
example: abc-def-123
17324+
type: string
17325+
to_ts:
17326+
description: Timestamp in seconds for the end of uptime.
17327+
format: int64
17328+
type: integer
17329+
type: object
1728617330
SyntheticsTiming:
1728717331
description: 'Object containing all metrics and their values collected for a
1728817332
Synthetic API test.
@@ -17406,6 +17450,62 @@ components:
1740617450
new_status:
1740717451
$ref: '#/components/schemas/SyntheticsTestPauseStatus'
1740817452
type: object
17453+
SyntheticsUptime:
17454+
description: Object containing the uptime information.
17455+
properties:
17456+
errors:
17457+
description: An array of error objects returned while querying the history
17458+
data for the service level objective.
17459+
items:
17460+
$ref: '#/components/schemas/SLOHistoryResponseErrorWithType'
17461+
nullable: true
17462+
type: array
17463+
group:
17464+
description: The location name
17465+
example: name
17466+
type: string
17467+
history:
17468+
description: 'The state transition history for the monitor, represented
17469+
as an array of
17470+
17471+
pairs. Each pair is an array where the first element is the transition
17472+
timestamp
17473+
17474+
in Unix epoch format (integer) and the second element is the state (integer).
17475+
17476+
For the state, an integer value of `0` indicates uptime, `1` indicates
17477+
downtime,
17478+
17479+
and `2` indicates no data.'
17480+
example:
17481+
- - 1579212382
17482+
- 0
17483+
items:
17484+
description: An array of transitions
17485+
example:
17486+
- 1579212382
17487+
- 0
17488+
items:
17489+
description: A timeseries data point which is a tuple of (timestamp,
17490+
value).
17491+
format: double
17492+
type: number
17493+
maxItems: 2
17494+
minItems: 2
17495+
type: array
17496+
type: array
17497+
span_precision:
17498+
description: The number of decimal places to which the SLI value is accurate
17499+
for the given from-to timestamps.
17500+
example: 2.0
17501+
format: double
17502+
type: number
17503+
uptime:
17504+
description: The overall uptime.
17505+
example: 99.99
17506+
format: double
17507+
type: number
17508+
type: object
1740917509
SyntheticsVariableParser:
1741017510
description: Details of the parser to use for the global variable.
1741117511
example:
@@ -32934,6 +33034,49 @@ paths:
3293433034
operator: OR
3293533035
permissions:
3293633036
- synthetics_write
33037+
/api/v1/synthetics/tests/uptimes:
33038+
post:
33039+
description: Fetch uptime for multiple Synthetic tests by ID.
33040+
operationId: FetchUptimes
33041+
requestBody:
33042+
content:
33043+
application/json:
33044+
schema:
33045+
$ref: '#/components/schemas/SyntheticsFetchUptimesPayload'
33046+
description: Public ID list of the Synthetic tests and timeframe.
33047+
required: true
33048+
responses:
33049+
'200':
33050+
content:
33051+
application/json:
33052+
schema:
33053+
items:
33054+
$ref: '#/components/schemas/SyntheticsTestUptime'
33055+
type: array
33056+
description: OK.
33057+
'400':
33058+
content:
33059+
application/json:
33060+
schema:
33061+
$ref: '#/components/schemas/APIErrorResponse'
33062+
description: '- JSON format is wrong'
33063+
'403':
33064+
content:
33065+
application/json:
33066+
schema:
33067+
$ref: '#/components/schemas/APIErrorResponse'
33068+
description: Forbidden
33069+
'429':
33070+
$ref: '#/components/responses/TooManyRequestsResponse'
33071+
security:
33072+
- apiKeyAuth: []
33073+
appKeyAuth: []
33074+
- AuthZ:
33075+
- synthetics_read
33076+
summary: Fetch uptime for multiple tests
33077+
tags:
33078+
- Synthetics
33079+
x-codegen-request-body-name: body
3293733080
/api/v1/synthetics/tests/{public_id}:
3293833081
get:
3293933082
description: Get the detailed configuration associated with a Synthetic test.

docs/datadog_api_client.v1.model.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4358,6 +4358,13 @@ datadog\_api\_client.v1.model.synthetics\_device\_id module
43584358
:members:
43594359
:show-inheritance:
43604360

4361+
datadog\_api\_client.v1.model.synthetics\_fetch\_uptimes\_payload module
4362+
------------------------------------------------------------------------
4363+
4364+
.. automodule:: datadog_api_client.v1.model.synthetics_fetch_uptimes_payload
4365+
:members:
4366+
:show-inheritance:
4367+
43614368
datadog\_api\_client.v1.model.synthetics\_get\_api\_test\_latest\_results\_response module
43624369
------------------------------------------------------------------------------------------
43634370

@@ -4904,6 +4911,13 @@ datadog\_api\_client.v1.model.synthetics\_test\_request\_proxy module
49044911
:members:
49054912
:show-inheritance:
49064913

4914+
datadog\_api\_client.v1.model.synthetics\_test\_uptime module
4915+
-------------------------------------------------------------
4916+
4917+
.. automodule:: datadog_api_client.v1.model.synthetics_test_uptime
4918+
:members:
4919+
:show-inheritance:
4920+
49074921
datadog\_api\_client.v1.model.synthetics\_timing module
49084922
-------------------------------------------------------
49094923

@@ -4953,6 +4967,13 @@ datadog\_api\_client.v1.model.synthetics\_update\_test\_pause\_status\_payload m
49534967
:members:
49544968
:show-inheritance:
49554969

4970+
datadog\_api\_client.v1.model.synthetics\_uptime module
4971+
-------------------------------------------------------
4972+
4973+
.. automodule:: datadog_api_client.v1.model.synthetics_uptime
4974+
:members:
4975+
:show-inheritance:
4976+
49564977
datadog\_api\_client.v1.model.synthetics\_variable\_parser module
49574978
-----------------------------------------------------------------
49584979

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
Fetch uptime for multiple tests returns "OK." response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
7+
from datadog_api_client.v1.model.synthetics_fetch_uptimes_payload import SyntheticsFetchUptimesPayload
8+
9+
body = SyntheticsFetchUptimesPayload(
10+
from_ts=1726041488,
11+
public_ids=[
12+
"p8m-9gw-nte",
13+
],
14+
to_ts=1726055954,
15+
)
16+
17+
configuration = Configuration()
18+
with ApiClient(configuration) as api_client:
19+
api_instance = SyntheticsApi(api_client)
20+
response = api_instance.fetch_uptimes(body=body)
21+
22+
print(response)

src/datadog_api_client/v1/api/synthetics_api.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
from datadog_api_client.v1.model.synthetics_trigger_ci_tests_response import SyntheticsTriggerCITestsResponse
3535
from datadog_api_client.v1.model.synthetics_trigger_body import SyntheticsTriggerBody
3636
from datadog_api_client.v1.model.synthetics_ci_test_body import SyntheticsCITestBody
37+
from datadog_api_client.v1.model.synthetics_test_uptime import SyntheticsTestUptime
38+
from datadog_api_client.v1.model.synthetics_fetch_uptimes_payload import SyntheticsFetchUptimesPayload
3739
from datadog_api_client.v1.model.synthetics_patch_test_body import SyntheticsPatchTestBody
3840
from datadog_api_client.v1.model.synthetics_get_api_test_latest_results_response import (
3941
SyntheticsGetAPITestLatestResultsResponse,
@@ -255,6 +257,26 @@ def __init__(self, api_client=None):
255257
api_client=api_client,
256258
)
257259

260+
self._fetch_uptimes_endpoint = _Endpoint(
261+
settings={
262+
"response_type": ([SyntheticsTestUptime],),
263+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
264+
"endpoint_path": "/api/v1/synthetics/tests/uptimes",
265+
"operation_id": "fetch_uptimes",
266+
"http_method": "POST",
267+
"version": "v1",
268+
},
269+
params_map={
270+
"body": {
271+
"required": True,
272+
"openapi_types": (SyntheticsFetchUptimesPayload,),
273+
"location": "body",
274+
},
275+
},
276+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
277+
api_client=api_client,
278+
)
279+
258280
self._get_api_test_endpoint = _Endpoint(
259281
settings={
260282
"response_type": (SyntheticsAPITest,),
@@ -981,6 +1003,23 @@ def edit_global_variable(
9811003

9821004
return self._edit_global_variable_endpoint.call_with_http_info(**kwargs)
9831005

1006+
def fetch_uptimes(
1007+
self,
1008+
body: SyntheticsFetchUptimesPayload,
1009+
) -> List[SyntheticsTestUptime]:
1010+
"""Fetch uptime for multiple tests.
1011+
1012+
Fetch uptime for multiple Synthetic tests by ID.
1013+
1014+
:param body: Public ID list of the Synthetic tests and timeframe.
1015+
:type body: SyntheticsFetchUptimesPayload
1016+
:rtype: [SyntheticsTestUptime]
1017+
"""
1018+
kwargs: Dict[str, Any] = {}
1019+
kwargs["body"] = body
1020+
1021+
return self._fetch_uptimes_endpoint.call_with_http_info(**kwargs)
1022+
9841023
def get_api_test(
9851024
self,
9861025
public_id: str,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import List
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
)
12+
13+
14+
class SyntheticsFetchUptimesPayload(ModelNormal):
15+
@cached_property
16+
def openapi_types(_):
17+
return {
18+
"from_ts": (int,),
19+
"public_ids": ([str],),
20+
"to_ts": (int,),
21+
}
22+
23+
attribute_map = {
24+
"from_ts": "from_ts",
25+
"public_ids": "public_ids",
26+
"to_ts": "to_ts",
27+
}
28+
29+
def __init__(self_, from_ts: int, public_ids: List[str], to_ts: int, **kwargs):
30+
"""
31+
Object containing IDs of Synthetic tests and a timeframe.
32+
33+
:param from_ts: Timestamp in seconds (Unix epoch) for the start of uptime.
34+
:type from_ts: int
35+
36+
:param public_ids: An array of Synthetic test IDs you want to delete.
37+
:type public_ids: [str]
38+
39+
:param to_ts: Timestamp in seconds (Unix epoch) for the end of uptime.
40+
:type to_ts: int
41+
"""
42+
super().__init__(kwargs)
43+
44+
self_.from_ts = from_ts
45+
self_.public_ids = public_ids
46+
self_.to_ts = to_ts

0 commit comments

Comments
 (0)