Skip to content
Open
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
9 changes: 9 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249124,6 +249124,15 @@ paths:
schema:
example: Active
type: string
- description: |-
Filter on the exact user handle. This filter also returns Datadog-managed users,
which the list otherwise excludes. Defaults to no filtering.
in: query
name: filter[handle]
required: false
schema:
example: example-handle
type: string
responses:
"200":
content:
Expand Down
31 changes: 31 additions & 0 deletions examples/v2/users/ListUsers_850007038.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* List all users filtered by handle returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.UsersApi(configuration);

// there is a valid "user" in the system
const USER_DATA_ATTRIBUTES_HANDLE = process.env
.USER_DATA_ATTRIBUTES_HANDLE as string;

const params: v2.UsersApiListUsersRequest = {
filterHandle: USER_DATA_ATTRIBUTES_HANDLE,
};

apiInstance
.listUsers(params)
.then((data: v2.UsersResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
7 changes: 7 additions & 0 deletions features/generated-test/test-runner-data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12614,6 +12614,13 @@
"scenario": "Get user details returns \"OK\" response",
"version": "v2"
},
{
"feature": "Users",
"feature_file": "../../v2/users.feature",
"file": "v2/users/list-all-users-filtered-by-handle-returns-ok-response.json",
"scenario": "List all users filtered by handle returns \"OK\" response",
"version": "v2"
},
{
"feature": "Users",
"feature_file": "../../v2/users.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"api": "Users",
"expected_status": 200,
"feature": "Users",
"id": "v2/Users/List all users filtered by handle returns \"OK\" response",
"operation_id": "ListUsers",
"request": {
"body": null,
"content_type": null,
"method": "GET",
"pagination": false,
"parameters": [
{
"explode": null,
"in": "query",
"name": "filter[handle]",
"required": false,
"schema": {
"format": null,
"ref": null,
"type": "string"
},
"source": {
"path": "user.data.attributes.handle",
"type": "fixture"
},
"style": null
}
],
"path": "/api/v2/users"
},
"scenario": "List all users filtered by handle returns \"OK\" response",
"schema_version": 1,
"version": "v2"
}
4 changes: 4 additions & 0 deletions features/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3979,6 +3979,10 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
"type": "string",
"format": "",
},
"filterHandle": {
"type": "string",
"format": "",
},
"operationResponseType": "UsersResponse",
},
"v2.CreateUser": {
Expand Down
10 changes: 10 additions & 0 deletions features/v2/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ Feature: Users
And the response "data.type" is equal to "users"
And the response "data.attributes.handle" is equal to "{{ unique_lower }}@datadoghq.com"

@team:ddoghq/org-management
Scenario: List all users filtered by handle returns "OK" response
Given there is a valid "user" in the system
And new "ListUsers" request
And request contains "filter[handle]" parameter from "user.data.attributes.handle"
When the request is sent
Then the response status is 200 OK
And the response "meta.page.total_filtered_count" is equal to 1
And the response "data[0].id" has the same value as "user.data.id"

@generated @skip @team:ddoghq/org-management
Scenario: List all users returns "Bad Request" response
Given new "ListUsers" request
Expand Down
16 changes: 16 additions & 0 deletions packages/datadog-api-client-v2/apis/UsersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ export class UsersApiRequestFactory extends BaseAPIRequestFactory {
sortDir?: QuerySortOrder,
filter?: string,
filterStatus?: string,
filterHandle?: string,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;
Expand Down Expand Up @@ -505,6 +506,13 @@ export class UsersApiRequestFactory extends BaseAPIRequestFactory {
""
);
}
if (filterHandle !== undefined) {
requestContext.setQueryParam(
"filter[handle]",
ObjectSerializer.serialize(filterHandle, "string", ""),
""
);
}

// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
Expand Down Expand Up @@ -1730,6 +1738,12 @@ export interface UsersApiListUsersRequest {
* @type string
*/
filterStatus?: string;
/**
* Filter on the exact user handle. This filter also returns Datadog-managed users,
* which the list otherwise excludes. Defaults to no filtering.
* @type string
*/
filterHandle?: string;
}

export interface UsersApiSendInvitationsRequest {
Expand Down Expand Up @@ -2019,6 +2033,7 @@ export class UsersApi {
param.sortDir,
param.filter,
param.filterStatus,
param.filterHandle,
options
);
return requestContextPromise.then((requestContext) => {
Expand Down Expand Up @@ -2051,6 +2066,7 @@ export class UsersApi {
param.sortDir,
param.filter,
param.filterStatus,
param.filterHandle,
options
);
const responseContext = await this.configuration.httpApi.send(
Expand Down
Loading