Skip to content

Commit 4e059cf

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add restriction policy APIs (#1337)
Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 4e71319 commit 4e059cf

30 files changed

+1129
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-02-15 14:54:05.761282",
8-
"spec_repo_commit": "3371aaa2"
7+
"regenerated": "2023-02-16 07:53:05.962816",
8+
"spec_repo_commit": "7d823ab8"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-02-15 14:54:05.774859",
13-
"spec_repo_commit": "3371aaa2"
12+
"regenerated": "2023-02-16 07:53:05.981326",
13+
"spec_repo_commit": "7d823ab8"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,15 @@ components:
347347
example: 10
348348
format: int64
349349
type: integer
350+
ResourceID:
351+
description: 'Identifier, formatted as `type:id`. Supported types: `connection`,
352+
`dashboard`, `notebook`, `security-rule`.'
353+
example: dashboard:abc-def-ghi
354+
in: path
355+
name: resource_id
356+
required: true
357+
schema:
358+
type: string
350359
RoleID:
351360
description: The unique identifier of the role.
352361
in: path
@@ -9010,6 +9019,91 @@ components:
90109019
page:
90119020
$ref: '#/components/schemas/Pagination'
90129021
type: object
9022+
RestrictionPolicy:
9023+
description: Restriction policy object.
9024+
properties:
9025+
attributes:
9026+
$ref: '#/components/schemas/RestrictionPolicyAttributes'
9027+
id:
9028+
description: The identifier, always equivalent to the value specified in
9029+
the `resource_id` path parameter.
9030+
example: dashboard:abc-def-ghi
9031+
type: string
9032+
type:
9033+
$ref: '#/components/schemas/RestrictionPolicyType'
9034+
required:
9035+
- type
9036+
- id
9037+
- attributes
9038+
type: object
9039+
RestrictionPolicyAttributes:
9040+
description: Restriction policy attributes.
9041+
example:
9042+
bindings: []
9043+
properties:
9044+
bindings:
9045+
description: An array of bindings.
9046+
items:
9047+
$ref: '#/components/schemas/RestrictionPolicyBinding'
9048+
type: array
9049+
required:
9050+
- bindings
9051+
type: object
9052+
RestrictionPolicyBinding:
9053+
description: Specifies which principals are associated with a relation.
9054+
properties:
9055+
principals:
9056+
description: 'An array of principals. A principal is a subject or group
9057+
of subjects.
9058+
9059+
Each principal is formatted as `type:id`. Supported types: `role`, `user`,
9060+
`org`.
9061+
9062+
The org ID can be obtained through the api/v2/current_user API.'
9063+
example:
9064+
- role:00000000-0000-1111-0000-000000000000
9065+
items:
9066+
description: 'Subject or group of subjects. Each principal is formatted
9067+
as `type:id`.
9068+
9069+
Supported types: `role`, `user`, `org`.
9070+
9071+
The org ID can be obtained through the api/v2/current_user API.'
9072+
type: string
9073+
type: array
9074+
relation:
9075+
description: The role/level of access.
9076+
example: editor
9077+
type: string
9078+
required:
9079+
- relation
9080+
- principals
9081+
type: object
9082+
RestrictionPolicyResponse:
9083+
description: Response containing information about a single restriction policy.
9084+
properties:
9085+
data:
9086+
$ref: '#/components/schemas/RestrictionPolicy'
9087+
required:
9088+
- data
9089+
type: object
9090+
RestrictionPolicyType:
9091+
default: restriction_policy
9092+
description: Restriction policy type.
9093+
enum:
9094+
- restriction_policy
9095+
example: restriction_policy
9096+
type: string
9097+
x-enum-varnames:
9098+
- RESTRICTION_POLICY
9099+
RestrictionPolicyUpdateRequest:
9100+
description: Update request for a restriction policy.
9101+
properties:
9102+
data:
9103+
$ref: '#/components/schemas/RestrictionPolicy'
9104+
required:
9105+
- data
9106+
type: object
90139107
Role:
90149108
description: Role object returned by the API.
90159109
properties:
@@ -16998,6 +17092,96 @@ paths:
1699817092
any
1699917093

1700017094
feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
17095+
/api/v2/restriction_policy/{resource_id}:
17096+
delete:
17097+
description: Deletes the restriction policy associated with a specified resource.
17098+
operationId: DeleteRestrictionPolicy
17099+
parameters:
17100+
- $ref: '#/components/parameters/ResourceID'
17101+
responses:
17102+
'204':
17103+
description: No Content
17104+
'400':
17105+
$ref: '#/components/responses/BadRequestResponse'
17106+
'403':
17107+
$ref: '#/components/responses/NotAuthorizedResponse'
17108+
'429':
17109+
$ref: '#/components/responses/TooManyRequestsResponse'
17110+
security:
17111+
- apiKeyAuth: []
17112+
appKeyAuth: []
17113+
summary: Delete a restriction policy
17114+
tags:
17115+
- Restriction Policies
17116+
get:
17117+
description: Retrieves the restriction policy associated with a specified resource.
17118+
operationId: GetRestrictionPolicy
17119+
parameters:
17120+
- $ref: '#/components/parameters/ResourceID'
17121+
responses:
17122+
'200':
17123+
content:
17124+
application/json:
17125+
schema:
17126+
$ref: '#/components/schemas/RestrictionPolicyResponse'
17127+
description: OK
17128+
'400':
17129+
$ref: '#/components/responses/BadRequestResponse'
17130+
'403':
17131+
$ref: '#/components/responses/NotAuthorizedResponse'
17132+
'429':
17133+
$ref: '#/components/responses/TooManyRequestsResponse'
17134+
security:
17135+
- apiKeyAuth: []
17136+
appKeyAuth: []
17137+
summary: Get a restriction policy
17138+
tags:
17139+
- Restriction Policies
17140+
post:
17141+
description: 'Updates the restriction policy associated with a resource.
17142+
17143+
17144+
#### Supported resources
17145+
17146+
Restriction policies can be applied to the following resources:
17147+
17148+
- Connections: `connection`
17149+
17150+
- Dashboards: `dashboard`
17151+
17152+
- Notebooks: `notebook`
17153+
17154+
- Security Rules: `security-rule`'
17155+
operationId: UpdateRestrictionPolicy
17156+
parameters:
17157+
- $ref: '#/components/parameters/ResourceID'
17158+
requestBody:
17159+
content:
17160+
application/json:
17161+
schema:
17162+
$ref: '#/components/schemas/RestrictionPolicyUpdateRequest'
17163+
description: Restriction policy payload
17164+
required: true
17165+
responses:
17166+
'200':
17167+
content:
17168+
application/json:
17169+
schema:
17170+
$ref: '#/components/schemas/RestrictionPolicyResponse'
17171+
description: OK
17172+
'400':
17173+
$ref: '#/components/responses/BadRequestResponse'
17174+
'403':
17175+
$ref: '#/components/responses/NotAuthorizedResponse'
17176+
'429':
17177+
$ref: '#/components/responses/TooManyRequestsResponse'
17178+
security:
17179+
- apiKeyAuth: []
17180+
appKeyAuth: []
17181+
summary: Update a restriction policy
17182+
tags:
17183+
- Restriction Policies
17184+
x-codegen-request-body-name: body
1700117185
/api/v2/roles:
1700217186
get:
1700317187
description: Returns all roles, including their names and their unique identifiers.
@@ -20733,6 +20917,14 @@ tags:
2073320917
name: Processes
2073420918
- description: Search or aggregate your RUM events over HTTP.
2073520919
name: RUM
20920+
- description: 'A restriction policy defines the access control rules for a resource,
20921+
mapping a set of relations
20922+
20923+
(such as editor and viewer) to a set of allowed principals (such as roles). The
20924+
restriction policy
20925+
20926+
determines who is authorized to perform what actions on the resource.'
20927+
name: Restriction Policies
2073620928
- description: 'The Roles API is used to create and manage Datadog roles, what
2073720929

2073820930
[global permissions](https://docs.datadoghq.com/account_management/rbac/)

docs/datadog_api_client.v2.api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@ processes\_api
155155
:members:
156156
:show-inheritance:
157157

158+
restriction\_policies\_api
159+
--------------------------
160+
161+
.. automodule:: datadog_api_client.v2.api.restriction_policies_api
162+
:members:
163+
:show-inheritance:
164+
158165
roles\_api
159166
----------
160167

docs/datadog_api_client.v2.model.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,6 +3725,48 @@ response\_meta\_attributes
37253725
:members:
37263726
:show-inheritance:
37273727

3728+
restriction\_policy
3729+
-------------------
3730+
3731+
.. automodule:: datadog_api_client.v2.model.restriction_policy
3732+
:members:
3733+
:show-inheritance:
3734+
3735+
restriction\_policy\_attributes
3736+
-------------------------------
3737+
3738+
.. automodule:: datadog_api_client.v2.model.restriction_policy_attributes
3739+
:members:
3740+
:show-inheritance:
3741+
3742+
restriction\_policy\_binding
3743+
----------------------------
3744+
3745+
.. automodule:: datadog_api_client.v2.model.restriction_policy_binding
3746+
:members:
3747+
:show-inheritance:
3748+
3749+
restriction\_policy\_response
3750+
-----------------------------
3751+
3752+
.. automodule:: datadog_api_client.v2.model.restriction_policy_response
3753+
:members:
3754+
:show-inheritance:
3755+
3756+
restriction\_policy\_type
3757+
-------------------------
3758+
3759+
.. automodule:: datadog_api_client.v2.model.restriction_policy_type
3760+
:members:
3761+
:show-inheritance:
3762+
3763+
restriction\_policy\_update\_request
3764+
------------------------------------
3765+
3766+
.. automodule:: datadog_api_client.v2.model.restriction_policy_update_request
3767+
:members:
3768+
:show-inheritance:
3769+
37283770
role
37293771
----
37303772

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Delete a restriction policy returns "No Content" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.restriction_policies_api import RestrictionPoliciesApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = RestrictionPoliciesApi(api_client)
11+
api_instance.delete_restriction_policy(
12+
resource_id="dashboard:abc-def-ghi",
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Get a restriction policy returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.restriction_policies_api import RestrictionPoliciesApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = RestrictionPoliciesApi(api_client)
11+
response = api_instance.get_restriction_policy(
12+
resource_id="dashboard:abc-def-ghi",
13+
)
14+
15+
print(response)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Update a restriction policy returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.restriction_policies_api import RestrictionPoliciesApi
8+
from datadog_api_client.v2.model.restriction_policy import RestrictionPolicy
9+
from datadog_api_client.v2.model.restriction_policy_attributes import RestrictionPolicyAttributes
10+
from datadog_api_client.v2.model.restriction_policy_binding import RestrictionPolicyBinding
11+
from datadog_api_client.v2.model.restriction_policy_type import RestrictionPolicyType
12+
from datadog_api_client.v2.model.restriction_policy_update_request import RestrictionPolicyUpdateRequest
13+
14+
# there is a valid "user" in the system
15+
USER_DATA_RELATIONSHIPS_ORG_DATA_ID = environ["USER_DATA_RELATIONSHIPS_ORG_DATA_ID"]
16+
17+
body = RestrictionPolicyUpdateRequest(
18+
data=RestrictionPolicy(
19+
id="dashboard:abc-def-ghi",
20+
type=RestrictionPolicyType.RESTRICTION_POLICY,
21+
attributes=RestrictionPolicyAttributes(
22+
bindings=[
23+
RestrictionPolicyBinding(
24+
relation="editor",
25+
principals=[
26+
"org:00000000-0000-beef-0000-000000000000",
27+
],
28+
),
29+
],
30+
),
31+
),
32+
)
33+
34+
configuration = Configuration()
35+
with ApiClient(configuration) as api_client:
36+
api_instance = RestrictionPoliciesApi(api_client)
37+
response = api_instance.update_restriction_policy(resource_id="dashboard:abc-def-ghi", body=body)
38+
39+
print(response)

0 commit comments

Comments
 (0)