Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
4 changes: 4 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-01-26T20:53:20.323Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions examples/v2/teams/GetTeamMemberships_3799131168.rb
Original file line number Diff line number Diff line change
@@ -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 }
9 changes: 9 additions & 0 deletions features/v2/teams.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions lib/datadog_api_client/v2/api/teams_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down