From 00cc6c4dcc49cd75ccec6130e5ef5bd967a9ee43 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 26 Jan 2024 20:59:05 +0000 Subject: [PATCH] Regenerate client from commit a1db94fd of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 4 + .../frozen.json | 1 + .../recording.har | 116 ++++++++++++++++++ .../v2/teams/GetTeamMemberships_3799131168.ts | 25 ++++ features/v2/teams.feature | 9 ++ .../datadog-api-client-v2/apis/TeamsApi.ts | 45 +++++++ 7 files changed, 204 insertions(+), 4 deletions(-) create mode 100644 cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/frozen.json create mode 100644 cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/recording.har create mode 100644 examples/v2/teams/GetTeamMemberships_3799131168.ts diff --git a/.apigentools-info b/.apigentools-info index bcc6e035b45..f61f4024e50 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-01-26 15:59:28.351864", - "spec_repo_commit": "28baf464" + "regenerated": "2024-01-26 20:56:59.043844", + "spec_repo_commit": "a1db94fd" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-01-26 15:59:28.366791", - "spec_repo_commit": "28baf464" + "regenerated": "2024-01-26 20:56:59.077077", + "spec_repo_commit": "a1db94fd" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 61c44d79455..fccffb364a2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -31989,6 +31989,10 @@ paths: summary: Get team memberships tags: - Teams + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data post: description: Add a user to a team. operationId: CreateTeamMembership diff --git a/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/frozen.json b/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/frozen.json new file mode 100644 index 00000000000..449b70bdce3 --- /dev/null +++ b/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/frozen.json @@ -0,0 +1 @@ +"2024-01-26T20:53:20.323Z" diff --git a/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/recording.har b/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/recording.har new file mode 100644 index 00000000000..404d72af176 --- /dev/null +++ b/cassettes/v2/Teams_3116892301/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagi_1121369630/recording.har @@ -0,0 +1,116 @@ +{ + "log": { + "_recordingName": "Teams/Get team memberships returns \"Represents a user's association to a team\" response with pagination", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "3c8d7929145ffc09b9363558091bd3a3", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 588, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [ + { + "name": "page", + "value": { + "number": "0", + "size": "2" + } + } + ], + "url": "https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=0" + }, + "response": { + "bodySize": 2081, + "content": { + "mimeType": "application/json", + "size": 2081, + "text": "{\"data\":[{\"type\":\"team_memberships\",\"id\":\"TeamMembership-2e06bf2c-193b-41d4-b3c2-afccc080458f-3736692\",\"attributes\":{\"role\":null,\"provisioned_by\":null,\"provisioned_by_id\":\"6018c832-80a7-11ea-93dd-43183212bc7a\"},\"relationships\":{\"user\":{\"data\":{\"type\":\"users\",\"id\":\"03b4bfc0-98b9-11ec-842d-da7ad0900002\"}}}},{\"type\":\"team_memberships\",\"id\":\"TeamMembership-2e06bf2c-193b-41d4-b3c2-afccc080458f-4055096\",\"attributes\":{\"role\":null,\"provisioned_by\":null,\"provisioned_by_id\":\"6018c832-80a7-11ea-93dd-43183212bc7a\"},\"relationships\":{\"user\":{\"data\":{\"type\":\"users\",\"id\":\"170a64a1-d9c6-11ec-af01-da7ad0900002\"}}}}],\"included\":[{\"type\":\"users\",\"id\":\"03b4bfc0-98b9-11ec-842d-da7ad0900002\",\"attributes\":{\"name\":\"Datadog API Client Python\",\"handle\":\"example-create_a_user_returns_ok_response_1646068093@datadoghq.com\",\"email\":\"example-create_a_user_returns_ok_response_1646068093@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/27fb863ad335246b65fe4989f1686f35?s=48&d=retro\",\"disabled\":false,\"service_account\":false}},{\"type\":\"users\",\"id\":\"170a64a1-d9c6-11ec-af01-da7ad0900002\",\"attributes\":{\"name\":\"Datadog API Client Python\",\"handle\":\"example-create_a_user_returns_ok_response_1653220535@datadoghq.com\",\"email\":\"example-create_a_user_returns_ok_response_1653220535@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/c5256983bba478dfd35e83bbb73621cc?s=48&d=retro\",\"disabled\":false,\"service_account\":false}}],\"meta\":{\"pagination\":{\"number\":0,\"first_number\":0,\"prev_number\":0,\"next_number\":1,\"last_number\":1,\"size\":2,\"type\":\"number_size\",\"total\":3}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=0\",\"last\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=1&page[size]=2\",\"next\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=1&page[size]=2\",\"prev\":null,\"first\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=0&page[size]=2\"}}\n" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 654, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-01-26T20:53:20.334Z", + "time": 152 + }, + { + "_id": "a72c08baf10659c0e4ff4ce823d38238", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + } + ], + "headersSize": 588, + "httpVersion": "HTTP/1.1", + "method": "GET", + "queryString": [ + { + "name": "page", + "value": { + "number": "1", + "size": "2" + } + } + ], + "url": "https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=1" + }, + "response": { + "bodySize": 1379, + "content": { + "mimeType": "application/json", + "size": 1379, + "text": "{\"data\":[{\"type\":\"team_memberships\",\"id\":\"TeamMembership-2e06bf2c-193b-41d4-b3c2-afccc080458f-1445416\",\"attributes\":{\"role\":null,\"provisioned_by\":null,\"provisioned_by_id\":\"6018c832-80a7-11ea-93dd-43183212bc7a\"},\"relationships\":{\"user\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}}],\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/28a16dfe36e73b60c1d55872cb0f1172?s=48&d=retro\",\"disabled\":false,\"service_account\":false}}],\"meta\":{\"pagination\":{\"number\":1,\"first_number\":0,\"prev_number\":0,\"next_number\":2,\"last_number\":1,\"size\":2,\"type\":\"number_size\",\"total\":3}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=1\",\"last\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=1&page[size]=2\",\"next\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=2&page[size]=2\",\"prev\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=0&page[size]=2\",\"first\":\"https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page[number]=0&page[size]=2\"}}\n" + }, + "cookies": [], + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "headersSize": 654, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-01-26T20:53:20.515Z", + "time": 114 + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/examples/v2/teams/GetTeamMemberships_3799131168.ts b/examples/v2/teams/GetTeamMemberships_3799131168.ts new file mode 100644 index 00000000000..f14af753abe --- /dev/null +++ b/examples/v2/teams/GetTeamMemberships_3799131168.ts @@ -0,0 +1,25 @@ +/** + * Get team memberships returns "Represents a user's association to a team" response with pagination + */ + +import { client, v2 } from "@datadog/datadog-api-client"; + +const configuration = client.createConfiguration(); +const apiInstance = new v2.TeamsApi(configuration); + +const params: v2.TeamsApiGetTeamMembershipsRequest = { + teamId: "2e06bf2c-193b-41d4-b3c2-afccc080458f", + pageSize: 2, +}; + +(async () => { + try { + for await (const item of apiInstance.getTeamMembershipsWithPagination( + params + )) { + console.log(item); + } + } catch (error) { + console.error(error); + } +})(); diff --git a/features/v2/teams.feature b/features/v2/teams.feature index e1ba489facf..9673e82ca9a 100644 --- a/features/v2/teams.feature +++ b/features/v2/teams.feature @@ -182,6 +182,15 @@ Feature: Teams When the request is sent Then the response status is 200 Represents a user's association to a team + @replay-only @skip-validation @team:DataDog/core-app @with-pagination + Scenario: Get team memberships returns "Represents a user's association to a team" response with pagination + Given new "GetTeamMemberships" request + And request contains "team_id" parameter with value "2e06bf2c-193b-41d4-b3c2-afccc080458f" + And request contains "page[size]" 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/core-app Scenario: Get user memberships returns "API error response." response Given new "GetUserMemberships" request diff --git a/packages/datadog-api-client-v2/apis/TeamsApi.ts b/packages/datadog-api-client-v2/apis/TeamsApi.ts index b1e5fd87167..4416037ffeb 100644 --- a/packages/datadog-api-client-v2/apis/TeamsApi.ts +++ b/packages/datadog-api-client-v2/apis/TeamsApi.ts @@ -32,6 +32,7 @@ import { TeamResponse } from "../models/TeamResponse"; import { TeamsField } from "../models/TeamsField"; import { TeamsResponse } from "../models/TeamsResponse"; import { TeamUpdateRequest } from "../models/TeamUpdateRequest"; +import { UserTeam } from "../models/UserTeam"; import { UserTeamRequest } from "../models/UserTeamRequest"; import { UserTeamResponse } from "../models/UserTeamResponse"; import { UserTeamsResponse } from "../models/UserTeamsResponse"; @@ -2335,6 +2336,50 @@ export class TeamsApi { }); } + /** + * Provide a paginated version of getTeamMemberships returning a generator with all the items. + */ + public async *getTeamMembershipsWithPagination( + param: TeamsApiGetTeamMembershipsRequest, + options?: Configuration + ): AsyncGenerator { + let pageSize = 10; + if (param.pageSize !== undefined) { + pageSize = param.pageSize; + } + param.pageSize = pageSize; + param.pageNumber = 0; + while (true) { + const requestContext = await this.requestFactory.getTeamMemberships( + param.teamId, + param.pageSize, + param.pageNumber, + param.sort, + param.filterKeyword, + options + ); + const responseContext = await this.configuration.httpApi.send( + requestContext + ); + + const response = await this.responseProcessor.getTeamMemberships( + responseContext + ); + const responseData = response.data; + if (responseData === undefined) { + break; + } + const results = responseData; + for (const item of results) { + yield item; + } + if (results.length < pageSize) { + break; + } + param.pageNumber = param.pageNumber + 1; + } + } + /** * Get all permission settings for a given team. * @param param The request object