Skip to content

Commit bc0c103

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add receives_permissions_from field to Roles API (#3179)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3432768 commit bc0c103

File tree

8 files changed

+111
-10
lines changed

8 files changed

+111
-10
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49931,6 +49931,18 @@ components:
4993149931
description: The name of the role. The name is neither unique nor a stable
4993249932
identifier of the role.
4993349933
type: string
49934+
receives_permissions_from:
49935+
description: 'The managed role from which this role automatically inherits
49936+
new permissions.
49937+
49938+
Specify one of the following: "Datadog Admin Role", "Datadog Standard
49939+
Role", or "Datadog Read Only Role".
49940+
49941+
If empty or not specified, the role does not automatically inherit permissions
49942+
from any managed role.'
49943+
items:
49944+
type: string
49945+
type: array
4993449946
user_count:
4993549947
description: Number of users with that role.
4993649948
format: int64
@@ -49956,6 +49968,18 @@ components:
4995649968
description: Name of the new role that is cloned.
4995749969
example: cloned-role
4995849970
type: string
49971+
receives_permissions_from:
49972+
description: 'The managed role from which this role automatically inherits
49973+
new permissions.
49974+
49975+
Specify one of the following: "Datadog Admin Role", "Datadog Standard
49976+
Role", or "Datadog Read Only Role".
49977+
49978+
If empty or not specified, the role does not automatically inherit permissions
49979+
from any managed role.'
49980+
items:
49981+
type: string
49982+
type: array
4995949983
required:
4996049984
- name
4996149985
type: object
@@ -49984,6 +50008,18 @@ components:
4998450008
description: Name of the role.
4998550009
example: developers
4998650010
type: string
50011+
receives_permissions_from:
50012+
description: 'The managed role from which this role automatically inherits
50013+
new permissions.
50014+
50015+
Specify one of the following: "Datadog Admin Role", "Datadog Standard
50016+
Role", or "Datadog Read Only Role".
50017+
50018+
If empty or not specified, the role does not automatically inherit permissions
50019+
from any managed role.'
50020+
items:
50021+
type: string
50022+
type: array
4998750023
required:
4998850024
- name
4998950025
type: object
@@ -50105,6 +50141,18 @@ components:
5010550141
name:
5010650142
description: Name of the role.
5010750143
type: string
50144+
receives_permissions_from:
50145+
description: 'The managed role from which this role automatically inherits
50146+
new permissions.
50147+
50148+
Specify one of the following: "Datadog Admin Role", "Datadog Standard
50149+
Role", or "Datadog Read Only Role".
50150+
50151+
If empty or not specified, the role does not automatically inherit permissions
50152+
from any managed role.'
50153+
items:
50154+
type: string
50155+
type: array
5010850156
user_count:
5010950157
description: The user count.
5011050158
format: int32
@@ -105571,7 +105619,12 @@ tags:
105571105619

105572105620
read access on a specific log index to a role can be done in Datadog from the
105573105621

105574-
[Pipelines page](https://app.datadoghq.com/logs/pipelines).'
105622+
[Pipelines page](https://app.datadoghq.com/logs/pipelines).
105623+
105624+
105625+
Roles can also be managed in bulk through the Datadog UI, which provides
105626+
105627+
the capability to assign a single permission to multiple roles simultaneously.'
105575105628
name: Roles
105576105629
- description: Auto-generated tag Rum Audience Management
105577105630
name: Rum Audience Management

examples/v2/roles/CreateRole.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
data=RoleCreateData(
1818
attributes=RoleCreateAttributes(
1919
name="developers",
20+
receives_permissions_from=[],
2021
),
2122
relationships=RoleRelationships(
2223
permissions=RelationshipToPermissions(

src/datadog_api_client/v2/api/roles_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class RolesApi:
3636
in the Datadog application without using this API. For example, granting
3737
read access on a specific log index to a role can be done in Datadog from the
3838
`Pipelines page <https://app.datadoghq.com/logs/pipelines>`_.
39+
40+
Roles can also be managed in bulk through the Datadog UI, which provides
41+
the capability to assign a single permission to multiple roles simultaneously.
3942
"""
4043

4144
def __init__(self, api_client=None):

src/datadog_api_client/v2/model/role_attributes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import Union
6+
from typing import List, Union
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -21,13 +21,15 @@ def openapi_types(_):
2121
"created_at": (datetime,),
2222
"modified_at": (datetime,),
2323
"name": (str,),
24+
"receives_permissions_from": ([str],),
2425
"user_count": (int,),
2526
}
2627

2728
attribute_map = {
2829
"created_at": "created_at",
2930
"modified_at": "modified_at",
3031
"name": "name",
32+
"receives_permissions_from": "receives_permissions_from",
3133
"user_count": "user_count",
3234
}
3335
read_only_vars = {
@@ -41,6 +43,7 @@ def __init__(
4143
created_at: Union[datetime, UnsetType] = unset,
4244
modified_at: Union[datetime, UnsetType] = unset,
4345
name: Union[str, UnsetType] = unset,
46+
receives_permissions_from: Union[List[str], UnsetType] = unset,
4447
user_count: Union[int, UnsetType] = unset,
4548
**kwargs,
4649
):
@@ -56,6 +59,11 @@ def __init__(
5659
:param name: The name of the role. The name is neither unique nor a stable identifier of the role.
5760
:type name: str, optional
5861
62+
:param receives_permissions_from: The managed role from which this role automatically inherits new permissions.
63+
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
64+
If empty or not specified, the role does not automatically inherit permissions from any managed role.
65+
:type receives_permissions_from: [str], optional
66+
5967
:param user_count: Number of users with that role.
6068
:type user_count: int, optional
6169
"""
@@ -65,6 +73,8 @@ def __init__(
6573
kwargs["modified_at"] = modified_at
6674
if name is not unset:
6775
kwargs["name"] = name
76+
if receives_permissions_from is not unset:
77+
kwargs["receives_permissions_from"] = receives_permissions_from
6878
if user_count is not unset:
6979
kwargs["user_count"] = user_count
7080
super().__init__(kwargs)

src/datadog_api_client/v2/model/role_clone_attributes.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6+
from typing import List, Union
67

78
from datadog_api_client.model_utils import (
89
ModelNormal,
910
cached_property,
11+
unset,
12+
UnsetType,
1013
)
1114

1215

@@ -15,19 +18,28 @@ class RoleCloneAttributes(ModelNormal):
1518
def openapi_types(_):
1619
return {
1720
"name": (str,),
21+
"receives_permissions_from": ([str],),
1822
}
1923

2024
attribute_map = {
2125
"name": "name",
26+
"receives_permissions_from": "receives_permissions_from",
2227
}
2328

24-
def __init__(self_, name: str, **kwargs):
29+
def __init__(self_, name: str, receives_permissions_from: Union[List[str], UnsetType] = unset, **kwargs):
2530
"""
2631
Attributes required to create a new role by cloning an existing one.
2732
2833
:param name: Name of the new role that is cloned.
2934
:type name: str
35+
36+
:param receives_permissions_from: The managed role from which this role automatically inherits new permissions.
37+
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
38+
If empty or not specified, the role does not automatically inherit permissions from any managed role.
39+
:type receives_permissions_from: [str], optional
3040
"""
41+
if receives_permissions_from is not unset:
42+
kwargs["receives_permissions_from"] = receives_permissions_from
3143
super().__init__(kwargs)
3244

3345
self_.name = name

src/datadog_api_client/v2/model/role_create_attributes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import Union
6+
from typing import List, Union
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -21,12 +21,14 @@ def openapi_types(_):
2121
"created_at": (datetime,),
2222
"modified_at": (datetime,),
2323
"name": (str,),
24+
"receives_permissions_from": ([str],),
2425
}
2526

2627
attribute_map = {
2728
"created_at": "created_at",
2829
"modified_at": "modified_at",
2930
"name": "name",
31+
"receives_permissions_from": "receives_permissions_from",
3032
}
3133
read_only_vars = {
3234
"created_at",
@@ -38,6 +40,7 @@ def __init__(
3840
name: str,
3941
created_at: Union[datetime, UnsetType] = unset,
4042
modified_at: Union[datetime, UnsetType] = unset,
43+
receives_permissions_from: Union[List[str], UnsetType] = unset,
4144
**kwargs,
4245
):
4346
"""
@@ -51,11 +54,18 @@ def __init__(
5154
5255
:param name: Name of the role.
5356
:type name: str
57+
58+
:param receives_permissions_from: The managed role from which this role automatically inherits new permissions.
59+
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
60+
If empty or not specified, the role does not automatically inherit permissions from any managed role.
61+
:type receives_permissions_from: [str], optional
5462
"""
5563
if created_at is not unset:
5664
kwargs["created_at"] = created_at
5765
if modified_at is not unset:
5866
kwargs["modified_at"] = modified_at
67+
if receives_permissions_from is not unset:
68+
kwargs["receives_permissions_from"] = receives_permissions_from
5969
super().__init__(kwargs)
6070

6171
self_.name = name

src/datadog_api_client/v2/model/role_update_attributes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import Union
6+
from typing import List, Union
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -27,13 +27,15 @@ def openapi_types(_):
2727
"created_at": (datetime,),
2828
"modified_at": (datetime,),
2929
"name": (str,),
30+
"receives_permissions_from": ([str],),
3031
"user_count": (int,),
3132
}
3233

3334
attribute_map = {
3435
"created_at": "created_at",
3536
"modified_at": "modified_at",
3637
"name": "name",
38+
"receives_permissions_from": "receives_permissions_from",
3739
"user_count": "user_count",
3840
}
3941
read_only_vars = {
@@ -46,6 +48,7 @@ def __init__(
4648
created_at: Union[datetime, UnsetType] = unset,
4749
modified_at: Union[datetime, UnsetType] = unset,
4850
name: Union[str, UnsetType] = unset,
51+
receives_permissions_from: Union[List[str], UnsetType] = unset,
4952
user_count: Union[int, UnsetType] = unset,
5053
**kwargs,
5154
):
@@ -61,6 +64,11 @@ def __init__(
6164
:param name: Name of the role.
6265
:type name: str, optional
6366
67+
:param receives_permissions_from: The managed role from which this role automatically inherits new permissions.
68+
Specify one of the following: "Datadog Admin Role", "Datadog Standard Role", or "Datadog Read Only Role".
69+
If empty or not specified, the role does not automatically inherit permissions from any managed role.
70+
:type receives_permissions_from: [str], optional
71+
6472
:param user_count: The user count.
6573
:type user_count: int, optional
6674
"""
@@ -70,6 +78,8 @@ def __init__(
7078
kwargs["modified_at"] = modified_at
7179
if name is not unset:
7280
kwargs["name"] = name
81+
if receives_permissions_from is not unset:
82+
kwargs["receives_permissions_from"] = receives_permissions_from
7383
if user_count is not unset:
7484
kwargs["user_count"] = user_count
7585
super().__init__(kwargs)

tests/v2/features/roles.feature

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Feature: Roles
66
account assets can be granted to roles in the Datadog application without
77
using this API. For example, granting read access on a specific log index
88
to a role can be done in Datadog from the [Pipelines
9-
page](https://app.datadoghq.com/logs/pipelines).
9+
page](https://app.datadoghq.com/logs/pipelines). Roles can also be
10+
managed in bulk through the Datadog UI, which provides the capability to
11+
assign a single permission to multiple roles simultaneously.
1012

1113
Background:
1214
Given a valid "apiKeyAuth" key in the system
@@ -64,7 +66,7 @@ Feature: Roles
6466
Scenario: Create a new role by cloning an existing role returns "Not found" response
6567
Given new "CloneRole" request
6668
And request contains "role_id" parameter from "REPLACE.ME"
67-
And body with value {"data": {"attributes": {"name": "cloned-role"}, "type": "roles"}}
69+
And body with value {"data": {"attributes": {"name": "cloned-role", "receives_permissions_from": []}, "type": "roles"}}
6870
When the request is sent
6971
Then the response status is 404 Not found
7072

@@ -81,14 +83,14 @@ Feature: Roles
8183
@generated @skip @team:DataDog/aaa-core-access
8284
Scenario: Create role returns "Bad Request" response
8385
Given new "CreateRole" request
84-
And body with value {"data": {"attributes": {"name": "developers"}, "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
86+
And body with value {"data": {"attributes": {"name": "developers", "receives_permissions_from": []}, "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
8587
When the request is sent
8688
Then the response status is 400 Bad Request
8789

8890
@generated @skip @team:DataDog/aaa-core-access
8991
Scenario: Create role returns "OK" response
9092
Given new "CreateRole" request
91-
And body with value {"data": {"attributes": {"name": "developers"}, "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
93+
And body with value {"data": {"attributes": {"name": "developers", "receives_permissions_from": []}, "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
9294
When the request is sent
9395
Then the response status is 200 OK
9496

@@ -335,6 +337,6 @@ Feature: Roles
335337
Scenario: Update a role returns "Unprocessable Entity" response
336338
Given new "UpdateRole" request
337339
And request contains "role_id" parameter from "REPLACE.ME"
338-
And body with value {"data": {"attributes": {}, "id": "00000000-0000-1111-0000-000000000000", "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
340+
And body with value {"data": {"attributes": {"receives_permissions_from": []}, "id": "00000000-0000-1111-0000-000000000000", "relationships": {"permissions": {"data": [{"type": "permissions"}]}}, "type": "roles"}}
339341
When the request is sent
340342
Then the response status is 422 Unprocessable Entity

0 commit comments

Comments
 (0)