From 8a9f257c8f88cd49252d15bab6f818d5fbbca55d Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 26 Jan 2024 20:57:42 +0000 Subject: [PATCH] Regenerate client from commit a1db94fd of spec repo --- .apigentools-info | 8 ++-- .generator/schemas/v2/openapi.yaml | 4 ++ ...-to-a-team-response-with-pagination.frozen | 1 + ...ion-to-a-team-response-with-pagination.yml | 44 +++++++++++++++++++ .../v2/teams/GetTeamMemberships_3799131168.rb | 8 ++++ features/v2/teams.feature | 9 ++++ lib/datadog_api_client/v2/api/teams_api.rb | 22 ++++++++++ 7 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.frozen create mode 100644 cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.yml create mode 100644 examples/v2/teams/GetTeamMemberships_3799131168.rb diff --git a/.apigentools-info b/.apigentools-info index f0f38630644f..cd211565b11c 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:24.298614", - "spec_repo_commit": "28baf464" + "regenerated": "2024-01-26 20:57:00.853640", + "spec_repo_commit": "a1db94fd" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-01-26 15:59:24.315324", - "spec_repo_commit": "28baf464" + "regenerated": "2024-01-26 20:57:00.877710", + "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 61c44d794551..fccffb364a2e 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/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.frozen b/cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.frozen new file mode 100644 index 000000000000..c1b94356d515 --- /dev/null +++ b/cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.frozen @@ -0,0 +1 @@ +2024-01-26T20:53:20.323Z \ No newline at end of file diff --git a/cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.yml b/cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.yml new file mode 100644 index 000000000000..41844518e5ea --- /dev/null +++ b/cassettes/features/v2/teams/Get-team-memberships-returns-Represents-a-user-s-association-to-a-team-response-with-pagination.yml @@ -0,0 +1,44 @@ +http_interactions: +- recorded_at: Fri, 26 Jan 2024 20:53:20 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=0 + response: + body: + encoding: UTF-8 + string: '{"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"}} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +- recorded_at: Fri, 26 Jan 2024 20:53:20 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/team/2e06bf2c-193b-41d4-b3c2-afccc080458f/memberships?page%5Bsize%5D=2&page%5Bnumber%5D=1 + response: + body: + encoding: UTF-8 + string: '{"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"}} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v2/teams/GetTeamMemberships_3799131168.rb b/examples/v2/teams/GetTeamMemberships_3799131168.rb new file mode 100644 index 000000000000..0f30bbc17133 --- /dev/null +++ b/examples/v2/teams/GetTeamMemberships_3799131168.rb @@ -0,0 +1,8 @@ +# Get team memberships returns "Represents a user's association to a team" response with pagination + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::TeamsAPI.new +opts = { + page_size: 2, +} +api_instance.get_team_memberships_with_pagination("2e06bf2c-193b-41d4-b3c2-afccc080458f", opts) { |item| puts item } diff --git a/features/v2/teams.feature b/features/v2/teams.feature index e1ba489facfb..9673e82ca9af 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/lib/datadog_api_client/v2/api/teams_api.rb b/lib/datadog_api_client/v2/api/teams_api.rb index 3623be39890d..c96a50c610b5 100644 --- a/lib/datadog_api_client/v2/api/teams_api.rb +++ b/lib/datadog_api_client/v2/api/teams_api.rb @@ -717,6 +717,28 @@ def get_team_memberships_with_http_info(team_id, opts = {}) return data, status_code, headers end + # Get team memberships. + # + # Provide a paginated version of {#get_team_memberships}, returning all items. + # + # To use it you need to use a block: get_team_memberships_with_pagination { |item| p item } + # + # @yield [UserTeam] Paginated items + def get_team_memberships_with_pagination(team_id, opts = {}) + api_version = "V2" + page_size = @api_client.get_attribute_from_path(opts, "page_size", 10) + @api_client.set_attribute_from_path(api_version, opts, "page_size", Integer, page_size) + @api_client.set_attribute_from_path(api_version, opts, "page_number", Integer, 0) + while true do + response = get_team_memberships(team_id, opts) + @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) } + if @api_client.get_attribute_from_path(response, "data").length < page_size + break + end + @api_client.set_attribute_from_path(api_version, opts, "page_number", Integer, @api_client.get_attribute_from_path(opts, "page_number", 0) + 1) + end + end + # Get permission settings for a team. # # @see #get_team_permission_settings_with_http_info