Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint for cloning roles #732

Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2021-12-21 22:39:17.263983",
"spec_repo_commit": "90bc255"
"regenerated": "2021-12-21 23:32:28.136622",
"spec_repo_commit": "4bb7a8e"
},
"v2": {
"apigentools_version": "1.5.1.dev2",
"regenerated": "2021-12-21 22:39:17.741810",
"spec_repo_commit": "90bc255"
"regenerated": "2021-12-21 23:32:28.666161",
"spec_repo_commit": "4bb7a8e"
}
}
}
92 changes: 92 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3927,6 +3927,36 @@ components:
readOnly: true
type: integer
type: object
RoleClone:
description: Data for the clone role request.
properties:
attributes:
$ref: '#/components/schemas/RoleCloneAttributes'
type:
$ref: '#/components/schemas/RolesType'
required:
- type
- attributes
type: object
RoleCloneAttributes:
description: Attributes required to create a new role by cloning an existing
one.
properties:
name:
description: Name of the new role that is cloned.
example: cloned-role
type: string
required:
- name
type: object
RoleCloneRequest:
description: Request to create a role by cloning an existing role.
properties:
data:
$ref: '#/components/schemas/RoleClone'
required:
- data
type: object
RoleCreateAttributes:
description: Attributes of the created role.
properties:
Expand Down Expand Up @@ -8028,6 +8058,68 @@ paths:
x-menu-order: 4
x-undo:
type: idempotent
/api/v2/roles/{role_id}/clone:
post:
description: Clone an existing role
operationId: CloneRole
parameters:
- $ref: '#/components/parameters/RoleID'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RoleCloneRequest'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/RoleResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
'403':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Authentication error
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Not found
'409':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Conflict
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- user_access_manage
summary: Create a new role by cloning an existing role
tags:
- Roles
x-codegen-request-body-name: body
x-menu-order: 12
x-permission: OR(USER_ACCESS_MANAGE)
x-undo:
operationId: DeleteRole
parameters:
- name: role_id
source: data.id
type: unsafe
/api/v2/roles/{role_id}/permissions:
delete:
description: Removes a permission from a role.
Expand Down
4 changes: 4 additions & 0 deletions docs/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/v2/RoleClone.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/v2/RoleCloneAttributes.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions docs/v2/RoleCloneRequest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 93 additions & 14 deletions docs/v2/RolesApi.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions examples/v2/roles/CloneRole.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Create a new role by cloning an existing role returns "OK" response
"""

from os import environ
from datadog_api_client.v2 import ApiClient, Configuration
from datadog_api_client.v2.api.roles_api import RolesApi
from datadog_api_client.v2.model.role_clone import RoleClone
from datadog_api_client.v2.model.role_clone_attributes import RoleCloneAttributes
from datadog_api_client.v2.model.role_clone_request import RoleCloneRequest
from datadog_api_client.v2.model.roles_type import RolesType

# there is a valid "role" in the system
ROLE_DATA_ID = environ["ROLE_DATA_ID"]

body = RoleCloneRequest(
data=RoleClone(
attributes=RoleCloneAttributes(
name="Example-Create_a_new_role_by_cloning_an_existing_role_returns_OK_response clone"
),
type=RolesType("roles"),
)
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = RolesApi(api_client)
response = api_instance.clone_role(role_id=ROLE_DATA_ID, body=body)

print(response)
Loading