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
13 changes: 13 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186259,6 +186259,19 @@ paths:
description: |-
Returns a list of all permissions, including name, description, and ID.
operationId: ListPermissions
parameters:
- description: |-
Set to `true` to return all permissions, including both permissions
that can be assigned to user roles and permissions that can only be
used as scopes for OAuth clients and scoped credentials. When `false`
(default), only permissions that can be assigned to user roles are
returned.
example: false
in: query
name: include_scopes
required: false
schema:
type: boolean
responses:
"200":
content:
Expand Down
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 @@ -8596,6 +8596,13 @@
"scenario": "List permissions for a role returns \"OK\" response",
"version": "v2"
},
{
"feature": "Roles",
"feature_file": "../../v2/roles.feature",
"file": "v2/roles/list-permissions-including-scopes-returns-ok-response.json",
"scenario": "List permissions including scopes returns \"OK\" response",
"version": "v2"
},
{
"feature": "Roles",
"feature_file": "../../v2/roles.feature",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"api": "Roles",
"expected_status": 200,
"feature": "Roles",
"id": "v2/Roles/List permissions including scopes returns \"OK\" response",
"operation_id": "ListPermissions",
"request": {
"body": null,
"content_type": null,
"method": "GET",
"pagination": false,
"parameters": [
{
"explode": null,
"in": "query",
"name": "include_scopes",
"required": false,
"schema": {
"format": null,
"ref": null,
"type": "boolean"
},
"source": {
"type": "literal",
"value": true
},
"style": null
}
],
"path": "/api/v2/permissions"
},
"scenario": "List permissions including scopes returns \"OK\" response",
"schema_version": 1,
"version": "v2"
}
36 changes: 36 additions & 0 deletions features/generated-test/test-server-data/v2/roles.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions features/v2/roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@ Feature: Roles
And the response "data[0].type" is equal to "{{ permission.type }}"
And the response "data" has item with field "id" with value "{{ permission.id }}"

@team:DataDog/aaa-core-access @team:DataDog/access-policies-lifecycle
Scenario: List permissions including scopes returns "OK" response
Given new "ListPermissions" request
And request contains "include_scopes" parameter with value true
When the request is sent
Then the response status is 200 OK
And the response "data" has item with field "attributes.name" with value "admin"

@generated @skip @team:DataDog/aaa-core-access @team:DataDog/access-policies-lifecycle
Scenario: List permissions returns "Bad Request" response
Given new "ListPermissions" request
Expand Down
4 changes: 4 additions & 0 deletions private/bdd_runner/src/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14480,6 +14480,10 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = {
operationResponseType: "OrgGroupResponse",
},
"RolesApi.V2.ListPermissions": {
includeScopes: {
type: "boolean",
format: "",
},
operationResponseType: "PermissionsResponse",
},
"RolesApi.V2.ListRoles": {
Expand Down
3 changes: 2 additions & 1 deletion services/roles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ import { v2 } from "@datadog/datadog-api-client-roles";

const configuration = createConfiguration();
const apiInstance = new RolesApiV2(configuration);
const params = {/* parameters */};

apiInstance.listPermissions().then((data) => {
apiInstance.listPermissions(params).then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}).catch((error) => {
console.error("Error calling API: " + error);
Expand Down
28 changes: 27 additions & 1 deletion services/roles/src/v2/RolesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ export class RolesApiRequestFactory extends BaseAPIRequestFactory {
}

public async listPermissions(
includeScopes?: boolean,
_options?: Configuration,
): Promise<RequestContext> {
const _config = _options || this.configuration;
Expand Down Expand Up @@ -429,6 +430,15 @@ export class RolesApiRequestFactory extends BaseAPIRequestFactory {
requestContext.setHeaderParam("X-Datadog-Managed-By", "iac");
}

// Query Params
if (includeScopes !== undefined) {
requestContext.setQueryParam(
"include_scopes",
serialize(includeScopes, TypingInfo, "boolean", ""),
"",
);
}

// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"apiKeyAuth",
Expand Down Expand Up @@ -1781,6 +1791,18 @@ export interface RolesApiGetRoleRequest {
roleId: string;
}

export interface RolesApiListPermissionsRequest {
/**
* Set to `true` to return all permissions, including both permissions
* that can be assigned to user roles and permissions that can only be
* used as scopes for OAuth clients and scoped credentials. When `false`
* (default), only permissions that can be assigned to user roles are
* returned.
* @type boolean
*/
includeScopes?: boolean;
}

export interface RolesApiListRolePermissionsRequest {
/**
* The unique identifier of the role.
Expand Down Expand Up @@ -2051,9 +2073,13 @@ export class RolesApi {
* @param param The request object
*/
public listPermissions(
param: RolesApiListPermissionsRequest = {},
options?: Configuration,
): Promise<PermissionsResponse> {
const requestContextPromise = this.requestFactory.listPermissions(options);
const requestContextPromise = this.requestFactory.listPermissions(
param.includeScopes,
options,
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
Expand Down
1 change: 1 addition & 0 deletions services/roles/src/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export {
RolesApiCreateRoleRequest,
RolesApiDeleteRoleRequest,
RolesApiGetRoleRequest,
RolesApiListPermissionsRequest,
RolesApiListRolePermissionsRequest,
RolesApiListRoleUsersRequest,
RolesApiListRolesRequest,
Expand Down
Loading