diff --git a/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.frozen b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.frozen new file mode 100644 index 000000000000..1858032e081c --- /dev/null +++ b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.frozen @@ -0,0 +1 @@ +2026-03-31T14:58:05.044Z \ No newline at end of file diff --git a/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.yml b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.yml new file mode 100644 index 000000000000..ea0897269d04 --- /dev/null +++ b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-API-error-response-response.yml @@ -0,0 +1,148 @@ +http_interactions: +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"handle":"test-handle-22e42ce95626a92a","name":"test-name-22e42ce95626a92a"},"type":"team"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/team + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"abc7c612-d3a1-4147-bcfa-f28b4af43d33","type":"team","attributes":{"avatar":null,"banner":10,"created_at":"2026-03-31T14:58:05.503733+00:00","description":null,"handle":"test-handle-22e42ce95626a92a","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-03-31T14:58:05.503733+00:00","name":"test-name-22e42ce95626a92a","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33/permission-settings"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Add_a_user_to_a_team_returns_API_error_response_response-1774969085@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data": {"type": "users", "id": "825c5f4c-585c-494a-aade-60f1e1aa189b", + "attributes": {"name": null, "handle": "test-add_a_user_to_a_team_returns_api_error_response_response-1774969085@datadoghq.com", + "created_at": "2026-03-31T14:58:06.030754+00:00", "modified_at": "2026-03-31T14:58:06.030754+00:00", + "email": "test-add_a_user_to_a_team_returns_api_error_response_response-1774969085@datadoghq.com", + "icon": "https://secure.gravatar.com/avatar/53ba6f826ef9a49acaeec55d1bcc1c47?s=48&d=retro", + "title": "user title", "verified": false, "service_account": false, "disabled": + false, "allowed_login_methods": [], "status": "Pending", "last_login_time": + null}, "relationships": {"roles": {"data": []}, "org": {"data": {"type": "orgs", + "id": "4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}}' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"role":"admin"},"relationships":{"user":{"data":{"id":"825c5f4c-585c-494a-aade-60f1e1aa189b","type":"users"}}},"type":"team_memberships"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33/memberships + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"TeamMembership-abc7c612-d3a1-4147-bcfa-f28b4af43d33-66215044","type":"team_memberships","attributes":{"provisioned_by":null,"provisioned_by_id":"a1d5ff5a-c6dd-11f0-9cb6-06640ca27ad4","role":"admin"},"relationships":{"user":{"data":{"id":"825c5f4c-585c-494a-aade-60f1e1aa189b","type":"users"}}}},"included":[{"id":"825c5f4c-585c-494a-aade-60f1e1aa189b","type":"users","attributes":{"disabled":false,"email":"test-add_a_user_to_a_team_returns_api_error_response_response-1774969085@datadoghq.com","handle":"test-add_a_user_to_a_team_returns_api_error_response_response-1774969085@datadoghq.com","icon":"https://secure.gravatar.com/avatar/53ba6f826ef9a49acaeec55d1bcc1c47?d=retro\u0026s=48","name":null,"service_account":false,"status":"Pending"}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"role":"admin"},"relationships":{"user":{"data":{"id":"825c5f4c-585c-494a-aade-60f1e1aa189b","type":"users"}}},"type":"team_memberships"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33/memberships + response: + body: + encoding: UTF-8 + string: '{"errors":[{"status":"409","title":"Conflict","detail":"users already + present on the team [825c5f4c-585c-494a-aade-60f1e1aa189b]"}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 409 + message: Conflict +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33/memberships/825c5f4c-585c-494a-aade-60f1e1aa189b + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/825c5f4c-585c-494a-aade-60f1e1aa189b + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Tue, 31 Mar 2026 14:58:05 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/team/abc7c612-d3a1-4147-bcfa-f28b4af43d33 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.frozen b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.frozen new file mode 100644 index 000000000000..41a13b9fdc58 --- /dev/null +++ b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.frozen @@ -0,0 +1 @@ +2026-03-31T14:57:49.739Z \ No newline at end of file diff --git a/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.yml b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.yml new file mode 100644 index 000000000000..aff973a5da83 --- /dev/null +++ b/cassettes/features/v2/teams/Add-a-user-to-a-team-returns-Represents-a-user-s-association-to-a-team-response.yml @@ -0,0 +1,125 @@ +http_interactions: +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"handle":"test-handle-3170c6f6f5b25b4d","name":"test-name-3170c6f6f5b25b4d"},"type":"team"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/team + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"95ac9e78-0a56-4a6a-9e5e-21580dc141cc","type":"team","attributes":{"avatar":null,"banner":9,"created_at":"2026-03-31T14:57:54.888553+00:00","description":null,"handle":"test-handle-3170c6f6f5b25b4d","hidden_modules":null,"is_managed":false,"link_count":0,"modified_at":"2026-03-31T14:57:54.888553+00:00","name":"test-name-3170c6f6f5b25b4d","summary":null,"user_count":0,"visible_modules":null},"relationships":{"team_links":{"data":[],"links":{"related":"/api/v2/team/95ac9e78-0a56-4a6a-9e5e-21580dc141cc/links"}},"user_team_permissions":{"data":null,"links":{"related":"/api/v2/team/95ac9e78-0a56-4a6a-9e5e-21580dc141cc/permission-settings"}}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"email":"Test-Add_a_user_to_a_team_returns_Represents_a_user_s_association_to_a_team_response-1774969069@datadoghq.com","title":"user + title"},"type":"users"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/users + response: + body: + encoding: UTF-8 + string: '{"data": {"type": "users", "id": "ebb17d15-5e46-4440-856f-75710cbbce4b", + "attributes": {"name": null, "handle": "test-add_a_user_to_a_team_returns_represents_a_user_s_association_to_a_team_response-1774969069@datadoghq.com", + "created_at": "2026-03-31T14:57:55.106406+00:00", "modified_at": "2026-03-31T14:57:55.106406+00:00", + "email": "test-add_a_user_to_a_team_returns_represents_a_user_s_association_to_a_team_response-1774969069@datadoghq.com", + "icon": "https://secure.gravatar.com/avatar/52a30c814f85968a9d363cc103840284?s=48&d=retro", + "title": "user title", "verified": false, "service_account": false, "disabled": + false, "allowed_login_methods": [], "status": "Pending", "last_login_time": + null}, "relationships": {"roles": {"data": []}, "org": {"data": {"type": "orgs", + "id": "4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}}' + headers: + Content-Type: + - application/json + status: + code: 201 + message: Created +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"role":"admin"},"relationships":{"user":{"data":{"id":"ebb17d15-5e46-4440-856f-75710cbbce4b","type":"users"}}},"type":"team_memberships"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/team/95ac9e78-0a56-4a6a-9e5e-21580dc141cc/memberships + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"TeamMembership-95ac9e78-0a56-4a6a-9e5e-21580dc141cc-66215040","type":"team_memberships","attributes":{"provisioned_by":null,"provisioned_by_id":"a1d5ff5a-c6dd-11f0-9cb6-06640ca27ad4","role":"admin"},"relationships":{"user":{"data":{"id":"ebb17d15-5e46-4440-856f-75710cbbce4b","type":"users"}}}},"included":[{"id":"ebb17d15-5e46-4440-856f-75710cbbce4b","type":"users","attributes":{"disabled":false,"email":"test-add_a_user_to_a_team_returns_represents_a_user_s_association_to_a_team_response-1774969069@datadoghq.com","handle":"test-add_a_user_to_a_team_returns_represents_a_user_s_association_to_a_team_response-1774969069@datadoghq.com","icon":"https://secure.gravatar.com/avatar/52a30c814f85968a9d363cc103840284?d=retro\u0026s=48","name":null,"service_account":false,"status":"Pending"}}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/team/95ac9e78-0a56-4a6a-9e5e-21580dc141cc/memberships/ebb17d15-5e46-4440-856f-75710cbbce4b + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/users/ebb17d15-5e46-4440-856f-75710cbbce4b + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Tue, 31 Mar 2026 14:57:49 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/team/95ac9e78-0a56-4a6a-9e5e-21580dc141cc + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/teams/CreateTeamMembership.rb b/examples/v2/teams/CreateTeamMembership.rb index 154fa151a7b5..c2392641a648 100644 --- a/examples/v2/teams/CreateTeamMembership.rb +++ b/examples/v2/teams/CreateTeamMembership.rb @@ -3,21 +3,21 @@ require "datadog_api_client" api_instance = DatadogAPIClient::V2::TeamsAPI.new +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = ENV["DD_TEAM_DATA_ID"] + +# there is a valid "user" in the system +USER_DATA_ID = ENV["USER_DATA_ID"] + body = DatadogAPIClient::V2::UserTeamRequest.new({ data: DatadogAPIClient::V2::UserTeamCreate.new({ attributes: DatadogAPIClient::V2::UserTeamAttributes.new({ role: DatadogAPIClient::V2::UserTeamRole::ADMIN, }), relationships: DatadogAPIClient::V2::UserTeamRelationships.new({ - team: DatadogAPIClient::V2::RelationshipToUserTeamTeam.new({ - data: DatadogAPIClient::V2::RelationshipToUserTeamTeamData.new({ - id: "d7e15d9d-d346-43da-81d8-3d9e71d9a5e9", - type: DatadogAPIClient::V2::UserTeamTeamType::TEAM, - }), - }), user: DatadogAPIClient::V2::RelationshipToUserTeamUser.new({ data: DatadogAPIClient::V2::RelationshipToUserTeamUserData.new({ - id: "b8626d7e-cedd-11eb-abf5-da7ad0900001", + id: USER_DATA_ID, type: DatadogAPIClient::V2::UserTeamUserType::USERS, }), }), @@ -25,4 +25,4 @@ type: DatadogAPIClient::V2::UserTeamType::TEAM_MEMBERSHIPS, }), }) -p api_instance.create_team_membership("team_id", body) +p api_instance.create_team_membership(DD_TEAM_DATA_ID, body) diff --git a/features/v2/teams.feature b/features/v2/teams.feature index c24ced9ffbf1..b21078ebf328 100644 --- a/features/v2/teams.feature +++ b/features/v2/teams.feature @@ -27,21 +27,28 @@ Feature: Teams When the request is sent Then the response status is 204 Added - @generated @skip @team:DataDog/aaa-omg + @team:DataDog/aaa-omg Scenario: Add a user to a team returns "API error response." response Given new "CreateTeamMembership" request - And request contains "team_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"role": "admin"}, "relationships": {"team": {"data": {"id": "d7e15d9d-d346-43da-81d8-3d9e71d9a5e9", "type": "team"}}, "user": {"data": {"id": "b8626d7e-cedd-11eb-abf5-da7ad0900001", "type": "users"}}}, "type": "team_memberships"}} + And there is a valid "dd_team" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And body with value {"data": {"attributes": {"role": "admin"}, "relationships": {"user": {"data": {"id": "{{user.data.id}}", "type": "users"}}}, "type": "team_memberships"}} When the request is sent Then the response status is 409 API error response. - @generated @skip @team:DataDog/aaa-omg + @team:DataDog/aaa-omg Scenario: Add a user to a team returns "Represents a user's association to a team" response Given new "CreateTeamMembership" request - And request contains "team_id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"role": "admin"}, "relationships": {"team": {"data": {"id": "d7e15d9d-d346-43da-81d8-3d9e71d9a5e9", "type": "team"}}, "user": {"data": {"id": "b8626d7e-cedd-11eb-abf5-da7ad0900001", "type": "users"}}}, "type": "team_memberships"}} + And there is a valid "dd_team" in the system + And there is a valid "user" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And body with value {"data": {"attributes": {"role": "admin"}, "relationships": {"user": {"data": {"id": "{{user.data.id}}", "type": "users"}}}, "type": "team_memberships"}} When the request is sent Then the response status is 200 Represents a user's association to a team + And the response "data.attributes.role" is equal to "admin" + And the response "data.relationships.user.data.id" is equal to "{{ user.data.id }}" @team:DataDog/aaa-omg Scenario: Create a team hierarchy link returns "Conflict" response