From bde63b7e847a10a59a40125e2d493461a2c74ece Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 25 Aug 2023 12:26:51 +0000 Subject: [PATCH] Regenerate client from commit 1a77c0b6 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 5 + .../frozen.json | 1 + .../recording.har | 114 ++++++++++++++++++ .../ListSLOCorrection_2647266873.ts | 24 ++++ ...ervice_level_objective_corrections.feature | 8 ++ .../ServiceLevelObjectiveCorrectionsApi.ts | 45 +++++++ 7 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/frozen.json create mode 100644 cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/recording.har create mode 100644 examples/v1/service-level-objective-corrections/ListSLOCorrection_2647266873.ts diff --git a/.apigentools-info b/.apigentools-info index 9a30e86a684..f500c1cbb15 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.5", - "regenerated": "2023-08-23 20:02:10.805710", - "spec_repo_commit": "7e4a4121" + "regenerated": "2023-08-25 12:25:26.250184", + "spec_repo_commit": "1a77c0b6" }, "v2": { "apigentools_version": "1.6.5", - "regenerated": "2023-08-23 20:02:10.823663", - "spec_repo_commit": "7e4a4121" + "regenerated": "2023-08-25 12:25:26.263034", + "spec_repo_commit": "1a77c0b6" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index ec93ec4e73e..dc922326080 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -27185,6 +27185,7 @@ paths: name: limit required: false schema: + default: 25 format: int64 type: integer responses: @@ -27210,6 +27211,10 @@ paths: summary: Get all SLO corrections tags: - Service Level Objective Corrections + x-pagination: + limitParam: limit + pageOffsetParam: offset + resultsPath: data post: description: Create an SLO Correction. operationId: CreateSLOCorrection diff --git a/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/frozen.json b/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/frozen.json new file mode 100644 index 00000000000..6cfa139d7ba --- /dev/null +++ b/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/frozen.json @@ -0,0 +1 @@ +"2023-08-25T11:50:34.970Z" diff --git a/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/recording.har b/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/recording.har new file mode 100644 index 00000000000..2bebf32355b --- /dev/null +++ b/cassettes/v1/Service-Level-Objective-Corrections_2301830752/Get-all-SLO-corrections-returns-OK-response-with-pagination_1089906795/recording.har @@ -0,0 +1,114 @@ +{ + "log": { + "_recordingName": "Service Level Objective Corrections/Get all SLO corrections returns \"OK\" response with pagination", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "a47256681b359bab367712eda16a1905", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 520, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [ + { + "name": "limit", + "value": "2" + } + ], + "url": "https://api.datadoghq.com/api/v1/slo/correction?limit=2" + }, + "response": { + "bodySize": 1358, + "content": { + "mimeType": "application/json", + "size": 1358, + "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" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 663, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2023-08-25T11:50:34.979Z", + "time": 551 + }, + { + "_id": "95d50d9a0ada960f9b57178aacd8f885", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 529, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [ + { + "name": "limit", + "value": "2" + }, + { + "name": "offset", + "value": "2" + } + ], + "url": "https://api.datadoghq.com/api/v1/slo/correction?limit=2&offset=2" + }, + "response": { + "bodySize": 714, + "content": { + "mimeType": "application/json", + "size": 714, + "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" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 662, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2023-08-25T11:50:35.538Z", + "time": 500 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/examples/v1/service-level-objective-corrections/ListSLOCorrection_2647266873.ts b/examples/v1/service-level-objective-corrections/ListSLOCorrection_2647266873.ts new file mode 100644 index 00000000000..fa2a682b8e9 --- /dev/null +++ b/examples/v1/service-level-objective-corrections/ListSLOCorrection_2647266873.ts @@ -0,0 +1,24 @@ +/** + * Get all SLO corrections returns "OK" response with pagination + */ + +import { client, v1 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v1.ServiceLevelObjectiveCorrectionsApi(configuration); + +const params: v1.ServiceLevelObjectiveCorrectionsApiListSLOCorrectionRequest = { + limit: 2, +}; + +(async () => { + try { + for await (const item of apiInstance.listSLOCorrectionWithPagination( + params + )) { + console.log(item); + } + } catch (error) { + console.error(error); + } +})(); diff --git a/features/v1/service_level_objective_corrections.feature b/features/v1/service_level_objective_corrections.feature index 8d7974996f6..5bd777cbd51 100644 --- a/features/v1/service_level_objective_corrections.feature +++ b/features/v1/service_level_objective_corrections.feature @@ -72,6 +72,14 @@ Feature: Service Level Objective Corrections Then the response status is 200 OK And the response "data" has length 1 + @replay-only @skip-validation @team:DataDog/slo-app @with-pagination + Scenario: Get all SLO corrections returns "OK" response with pagination + Given new "ListSLOCorrection" request + And request contains "limit" parameter with value 2 + When the request with pagination is sent + Then the response status is 200 OK + And the response has 3 items + @generated @skip @team:DataDog/slo-app Scenario: Get an SLO correction for an SLO returns "Bad Request" response Given new "GetSLOCorrection" request diff --git a/packages/datadog-api-client-v1/apis/ServiceLevelObjectiveCorrectionsApi.ts b/packages/datadog-api-client-v1/apis/ServiceLevelObjectiveCorrectionsApi.ts index 43705b58240..2c726787421 100644 --- a/packages/datadog-api-client-v1/apis/ServiceLevelObjectiveCorrectionsApi.ts +++ b/packages/datadog-api-client-v1/apis/ServiceLevelObjectiveCorrectionsApi.ts @@ -17,6 +17,7 @@ import { ObjectSerializer } from "../models/ObjectSerializer"; import { ApiException } from "../../datadog-api-client-common/exception"; import { APIErrorResponse } from "../models/APIErrorResponse"; +import { SLOCorrection } from "../models/SLOCorrection"; import { SLOCorrectionCreateRequest } from "../models/SLOCorrectionCreateRequest"; import { SLOCorrectionListResponse } from "../models/SLOCorrectionListResponse"; import { SLOCorrectionResponse } from "../models/SLOCorrectionResponse"; @@ -681,6 +682,50 @@ export class ServiceLevelObjectiveCorrectionsApi { }); } + /** + * Provide a paginated version of listSLOCorrection returning a generator with all the items. + */ + public async *listSLOCorrectionWithPagination( + param: ServiceLevelObjectiveCorrectionsApiListSLOCorrectionRequest = {}, + options?: Configuration + ): AsyncGenerator { + let pageSize = 25; + if (param.limit !== undefined) { + pageSize = param.limit; + } + param.limit = pageSize; + while (true) { + const requestContext = await this.requestFactory.listSLOCorrection( + param.offset, + param.limit, + options + ); + const responseContext = await this.configuration.httpApi.send( + requestContext + ); + + const response = await this.responseProcessor.listSLOCorrection( + responseContext + ); + const responseData = response.data; + if (responseData === undefined) { + break; + } + const results = responseData; + for (const item of results) { + yield item; + } + if (results.length < pageSize) { + break; + } + if (param.offset === undefined) { + param.offset = pageSize; + } else { + param.offset = param.offset + pageSize; + } + } + } + /** * Update the specified SLO correction object. * @param param The request object