diff --git a/.apigentools-info b/.apigentools-info index 27ffe48bf3..846a31051f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -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" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 77dd5c5538..3466543af0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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: @@ -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. diff --git a/docs/v2/README.md b/docs/v2/README.md index b414365c80..b54a88b125 100644 --- a/docs/v2/README.md +++ b/docs/v2/README.md @@ -159,6 +159,7 @@ All URIs are relative to *https://api.datadoghq.com* | _ProcessesApi_ | [**list_processes**](ProcessesApi.md#list_processes) | **GET** /api/v2/processes | Get all processes | | _RolesApi_ | [**add_permission_to_role**](RolesApi.md#add_permission_to_role) | **POST** /api/v2/roles/{role_id}/permissions | Grant permission to a role | | _RolesApi_ | [**add_user_to_role**](RolesApi.md#add_user_to_role) | **POST** /api/v2/roles/{role_id}/users | Add a user to a role | +| _RolesApi_ | [**clone_role**](RolesApi.md#clone_role) | **POST** /api/v2/roles/{role_id}/clone | Create a new role by cloning an existing role | | _RolesApi_ | [**create_role**](RolesApi.md#create_role) | **POST** /api/v2/roles | Create role | | _RolesApi_ | [**delete_role**](RolesApi.md#delete_role) | **DELETE** /api/v2/roles/{role_id} | Delete role | | _RolesApi_ | [**get_role**](RolesApi.md#get_role) | **GET** /api/v2/roles/{role_id} | Get a role | @@ -444,6 +445,9 @@ All URIs are relative to *https://api.datadoghq.com* - [ResponseMetaAttributes](ResponseMetaAttributes.md) - [Role](Role.md) - [RoleAttributes](RoleAttributes.md) +- [RoleClone](RoleClone.md) +- [RoleCloneAttributes](RoleCloneAttributes.md) +- [RoleCloneRequest](RoleCloneRequest.md) - [RoleCreateAttributes](RoleCreateAttributes.md) - [RoleCreateData](RoleCreateData.md) - [RoleCreateRequest](RoleCreateRequest.md) diff --git a/docs/v2/RoleClone.md b/docs/v2/RoleClone.md new file mode 100644 index 0000000000..e706beb857 --- /dev/null +++ b/docs/v2/RoleClone.md @@ -0,0 +1,13 @@ +# RoleClone + +Data for the clone role request. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributes** | [**RoleCloneAttributes**](RoleCloneAttributes.md) | | +**type** | [**RolesType**](RolesType.md) | | + +[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) + + diff --git a/docs/v2/RoleCloneAttributes.md b/docs/v2/RoleCloneAttributes.md new file mode 100644 index 0000000000..6e21b81dc9 --- /dev/null +++ b/docs/v2/RoleCloneAttributes.md @@ -0,0 +1,12 @@ +# RoleCloneAttributes + +Attributes required to create a new role by cloning an existing one. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | Name of the new role that is cloned. | + +[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) + + diff --git a/docs/v2/RoleCloneRequest.md b/docs/v2/RoleCloneRequest.md new file mode 100644 index 0000000000..4cf38ba42b --- /dev/null +++ b/docs/v2/RoleCloneRequest.md @@ -0,0 +1,12 @@ +# RoleCloneRequest + +Request to create a role by cloning an existing role. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**RoleClone**](RoleClone.md) | | + +[[Back to Model list]](README.md#documentation-for-models) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to README]](README.md) + + diff --git a/docs/v2/RolesApi.md b/docs/v2/RolesApi.md index 18f3d69b4c..f74eaa40cd 100644 --- a/docs/v2/RolesApi.md +++ b/docs/v2/RolesApi.md @@ -2,20 +2,21 @@ All URIs are relative to *https://api.datadoghq.com* -| Method | HTTP request | Description | -| -------------------------------------------------------------------------- | ---------------------------------------------- | --------------------------- | -| [**add_permission_to_role**](RolesApi.md#add_permission_to_role) | **POST** /api/v2/roles/{role_id}/permissions | Grant permission to a role | -| [**add_user_to_role**](RolesApi.md#add_user_to_role) | **POST** /api/v2/roles/{role_id}/users | Add a user to a role | -| [**create_role**](RolesApi.md#create_role) | **POST** /api/v2/roles | Create role | -| [**delete_role**](RolesApi.md#delete_role) | **DELETE** /api/v2/roles/{role_id} | Delete role | -| [**get_role**](RolesApi.md#get_role) | **GET** /api/v2/roles/{role_id} | Get a role | -| [**list_permissions**](RolesApi.md#list_permissions) | **GET** /api/v2/permissions | List permissions | -| [**list_role_permissions**](RolesApi.md#list_role_permissions) | **GET** /api/v2/roles/{role_id}/permissions | List permissions for a role | -| [**list_role_users**](RolesApi.md#list_role_users) | **GET** /api/v2/roles/{role_id}/users | Get all users of a role | -| [**list_roles**](RolesApi.md#list_roles) | **GET** /api/v2/roles | List roles | -| [**remove_permission_from_role**](RolesApi.md#remove_permission_from_role) | **DELETE** /api/v2/roles/{role_id}/permissions | Revoke permission | -| [**remove_user_from_role**](RolesApi.md#remove_user_from_role) | **DELETE** /api/v2/roles/{role_id}/users | Remove a user from a role | -| [**update_role**](RolesApi.md#update_role) | **PATCH** /api/v2/roles/{role_id} | Update a role | +| Method | HTTP request | Description | +| -------------------------------------------------------------------------- | ---------------------------------------------- | --------------------------------------------- | +| [**add_permission_to_role**](RolesApi.md#add_permission_to_role) | **POST** /api/v2/roles/{role_id}/permissions | Grant permission to a role | +| [**add_user_to_role**](RolesApi.md#add_user_to_role) | **POST** /api/v2/roles/{role_id}/users | Add a user to a role | +| [**clone_role**](RolesApi.md#clone_role) | **POST** /api/v2/roles/{role_id}/clone | Create a new role by cloning an existing role | +| [**create_role**](RolesApi.md#create_role) | **POST** /api/v2/roles | Create role | +| [**delete_role**](RolesApi.md#delete_role) | **DELETE** /api/v2/roles/{role_id} | Delete role | +| [**get_role**](RolesApi.md#get_role) | **GET** /api/v2/roles/{role_id} | Get a role | +| [**list_permissions**](RolesApi.md#list_permissions) | **GET** /api/v2/permissions | List permissions | +| [**list_role_permissions**](RolesApi.md#list_role_permissions) | **GET** /api/v2/roles/{role_id}/permissions | List permissions for a role | +| [**list_role_users**](RolesApi.md#list_role_users) | **GET** /api/v2/roles/{role_id}/users | Get all users of a role | +| [**list_roles**](RolesApi.md#list_roles) | **GET** /api/v2/roles | List roles | +| [**remove_permission_from_role**](RolesApi.md#remove_permission_from_role) | **DELETE** /api/v2/roles/{role_id}/permissions | Revoke permission | +| [**remove_user_from_role**](RolesApi.md#remove_user_from_role) | **DELETE** /api/v2/roles/{role_id}/users | Remove a user from a role | +| [**update_role**](RolesApi.md#update_role) | **PATCH** /api/v2/roles/{role_id} | Update a role | # **add_permission_to_role** @@ -167,6 +168,84 @@ with ApiClient(configuration) as api_client: [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) +# **clone_role** + +> RoleResponse clone_role(role_id, body) + +Clone an existing role + +### Example + +- OAuth Authentication (AuthZ): +- Api Key Authentication (apiKeyAuth): +- Api Key Authentication (appKeyAuth): + +```python +import os +from dateutil.parser import parse as dateutil_parser +from datadog_api_client.v2 import ApiClient, ApiException, Configuration +from datadog_api_client.v2.api import roles_api +from datadog_api_client.v2.models import * +from pprint import pprint +# See configuration.py for a list of all supported configuration parameters. +configuration = Configuration() + +# Enter a context with an instance of the API client +with ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = roles_api.RolesApi(api_client) + role_id = "role_id_example" # str | The ID of the role. + body = RoleCloneRequest( + data=RoleClone( + attributes=RoleCloneAttributes( + name="cloned-role", + ), + type=RolesType("roles"), + ), + ) # RoleCloneRequest | + + # example passing only required values which don't have defaults set + try: + # Create a new role by cloning an existing role + api_response = api_instance.clone_role(role_id, body) + pprint(api_response) + except ApiException as e: + print("Exception when calling RolesApi->clone_role: %s\n" % e) +``` + +### Parameters + +| Name | Type | Description | Notes | +| ----------- | ------------------------------------------- | ------------------- | ----- | +| **role_id** | **str** | The ID of the role. | +| **body** | [**RoleCloneRequest**](RoleCloneRequest.md) | | + +### Return type + +[**RoleResponse**](RoleResponse.md) + +### Authorization + +[AuthZ](README.md#AuthZ), [apiKeyAuth](README.md#apiKeyAuth), [appKeyAuth](README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | -------------------- | ---------------- | +| **200** | OK | - | +| **400** | Bad Request | - | +| **403** | Authentication error | - | +| **404** | Not found | - | +| **409** | Conflict | - | +| **429** | Too many requests | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + # **create_role** > RoleCreateResponse create_role(body) diff --git a/examples/v2/roles/CloneRole.py b/examples/v2/roles/CloneRole.py new file mode 100644 index 0000000000..2649b220a1 --- /dev/null +++ b/examples/v2/roles/CloneRole.py @@ -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) diff --git a/src/datadog_api_client/v2/api/roles_api.py b/src/datadog_api_client/v2/api/roles_api.py index d268fc4928..32ffaebc8f 100644 --- a/src/datadog_api_client/v2/api/roles_api.py +++ b/src/datadog_api_client/v2/api/roles_api.py @@ -16,6 +16,7 @@ from datadog_api_client.v2.model.permissions_response import PermissionsResponse from datadog_api_client.v2.model.relationship_to_permission import RelationshipToPermission from datadog_api_client.v2.model.relationship_to_user import RelationshipToUser +from datadog_api_client.v2.model.role_clone_request import RoleCloneRequest from datadog_api_client.v2.model.role_create_request import RoleCreateRequest from datadog_api_client.v2.model.role_create_response import RoleCreateResponse from datadog_api_client.v2.model.role_response import RoleResponse @@ -90,6 +91,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._clone_role_endpoint = _Endpoint( + settings={ + "response_type": (RoleResponse,), + "auth": ["AuthZ", "apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/roles/{role_id}/clone", + "operation_id": "clone_role", + "http_method": "POST", + "servers": None, + }, + params_map={ + "role_id": { + "required": True, + "openapi_types": (str,), + "attribute": "role_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (RoleCloneRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._create_role_endpoint = _Endpoint( settings={ "response_type": (RoleCreateResponse,), @@ -449,6 +476,51 @@ def add_user_to_role(self, role_id, body, **kwargs): kwargs["body"] = body return self._add_user_to_role_endpoint.call_with_http_info(**kwargs) + def clone_role(self, role_id, body, **kwargs): + """Create a new role by cloning an existing role + + Clone an existing role + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True. + + >>> thread = api.clone_role(role_id, body, async_req=True) + >>> result = thread.get() + + Args: + role_id (str): The ID of the role. + body (RoleCloneRequest): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + RoleResponse + If the method is called asynchronously, returns the request + thread. + """ + kwargs = self._clone_role_endpoint.default_arguments(kwargs) + kwargs["role_id"] = role_id + kwargs["body"] = body + return self._clone_role_endpoint.call_with_http_info(**kwargs) + def create_role(self, body, **kwargs): """Create role diff --git a/src/datadog_api_client/v2/model/role_clone.py b/src/datadog_api_client/v2/model/role_clone.py new file mode 100644 index 0000000000..d6dc705fce --- /dev/null +++ b/src/datadog_api_client/v2/model/role_clone.py @@ -0,0 +1,93 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. + + +from datadog_api_client.v2.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + date, + datetime, + file_type, + none_type, +) + + +def lazy_import(): + from datadog_api_client.v2.model.role_clone_attributes import RoleCloneAttributes + from datadog_api_client.v2.model.roles_type import RolesType + globals()['RoleCloneAttributes'] = RoleCloneAttributes + globals()['RolesType'] = RolesType + + +class RoleClone(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + validations = { + } + + + + + @cached_property + def openapi_types(): + lazy_import() + return { + 'attributes': (RoleCloneAttributes,), + 'type': (RolesType,), + } + + + + + attribute_map = { + 'attributes': 'attributes', + 'type': 'type', + } + + read_only_vars = { + } + + def __init__(self, attributes, type, *args, **kwargs): + """RoleClone - a model defined in OpenAPI + + Args: + attributes (RoleCloneAttributes): + type (RolesType): + + Keyword Args: + """ + super().__init__(kwargs) + + + self._check_pos_args(args) + + + + self.attributes = attributes + self.type = type + + + @classmethod + def _from_openapi_data(cls, attributes, type, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(RoleClone, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + + + self.attributes = attributes + self.type = type + return self + + diff --git a/src/datadog_api_client/v2/model/role_clone_attributes.py b/src/datadog_api_client/v2/model/role_clone_attributes.py new file mode 100644 index 0000000000..2aff05e8dc --- /dev/null +++ b/src/datadog_api_client/v2/model/role_clone_attributes.py @@ -0,0 +1,81 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. + + +from datadog_api_client.v2.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + date, + datetime, + file_type, + none_type, +) + + + +class RoleCloneAttributes(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + validations = { + } + + + + + @cached_property + def openapi_types(): + return { + 'name': (str,), + } + + + + + attribute_map = { + 'name': 'name', + } + + read_only_vars = { + } + + def __init__(self, name, *args, **kwargs): + """RoleCloneAttributes - a model defined in OpenAPI + + Args: + name (str): Name of the new role that is cloned. + + Keyword Args: + """ + super().__init__(kwargs) + + + self._check_pos_args(args) + + + + self.name = name + + + @classmethod + def _from_openapi_data(cls, name, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(RoleCloneAttributes, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + + + self.name = name + return self + + diff --git a/src/datadog_api_client/v2/model/role_clone_request.py b/src/datadog_api_client/v2/model/role_clone_request.py new file mode 100644 index 0000000000..6ac1ab346b --- /dev/null +++ b/src/datadog_api_client/v2/model/role_clone_request.py @@ -0,0 +1,86 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. + + +from datadog_api_client.v2.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + date, + datetime, + file_type, + none_type, +) + + +def lazy_import(): + from datadog_api_client.v2.model.role_clone import RoleClone + globals()['RoleClone'] = RoleClone + + +class RoleCloneRequest(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + + validations = { + } + + + + + @cached_property + def openapi_types(): + lazy_import() + return { + 'data': (RoleClone,), + } + + + + + attribute_map = { + 'data': 'data', + } + + read_only_vars = { + } + + def __init__(self, data, *args, **kwargs): + """RoleCloneRequest - a model defined in OpenAPI + + Args: + data (RoleClone): + + Keyword Args: + """ + super().__init__(kwargs) + + + self._check_pos_args(args) + + + + self.data = data + + + @classmethod + def _from_openapi_data(cls, data, *args, **kwargs): + """Helper creating a new instance from a response.""" + + self = super(RoleCloneRequest, cls)._from_openapi_data(kwargs) + + self._check_pos_args(args) + + + + self.data = data + return self + + diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index f346fd6ab8..399cef0d18 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -278,6 +278,9 @@ from datadog_api_client.v2.model.response_meta_attributes import ResponseMetaAttributes from datadog_api_client.v2.model.role import Role from datadog_api_client.v2.model.role_attributes import RoleAttributes +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.role_create_attributes import RoleCreateAttributes from datadog_api_client.v2.model.role_create_data import RoleCreateData from datadog_api_client.v2.model.role_create_request import RoleCreateRequest diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.frozen new file mode 100644 index 0000000000..822b3c7144 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.frozen @@ -0,0 +1 @@ +2021-12-21T20:35:38.317Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.yaml new file mode 100644 index 0000000000..03f4c989e5 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_bad_request_response.yaml @@ -0,0 +1,160 @@ +interactions: +- request: + body: '{"data":{"attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_Bad_Request_response-1640118938"},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '140' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '5882917064409071607' + x-datadog-trace-id: + - '5013029190881370125' + method: POST + uri: https://api.datadoghq.com/api/v2/roles + response: + body: + string: '{"data":{"type":"roles","id":"8eadd0f0-629d-11ec-af3f-da7ad0900002","attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_Bad_Request_response-1640118938","created_at":"2021-12-21T20:35:38.477734+00:00","modified_at":"2021-12-21T20:35:38.562460+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"}]}}}}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '726' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:38 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '499' + x-ratelimit-reset: + - '22' + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"name":" "},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '54' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '2838613727096632313' + x-datadog-trace-id: + - '5013029190881370125' + method: POST + uri: https://api.datadoghq.com/api/v2/roles/8eadd0f0-629d-11ec-af3f-da7ad0900002/clone + response: + body: + string: '{"errors": ["Role names cannot be only whitespace"]}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '52' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:38 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + status: + code: 400 + message: Bad Request +- request: + body: null + headers: + accept: + - '*/*' + connection: + - close + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '606368063604124071' + x-datadog-trace-id: + - '5013029190881370125' + method: DELETE + uri: https://api.datadoghq.com/api/v2/roles/8eadd0f0-629d-11ec-af3f-da7ad0900002 + response: + body: + string: '' + headers: + cache-control: + - no-cache + connection: + - close + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + date: + - Tue, 21 Dec 2021 20:35:38 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '497' + x-ratelimit-reset: + - '22' + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.frozen new file mode 100644 index 0000000000..e26f00b4bb --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.frozen @@ -0,0 +1 @@ +2021-12-21T20:35:38.858Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.yaml new file mode 100644 index 0000000000..76b278f5d9 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_conflict_response.yaml @@ -0,0 +1,168 @@ +interactions: +- request: + body: '{"data":{"attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_Conflict_response-1640118938"},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '137' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '7949852312625341114' + x-datadog-trace-id: + - '4105415849582287635' + method: POST + uri: https://api.datadoghq.com/api/v2/roles + response: + body: + string: '{"data":{"type":"roles","id":"8ef5c3ba-629d-11ec-af3f-da7ad0900002","attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_Conflict_response-1640118938","created_at":"2021-12-21T20:35:38.949398+00:00","modified_at":"2021-12-21T20:35:39.017421+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"}]}}}}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '723' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '496' + x-ratelimit-reset: + - '22' + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_Conflict_response-1640118938"},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '137' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '8121183684589003523' + x-datadog-trace-id: + - '4105415849582287635' + method: POST + uri: https://api.datadoghq.com/api/v2/roles/8ef5c3ba-629d-11ec-af3f-da7ad0900002/clone + response: + body: + string: '{"errors": ["A role with the same name already exists"]}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '56' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '495' + x-ratelimit-reset: + - '21' + status: + code: 409 + message: Conflict +- request: + body: null + headers: + accept: + - '*/*' + connection: + - close + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '2597019349126246186' + x-datadog-trace-id: + - '4105415849582287635' + method: DELETE + uri: https://api.datadoghq.com/api/v2/roles/8ef5c3ba-629d-11ec-af3f-da7ad0900002 + response: + body: + string: '' + headers: + cache-control: + - no-cache + connection: + - close + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '494' + x-ratelimit-reset: + - '21' + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.frozen new file mode 100644 index 0000000000..db78a19d95 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.frozen @@ -0,0 +1 @@ +2021-12-21T20:35:39.471Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.yaml new file mode 100644 index 0000000000..34d9299e7a --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_create_a_new_role_by_cloning_an_existing_role_returns_ok_response.yaml @@ -0,0 +1,220 @@ +interactions: +- request: + body: '{"data":{"attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_OK_response-1640118939"},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '131' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '4519272552005973084' + x-datadog-trace-id: + - '1393947245898415412' + method: POST + uri: https://api.datadoghq.com/api/v2/roles + response: + body: + string: '{"data":{"type":"roles","id":"8f5027c4-629d-11ec-af3f-da7ad0900002","attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_OK_response-1640118939","created_at":"2021-12-21T20:35:39.542012+00:00","modified_at":"2021-12-21T20:35:39.595689+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"}]}}}}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '717' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '493' + x-ratelimit-reset: + - '21' + status: + code: 200 + message: OK +- request: + body: '{"data":{"attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_OK_response-1640118939 + clone"},"type":"roles"}}' + headers: + accept: + - '*/*' + connection: + - close + content-length: + - '137' + content-type: + - application/json + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '5155236888493867346' + x-datadog-trace-id: + - '1393947245898415412' + method: POST + uri: https://api.datadoghq.com/api/v2/roles/8f5027c4-629d-11ec-af3f-da7ad0900002/clone + response: + body: + string: '{"data":{"type":"roles","id":"8f696e1e-629d-11ec-af3f-da7ad0900002","attributes":{"name":"Test-Create_a_new_role_by_cloning_an_existing_role_returns_OK_response-1640118939 + clone","created_at":"2021-12-21T20:35:39.707367+00:00","modified_at":"2021-12-21T20:35:39.754954+00:00"},"relationships":{"permissions":{"data":[{"type":"permissions","id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2"},{"type":"permissions","id":"4441648c-d8b1-11e9-a77a-1b899a04b304"},{"type":"permissions","id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0"},{"type":"permissions","id":"12efc20e-d36c-11eb-a9b8-da7ad0900002"},{"type":"permissions","id":"97971c1c-e895-11eb-b13c-da7ad0900002"},{"type":"permissions","id":"7605ef24-f376-11eb-b90b-da7ad0900002"}]}}}}' + headers: + cache-control: + - no-cache + connection: + - close + content-length: + - '723' + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + content-type: + - application/json + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '492' + x-ratelimit-reset: + - '21' + status: + code: 200 + message: OK +- request: + body: null + headers: + accept: + - '*/*' + connection: + - close + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '5380877147136164274' + x-datadog-trace-id: + - '1393947245898415412' + method: DELETE + uri: https://api.datadoghq.com/api/v2/roles/8f696e1e-629d-11ec-af3f-da7ad0900002 + response: + body: + string: '' + headers: + cache-control: + - no-cache + connection: + - close + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + date: + - Tue, 21 Dec 2021 20:35:39 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '491' + x-ratelimit-reset: + - '21' + status: + code: 204 + message: No Content +- request: + body: null + headers: + accept: + - '*/*' + connection: + - close + host: + - api.datadoghq.com + user-agent: + - datadog-api-spec/scripts/bdd-runner + x-datadog-parent-id: + - '957490087389621295' + x-datadog-trace-id: + - '1393947245898415412' + method: DELETE + uri: https://api.datadoghq.com/api/v2/roles/8f5027c4-629d-11ec-af3f-da7ad0900002 + response: + body: + string: '' + headers: + cache-control: + - no-cache + connection: + - close + content-security-policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + date: + - Tue, 21 Dec 2021 20:35:40 GMT + pragma: + - no-cache + strict-transport-security: + - max-age=15724800; + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-frame-options: + - SAMEORIGIN + x-ratelimit-limit: + - '500' + x-ratelimit-period: + - '60' + x-ratelimit-remaining: + - '490' + x-ratelimit-reset: + - '21' + status: + code: 204 + message: No Content +version: 1 diff --git a/tests/v2/features/roles.feature b/tests/v2/features/roles.feature index f7b2007d3c..24bd606a84 100644 --- a/tests/v2/features/roles.feature +++ b/tests/v2/features/roles.feature @@ -39,6 +39,42 @@ Feature: Roles When the request is sent Then the response status is 200 OK + @team:DataDog/team-aaa + Scenario: Create a new role by cloning an existing role returns "Bad Request" response + Given there is a valid "role" in the system + And new "CloneRole" request + And request contains "role_id" parameter from "role.data.id" + And body with value {"data": {"attributes": {"name": " "}, "type": "roles"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa + Scenario: Create a new role by cloning an existing role returns "Conflict" response + Given there is a valid "role" in the system + And new "CloneRole" request + And request contains "role_id" parameter from "role.data.id" + And body with value {"data": {"attributes": {"name": "{{ role.data.attributes.name }}"}, "type": "roles"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/team-aaa + Scenario: Create a new role by cloning an existing role returns "Not found" response + Given new "CloneRole" request + And request contains "role_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "cloned-role"}, "type": "roles"}} + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/team-aaa + Scenario: Create a new role by cloning an existing role returns "OK" response + Given there is a valid "role" in the system + And new "CloneRole" request + And request contains "role_id" parameter from "role.data.id" + And body with value {"data": {"attributes": {"name": "{{ unique }} clone"}, "type": "roles"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "{{ unique }} clone" + @generated @skip @team:DataDog/team-aaa Scenario: Create role returns "Bad Request" response Given new "CreateRole" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index b72bdeb64c..bd019435e0 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -384,6 +384,19 @@ "type": "idempotent" } }, + "CloneRole": { + "tag": "Roles", + "undo": { + "operationId": "DeleteRole", + "parameters": [ + { + "name": "role_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, "RemovePermissionFromRole": { "tag": "Roles", "undo": {