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.5",
"regenerated": "2023-08-03 18:00:12.583242",
"spec_repo_commit": "b1453658"
"regenerated": "2023-08-10 19:08:09.601897",
"spec_repo_commit": "991b8a6f"
},
"v2": {
"apigentools_version": "1.6.5",
"regenerated": "2023-08-03 18:00:12.596668",
"spec_repo_commit": "b1453658"
"regenerated": "2023-08-10 19:08:09.615583",
"spec_repo_commit": "991b8a6f"
}
}
}
34 changes: 34 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27621,6 +27621,40 @@ paths:
tags:
- Users
x-codegen-request-body-name: body
/api/v2/users/{user_uuid}/memberships:
get:
description: Get a list of memberships for a user
operationId: GetUserMemberships
parameters:
- description: None
in: path
name: user_uuid
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/UserTeamsResponse'
description: Represents a user's association to a team
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: API error response.
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- teams_read
summary: Get user memberships
tags:
- Teams
security:
- apiKeyAuth: []
appKeyAuth: []
Expand Down
27 changes: 27 additions & 0 deletions examples/v2/teams/GetUserMemberships.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Get user memberships returns "Represents a user's association to a team" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TeamsApi;
import com.datadog.api.client.v2.model.UserTeamsResponse;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
TeamsApi apiInstance = new TeamsApi(defaultClient);

// there is a valid "user" in the system
String USER_DATA_ID = System.getenv("USER_DATA_ID");

try {
UserTeamsResponse result = apiInstance.getUserMemberships(USER_DATA_ID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TeamsApi#getUserMemberships");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
134 changes: 134 additions & 0 deletions src/main/java/com/datadog/api/client/v2/api/TeamsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,140 @@ public ApiResponse<TeamPermissionSettingsResponse> getTeamPermissionSettingsWith
new GenericType<TeamPermissionSettingsResponse>() {});
}

/**
* Get user memberships.
*
* <p>See {@link #getUserMembershipsWithHttpInfo}.
*
* @param userUuid None (required)
* @return UserTeamsResponse
* @throws ApiException if fails to make API call
*/
public UserTeamsResponse getUserMemberships(String userUuid) throws ApiException {
return getUserMembershipsWithHttpInfo(userUuid).getData();
}

/**
* Get user memberships.
*
* <p>See {@link #getUserMembershipsWithHttpInfoAsync}.
*
* @param userUuid None (required)
* @return CompletableFuture&lt;UserTeamsResponse&gt;
*/
public CompletableFuture<UserTeamsResponse> getUserMembershipsAsync(String userUuid) {
return getUserMembershipsWithHttpInfoAsync(userUuid)
.thenApply(
response -> {
return response.getData();
});
}

/**
* Get a list of memberships for a user
*
* @param userUuid None (required)
* @return ApiResponse&lt;UserTeamsResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table border="1">
* <caption>Response details</caption>
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> Represents a user&#39;s association to a team </td><td> - </td></tr>
* <tr><td> 404 </td><td> API error response. </td><td> - </td></tr>
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<UserTeamsResponse> getUserMembershipsWithHttpInfo(String userUuid)
throws ApiException {
Object localVarPostBody = null;

// verify the required parameter 'userUuid' is set
if (userUuid == null) {
throw new ApiException(
400, "Missing the required parameter 'userUuid' when calling getUserMemberships");
}
// create path and map variables
String localVarPath =
"/api/v2/users/{user_uuid}/memberships"
.replaceAll("\\{" + "user_uuid" + "\\}", apiClient.escapeString(userUuid.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder =
apiClient.createBuilder(
"v2.TeamsApi.getUserMemberships",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"});
return apiClient.invokeAPI(
"GET",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<UserTeamsResponse>() {});
}

/**
* Get user memberships.
*
* <p>See {@link #getUserMembershipsWithHttpInfo}.
*
* @param userUuid None (required)
* @return CompletableFuture&lt;ApiResponse&lt;UserTeamsResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<UserTeamsResponse>> getUserMembershipsWithHttpInfoAsync(
String userUuid) {
Object localVarPostBody = null;

// verify the required parameter 'userUuid' is set
if (userUuid == null) {
CompletableFuture<ApiResponse<UserTeamsResponse>> result = new CompletableFuture<>();
result.completeExceptionally(
new ApiException(
400, "Missing the required parameter 'userUuid' when calling getUserMemberships"));
return result;
}
// create path and map variables
String localVarPath =
"/api/v2/users/{user_uuid}/memberships"
.replaceAll("\\{" + "user_uuid" + "\\}", apiClient.escapeString(userUuid.toString()));

Map<String, String> localVarHeaderParams = new HashMap<String, String>();

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.TeamsApi.getUserMemberships",
localVarPath,
new ArrayList<Pair>(),
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"});
} catch (ApiException ex) {
CompletableFuture<ApiResponse<UserTeamsResponse>> result = new CompletableFuture<>();
result.completeExceptionally(ex);
return result;
}
return apiClient.invokeAPIAsync(
"GET",
builder,
localVarHeaderParams,
new String[] {},
localVarPostBody,
new HashMap<String, Object>(),
false,
new GenericType<UserTeamsResponse>() {});
}

/** Manage optional parameters to listTeams. */
public static class ListTeamsOptionalParameters {
private Long pageNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-08-10T19:02:36.392Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
[
{
"httpRequest": {
"body": {
"type": "JSON",
"json": "{\"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\"}}"
},
"headers": {},
"method": "POST",
"path": "/api/v2/users",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"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",
"headers": {
"Content-Type": [
"application/json"
]
},
"statusCode": 201,
"reasonPhrase": "Created"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "15eeb642-a341-176b-40d8-a100ffcb45d0"
},
{
"httpRequest": {
"headers": {},
"method": "GET",
"path": "/api/v2/users/7833e13f-37b0-11ee-a0ea-725cd22022ad/memberships",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"data\":[]}\n",
"headers": {
"Content-Type": [
"application/json"
]
},
"statusCode": 200,
"reasonPhrase": "OK"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "51a7dd59-d6bc-90e4-d129-37fce700d437"
},
{
"httpRequest": {
"headers": {},
"method": "DELETE",
"path": "/api/v2/users/7833e13f-37b0-11ee-a0ea-725cd22022ad",
"keepAlive": false,
"secure": true
},
"httpResponse": {
"headers": {},
"statusCode": 204,
"reasonPhrase": "No Content"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "3065e874-e9c6-c185-4261-f76aef73f03d"
}
]
16 changes: 16 additions & 0 deletions src/test/resources/com/datadog/api/client/v2/api/teams.feature
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,22 @@ Feature: Teams
When the request is sent
Then the response status is 200 Represents a user's association to a team

@generated @skip @team:DataDog/core-app
Scenario: Get user memberships returns "API error response." response
Given new "GetUserMemberships" request
And request contains "user_uuid" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 404 API error response.

@team:DataDog/core-app
Scenario: Get user memberships returns "Represents a user's association to a team" response
Given new "GetUserMemberships" request
And there is a valid "user" in the system
And request contains "user_uuid" parameter from "user.data.id"
When the request is sent
Then the response status is 200 Represents a user's association to a team
And the response "data" has length 0

@team:DataDog/core-app
Scenario: Remove a team link returns "API error response." response
Given new "DeleteTeamLink" request
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/com/datadog/api/client/v2/api/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1815,5 +1815,11 @@
"undo": {
"type": "safe"
}
},
"GetUserMemberships": {
"tag": "Teams",
"undo": {
"type": "safe"
}
}
}