Skip to content

Commit baa0d7a

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 07ee6775 of spec repo
1 parent 85108b5 commit baa0d7a

File tree

7 files changed

+161
-4
lines changed

7 files changed

+161
-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.5",
7-
"regenerated": "2023-09-06 11:51:23.573590",
8-
"spec_repo_commit": "c59cafad"
7+
"regenerated": "2023-09-06 12:26:22.456754",
8+
"spec_repo_commit": "07ee6775"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-09-06 11:51:23.586262",
13-
"spec_repo_commit": "c59cafad"
12+
"regenerated": "2023-09-06 12:26:22.469339",
13+
"spec_repo_commit": "07ee6775"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18815,6 +18815,16 @@ paths:
1881518815
schema:
1881618816
example: created_by,monitor
1881718817
type: string
18818+
- $ref: '#/components/parameters/PageOffset'
18819+
- description: Maximum number of downtimes in the response.
18820+
example: 100
18821+
in: query
18822+
name: page[limit]
18823+
required: false
18824+
schema:
18825+
default: 30
18826+
format: int64
18827+
type: integer
1881818828
responses:
1881918829
'200':
1882018830
content:
@@ -18838,6 +18848,10 @@ paths:
1883818848
summary: Get all downtimes
1883918849
tags:
1884018850
- Downtimes
18851+
x-pagination:
18852+
limitParam: page[limit]
18853+
pageOffsetParam: page[offset]
18854+
resultsPath: data
1884118855
x-unstable: '**Note**: This endpoint is in private beta.
1884218856

1884318857
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Get all downtimes returns "OK" response with pagination
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.downtimes_api import DowntimesApi
7+
8+
configuration = Configuration()
9+
configuration.unstable_operations["list_downtimes"] = True
10+
with ApiClient(configuration) as api_client:
11+
api_instance = DowntimesApi(api_client)
12+
items = api_instance.list_downtimes_with_pagination(
13+
page_limit=2,
14+
)
15+
for item in items:
16+
print(item)

src/datadog_api_client/v2/api/downtimes_api.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6+
import collections
67
from typing import Any, Dict, Union
78

89
from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
910
from datadog_api_client.configuration import Configuration
1011
from datadog_api_client.model_utils import (
12+
set_attribute_from_path,
13+
get_attribute_from_path,
1114
UnsetType,
1215
unset,
1316
)
1417
from datadog_api_client.v2.model.list_downtimes_response import ListDowntimesResponse
18+
from datadog_api_client.v2.model.downtime_response_data import DowntimeResponseData
1519
from datadog_api_client.v2.model.downtime_response import DowntimeResponse
1620
from datadog_api_client.v2.model.downtime_create_request import DowntimeCreateRequest
1721
from datadog_api_client.v2.model.downtime_update_request import DowntimeUpdateRequest
@@ -124,6 +128,16 @@ def __init__(self, api_client=None):
124128
"attribute": "include",
125129
"location": "query",
126130
},
131+
"page_offset": {
132+
"openapi_types": (int,),
133+
"attribute": "page[offset]",
134+
"location": "query",
135+
},
136+
"page_limit": {
137+
"openapi_types": (int,),
138+
"attribute": "page[limit]",
139+
"location": "query",
140+
},
127141
},
128142
headers_map={
129143
"accept": ["application/json"],
@@ -244,6 +258,8 @@ def list_downtimes(
244258
*,
245259
current_only: Union[bool, UnsetType] = unset,
246260
include: Union[str, UnsetType] = unset,
261+
page_offset: Union[int, UnsetType] = unset,
262+
page_limit: Union[int, UnsetType] = unset,
247263
) -> ListDowntimesResponse:
248264
"""Get all downtimes.
249265
@@ -254,6 +270,10 @@ def list_downtimes(
254270
:param include: Comma-separated list of resource paths for related resources to include in the response. Supported resource
255271
paths are ``created_by`` and ``monitor``.
256272
:type include: str, optional
273+
:param page_offset: Specific offset to use as the beginning of the returned page.
274+
:type page_offset: int, optional
275+
:param page_limit: Maximum number of downtimes in the response.
276+
:type page_limit: int, optional
257277
:rtype: ListDowntimesResponse
258278
"""
259279
kwargs: Dict[str, Any] = {}
@@ -263,8 +283,64 @@ def list_downtimes(
263283
if include is not unset:
264284
kwargs["include"] = include
265285

286+
if page_offset is not unset:
287+
kwargs["page_offset"] = page_offset
288+
289+
if page_limit is not unset:
290+
kwargs["page_limit"] = page_limit
291+
266292
return self._list_downtimes_endpoint.call_with_http_info(**kwargs)
267293

294+
def list_downtimes_with_pagination(
295+
self,
296+
*,
297+
current_only: Union[bool, UnsetType] = unset,
298+
include: Union[str, UnsetType] = unset,
299+
page_offset: Union[int, UnsetType] = unset,
300+
page_limit: Union[int, UnsetType] = unset,
301+
) -> collections.abc.Iterable[DowntimeResponseData]:
302+
"""Get all downtimes.
303+
304+
Provide a paginated version of :meth:`list_downtimes`, returning all items.
305+
306+
:param current_only: Only return downtimes that are active when the request is made.
307+
:type current_only: bool, optional
308+
:param include: Comma-separated list of resource paths for related resources to include in the response. Supported resource
309+
paths are ``created_by`` and ``monitor``.
310+
:type include: str, optional
311+
:param page_offset: Specific offset to use as the beginning of the returned page.
312+
:type page_offset: int, optional
313+
:param page_limit: Maximum number of downtimes in the response.
314+
:type page_limit: int, optional
315+
316+
:return: A generator of paginated results.
317+
:rtype: collections.abc.Iterable[DowntimeResponseData]
318+
"""
319+
kwargs: Dict[str, Any] = {}
320+
if current_only is not unset:
321+
kwargs["current_only"] = current_only
322+
323+
if include is not unset:
324+
kwargs["include"] = include
325+
326+
if page_offset is not unset:
327+
kwargs["page_offset"] = page_offset
328+
329+
if page_limit is not unset:
330+
kwargs["page_limit"] = page_limit
331+
332+
local_page_size = get_attribute_from_path(kwargs, "page_limit", 30)
333+
endpoint = self._list_downtimes_endpoint
334+
set_attribute_from_path(kwargs, "page_limit", local_page_size, endpoint.params_map)
335+
pagination = {
336+
"limit_value": local_page_size,
337+
"results_path": "data",
338+
"page_offset_param": "page_offset",
339+
"endpoint": endpoint,
340+
"kwargs": kwargs,
341+
}
342+
return endpoint.call_with_http_info_paginated(pagination)
343+
268344
def list_monitor_downtimes(
269345
self,
270346
monitor_id: int,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-09-05T12:32:39.085Z
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
accept:
6+
- application/json
7+
method: GET
8+
uri: https://api.datadoghq.com/api/v2/downtime?page%5Blimit%5D=2
9+
response:
10+
body:
11+
string: '{"data":[{"type":"downtime","attributes":{"mute_first_recovery_notification":false,"canceled":null,"monitor_identifier":{"monitor_tags":["*"]},"schedule":{"start":"2023-05-22T03:06:54.072998+00:00","end":null},"notify_end_types":["expired"],"notify_end_states":["no
12+
data","warn","alert"],"status":"active","scope":"host:\"java-hostsMuteErrorsTest-local-1684724813\"","created":"2023-05-22T03:06:54.079122+00:00","display_timezone":"UTC","message":null,"modified":"2023-05-22T03:06:54.079122+00:00"},"id":"b4613732-f84d-11ed-a766-da7ad0900002"},{"type":"downtime","attributes":{"mute_first_recovery_notification":false,"canceled":null,"monitor_identifier":{"monitor_tags":["*"]},"schedule":{"start":"2023-05-23T03:21:54.687109+00:00","end":null},"notify_end_types":["expired"],"notify_end_states":["no
13+
data","warn","alert"],"status":"active","scope":"host:\"java-hostsMuteErrorsTest-local-1684812114\"","created":"2023-05-23T03:21:54.690618+00:00","display_timezone":"UTC","message":null,"modified":"2023-05-23T03:21:54.690618+00:00"},"id":"f799770a-f918-11ed-8b48-da7ad0900002"}],"meta":{"page":{"total_filtered_count":3}}}
14+
15+
'
16+
headers:
17+
content-type:
18+
- application/json
19+
status:
20+
code: 200
21+
message: OK
22+
- request:
23+
body: null
24+
headers:
25+
accept:
26+
- application/json
27+
method: GET
28+
uri: https://api.datadoghq.com/api/v2/downtime?page%5Blimit%5D=2&page%5Boffset%5D=2
29+
response:
30+
body:
31+
string: '{"data":[{"type":"downtime","attributes":{"modified":"2023-05-24T03:29:35.343207+00:00","created":"2023-05-24T03:29:35.343207+00:00","canceled":null,"status":"active","scope":"host:\"java-hostsMuteErrorsTest-local-1684898975\"","display_timezone":"UTC","schedule":{"end":null,"start":"2023-05-24T03:29:35.340446+00:00"},"message":null,"mute_first_recovery_notification":false,"notify_end_types":["expired"],"notify_end_states":["warn","no
32+
data","alert"],"monitor_identifier":{"monitor_tags":["*"]}},"id":"34953930-f9e3-11ed-85d4-da7ad0900002"}],"meta":{"page":{"total_filtered_count":3}}}
33+
34+
'
35+
headers:
36+
content-type:
37+
- application/json
38+
status:
39+
code: 200
40+
message: OK
41+
version: 1

tests/v2/features/downtimes.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ Feature: Downtimes
9898
Then the response status is 200 OK
9999
And the response "data" has item with field "id" with value "1dcb33f8-b23a-11ed-ae77-da7ad0900002"
100100

101+
@replay-only @skip-validation @team:DataDog/monitor-app @with-pagination
102+
Scenario: Get all downtimes returns "OK" response with pagination
103+
Given operation "ListDowntimes" enabled
104+
And new "ListDowntimes" request
105+
And request contains "page[limit]" parameter with value 2
106+
When the request with pagination is sent
107+
Then the response status is 200 OK
108+
And the response has 3 items
109+
101110
@skip-validation @team:DataDog/monitor-app
102111
Scenario: Schedule a downtime returns "Bad Request" response
103112
Given new "CreateDowntime" request

0 commit comments

Comments
 (0)