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
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
15 changes: 15 additions & 0 deletions examples/v2/roles/ListPermissions_1350046915.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
List permissions including scopes returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.list_permissions(
include_scopes=True,
)

print(response)
19 changes: 18 additions & 1 deletion src/datadog_api_client/v2/api/roles_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,13 @@ def __init__(self, api_client=None):
"http_method": "GET",
"version": "v2",
},
params_map={},
params_map={
"include_scopes": {
"openapi_types": (bool,),
"attribute": "include_scopes",
"location": "query",
},
},
headers_map={
"accept": ["application/json"],
},
Expand Down Expand Up @@ -536,14 +542,25 @@ def get_role(

def list_permissions(
self,
*,
include_scopes: Union[bool, UnsetType] = unset,
) -> PermissionsResponse:
"""List permissions.

Returns a list of all permissions, including name, description, and ID.

:param include_scopes: 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 include_scopes: bool, optional
:rtype: PermissionsResponse
"""
kwargs: Dict[str, Any] = {}
if include_scopes is not unset:
kwargs["include_scopes"] = include_scopes

return self._list_permissions_endpoint.call_with_http_info(**kwargs)

def list_role_permissions(
Expand Down
7 changes: 7 additions & 0 deletions tests/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/features/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/features/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 tests/generated-test/test-server-data/v2/roles.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tests/v2/features/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
Loading