Skip to content

Commit 5f2a1fa

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
API specs for user team memberships (#1277)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent affc45a commit 5f2a1fa

File tree

10 files changed

+362
-4
lines changed

10 files changed

+362
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.5",
7-
"regenerated": "2023-08-03 18:00:18.464046",
8-
"spec_repo_commit": "b1453658"
7+
"regenerated": "2023-08-10 19:08:17.325687",
8+
"spec_repo_commit": "991b8a6f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-08-03 18:00:18.481981",
13-
"spec_repo_commit": "b1453658"
12+
"regenerated": "2023-08-10 19:08:17.348450",
13+
"spec_repo_commit": "991b8a6f"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27621,6 +27621,40 @@ paths:
2762127621
tags:
2762227622
- Users
2762327623
x-codegen-request-body-name: body
27624+
/api/v2/users/{user_uuid}/memberships:
27625+
get:
27626+
description: Get a list of memberships for a user
27627+
operationId: GetUserMemberships
27628+
parameters:
27629+
- description: None
27630+
in: path
27631+
name: user_uuid
27632+
required: true
27633+
schema:
27634+
type: string
27635+
responses:
27636+
'200':
27637+
content:
27638+
application/json:
27639+
schema:
27640+
$ref: '#/components/schemas/UserTeamsResponse'
27641+
description: Represents a user's association to a team
27642+
'404':
27643+
content:
27644+
application/json:
27645+
schema:
27646+
$ref: '#/components/schemas/APIErrorResponse'
27647+
description: API error response.
27648+
'429':
27649+
$ref: '#/components/responses/TooManyRequestsResponse'
27650+
security:
27651+
- apiKeyAuth: []
27652+
appKeyAuth: []
27653+
- AuthZ:
27654+
- teams_read
27655+
summary: Get user memberships
27656+
tags:
27657+
- Teams
2762427658
security:
2762527659
- apiKeyAuth: []
2762627660
appKeyAuth: []
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-08-10T19:02:36.392Z"
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"log": {
3+
"_recordingName": "Teams/Get user memberships returns \"Represents a user's association to a team\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "15eeb642a341176b40d8a100ffcb45d0",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 181,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 550,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"data\":{\"attributes\":{\"email\":\"Test-Get_user_memberships_returns_Represents_a_user_s_association_to_a_team_response-1691694156@datadoghq.com\",\"title\":\"user title\"},\"type\":\"users\"}}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v2/users"
39+
},
40+
"response": {
41+
"bodySize": 763,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 763,
45+
"text": "{\"data\":{\"type\":\"users\",\"id\":\"7833e13f-37b0-11ee-a0ea-725cd22022ad\",\"attributes\":{\"name\":null,\"handle\":\"test-get_user_memberships_returns_represents_a_user_s_association_to_a_team_response-1691694156@datadoghq.com\",\"created_at\":\"2023-08-10T19:02:36.551631+00:00\",\"modified_at\":\"2023-08-10T19:02:36.555165+00:00\",\"email\":\"test-get_user_memberships_returns_represents_a_user_s_association_to_a_team_response-1691694156@datadoghq.com\",\"icon\":\"https://secure.gravatar.com/avatar/8773e3c21e198b2955b34d27f0208990?s=48&d=retro\",\"title\":\"user title\",\"verified\":false,\"service_account\":false,\"disabled\":false,\"allowed_login_methods\":[],\"status\":\"Pending\"},\"relationships\":{\"roles\":{\"data\":[]},\"org\":{\"data\":{\"type\":\"orgs\",\"id\":\"4dee724d-00cc-11ea-a77b-570c9d03c6c5\"}}}}}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 650,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 201,
58+
"statusText": "Created"
59+
},
60+
"startedDateTime": "2023-08-10T19:02:36.418Z",
61+
"time": 207
62+
},
63+
{
64+
"_id": "51a7dd59d6bc90e4d12937fce700d437",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 553,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "GET",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v2/users/7833e13f-37b0-11ee-a0ea-725cd22022ad/memberships"
82+
},
83+
"response": {
84+
"bodySize": 12,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 12,
88+
"text": "{\"data\":[]}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 629,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2023-08-10T19:02:36.632Z",
104+
"time": 103
105+
},
106+
{
107+
"_id": "3065e874e9c6c1854261f76aef73f03d",
108+
"_order": 0,
109+
"cache": {},
110+
"request": {
111+
"bodySize": 0,
112+
"cookies": [],
113+
"headers": [
114+
{
115+
"_fromType": "array",
116+
"name": "accept",
117+
"value": "*/*"
118+
}
119+
],
120+
"headersSize": 524,
121+
"httpVersion": "HTTP/1.1",
122+
"method": "DELETE",
123+
"queryString": [],
124+
"url": "https://api.datadoghq.com/api/v2/users/7833e13f-37b0-11ee-a0ea-725cd22022ad"
125+
},
126+
"response": {
127+
"bodySize": 0,
128+
"content": {
129+
"mimeType": "text/plain",
130+
"size": 0
131+
},
132+
"cookies": [],
133+
"headers": [],
134+
"headersSize": 464,
135+
"httpVersion": "HTTP/1.1",
136+
"redirectURL": "",
137+
"status": 204,
138+
"statusText": "No Content"
139+
},
140+
"startedDateTime": "2023-08-10T19:02:36.742Z",
141+
"time": 360
142+
}
143+
],
144+
"pages": [],
145+
"version": "1.2"
146+
}
147+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Get user memberships returns "Represents a user's association to a team" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.TeamsApi(configuration);
9+
10+
// there is a valid "user" in the system
11+
const USER_DATA_ID = process.env.USER_DATA_ID as string;
12+
13+
const params: v2.TeamsApiGetUserMembershipsRequest = {
14+
userUuid: USER_DATA_ID,
15+
};
16+
17+
apiInstance
18+
.getUserMemberships(params)
19+
.then((data: v2.UserTeamsResponse) => {
20+
console.log(
21+
"API called successfully. Returned data: " + JSON.stringify(data)
22+
);
23+
})
24+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4710,6 +4710,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
47104710
},
47114711
"operationResponseType": "TeamPermissionSettingResponse",
47124712
},
4713+
"v2.GetUserMemberships": {
4714+
"userUuid": {
4715+
"type": "string",
4716+
"format": "",
4717+
},
4718+
"operationResponseType": "UserTeamsResponse",
4719+
},
47134720
"v2.ListIncidentTeams": {
47144721
"include": {
47154722
"type": "IncidentRelatedObject",

features/v2/teams.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ Feature: Teams
144144
When the request is sent
145145
Then the response status is 200 Represents a user's association to a team
146146

147+
@generated @skip @team:DataDog/core-app
148+
Scenario: Get user memberships returns "API error response." response
149+
Given new "GetUserMemberships" request
150+
And request contains "user_uuid" parameter from "REPLACE.ME"
151+
When the request is sent
152+
Then the response status is 404 API error response.
153+
154+
@team:DataDog/core-app
155+
Scenario: Get user memberships returns "Represents a user's association to a team" response
156+
Given new "GetUserMemberships" request
157+
And there is a valid "user" in the system
158+
And request contains "user_uuid" parameter from "user.data.id"
159+
When the request is sent
160+
Then the response status is 200 Represents a user's association to a team
161+
And the response "data" has length 0
162+
147163
@team:DataDog/core-app
148164
Scenario: Remove a team link returns "API error response." response
149165
Given new "DeleteTeamLink" request

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,5 +1815,11 @@
18151815
"undo": {
18161816
"type": "safe"
18171817
}
1818+
},
1819+
"GetUserMemberships": {
1820+
"tag": "Teams",
1821+
"undo": {
1822+
"type": "safe"
1823+
}
18181824
}
18191825
}

0 commit comments

Comments
 (0)