Skip to content

Commit ab23177

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add pagination extension to SLO corrections (#1631)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 179153d commit ab23177

File tree

7 files changed

+115
-4
lines changed

7 files changed

+115
-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-08-23 20:02:20.233538",
8-
"spec_repo_commit": "7e4a4121"
7+
"regenerated": "2023-08-25 12:25:40.724264",
8+
"spec_repo_commit": "1a77c0b6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-08-23 20:02:20.251225",
13-
"spec_repo_commit": "7e4a4121"
12+
"regenerated": "2023-08-25 12:25:40.743585",
13+
"spec_repo_commit": "1a77c0b6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27185,6 +27185,7 @@ paths:
2718527185
name: limit
2718627186
required: false
2718727187
schema:
27188+
default: 25
2718827189
format: int64
2718927190
type: integer
2719027191
responses:
@@ -27210,6 +27211,10 @@ paths:
2721027211
summary: Get all SLO corrections
2721127212
tags:
2721227213
- Service Level Objective Corrections
27214+
x-pagination:
27215+
limitParam: limit
27216+
pageOffsetParam: offset
27217+
resultsPath: data
2721327218
post:
2721427219
description: Create an SLO Correction.
2721527220
operationId: CreateSLOCorrection
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Get all SLO corrections returns "OK" response with pagination
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.service_level_objective_corrections_api import ServiceLevelObjectiveCorrectionsApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = ServiceLevelObjectiveCorrectionsApi(api_client)
11+
items = api_instance.list_slo_correction_with_pagination(
12+
limit=2,
13+
)
14+
for item in items:
15+
print(item)

src/datadog_api_client/v1/api/service_level_objective_corrections_api.py

Lines changed: 41 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.v1.model.slo_correction_list_response import SLOCorrectionListResponse
18+
from datadog_api_client.v1.model.slo_correction import SLOCorrection
1519
from datadog_api_client.v1.model.slo_correction_response import SLOCorrectionResponse
1620
from datadog_api_client.v1.model.slo_correction_create_request import SLOCorrectionCreateRequest
1721
from datadog_api_client.v1.model.slo_correction_update_request import SLOCorrectionUpdateRequest
@@ -225,6 +229,43 @@ def list_slo_correction(
225229

226230
return self._list_slo_correction_endpoint.call_with_http_info(**kwargs)
227231

232+
def list_slo_correction_with_pagination(
233+
self,
234+
*,
235+
offset: Union[int, UnsetType] = unset,
236+
limit: Union[int, UnsetType] = unset,
237+
) -> collections.abc.Iterable[SLOCorrection]:
238+
"""Get all SLO corrections.
239+
240+
Provide a paginated version of :meth:`list_slo_correction`, returning all items.
241+
242+
:param offset: The specific offset to use as the beginning of the returned response.
243+
:type offset: int, optional
244+
:param limit: The number of SLO corrections to return in the response. Default is 25.
245+
:type limit: int, optional
246+
247+
:return: A generator of paginated results.
248+
:rtype: collections.abc.Iterable[SLOCorrection]
249+
"""
250+
kwargs: Dict[str, Any] = {}
251+
if offset is not unset:
252+
kwargs["offset"] = offset
253+
254+
if limit is not unset:
255+
kwargs["limit"] = limit
256+
257+
local_page_size = get_attribute_from_path(kwargs, "limit", 25)
258+
endpoint = self._list_slo_correction_endpoint
259+
set_attribute_from_path(kwargs, "limit", local_page_size, endpoint.params_map)
260+
pagination = {
261+
"limit_value": local_page_size,
262+
"results_path": "data",
263+
"page_offset_param": "offset",
264+
"endpoint": endpoint,
265+
"kwargs": kwargs,
266+
}
267+
return endpoint.call_with_http_info_paginated(pagination)
268+
228269
def update_slo_correction(
229270
self,
230271
slo_correction_id: str,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-08-25T11:50:34.970Z
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/v1/slo/correction?limit=2
9+
response:
10+
body:
11+
string: '{"data":[{"type":"correction","id":"fb76e0fa-bf7b-11ed-ba7e-da7ad0902002","attributes":{"slo_id":"a17acfd48b7c55d19192e3a697cc1d01","start":1678255200,"end":1678355280,"description":"","category":"Other","timezone":"UTC","created_at":1678477473,"modified_at":1678477473,"rrule":null,"duration":null,"creator":{"data":{"type":"users","id":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","attributes":{"uuid":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","handle":"support-nickautotestingorg","email":"[email protected]","name":"Datadog
12+
Support","icon":"https://secure.gravatar.com/avatar/e6952b5f29fe2d996cf4e63f40db9e71?s=48&d=retro"}}},"modifier":null}},{"type":"correction","id":"2d16c2ee-bf70-11ed-895f-da7ad0902002","attributes":{"slo_id":"70e82706f4ae56ff8bdd7f02e767f97c","start":1678255200,"end":1678339140,"description":"","category":"Other","timezone":"UTC","created_at":1678472403,"modified_at":1678472403,"rrule":null,"duration":null,"creator":{"data":{"type":"users","id":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","attributes":{"uuid":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","handle":"support-nickautotestingorg","email":"[email protected]","name":"Datadog
13+
Support","icon":"https://secure.gravatar.com/avatar/e6952b5f29fe2d996cf4e63f40db9e71?s=48&d=retro"}}},"modifier":null}}],"meta":{"page":{"total_count":3,"total_filtered_count":2}}}
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/v1/slo/correction?limit=2&offset=2
29+
response:
30+
body:
31+
string: '{"data":[{"type":"correction","id":"cc2316d2-bf6e-11ed-82f2-da7ad0902002","attributes":{"slo_id":"955ab6301fa656e7b061de4a05ad4774","start":1678255200,"end":1678339140,"description":"","category":"Other","timezone":"UTC","created_at":1678471811,"modified_at":1678471811,"rrule":null,"duration":null,"creator":{"data":{"type":"users","id":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","attributes":{"uuid":"35c75d43-eba0-11e9-a77a-2b3585ff5dfb","handle":"support-nickautotestingorg","email":"[email protected]","name":"Datadog
32+
Support","icon":"https://secure.gravatar.com/avatar/e6952b5f29fe2d996cf4e63f40db9e71?s=48&d=retro"}}},"modifier":null}}],"meta":{"page":{"total_count":3,"total_filtered_count":1}}}
33+
34+
'
35+
headers:
36+
content-type:
37+
- application/json
38+
status:
39+
code: 200
40+
message: OK
41+
version: 1

tests/v1/features/service_level_objective_corrections.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Feature: Service Level Objective Corrections
7272
Then the response status is 200 OK
7373
And the response "data" has length 1
7474

75+
@replay-only @skip-validation @team:DataDog/slo-app @with-pagination
76+
Scenario: Get all SLO corrections returns "OK" response with pagination
77+
Given new "ListSLOCorrection" request
78+
And request contains "limit" parameter with value 2
79+
When the request with pagination is sent
80+
Then the response status is 200 OK
81+
And the response has 3 items
82+
7583
@generated @skip @team:DataDog/slo-app
7684
Scenario: Get an SLO correction for an SLO returns "Bad Request" response
7785
Given new "GetSLOCorrection" request

0 commit comments

Comments
 (0)