Skip to content

Commit ca7af7f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add pagination extension to SLO corrections (#1294)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 500e808 commit ca7af7f

File tree

7 files changed

+201
-4
lines changed

7 files changed

+201
-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:10.805710",
8-
"spec_repo_commit": "7e4a4121"
7+
"regenerated": "2023-08-25 12:25:26.250184",
8+
"spec_repo_commit": "1a77c0b6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-08-23 20:02:10.823663",
13-
"spec_repo_commit": "7e4a4121"
12+
"regenerated": "2023-08-25 12:25:26.263034",
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-08-25T11:50:34.970Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"log": {
3+
"_recordingName": "Service Level Objective Corrections/Get all SLO corrections returns \"OK\" response with pagination",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "a47256681b359bab367712eda16a1905",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 0,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
}
23+
],
24+
"headersSize": 520,
25+
"httpVersion": "HTTP/1.1",
26+
"method": "GET",
27+
"queryString": [
28+
{
29+
"name": "limit",
30+
"value": "2"
31+
}
32+
],
33+
"url": "https://api.datadoghq.com/api/v1/slo/correction?limit=2"
34+
},
35+
"response": {
36+
"bodySize": 1358,
37+
"content": {
38+
"mimeType": "application/json",
39+
"size": 1358,
40+
"text": "{\"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\":\"support-user-prod@datadoghq.com\",\"name\":\"Datadog 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\":\"support-user-prod@datadoghq.com\",\"name\":\"Datadog Support\",\"icon\":\"https://secure.gravatar.com/avatar/e6952b5f29fe2d996cf4e63f40db9e71?s=48&d=retro\"}}},\"modifier\":null}}],\"meta\":{\"page\":{\"total_count\":3,\"total_filtered_count\":2}}}\n"
41+
},
42+
"cookies": [],
43+
"headers": [
44+
{
45+
"name": "content-type",
46+
"value": "application/json"
47+
}
48+
],
49+
"headersSize": 663,
50+
"httpVersion": "HTTP/1.1",
51+
"redirectURL": "",
52+
"status": 200,
53+
"statusText": "OK"
54+
},
55+
"startedDateTime": "2023-08-25T11:50:34.979Z",
56+
"time": 551
57+
},
58+
{
59+
"_id": "95d50d9a0ada960f9b57178aacd8f885",
60+
"_order": 0,
61+
"cache": {},
62+
"request": {
63+
"bodySize": 0,
64+
"cookies": [],
65+
"headers": [
66+
{
67+
"_fromType": "array",
68+
"name": "accept",
69+
"value": "application/json"
70+
}
71+
],
72+
"headersSize": 529,
73+
"httpVersion": "HTTP/1.1",
74+
"method": "GET",
75+
"queryString": [
76+
{
77+
"name": "limit",
78+
"value": "2"
79+
},
80+
{
81+
"name": "offset",
82+
"value": "2"
83+
}
84+
],
85+
"url": "https://api.datadoghq.com/api/v1/slo/correction?limit=2&offset=2"
86+
},
87+
"response": {
88+
"bodySize": 714,
89+
"content": {
90+
"mimeType": "application/json",
91+
"size": 714,
92+
"text": "{\"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\":\"support-user-prod@datadoghq.com\",\"name\":\"Datadog Support\",\"icon\":\"https://secure.gravatar.com/avatar/e6952b5f29fe2d996cf4e63f40db9e71?s=48&d=retro\"}}},\"modifier\":null}}],\"meta\":{\"page\":{\"total_count\":3,\"total_filtered_count\":1}}}\n"
93+
},
94+
"cookies": [],
95+
"headers": [
96+
{
97+
"name": "content-type",
98+
"value": "application/json"
99+
}
100+
],
101+
"headersSize": 662,
102+
"httpVersion": "HTTP/1.1",
103+
"redirectURL": "",
104+
"status": 200,
105+
"statusText": "OK"
106+
},
107+
"startedDateTime": "2023-08-25T11:50:35.538Z",
108+
"time": 500
109+
}
110+
],
111+
"pages": [],
112+
"version": "1.2"
113+
}
114+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Get all SLO corrections returns "OK" response with pagination
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.ServiceLevelObjectiveCorrectionsApi(configuration);
9+
10+
const params: v1.ServiceLevelObjectiveCorrectionsApiListSLOCorrectionRequest = {
11+
limit: 2,
12+
};
13+
14+
(async () => {
15+
try {
16+
for await (const item of apiInstance.listSLOCorrectionWithPagination(
17+
params
18+
)) {
19+
console.log(item);
20+
}
21+
} catch (error) {
22+
console.error(error);
23+
}
24+
})();

features/v1/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

packages/datadog-api-client-v1/apis/ServiceLevelObjectiveCorrectionsApi.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ObjectSerializer } from "../models/ObjectSerializer";
1717
import { ApiException } from "../../datadog-api-client-common/exception";
1818

1919
import { APIErrorResponse } from "../models/APIErrorResponse";
20+
import { SLOCorrection } from "../models/SLOCorrection";
2021
import { SLOCorrectionCreateRequest } from "../models/SLOCorrectionCreateRequest";
2122
import { SLOCorrectionListResponse } from "../models/SLOCorrectionListResponse";
2223
import { SLOCorrectionResponse } from "../models/SLOCorrectionResponse";
@@ -681,6 +682,50 @@ export class ServiceLevelObjectiveCorrectionsApi {
681682
});
682683
}
683684

685+
/**
686+
* Provide a paginated version of listSLOCorrection returning a generator with all the items.
687+
*/
688+
public async *listSLOCorrectionWithPagination(
689+
param: ServiceLevelObjectiveCorrectionsApiListSLOCorrectionRequest = {},
690+
options?: Configuration
691+
): AsyncGenerator<SLOCorrection> {
692+
let pageSize = 25;
693+
if (param.limit !== undefined) {
694+
pageSize = param.limit;
695+
}
696+
param.limit = pageSize;
697+
while (true) {
698+
const requestContext = await this.requestFactory.listSLOCorrection(
699+
param.offset,
700+
param.limit,
701+
options
702+
);
703+
const responseContext = await this.configuration.httpApi.send(
704+
requestContext
705+
);
706+
707+
const response = await this.responseProcessor.listSLOCorrection(
708+
responseContext
709+
);
710+
const responseData = response.data;
711+
if (responseData === undefined) {
712+
break;
713+
}
714+
const results = responseData;
715+
for (const item of results) {
716+
yield item;
717+
}
718+
if (results.length < pageSize) {
719+
break;
720+
}
721+
if (param.offset === undefined) {
722+
param.offset = pageSize;
723+
} else {
724+
param.offset = param.offset + pageSize;
725+
}
726+
}
727+
}
728+
684729
/**
685730
* Update the specified SLO correction object.
686731
* @param param The request object

0 commit comments

Comments
 (0)