diff --git a/examples/test_iam_policy_management_v1_examples.py b/examples/test_iam_policy_management_v1_examples.py index 5e32e3d..496ea6d 100644 --- a/examples/test_iam_policy_management_v1_examples.py +++ b/examples/test_iam_policy_management_v1_examples.py @@ -67,6 +67,11 @@ example_basic_action_control_template_version = None example_action_control_assignment_id = None example_action_control_assignment_etag = None +example_role_template_id = None +example_role_template_version = None +example_role_template_etag = None +example_role_template_assignment_id = None +example_role_template_assignment_etag = None ############################################################################## @@ -1429,6 +1434,388 @@ def test_delete_action_control_template_example(self): except ApiException as e: pytest.fail(str(e)) + # @needscredentials + def test_create_role_template_example(self): + """ + create_role_template request example + """ + try: + print('\ncreate_role_template() result:') + + # begin-create_role_template + + response = iam_policy_management_service.create_role_template( + name='SDKRoleTemplateExample', + account_id=example_account_id, + ) + role_template = response.get_result() + + global example_role_template_id + example_role_template_id = role_template['id'] + global example_role_template_version + example_role_template_version = role_template['version'] + + print(json.dumps(role_template, indent=2)) + + # end-create_role_template + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_get_role_template_example(self): + """ + get_role_template request example + """ + try: + print('\nget_role_template() result:') + + # begin-get_role_template + + response = iam_policy_management_service.get_role_template( + role_template_id=example_role_template_id, + ) + role_template = response.get_result() + + global example_role_template_etag + example_role_template_etag = response.get_headers().get("Etag") + + print(json.dumps(role_template, indent=2)) + + # end-get_role_template + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_replace_role_template_example(self): + """ + replace_role_template request example + """ + try: + print('\nreplace_role_template() result:') + + # begin-replace_role_template + + template_role_model = { + 'name': 'SDKRoleTemplateExampleRe', + 'display_name': 'am-test-service', + 'service_name': 'am-test-service', + 'actions': ['am-test-service.test.delete'], + } + + response = iam_policy_management_service.replace_role_template( + role_template_id=example_role_template_id, + version=example_role_template_version, + if_match=example_role_template_etag, + role=template_role_model, + ) + role_template = response.get_result() + + print(json.dumps(role_template, indent=2)) + + # end-replace_role_template + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_role_templates_example(self): + """ + list_role_templates request example + """ + try: + print('\nlist_role_templates() result:') + + # begin-list_role_templates + + all_results = [] + pager = RoleTemplatesPager( + client=iam_policy_management_service, + account_id=example_account_id, + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_role_templates + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_create_role_template_version_example(self): + """ + create_role_template_version request example + """ + try: + print('\ncreate_role_template_version() result:') + + # begin-create_role_template_version + + template_role_model = { + 'name': 'SDKRoleTemplateExampleVer', + 'display_name': 'am-test-service', + 'service_name': 'am-test-service', + 'actions': ['am-test-service.test.delete', 'am-test-service.test.create'], + } + + response = iam_policy_management_service.create_role_template_version( + role_template_id=example_role_template_id, + role=template_role_model, + ) + role_template = response.get_result() + + global example_role_template_version + example_role_template_version = role_template['version'] + + print(json.dumps(role_template, indent=2)) + + # end-create_role_template_version + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_role_template_versions_example(self): + """ + list_role_template_versions request example + """ + try: + print('\nlist_role_template_versions() result:') + + # begin-list_role_template_versions + + all_results = [] + pager = RoleTemplateVersionsPager( + client=iam_policy_management_service, + role_template_id=example_role_template_id, + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_role_template_versions + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_get_role_template_version_example(self): + """ + get_role_template_version request example + """ + try: + print('\nget_role_template_version() result:') + + # begin-get_role_template_version + + response = iam_policy_management_service.get_role_template_version( + role_template_id=example_role_template_id, + version=example_role_template_version, + ) + role_template = response.get_result() + + print(json.dumps(role_template, indent=2)) + + # end-get_role_template_version + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_commit_role_template_example(self): + """ + commit_role_template request example + """ + try: + # begin-commit_role_template + + response = iam_policy_management_service.commit_role_template( + role_template_id=example_role_template_id, + version=example_role_template_version, + ) + + # end-commit_role_template + print('\ncommit_role_template() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_create_role_template_assignment_example(self): + """ + create_role_template_assignment request example + """ + try: + print('\ncreate_role_template_assignment() result:') + + # begin-create_role_template_assignment + + assignment_target_details_model = { + 'type': 'Account', + 'id': example_target_account_id, + } + + role_assignment_template_model = { + 'id': example_role_template_id, + 'version': example_role_template_version, + } + + response = iam_policy_management_service.create_role_template_assignment( + target=assignment_target_details_model, + templates=[role_assignment_template_model], + ) + role_assignment_collection = response.get_result() + + global example_role_template_assignment_id + example_role_template_assignment_id = role_assignment_collection['assignments'][0]['id'] + global example_role_template_assignment_etag + example_role_template_assignment_etag = response.get_headers().get("Etag") + + print(json.dumps(role_assignment_collection, indent=2)) + + # end-create_role_template_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_role_assignments_example(self): + """ + list_role_assignments request example + """ + try: + print('\nlist_role_assignments() result:') + + # begin-list_role_assignments + + all_results = [] + pager = RoleAssignmentsPager( + client=iam_policy_management_service, + account_id=example_account_id, + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_role_assignments + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_get_role_assignment_example(self): + """ + get_role_assignment request example + """ + try: + print('\nget_role_assignment() result:') + + # begin-get_role_assignment + + response = iam_policy_management_service.get_role_assignment( + assignment_id=example_role_template_assignment_id, + ) + role_assignment = response.get_result() + + print(json.dumps(role_assignment, indent=2)) + + # end-get_role_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_update_role_assignment_example(self): + """ + update_role_assignment request example + """ + try: + print('\nupdate_role_assignment() result:') + + # begin-update_role_assignment + + response = iam_policy_management_service.update_role_assignment( + assignment_id=example_role_template_assignment_id, + if_match=example_role_template_assignment_etag, + template_version=example_role_template_version, + ) + role_assignment = response.get_result() + + print(json.dumps(role_assignment, indent=2)) + + # end-update_role_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_delete_role_assignment_example(self): + """ + delete_role_assignment request example + """ + try: + # begin-delete_role_assignment + + response = iam_policy_management_service.delete_role_assignment( + assignment_id=example_role_template_assignment_id, + ) + + # end-delete_role_assignment + print('\ndelete_role_assignment() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_delete_role_template_version_example(self): + """ + delete_role_template_version request example + """ + try: + # begin-delete_role_template_version + + response = iam_policy_management_service.delete_role_template_version( + role_template_id=example_role_template_id, + version=example_role_template_version, + ) + + # end-delete_role_template_version + print('\ndelete_role_template_version() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_delete_role_template_example(self): + """ + delete_role_template request example + """ + try: + # begin-delete_role_template + + response = iam_policy_management_service.delete_role_template( + role_template_id=example_role_template_id, + ) + + # end-delete_role_template + print('\ndelete_role_template() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + # endregion ############################################################################## diff --git a/ibm_platform_services/iam_policy_management_v1.py b/ibm_platform_services/iam_policy_management_v1.py index 2782aac..21a2f71 100644 --- a/ibm_platform_services/iam_policy_management_v1.py +++ b/ibm_platform_services/iam_policy_management_v1.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.103.0-e8b84313-20250402-201816 +# IBM OpenAPI SDK Code Generator Version: 3.107.1-41b0fbd0-20250825-080732 """ IAM Policy Management API @@ -3774,271 +3774,1858 @@ def delete_action_control_assignment( response = self.send(request, **kwargs) return response + ######################### + # Role Templates + ######################### + + def list_role_templates( + self, + account_id: str, + *, + accept_language: Optional[str] = None, + name: Optional[str] = None, + role_name: Optional[str] = None, + role_service_name: Optional[str] = None, + state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + List role templates by attributes. + + List role templates and filter by attributes by using query parameters. The + following attributes are supported: + `account_id`, `name`, `role_name`, `role_service_name`, `state`, `limit`, `start`. + `account_id` is a required query parameter. Only role templates that have the + specified attributes and that the caller has read access to are returned. If the + caller does not have read access to any role templates an empty array is returned. + + :param str account_id: The account GUID that the role templates belong to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str name: (optional) The role template name. + :param str role_name: (optional) The template role name. + :param str role_service_name: (optional) The template role service name. + :param str state: (optional) The role template state. + :param int limit: (optional) The number of documents to include in the + collection. + :param str start: (optional) Page token that refers to the page of the + collection to return. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplateCollection` object + """ + + if not account_id: + raise ValueError('account_id must be provided') + headers = { + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_role_templates', + ) + headers.update(sdk_headers) + + params = { + 'account_id': account_id, + 'name': name, + 'role_name': role_name, + 'role_service_name': role_service_name, + 'state': state, + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/role_templates' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_role_template( + self, + name: str, + account_id: str, + *, + description: Optional[str] = None, + committed: Optional[bool] = None, + role: Optional['TemplateRole'] = None, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create role template. + + Create a role template. Role templates define roles from an existing system or + service defined role. + + :param str name: Required field when creating a new template. Otherwise, + this field is optional. If the field is included, it changes the name value + for all existing versions of the template. + :param str account_id: Enterprise account ID where this template is + created. + :param str description: (optional) Description of the role template. This + is shown to users in the enterprise account. Use this to describe the + purpose or context of the role for enterprise users managing IAM templates. + :param bool committed: (optional) Committed status of the template. If + committed is set to true, then the template version can no longer be + updated. + :param TemplateRole role: (optional) The role properties that are created + in an action resource when the template is assigned. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplate` object + """ + + if name is None: + raise ValueError('name must be provided') + if account_id is None: + raise ValueError('account_id must be provided') + if role is not None: + role = convert_model(role) + headers = { + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_role_template', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'account_id': account_id, + 'description': description, + 'committed': committed, + 'role': role, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/role_templates' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_role_template( + self, + role_template_id: str, + *, + state: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve the latest version of a role template. + + Retrieve the latest version of a role template by providing a role template ID. + + :param str role_template_id: Role template ID. + :param str state: (optional) The role template state. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplate` object + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_role_template', + ) + headers.update(sdk_headers) + + params = { + 'state': state, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['role_template_id'] + path_param_values = self.encode_path_vars(role_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def delete_role_template( + self, + role_template_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete a Role template. + + Delete a role template by providing the role template ID. This deletes all + versions of this template. A role template can't be deleted if any version of the + template is assigned to one or more child accounts. You must remove the role + assignments first. + + :param str role_template_id: Role template ID. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_role_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['role_template_id'] + path_param_values = self.encode_path_vars(role_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def create_role_template_version( + self, + role_template_id: str, + role: 'TemplateRole', + *, + name: Optional[str] = None, + description: Optional[str] = None, + committed: Optional[bool] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a new role template version. + + Create a new version of a role template. Use this if you need to make updates to a + role template that is committed. + + :param str role_template_id: The role template ID. + :param TemplateRole role: The role properties that are created in an action + resource when the template is assigned. + :param str name: (optional) Required field when creating a new template. + Otherwise, this field is optional. If the field is included, it will change + the name value for all existing versions of the template. + :param str description: (optional) Description of the role template. This + is shown to users in the enterprise account. Use this to describe the + purpose or context of the role for enterprise users managing IAM templates. + :param bool committed: (optional) Committed status of the template version. + If committed is set to true, then the template version can no longer be + updated. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplate` object + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + if role is None: + raise ValueError('role must be provided') + role = convert_model(role) + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_role_template_version', + ) + headers.update(sdk_headers) + + data = { + 'role': role, + 'name': name, + 'description': description, + 'committed': committed, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['role_template_id'] + path_param_values = self.encode_path_vars(role_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def list_role_template_versions( + self, + role_template_id: str, + *, + state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve role template versions. + + Retrieve the versions of a role template by providing a role template ID. + + :param str role_template_id: The role template ID. + :param str state: (optional) Role template state. + :param int limit: (optional) The number of documents to include in the + collection. + :param str start: (optional) Page token that refers to the page of the + collection to return. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplateVersionsCollection` object + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_role_template_versions', + ) + headers.update(sdk_headers) + + params = { + 'state': state, + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['role_template_id'] + path_param_values = self.encode_path_vars(role_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def replace_role_template( + self, + role_template_id: str, + version: str, + if_match: str, + role: 'TemplateRole', + *, + name: Optional[str] = None, + description: Optional[str] = None, + committed: Optional[bool] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update a role template version. + + Update a specific version of a role template. You can use this only if the version + isn't committed. + + :param str role_template_id: Role template ID. + :param str version: Role template version. + :param str if_match: The revision number for updating a role template + version must match the Etag value of the existing role template version. + The Etag can be retrieved using the GET + /v1/role_templates/{template_id}/versions/{version} API and looking at the + Etag response header. + :param TemplateRole role: The role properties that are created in an action + resource when the template is assigned. + :param str name: (optional) Required field when creating a new template. + Otherwise, this field is optional. If the field is included, it will change + the name value for all existing versions of the template. + :param str description: (optional) Description of the role template. This + is shown to users in the enterprise account. Use this to describe the + purpose or context of the role for enterprise users managing IAM templates. + :param bool committed: (optional) Committed status of the template version. + If committed is set to true, then the template version can no longer be + updated. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplate` object + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + if not version: + raise ValueError('version must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if role is None: + raise ValueError('role must be provided') + role = convert_model(role) + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='replace_role_template', + ) + headers.update(sdk_headers) + + data = { + 'role': role, + 'name': name, + 'description': description, + 'committed': committed, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['role_template_id', 'version'] + path_param_values = self.encode_path_vars(role_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions/{version}'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_role_template_version( + self, + role_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete a role template version. + + Delete a specific version of a role template by providing a role template ID and + version number. You can't delete a role template version that is assigned to one + or more child accounts. You must remove the role assignments first. + + :param str role_template_id: Role template ID. + :param str version: Role template version. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + if not version: + raise ValueError('version must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_role_template_version', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['role_template_id', 'version'] + path_param_values = self.encode_path_vars(role_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions/{version}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_role_template_version( + self, + role_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve a role template version. + + Retrieve a role template by providing a role template ID and version number. + + :param str role_template_id: Role template ID. + :param str version: Role template version. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleTemplate` object + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + if not version: + raise ValueError('version must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_role_template_version', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['role_template_id', 'version'] + path_param_values = self.encode_path_vars(role_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions/{version}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def commit_role_template( + self, + role_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Commit a role template version. + + Commit a role template version. You cannot make any further changes to the role + template once it's committed. If you have to make updates after committing a + version, create a new version. + + :param str role_template_id: Role template ID. + :param str version: The role template version. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not role_template_id: + raise ValueError('role_template_id must be provided') + if not version: + raise ValueError('version must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='commit_role_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['role_template_id', 'version'] + path_param_values = self.encode_path_vars(role_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_templates/{role_template_id}/versions/{version}/commit'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + ######################### + # Role Assignments + ######################### + + def list_role_assignments( + self, + account_id: str, + *, + accept_language: Optional[str] = None, + template_id: Optional[str] = None, + template_version: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Get role template assignments. + + Get role template assignments by attributes. The following attributes are + supported: + `account_id`, `template_id`, `template_version`, `target`, `target_type`, `limit`, + `start`. + `account_id` is a required query parameter. Only role template assignments with + the specified attributes and accessible by the caller are returned. If the caller + does not have read access to any role template assignments, an empty array is + returned. + + :param str account_id: The account GUID in which the role assignment + belongs to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str template_id: (optional) Optional template ID. + :param str template_version: (optional) Optional role template version. + :param int limit: (optional) The number of documents to include in the + collection. + :param str start: (optional) Page token that refers to the page of the + collection to return. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleAssignmentCollection` object + """ + + if not account_id: + raise ValueError('account_id must be provided') + headers = { + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_role_assignments', + ) + headers.update(sdk_headers) + + params = { + 'account_id': account_id, + 'template_id': template_id, + 'template_version': template_version, + 'limit': limit, + 'start': start, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/role_assignments' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_role_template_assignment( + self, + target: 'AssignmentTargetDetails', + templates: List['RoleAssignmentTemplate'], + *, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a role template assignment. + + Assign a role template to child accounts and account groups. This creates the role + in the accounts and account groups that you specify. + + :param AssignmentTargetDetails target: assignment target account and type. + :param List[RoleAssignmentTemplate] templates: List of role template + details for role assignment. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleAssignmentCollection` object + """ + + if target is None: + raise ValueError('target must be provided') + if templates is None: + raise ValueError('templates must be provided') + target = convert_model(target) + templates = [convert_model(x) for x in templates] + headers = { + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_role_template_assignment', + ) + headers.update(sdk_headers) + + data = { + 'target': target, + 'templates': templates, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/role_assignments' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_role_assignment( + self, + assignment_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve a role assignment. + + Retrieve a role template assignment by providing a role assignment ID. + + :param str assignment_id: Role template assignment ID. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleAssignment` object + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_role_assignment', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_role_assignment( + self, + assignment_id: str, + if_match: str, + template_version: str, + **kwargs, + ) -> DetailedResponse: + """ + Update a role assignment. + + Update a role assignment by providing a role assignment ID. + + :param str assignment_id: Role template assignment ID. + :param str if_match: The revision number for updating a role assignment and + must match the Etag value of the existing role assignment. The Etag can be + retrieved using the GET /v1/role_assignments/{assignment_id} API and + looking at the Etag response header. + :param str template_version: The version number of the template used to + identify different versions of same template. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse with `dict` result representing a `RoleAssignment` object + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if template_version is None: + raise ValueError('template_version must be provided') + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_role_assignment', + ) + headers.update(sdk_headers) + + data = { + 'template_version': template_version, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_role_assignment( + self, + assignment_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Remove a role assignment. + + Remove a role template assignment by providing a role assignment ID. You can't + delete a role assignment if the status is "in_progress". + + :param str assignment_id: Role template assignment ID. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_role_assignment', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/role_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + +class ListPoliciesEnums: + """ + Enums for list_policies parameters. + """ + + class Type(str, Enum): + """ + Optional type of policy. + """ + + ACCESS = 'access' + AUTHORIZATION = 'authorization' + + class ServiceType(str, Enum): + """ + Optional type of service. + """ + + SERVICE = 'service' + PLATFORM_SERVICE = 'platform_service' + + class Sort(str, Enum): + """ + Optional top level policy field to sort results. Ascending sort is default. + Descending sort available by prepending '-' to field. Example '-last_modified_at'. + """ + + ID = 'id' + TYPE = 'type' + HREF = 'href' + CREATED_AT = 'created_at' + CREATED_BY_ID = 'created_by_id' + LAST_MODIFIED_AT = 'last_modified_at' + LAST_MODIFIED_BY_ID = 'last_modified_by_id' + STATE = 'state' + + class Format(str, Enum): + """ + Include additional data per policy returned + * `include_last_permit` - returns details of when the policy last granted a permit + decision and the number of times it has done so + * `display` - returns the list of all actions included in each of the policy + roles. + """ + + INCLUDE_LAST_PERMIT = 'include_last_permit' + DISPLAY = 'display' + + class State(str, Enum): + """ + The state of the policy. + * `active` - returns active policies + * `deleted` - returns non-active policies. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class ListV2PoliciesEnums: + """ + Enums for list_v2_policies parameters. + """ + + class Type(str, Enum): + """ + Optional type of policy. + """ + + ACCESS = 'access' + AUTHORIZATION = 'authorization' + + class ServiceType(str, Enum): + """ + Optional type of service. + """ + + SERVICE = 'service' + PLATFORM_SERVICE = 'platform_service' + + class Format(str, Enum): + """ + Include additional data per policy returned + * `include_last_permit` - returns details of when the policy last granted a permit + decision and the number of times it has done so + * `display` - returns the list of all actions included in each of the policy roles + and translations for all relevant fields. + """ + + INCLUDE_LAST_PERMIT = 'include_last_permit' + DISPLAY = 'display' + + class State(str, Enum): + """ + The state of the policy. + * `active` - returns active policies + * `deleted` - returns non-active policies. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class GetV2PolicyEnums: + """ + Enums for get_v2_policy parameters. + """ + + class Format(str, Enum): + """ + Include additional data for policy returned + * `include_last_permit` - returns details of when the policy last granted a permit + decision and the number of times it has done so + * `display` - returns the list of all actions included in each of the policy roles + and translations for all relevant fields. + """ + + INCLUDE_LAST_PERMIT = 'include_last_permit' + DISPLAY = 'display' + + +class ListPolicyTemplatesEnums: + """ + Enums for list_policy_templates parameters. + """ + + class State(str, Enum): + """ + The policy template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + class PolicyServiceType(str, Enum): + """ + Service type, Optional. + """ + + SERVICE = 'service' + PLATFORM_SERVICE = 'platform_service' -class ListPoliciesEnums: + class PolicyType(str, Enum): + """ + Policy type, Optional. + """ + + ACCESS = 'access' + AUTHORIZATION = 'authorization' + + +class GetPolicyTemplateEnums: """ - Enums for list_policies parameters. + Enums for get_policy_template parameters. + """ + + class State(str, Enum): + """ + The policy template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class ListPolicyTemplateVersionsEnums: + """ + Enums for list_policy_template_versions parameters. + """ + + class State(str, Enum): + """ + The policy template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class GetActionControlTemplateEnums: + """ + Enums for get_action_control_template parameters. + """ + + class State(str, Enum): + """ + The action control template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class ListActionControlTemplateVersionsEnums: + """ + Enums for list_action_control_template_versions parameters. + """ + + class State(str, Enum): + """ + Action control template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class ListRoleTemplatesEnums: + """ + Enums for list_role_templates parameters. + """ + + class State(str, Enum): + """ + The role template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class GetRoleTemplateEnums: + """ + Enums for get_role_template parameters. + """ + + class State(str, Enum): + """ + The role template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class ListRoleTemplateVersionsEnums: + """ + Enums for list_role_template_versions parameters. + """ + + class State(str, Enum): + """ + Role template state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +############################################################################## +# Models +############################################################################## + + +class AccountSettingsAccessManagement: + """ + The Access Management Account Settings that are currently set for the requested + account. + + :param ExternalAccountIdentityInteraction external_account_identity_interaction: + How external accounts can interact in relation to the requested account. + """ + + def __init__( + self, + external_account_identity_interaction: 'ExternalAccountIdentityInteraction', + ) -> None: + """ + Initialize a AccountSettingsAccessManagement object. + + :param ExternalAccountIdentityInteraction + external_account_identity_interaction: How external accounts can interact + in relation to the requested account. + """ + self.external_account_identity_interaction = external_account_identity_interaction + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccountSettingsAccessManagement': + """Initialize a AccountSettingsAccessManagement object from a json dictionary.""" + args = {} + if (external_account_identity_interaction := _dict.get('external_account_identity_interaction')) is not None: + args['external_account_identity_interaction'] = ExternalAccountIdentityInteraction.from_dict( + external_account_identity_interaction + ) + else: + raise ValueError( + 'Required property \'external_account_identity_interaction\' not present in AccountSettingsAccessManagement JSON' + ) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccountSettingsAccessManagement object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if ( + hasattr(self, 'external_account_identity_interaction') + and self.external_account_identity_interaction is not None + ): + if isinstance(self.external_account_identity_interaction, dict): + _dict['external_account_identity_interaction'] = self.external_account_identity_interaction + else: + _dict['external_account_identity_interaction'] = self.external_account_identity_interaction.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AccountSettingsAccessManagement object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccountSettingsAccessManagement') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'AccountSettingsAccessManagement') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ActionControlAssignment: + """ + The set of properties associated with the assigned action control template. + + :param str id: (optional) Action control assignment ID. + :param str account_id: (optional) The account GUID that the action control + assignments belong to. + :param str href: (optional) The href URL that links to the action control + assignments API by action control assignment ID. + :param datetime created_at: (optional) The UTC timestamp when the action control + assignment was created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + action control assignment. + :param datetime last_modified_at: (optional) The UTC timestamp when the action + control assignment was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the action control assignment. + :param str operation: (optional) The current operation of the action control + assignment. + :param List[ActionControlAssignmentResource] resources: (optional) Resources + created when action control template is assigned. + :param ActionControlAssignmentTemplate template: The action control template id + and version that will be assigned. + :param AssignmentTargetDetails target: assignment target account and type. + :param str status: (optional) The action control assignment status. """ - class Type(str, Enum): - """ - Optional type of policy. - """ + def __init__( + self, + template: 'ActionControlAssignmentTemplate', + target: 'AssignmentTargetDetails', + *, + id: Optional[str] = None, + account_id: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + operation: Optional[str] = None, + resources: Optional[List['ActionControlAssignmentResource']] = None, + status: Optional[str] = None, + ) -> None: + """ + Initialize a ActionControlAssignment object. + + :param ActionControlAssignmentTemplate template: The action control + template id and version that will be assigned. + :param AssignmentTargetDetails target: assignment target account and type. + """ + self.id = id + self.account_id = account_id + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.operation = operation + self.resources = resources + self.template = template + self.target = target + self.status = status + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignment': + """Initialize a ActionControlAssignment object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (operation := _dict.get('operation')) is not None: + args['operation'] = operation + if (resources := _dict.get('resources')) is not None: + args['resources'] = [ActionControlAssignmentResource.from_dict(v) for v in resources] + if (template := _dict.get('template')) is not None: + args['template'] = ActionControlAssignmentTemplate.from_dict(template) + else: + raise ValueError('Required property \'template\' not present in ActionControlAssignment JSON') + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + else: + raise ValueError('Required property \'target\' not present in ActionControlAssignment JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignment object from a json dictionary.""" + return cls.from_dict(_dict) - ACCESS = 'access' - AUTHORIZATION = 'authorization' + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: + _dict['account_id'] = getattr(self, 'account_id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'operation') and getattr(self, 'operation') is not None: + _dict['operation'] = getattr(self, 'operation') + if hasattr(self, 'resources') and getattr(self, 'resources') is not None: + resources_list = [] + for v in getattr(self, 'resources'): + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') + return _dict - class ServiceType(str, Enum): - """ - Optional type of service. - """ + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' + def __str__(self) -> str: + """Return a `str` version of this ActionControlAssignment object.""" + return json.dumps(self.to_dict(), indent=2) - class Sort(str, Enum): - """ - Optional top level policy field to sort results. Ascending sort is default. - Descending sort available by prepending '-' to field. Example '-last_modified_at'. - """ + def __eq__(self, other: 'ActionControlAssignment') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ - ID = 'id' - TYPE = 'type' - HREF = 'href' - CREATED_AT = 'created_at' - CREATED_BY_ID = 'created_by_id' - LAST_MODIFIED_AT = 'last_modified_at' - LAST_MODIFIED_BY_ID = 'last_modified_by_id' - STATE = 'state' + def __ne__(self, other: 'ActionControlAssignment') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other - class Format(str, Enum): + class OperationEnum(str, Enum): """ - Include additional data per policy returned - * `include_last_permit` - returns details of when the policy last granted a permit - decision and the number of times it has done so - * `display` - returns the list of all actions included in each of the policy - roles. + The current operation of the action control assignment. """ - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' + CREATE = 'create' + APPLY = 'apply' + UPDATE = 'update' + REMOVE = 'remove' - class State(str, Enum): + class StatusEnum(str, Enum): """ - The state of the policy. - * `active` - returns active policies - * `deleted` - returns non-active policies. + The action control assignment status. """ - ACTIVE = 'active' - DELETED = 'deleted' + ACCEPTED = 'accepted' + FAILURE = 'failure' + IN_PROGRESS = 'in_progress' + SUPERSEDED = 'superseded' -class ListV2PoliciesEnums: +class ActionControlAssignmentCollection: """ - Enums for list_v2_policies parameters. + A collection of action control assignments. + + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[ActionControlAssignment] assignments: List of action control + assignments. """ - class Type(str, Enum): + def __init__( + self, + assignments: List['ActionControlAssignment'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + ) -> None: """ - Optional type of policy. + Initialize a ActionControlAssignmentCollection object. + + :param List[ActionControlAssignment] assignments: List of action control + assignments. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.assignments = assignments - ACCESS = 'access' - AUTHORIZATION = 'authorization' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentCollection': + """Initialize a ActionControlAssignmentCollection object from a json dictionary.""" + args = {} + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (assignments := _dict.get('assignments')) is not None: + args['assignments'] = [ActionControlAssignment.from_dict(v) for v in assignments] + else: + raise ValueError('Required property \'assignments\' not present in ActionControlAssignmentCollection JSON') + return cls(**args) - class ServiceType(str, Enum): - """ - Optional type of service. - """ + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentCollection object from a json dictionary.""" + return cls.from_dict(_dict) - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: + if isinstance(v, dict): + assignments_list.append(v) + else: + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list + return _dict - class Format(str, Enum): - """ - Include additional data per policy returned - * `include_last_permit` - returns details of when the policy last granted a permit - decision and the number of times it has done so - * `display` - returns the list of all actions included in each of the policy roles - and translations for all relevant fields. - """ + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' + def __str__(self) -> str: + """Return a `str` version of this ActionControlAssignmentCollection object.""" + return json.dumps(self.to_dict(), indent=2) - class State(str, Enum): - """ - The state of the policy. - * `active` - returns active policies - * `deleted` - returns non-active policies. - """ + def __eq__(self, other: 'ActionControlAssignmentCollection') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ - ACTIVE = 'active' - DELETED = 'deleted' + def __ne__(self, other: 'ActionControlAssignmentCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other -class GetV2PolicyEnums: +class ActionControlAssignmentResource: """ - Enums for get_v2_policy parameters. + The action control assignment resources and target where the template is assigned. + + :param AssignmentTargetDetails target: assignment target account and type. + :param ActionControlAssignmentResourceActionControl action_control: (optional) + Set of properties of the assigned resource or error message if assignment + failed. """ - class Format(str, Enum): - """ - Include additional data for policy returned - * `include_last_permit` - returns details of when the policy last granted a permit - decision and the number of times it has done so - * `display` - returns the list of all actions included in each of the policy roles - and translations for all relevant fields. + def __init__( + self, + target: 'AssignmentTargetDetails', + *, + action_control: Optional['ActionControlAssignmentResourceActionControl'] = None, + ) -> None: """ + Initialize a ActionControlAssignmentResource object. - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' - + :param AssignmentTargetDetails target: assignment target account and type. + :param ActionControlAssignmentResourceActionControl action_control: + (optional) Set of properties of the assigned resource or error message if + assignment failed. + """ + self.target = target + self.action_control = action_control -class ListPolicyTemplatesEnums: - """ - Enums for list_policy_templates parameters. - """ + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResource': + """Initialize a ActionControlAssignmentResource object from a json dictionary.""" + args = {} + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + else: + raise ValueError('Required property \'target\' not present in ActionControlAssignmentResource JSON') + if (action_control := _dict.get('action_control')) is not None: + args['action_control'] = ActionControlAssignmentResourceActionControl.from_dict(action_control) + return cls(**args) - class State(str, Enum): - """ - The policy template state. - """ + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentResource object from a json dictionary.""" + return cls.from_dict(_dict) - ACTIVE = 'active' - DELETED = 'deleted' + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'action_control') and self.action_control is not None: + if isinstance(self.action_control, dict): + _dict['action_control'] = self.action_control + else: + _dict['action_control'] = self.action_control.to_dict() + return _dict - class PolicyServiceType(str, Enum): - """ - Service type, Optional. - """ + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' + def __str__(self) -> str: + """Return a `str` version of this ActionControlAssignmentResource object.""" + return json.dumps(self.to_dict(), indent=2) - class PolicyType(str, Enum): - """ - Policy type, Optional. - """ + def __eq__(self, other: 'ActionControlAssignmentResource') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ - ACCESS = 'access' - AUTHORIZATION = 'authorization' + def __ne__(self, other: 'ActionControlAssignmentResource') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other -class GetPolicyTemplateEnums: +class ActionControlAssignmentResourceActionControl: """ - Enums for get_policy_template parameters. + Set of properties of the assigned resource or error message if assignment failed. + + :param ActionControlAssignmentResourceCreated resource_created: (optional) On + success, it includes the action control assigned. + :param AssignmentResourceError error_message: (optional) Body parameters for + assignment error. """ - class State(str, Enum): + def __init__( + self, + *, + resource_created: Optional['ActionControlAssignmentResourceCreated'] = None, + error_message: Optional['AssignmentResourceError'] = None, + ) -> None: """ - The policy template state. + Initialize a ActionControlAssignmentResourceActionControl object. + + :param ActionControlAssignmentResourceCreated resource_created: (optional) + On success, it includes the action control assigned. + :param AssignmentResourceError error_message: (optional) Body parameters + for assignment error. """ + self.resource_created = resource_created + self.error_message = error_message - ACTIVE = 'active' - DELETED = 'deleted' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResourceActionControl': + """Initialize a ActionControlAssignmentResourceActionControl object from a json dictionary.""" + args = {} + if (resource_created := _dict.get('resource_created')) is not None: + args['resource_created'] = ActionControlAssignmentResourceCreated.from_dict(resource_created) + if (error_message := _dict.get('error_message')) is not None: + args['error_message'] = AssignmentResourceError.from_dict(error_message) + return cls(**args) + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentResourceActionControl object from a json dictionary.""" + return cls.from_dict(_dict) -class ListPolicyTemplateVersionsEnums: - """ - Enums for list_policy_template_versions parameters. - """ + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'resource_created') and self.resource_created is not None: + if isinstance(self.resource_created, dict): + _dict['resource_created'] = self.resource_created + else: + _dict['resource_created'] = self.resource_created.to_dict() + if hasattr(self, 'error_message') and self.error_message is not None: + if isinstance(self.error_message, dict): + _dict['error_message'] = self.error_message + else: + _dict['error_message'] = self.error_message.to_dict() + return _dict - class State(str, Enum): - """ - The policy template state. - """ + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() - ACTIVE = 'active' - DELETED = 'deleted' + def __str__(self) -> str: + """Return a `str` version of this ActionControlAssignmentResourceActionControl object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ActionControlAssignmentResourceActionControl') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ActionControlAssignmentResourceActionControl') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other -class GetActionControlTemplateEnums: +class ActionControlAssignmentResourceCreated: """ - Enums for get_action_control_template parameters. + On success, it includes the action control assigned. + + :param str id: (optional) action control id. """ - class State(str, Enum): + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: """ - The action control template state. + Initialize a ActionControlAssignmentResourceCreated object. + + :param str id: (optional) action control id. """ + self.id = id - ACTIVE = 'active' - DELETED = 'deleted' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResourceCreated': + """Initialize a ActionControlAssignmentResourceCreated object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + return cls(**args) + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentResourceCreated object from a json dictionary.""" + return cls.from_dict(_dict) -class ListActionControlTemplateVersionsEnums: - """ - Enums for list_action_control_template_versions parameters. - """ + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + return _dict - class State(str, Enum): - """ - Action control template state. - """ + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() - ACTIVE = 'active' - DELETED = 'deleted' + def __str__(self) -> str: + """Return a `str` version of this ActionControlAssignmentResourceCreated object.""" + return json.dumps(self.to_dict(), indent=2) + def __eq__(self, other: 'ActionControlAssignmentResourceCreated') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ -############################################################################## -# Models -############################################################################## + def __ne__(self, other: 'ActionControlAssignmentResourceCreated') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other -class AccountSettingsAccessManagement: +class ActionControlAssignmentTemplate: """ - The Access Management Account Settings that are currently set for the requested - account. + The action control template id and version that will be assigned. - :param ExternalAccountIdentityInteraction external_account_identity_interaction: - How external accounts can interact in relation to the requested account. + :param str id: Action control template ID. + :param str version: Action control template version. """ def __init__( self, - external_account_identity_interaction: 'ExternalAccountIdentityInteraction', + id: str, + version: str, ) -> None: """ - Initialize a AccountSettingsAccessManagement object. - - :param ExternalAccountIdentityInteraction - external_account_identity_interaction: How external accounts can interact - in relation to the requested account. + Initialize a ActionControlAssignmentTemplate object. + + :param str id: Action control template ID. + :param str version: Action control template version. """ - self.external_account_identity_interaction = external_account_identity_interaction + self.id = id + self.version = version @classmethod - def from_dict(cls, _dict: Dict) -> 'AccountSettingsAccessManagement': - """Initialize a AccountSettingsAccessManagement object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentTemplate': + """Initialize a ActionControlAssignmentTemplate object from a json dictionary.""" args = {} - if (external_account_identity_interaction := _dict.get('external_account_identity_interaction')) is not None: - args['external_account_identity_interaction'] = ExternalAccountIdentityInteraction.from_dict( - external_account_identity_interaction - ) + if (id := _dict.get('id')) is not None: + args['id'] = id else: - raise ValueError( - 'Required property \'external_account_identity_interaction\' not present in AccountSettingsAccessManagement JSON' - ) + raise ValueError('Required property \'id\' not present in ActionControlAssignmentTemplate JSON') + if (version := _dict.get('version')) is not None: + args['version'] = version + else: + raise ValueError('Required property \'version\' not present in ActionControlAssignmentTemplate JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AccountSettingsAccessManagement object from a json dictionary.""" + """Initialize a ActionControlAssignmentTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if ( - hasattr(self, 'external_account_identity_interaction') - and self.external_account_identity_interaction is not None - ): - if isinstance(self.external_account_identity_interaction, dict): - _dict['external_account_identity_interaction'] = self.external_account_identity_interaction - else: - _dict['external_account_identity_interaction'] = self.external_account_identity_interaction.to_dict() + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version return _dict def _to_dict(self): @@ -4046,91 +5633,126 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AccountSettingsAccessManagement object.""" + """Return a `str` version of this ActionControlAssignmentTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AccountSettingsAccessManagement') -> bool: + def __eq__(self, other: 'ActionControlAssignmentTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AccountSettingsAccessManagement') -> bool: + def __ne__(self, other: 'ActionControlAssignmentTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlAssignment: +class ActionControlTemplate: """ - The set of properties associated with the assigned action control template. + The set of properties associated with the action control template. - :param str id: (optional) Action control assignment ID. - :param str account_id: (optional) The account GUID that the action control - assignments belong to. + :param str name: Required field when creating a new template. Otherwise, this + field is optional. If the field is included, it changes the name value for all + existing versions of the template. + :param str description: Description of the action control template. This is + shown to users in the enterprise account. Use this to describe the purpose or + context of the action control for enterprise users managing IAM templates. + :param str account_id: Enterprise account ID where this template is created. + :param bool committed: (optional) Committed status of the template. If committed + is set to true, then the template version can no longer be updated. + :param TemplateActionControl action_control: (optional) The action control + properties that are created in an action resource when the template is assigned. + :param str id: (optional) The action control template ID. :param str href: (optional) The href URL that links to the action control - assignments API by action control assignment ID. + templates API by action control template ID. :param datetime created_at: (optional) The UTC timestamp when the action control - assignment was created. + template was created. :param str created_by_id: (optional) The IAM ID of the entity that created the - action control assignment. + action control template. :param datetime last_modified_at: (optional) The UTC timestamp when the action - control assignment was last modified. + control template was last modified. :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the action control assignment. - :param str operation: (optional) The current operation of the action control - assignment. - :param List[ActionControlAssignmentResource] resources: (optional) Resources - created when action control template is assigned. - :param ActionControlAssignmentTemplate template: The action control template id - and version that will be assigned. - :param AssignmentTargetDetails target: assignment target account and type. - :param str status: (optional) The action control assignment status. + modified the action control template. + :param str version: The version number of the template used to identify + different versions of same template. + :param str state: State of action control template. """ def __init__( self, - template: 'ActionControlAssignmentTemplate', - target: 'AssignmentTargetDetails', + name: str, + description: str, + account_id: str, + version: str, + state: str, *, + committed: Optional[bool] = None, + action_control: Optional['TemplateActionControl'] = None, id: Optional[str] = None, - account_id: Optional[str] = None, href: Optional[str] = None, created_at: Optional[datetime] = None, created_by_id: Optional[str] = None, last_modified_at: Optional[datetime] = None, last_modified_by_id: Optional[str] = None, - operation: Optional[str] = None, - resources: Optional[List['ActionControlAssignmentResource']] = None, - status: Optional[str] = None, ) -> None: """ - Initialize a ActionControlAssignment object. + Initialize a ActionControlTemplate object. - :param ActionControlAssignmentTemplate template: The action control - template id and version that will be assigned. - :param AssignmentTargetDetails target: assignment target account and type. + :param str name: Required field when creating a new template. Otherwise, + this field is optional. If the field is included, it changes the name value + for all existing versions of the template. + :param str description: Description of the action control template. This is + shown to users in the enterprise account. Use this to describe the purpose + or context of the action control for enterprise users managing IAM + templates. + :param str account_id: Enterprise account ID where this template is + created. + :param str version: The version number of the template used to identify + different versions of same template. + :param str state: State of action control template. + :param bool committed: (optional) Committed status of the template. If + committed is set to true, then the template version can no longer be + updated. + :param TemplateActionControl action_control: (optional) The action control + properties that are created in an action resource when the template is + assigned. """ - self.id = id + self.name = name + self.description = description self.account_id = account_id + self.committed = committed + self.action_control = action_control + self.id = id self.href = href self.created_at = created_at self.created_by_id = created_by_id self.last_modified_at = last_modified_at self.last_modified_by_id = last_modified_by_id - self.operation = operation - self.resources = resources - self.template = template - self.target = target - self.status = status + self.version = version + self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignment': - """Initialize a ActionControlAssignment object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ActionControlTemplate': + """Initialize a ActionControlTemplate object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ActionControlTemplate JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + else: + raise ValueError('Required property \'description\' not present in ActionControlTemplate JSON') if (account_id := _dict.get('account_id')) is not None: args['account_id'] = account_id + else: + raise ValueError('Required property \'account_id\' not present in ActionControlTemplate JSON') + if (committed := _dict.get('committed')) is not None: + args['committed'] = committed + if (action_control := _dict.get('action_control')) is not None: + args['action_control'] = TemplateActionControl.from_dict(action_control) + if (id := _dict.get('id')) is not None: + args['id'] = id if (href := _dict.get('href')) is not None: args['href'] = href if (created_at := _dict.get('created_at')) is not None: @@ -4141,34 +5763,39 @@ def from_dict(cls, _dict: Dict) -> 'ActionControlAssignment': args['last_modified_at'] = string_to_datetime(last_modified_at) if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: args['last_modified_by_id'] = last_modified_by_id - if (operation := _dict.get('operation')) is not None: - args['operation'] = operation - if (resources := _dict.get('resources')) is not None: - args['resources'] = [ActionControlAssignmentResource.from_dict(v) for v in resources] - if (template := _dict.get('template')) is not None: - args['template'] = ActionControlAssignmentTemplate.from_dict(template) + if (version := _dict.get('version')) is not None: + args['version'] = version else: - raise ValueError('Required property \'template\' not present in ActionControlAssignment JSON') - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) + raise ValueError('Required property \'version\' not present in ActionControlTemplate JSON') + if (state := _dict.get('state')) is not None: + args['state'] = state else: - raise ValueError('Required property \'target\' not present in ActionControlAssignment JSON') - if (status := _dict.get('status')) is not None: - args['status'] = status + raise ValueError('Required property \'state\' not present in ActionControlTemplate JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignment object from a json dictionary.""" + """Initialize a ActionControlTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'committed') and self.committed is not None: + _dict['committed'] = self.committed + if hasattr(self, 'action_control') and self.action_control is not None: + if isinstance(self.action_control, dict): + _dict['action_control'] = self.action_control + else: + _dict['action_control'] = self.action_control.to_dict() if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: @@ -4179,28 +5806,10 @@ def to_dict(self) -> Dict: _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'operation') and getattr(self, 'operation') is not None: - _dict['operation'] = getattr(self, 'operation') - if hasattr(self, 'resources') and getattr(self, 'resources') is not None: - resources_list = [] - for v in getattr(self, 'resources'): - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template - else: - _dict['template'] = self.template.to_dict() - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target - else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'status') and getattr(self, 'status') is not None: - _dict['status'] = getattr(self, 'status') + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state return _dict def _to_dict(self): @@ -4208,43 +5817,31 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignment object.""" + """Return a `str` version of this ActionControlTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignment') -> bool: + def __eq__(self, other: 'ActionControlTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignment') -> bool: + def __ne__(self, other: 'ActionControlTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class OperationEnum(str, Enum): - """ - The current operation of the action control assignment. - """ - - CREATE = 'create' - APPLY = 'apply' - UPDATE = 'update' - REMOVE = 'remove' - - class StatusEnum(str, Enum): + class StateEnum(str, Enum): """ - The action control assignment status. + State of action control template. """ - ACCEPTED = 'accepted' - FAILURE = 'failure' - IN_PROGRESS = 'in_progress' - SUPERSEDED = 'superseded' + ACTIVE = 'active' + DELETED = 'deleted' -class ActionControlAssignmentCollection: +class ActionControlTemplateCollection: """ - A collection of action control assignments. + A collection of action control templates. :param int limit: (optional) The number of documents to include per each page of the collection. @@ -4254,13 +5851,13 @@ class ActionControlAssignmentCollection: requested collection. :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[ActionControlAssignment] assignments: List of action control - assignments. + :param List[ActionControlTemplate] action_control_templates: List of action + control templates. """ def __init__( self, - assignments: List['ActionControlAssignment'], + action_control_templates: List['ActionControlTemplate'], *, limit: Optional[int] = None, first: Optional['First'] = None, @@ -4268,10 +5865,10 @@ def __init__( previous: Optional['Previous'] = None, ) -> None: """ - Initialize a ActionControlAssignmentCollection object. + Initialize a ActionControlTemplateCollection object. - :param List[ActionControlAssignment] assignments: List of action control - assignments. + :param List[ActionControlTemplate] action_control_templates: List of action + control templates. :param int limit: (optional) The number of documents to include per each page of the collection. :param First first: (optional) Details with linking href to first page of @@ -4285,11 +5882,11 @@ def __init__( self.first = first self.next = next self.previous = previous - self.assignments = assignments + self.action_control_templates = action_control_templates @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentCollection': - """Initialize a ActionControlAssignmentCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ActionControlTemplateCollection': + """Initialize a ActionControlTemplateCollection object from a json dictionary.""" args = {} if (limit := _dict.get('limit')) is not None: args['limit'] = limit @@ -4299,15 +5896,17 @@ def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentCollection': args['next'] = Next.from_dict(next) if (previous := _dict.get('previous')) is not None: args['previous'] = Previous.from_dict(previous) - if (assignments := _dict.get('assignments')) is not None: - args['assignments'] = [ActionControlAssignment.from_dict(v) for v in assignments] + if (action_control_templates := _dict.get('action_control_templates')) is not None: + args['action_control_templates'] = [ActionControlTemplate.from_dict(v) for v in action_control_templates] else: - raise ValueError('Required property \'assignments\' not present in ActionControlAssignmentCollection JSON') + raise ValueError( + 'Required property \'action_control_templates\' not present in ActionControlTemplateCollection JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignmentCollection object from a json dictionary.""" + """Initialize a ActionControlTemplateCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -4330,14 +5929,14 @@ def to_dict(self) -> Dict: _dict['previous'] = self.previous else: _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'assignments') and self.assignments is not None: - assignments_list = [] - for v in self.assignments: + if hasattr(self, 'action_control_templates') and self.action_control_templates is not None: + action_control_templates_list = [] + for v in self.action_control_templates: if isinstance(v, dict): - assignments_list.append(v) + action_control_templates_list.append(v) else: - assignments_list.append(v.to_dict()) - _dict['assignments'] = assignments_list + action_control_templates_list.append(v.to_dict()) + _dict['action_control_templates'] = action_control_templates_list return _dict def _to_dict(self): @@ -4345,77 +5944,118 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignmentCollection object.""" + """Return a `str` version of this ActionControlTemplateCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignmentCollection') -> bool: + def __eq__(self, other: 'ActionControlTemplateCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignmentCollection') -> bool: + def __ne__(self, other: 'ActionControlTemplateCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlAssignmentResource: +class ActionControlTemplateVersionsCollection: """ - The action control assignment resources and target where the template is assigned. + A collection of versions for a specific action control template. - :param AssignmentTargetDetails target: assignment target account and type. - :param ActionControlAssignmentResourceActionControl action_control: (optional) - Set of properties of the assigned resource or error message if assignment - failed. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[ActionControlTemplate] versions: List of action control templates + versions. """ def __init__( self, - target: 'AssignmentTargetDetails', + versions: List['ActionControlTemplate'], *, - action_control: Optional['ActionControlAssignmentResourceActionControl'] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a ActionControlAssignmentResource object. + Initialize a ActionControlTemplateVersionsCollection object. - :param AssignmentTargetDetails target: assignment target account and type. - :param ActionControlAssignmentResourceActionControl action_control: - (optional) Set of properties of the assigned resource or error message if - assignment failed. + :param List[ActionControlTemplate] versions: List of action control + templates versions. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ - self.target = target - self.action_control = action_control + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.versions = versions @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResource': - """Initialize a ActionControlAssignmentResource object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ActionControlTemplateVersionsCollection': + """Initialize a ActionControlTemplateVersionsCollection object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (versions := _dict.get('versions')) is not None: + args['versions'] = [ActionControlTemplate.from_dict(v) for v in versions] else: - raise ValueError('Required property \'target\' not present in ActionControlAssignmentResource JSON') - if (action_control := _dict.get('action_control')) is not None: - args['action_control'] = ActionControlAssignmentResourceActionControl.from_dict(action_control) + raise ValueError( + 'Required property \'versions\' not present in ActionControlTemplateVersionsCollection JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignmentResource object from a json dictionary.""" + """Initialize a ActionControlTemplateVersionsCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'action_control') and self.action_control is not None: - if isinstance(self.action_control, dict): - _dict['action_control'] = self.action_control + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next else: - _dict['action_control'] = self.action_control.to_dict() + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'versions') and self.versions is not None: + versions_list = [] + for v in self.versions: + if isinstance(v, dict): + versions_list.append(v) + else: + versions_list.append(v.to_dict()) + _dict['versions'] = versions_list return _dict def _to_dict(self): @@ -4423,73 +6063,57 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignmentResource object.""" + """Return a `str` version of this ActionControlTemplateVersionsCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignmentResource') -> bool: + def __eq__(self, other: 'ActionControlTemplateVersionsCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignmentResource') -> bool: + def __ne__(self, other: 'ActionControlTemplateVersionsCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlAssignmentResourceActionControl: +class AssignmentResourceCreated: """ - Set of properties of the assigned resource or error message if assignment failed. + On success, includes the policy that is assigned. - :param ActionControlAssignmentResourceCreated resource_created: (optional) On - success, it includes the action control assigned. - :param ErrorResponse error_message: (optional) The error response from API. + :param str id: (optional) Policy id. """ def __init__( self, *, - resource_created: Optional['ActionControlAssignmentResourceCreated'] = None, - error_message: Optional['ErrorResponse'] = None, + id: Optional[str] = None, ) -> None: """ - Initialize a ActionControlAssignmentResourceActionControl object. + Initialize a AssignmentResourceCreated object. - :param ActionControlAssignmentResourceCreated resource_created: (optional) - On success, it includes the action control assigned. - :param ErrorResponse error_message: (optional) The error response from API. + :param str id: (optional) Policy id. """ - self.resource_created = resource_created - self.error_message = error_message + self.id = id @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResourceActionControl': - """Initialize a ActionControlAssignmentResourceActionControl object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'AssignmentResourceCreated': + """Initialize a AssignmentResourceCreated object from a json dictionary.""" args = {} - if (resource_created := _dict.get('resource_created')) is not None: - args['resource_created'] = ActionControlAssignmentResourceCreated.from_dict(resource_created) - if (error_message := _dict.get('error_message')) is not None: - args['error_message'] = ErrorResponse.from_dict(error_message) + if (id := _dict.get('id')) is not None: + args['id'] = id return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignmentResourceActionControl object from a json dictionary.""" + """Initialize a AssignmentResourceCreated object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'resource_created') and self.resource_created is not None: - if isinstance(self.resource_created, dict): - _dict['resource_created'] = self.resource_created - else: - _dict['resource_created'] = self.resource_created.to_dict() - if hasattr(self, 'error_message') and self.error_message is not None: - if isinstance(self.error_message, dict): - _dict['error_message'] = self.error_message - else: - _dict['error_message'] = self.error_message.to_dict() + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id return _dict def _to_dict(self): @@ -4497,57 +6121,98 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignmentResourceActionControl object.""" + """Return a `str` version of this AssignmentResourceCreated object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignmentResourceActionControl') -> bool: + def __eq__(self, other: 'AssignmentResourceCreated') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignmentResourceActionControl') -> bool: + def __ne__(self, other: 'AssignmentResourceCreated') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlAssignmentResourceCreated: +class AssignmentResourceError: """ - On success, it includes the action control assigned. + Body parameters for assignment error. - :param str id: (optional) action control id. + :param str name: (optional) Name of the error. + :param str error_code: (optional) error code. + :param str message: (optional) Error message detailing the nature of the error. + :param str code: (optional) Internal status code for the error. + :param List[ErrorObject] errors: (optional) The errors encountered during the + response. """ def __init__( self, *, - id: Optional[str] = None, + name: Optional[str] = None, + error_code: Optional[str] = None, + message: Optional[str] = None, + code: Optional[str] = None, + errors: Optional[List['ErrorObject']] = None, ) -> None: """ - Initialize a ActionControlAssignmentResourceCreated object. + Initialize a AssignmentResourceError object. - :param str id: (optional) action control id. + :param str name: (optional) Name of the error. + :param str error_code: (optional) error code. + :param str message: (optional) Error message detailing the nature of the + error. + :param str code: (optional) Internal status code for the error. + :param List[ErrorObject] errors: (optional) The errors encountered during + the response. """ - self.id = id + self.name = name + self.error_code = error_code + self.message = message + self.code = code + self.errors = errors @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentResourceCreated': - """Initialize a ActionControlAssignmentResourceCreated object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'AssignmentResourceError': + """Initialize a AssignmentResourceError object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id + if (name := _dict.get('name')) is not None: + args['name'] = name + if (error_code := _dict.get('errorCode')) is not None: + args['error_code'] = error_code + if (message := _dict.get('message')) is not None: + args['message'] = message + if (code := _dict.get('code')) is not None: + args['code'] = code + if (errors := _dict.get('errors')) is not None: + args['errors'] = [ErrorObject.from_dict(v) for v in errors] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignmentResourceCreated object from a json dictionary.""" + """Initialize a AssignmentResourceError object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'error_code') and self.error_code is not None: + _dict['errorCode'] = self.error_code + if hasattr(self, 'message') and self.message is not None: + _dict['message'] = self.message + if hasattr(self, 'code') and self.code is not None: + _dict['code'] = self.code + if hasattr(self, 'errors') and self.errors is not None: + errors_list = [] + for v in self.errors: + if isinstance(v, dict): + errors_list.append(v) + else: + errors_list.append(v.to_dict()) + _dict['errors'] = errors_list return _dict def _to_dict(self): @@ -4555,68 +6220,68 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignmentResourceCreated object.""" + """Return a `str` version of this AssignmentResourceError object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignmentResourceCreated') -> bool: + def __eq__(self, other: 'AssignmentResourceError') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignmentResourceCreated') -> bool: + def __ne__(self, other: 'AssignmentResourceError') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlAssignmentTemplate: +class AssignmentTargetDetails: """ - The action control template id and version that will be assigned. + assignment target account and type. - :param str id: Action control template ID. - :param str version: Action control template version. + :param str type: Assignment target type. + :param str id: ID of the target account. """ def __init__( self, + type: str, id: str, - version: str, ) -> None: """ - Initialize a ActionControlAssignmentTemplate object. + Initialize a AssignmentTargetDetails object. - :param str id: Action control template ID. - :param str version: Action control template version. + :param str type: Assignment target type. + :param str id: ID of the target account. """ + self.type = type self.id = id - self.version = version @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentTemplate': - """Initialize a ActionControlAssignmentTemplate object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'AssignmentTargetDetails': + """Initialize a AssignmentTargetDetails object from a json dictionary.""" args = {} + if (type := _dict.get('type')) is not None: + args['type'] = type + else: + raise ValueError('Required property \'type\' not present in AssignmentTargetDetails JSON') if (id := _dict.get('id')) is not None: args['id'] = id else: - raise ValueError('Required property \'id\' not present in ActionControlAssignmentTemplate JSON') - if (version := _dict.get('version')) is not None: - args['version'] = version - else: - raise ValueError('Required property \'version\' not present in ActionControlAssignmentTemplate JSON') + raise ValueError('Required property \'id\' not present in AssignmentTargetDetails JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlAssignmentTemplate object from a json dictionary.""" + """Initialize a AssignmentTargetDetails object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type if hasattr(self, 'id') and self.id is not None: _dict['id'] = self.id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version return _dict def _to_dict(self): @@ -4624,183 +6289,72 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlAssignmentTemplate object.""" + """Return a `str` version of this AssignmentTargetDetails object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlAssignmentTemplate') -> bool: + def __eq__(self, other: 'AssignmentTargetDetails') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlAssignmentTemplate') -> bool: + def __ne__(self, other: 'AssignmentTargetDetails') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TypeEnum(str, Enum): + """ + Assignment target type. + """ + + ACCOUNT = 'Account' -class ActionControlTemplate: + +class AssignmentTemplateDetails: """ - The set of properties associated with the action control template. + policy template details. - :param str name: Required field when creating a new template. Otherwise, this - field is optional. If the field is included, it changes the name value for all - existing versions of the template. - :param str description: Description of the action control template. This is - shown to users in the enterprise account. Use this to describe the purpose or - context of the action control for enterprise users managing IAM templates. - :param str account_id: Enterprise account ID where this template is created. - :param bool committed: (optional) Committed status of the template. If committed - is set to true, then the template version can no longer be updated. - :param TemplateActionControl action_control: (optional) The action control - properties that are created in an action resource when the template is assigned. - :param str id: (optional) The action control template ID. - :param str href: (optional) The href URL that links to the action control - templates API by action control template ID. - :param datetime created_at: (optional) The UTC timestamp when the action control - template was created. - :param str created_by_id: (optional) The IAM ID of the entity that created the - action control template. - :param datetime last_modified_at: (optional) The UTC timestamp when the action - control template was last modified. - :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the action control template. - :param str version: The version number of the template used to identify - different versions of same template. - :param str state: State of action control template. + :param str id: (optional) Policy template ID. + :param str version: (optional) Policy template version. """ def __init__( self, - name: str, - description: str, - account_id: str, - version: str, - state: str, *, - committed: Optional[bool] = None, - action_control: Optional['TemplateActionControl'] = None, id: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, + version: Optional[str] = None, ) -> None: """ - Initialize a ActionControlTemplate object. + Initialize a AssignmentTemplateDetails object. - :param str name: Required field when creating a new template. Otherwise, - this field is optional. If the field is included, it changes the name value - for all existing versions of the template. - :param str description: Description of the action control template. This is - shown to users in the enterprise account. Use this to describe the purpose - or context of the action control for enterprise users managing IAM - templates. - :param str account_id: Enterprise account ID where this template is - created. - :param str version: The version number of the template used to identify - different versions of same template. - :param str state: State of action control template. - :param bool committed: (optional) Committed status of the template. If - committed is set to true, then the template version can no longer be - updated. - :param TemplateActionControl action_control: (optional) The action control - properties that are created in an action resource when the template is - assigned. + :param str id: (optional) Policy template ID. + :param str version: (optional) Policy template version. """ - self.name = name - self.description = description - self.account_id = account_id - self.committed = committed - self.action_control = action_control self.id = id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id self.version = version - self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlTemplate': - """Initialize a ActionControlTemplate object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'AssignmentTemplateDetails': + """Initialize a AssignmentTemplateDetails object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name - else: - raise ValueError('Required property \'name\' not present in ActionControlTemplate JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - else: - raise ValueError('Required property \'description\' not present in ActionControlTemplate JSON') - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - else: - raise ValueError('Required property \'account_id\' not present in ActionControlTemplate JSON') - if (committed := _dict.get('committed')) is not None: - args['committed'] = committed - if (action_control := _dict.get('action_control')) is not None: - args['action_control'] = TemplateActionControl.from_dict(action_control) if (id := _dict.get('id')) is not None: args['id'] = id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id if (version := _dict.get('version')) is not None: args['version'] = version - else: - raise ValueError('Required property \'version\' not present in ActionControlTemplate JSON') - if (state := _dict.get('state')) is not None: - args['state'] = state - else: - raise ValueError('Required property \'state\' not present in ActionControlTemplate JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlTemplate object from a json dictionary.""" + """Initialize a AssignmentTemplateDetails object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'committed') and self.committed is not None: - _dict['committed'] = self.committed - if hasattr(self, 'action_control') and self.action_control is not None: - if isinstance(self.action_control, dict): - _dict['action_control'] = self.action_control - else: - _dict['action_control'] = self.action_control.to_dict() - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id if hasattr(self, 'version') and self.version is not None: _dict['version'] = self.version - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state return _dict def _to_dict(self): @@ -4808,126 +6362,73 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlTemplate object.""" + """Return a `str` version of this AssignmentTemplateDetails object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlTemplate') -> bool: + def __eq__(self, other: 'AssignmentTemplateDetails') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlTemplate') -> bool: + def __ne__(self, other: 'AssignmentTemplateDetails') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - State of action control template. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class ActionControlTemplateCollection: +class ConflictsWith: """ - A collection of action control templates. + Details of conflicting resource. - :param int limit: (optional) The number of documents to include per each page of - the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following page of - requested collection. - :param Previous previous: (optional) Details with linking href to previous page - of requested collection. - :param List[ActionControlTemplate] action_control_templates: List of action - control templates. + :param str etag: (optional) The revision number of the resource. + :param str role: (optional) The conflicting role of ID. + :param str policy: (optional) The conflicting policy ID. """ def __init__( self, - action_control_templates: List['ActionControlTemplate'], *, - limit: Optional[int] = None, - first: Optional['First'] = None, - next: Optional['Next'] = None, - previous: Optional['Previous'] = None, + etag: Optional[str] = None, + role: Optional[str] = None, + policy: Optional[str] = None, ) -> None: """ - Initialize a ActionControlTemplateCollection object. + Initialize a ConflictsWith object. - :param List[ActionControlTemplate] action_control_templates: List of action - control templates. - :param int limit: (optional) The number of documents to include per each - page of the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following - page of requested collection. - :param Previous previous: (optional) Details with linking href to previous - page of requested collection. + :param str etag: (optional) The revision number of the resource. + :param str role: (optional) The conflicting role of ID. + :param str policy: (optional) The conflicting policy ID. """ - self.limit = limit - self.first = first - self.next = next - self.previous = previous - self.action_control_templates = action_control_templates + self.etag = etag + self.role = role + self.policy = policy @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlTemplateCollection': - """Initialize a ActionControlTemplateCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ConflictsWith': + """Initialize a ConflictsWith object from a json dictionary.""" args = {} - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit - if (first := _dict.get('first')) is not None: - args['first'] = First.from_dict(first) - if (next := _dict.get('next')) is not None: - args['next'] = Next.from_dict(next) - if (previous := _dict.get('previous')) is not None: - args['previous'] = Previous.from_dict(previous) - if (action_control_templates := _dict.get('action_control_templates')) is not None: - args['action_control_templates'] = [ActionControlTemplate.from_dict(v) for v in action_control_templates] - else: - raise ValueError( - 'Required property \'action_control_templates\' not present in ActionControlTemplateCollection JSON' - ) + if (etag := _dict.get('etag')) is not None: + args['etag'] = etag + if (role := _dict.get('role')) is not None: + args['role'] = role + if (policy := _dict.get('policy')) is not None: + args['policy'] = policy return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlTemplateCollection object from a json dictionary.""" + """Initialize a ConflictsWith object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'previous') and self.previous is not None: - if isinstance(self.previous, dict): - _dict['previous'] = self.previous - else: - _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'action_control_templates') and self.action_control_templates is not None: - action_control_templates_list = [] - for v in self.action_control_templates: - if isinstance(v, dict): - action_control_templates_list.append(v) - else: - action_control_templates_list.append(v.to_dict()) - _dict['action_control_templates'] = action_control_templates_list + if hasattr(self, 'etag') and self.etag is not None: + _dict['etag'] = self.etag + if hasattr(self, 'role') and self.role is not None: + _dict['role'] = self.role + if hasattr(self, 'policy') and self.policy is not None: + _dict['policy'] = self.policy return _dict def _to_dict(self): @@ -4935,118 +6436,61 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlTemplateCollection object.""" + """Return a `str` version of this ConflictsWith object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlTemplateCollection') -> bool: + def __eq__(self, other: 'ConflictsWith') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlTemplateCollection') -> bool: + def __ne__(self, other: 'ConflictsWith') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ActionControlTemplateVersionsCollection: +class Control: """ - A collection of versions for a specific action control template. + Specifies the type of access that is granted by the policy. - :param int limit: (optional) The number of documents to include per each page of - the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following page of - requested collection. - :param Previous previous: (optional) Details with linking href to previous page - of requested collection. - :param List[ActionControlTemplate] versions: List of action control templates - versions. + :param Grant grant: Permission is granted by the policy. """ def __init__( self, - versions: List['ActionControlTemplate'], - *, - limit: Optional[int] = None, - first: Optional['First'] = None, - next: Optional['Next'] = None, - previous: Optional['Previous'] = None, + grant: 'Grant', ) -> None: """ - Initialize a ActionControlTemplateVersionsCollection object. + Initialize a Control object. - :param List[ActionControlTemplate] versions: List of action control - templates versions. - :param int limit: (optional) The number of documents to include per each - page of the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following - page of requested collection. - :param Previous previous: (optional) Details with linking href to previous - page of requested collection. + :param Grant grant: Permission is granted by the policy. """ - self.limit = limit - self.first = first - self.next = next - self.previous = previous - self.versions = versions + self.grant = grant @classmethod - def from_dict(cls, _dict: Dict) -> 'ActionControlTemplateVersionsCollection': - """Initialize a ActionControlTemplateVersionsCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Control': + """Initialize a Control object from a json dictionary.""" args = {} - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit - if (first := _dict.get('first')) is not None: - args['first'] = First.from_dict(first) - if (next := _dict.get('next')) is not None: - args['next'] = Next.from_dict(next) - if (previous := _dict.get('previous')) is not None: - args['previous'] = Previous.from_dict(previous) - if (versions := _dict.get('versions')) is not None: - args['versions'] = [ActionControlTemplate.from_dict(v) for v in versions] + if (grant := _dict.get('grant')) is not None: + args['grant'] = Grant.from_dict(grant) else: - raise ValueError( - 'Required property \'versions\' not present in ActionControlTemplateVersionsCollection JSON' - ) + raise ValueError('Required property \'grant\' not present in Control JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ActionControlTemplateVersionsCollection object from a json dictionary.""" + """Initialize a Control object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'previous') and self.previous is not None: - if isinstance(self.previous, dict): - _dict['previous'] = self.previous + if hasattr(self, 'grant') and self.grant is not None: + if isinstance(self.grant, dict): + _dict['grant'] = self.grant else: - _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'versions') and self.versions is not None: - versions_list = [] - for v in self.versions: - if isinstance(v, dict): - versions_list.append(v) - else: - versions_list.append(v.to_dict()) - _dict['versions'] = versions_list + _dict['grant'] = self.grant.to_dict() return _dict def _to_dict(self): @@ -5054,57 +6498,188 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ActionControlTemplateVersionsCollection object.""" + """Return a `str` version of this Control object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ActionControlTemplateVersionsCollection') -> bool: + def __eq__(self, other: 'Control') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ActionControlTemplateVersionsCollection') -> bool: + def __ne__(self, other: 'Control') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AssignmentResourceCreated: +class ControlResponse: """ - On success, includes the policy that is assigned. + ControlResponse. - :param str id: (optional) Policy id. """ def __init__( self, + ) -> None: + """ + Initialize a ControlResponse object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['ControlResponseControl', 'ControlResponseControlWithEnrichedRoles']) + ) + raise Exception(msg) + + +class CustomRole: + """ + An additional set of properties associated with a role. + + :param str id: (optional) The role ID. Composed of hexadecimal characters. + :param str display_name: The display the name of the role that is shown in the + console. + :param str description: (optional) The description of the role. + :param List[str] actions: The actions of the role. For more information, see + [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: + 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. + :param str name: The name of the role that is used in the CRN. This must be + alphanumeric and capitalized. + :param str account_id: The account GUID. + :param str service_name: The service name. + :param datetime created_at: (optional) The UTC timestamp when the role was + created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + role. + :param datetime last_modified_at: (optional) The UTC timestamp when the role was + last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the policy. + :param str href: (optional) The href links back to the role. + """ + + def __init__( + self, + display_name: str, + actions: List[str], + name: str, + account_id: str, + service_name: str, *, id: Optional[str] = None, + description: Optional[str] = None, + crn: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + href: Optional[str] = None, ) -> None: """ - Initialize a AssignmentResourceCreated object. + Initialize a CustomRole object. - :param str id: (optional) Policy id. + :param str display_name: The display the name of the role that is shown in + the console. + :param List[str] actions: The actions of the role. For more information, + see [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str name: The name of the role that is used in the CRN. This must be + alphanumeric and capitalized. + :param str account_id: The account GUID. + :param str service_name: The service name. + :param str description: (optional) The description of the role. """ self.id = id + self.display_name = display_name + self.description = description + self.actions = actions + self.crn = crn + self.name = name + self.account_id = account_id + self.service_name = service_name + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.href = href @classmethod - def from_dict(cls, _dict: Dict) -> 'AssignmentResourceCreated': - """Initialize a AssignmentResourceCreated object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'CustomRole': + """Initialize a CustomRole object from a json dictionary.""" args = {} if (id := _dict.get('id')) is not None: args['id'] = id + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + else: + raise ValueError('Required property \'display_name\' not present in CustomRole JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (actions := _dict.get('actions')) is not None: + args['actions'] = actions + else: + raise ValueError('Required property \'actions\' not present in CustomRole JSON') + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in CustomRole JSON') + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + else: + raise ValueError('Required property \'account_id\' not present in CustomRole JSON') + if (service_name := _dict.get('service_name')) is not None: + args['service_name'] = service_name + else: + raise ValueError('Required property \'service_name\' not present in CustomRole JSON') + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (href := _dict.get('href')) is not None: + args['href'] = href return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AssignmentResourceCreated object from a json dictionary.""" + """Initialize a CustomRole object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'actions') and self.actions is not None: + _dict['actions'] = self.actions + if hasattr(self, 'crn') and getattr(self, 'crn') is not None: + _dict['crn'] = getattr(self, 'crn') + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'service_name') and self.service_name is not None: + _dict['service_name'] = self.service_name + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') return _dict def _to_dict(self): @@ -5112,68 +6687,98 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AssignmentResourceCreated object.""" + """Return a `str` version of this CustomRole object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AssignmentResourceCreated') -> bool: + def __eq__(self, other: 'CustomRole') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AssignmentResourceCreated') -> bool: + def __ne__(self, other: 'CustomRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AssignmentTargetDetails: +class EnrichedRoles: """ - assignment target account and type. + A role associated with a policy with additional information (display_name, + description, actions) when `format=display`. - :param str type: Assignment target type. - :param str id: ID of the target account. + :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. + Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param str display_name: (optional) The display name of the role, either + service-defined or user-defined for custom roles. + :param str description: (optional) The role description, either service-defined + or user-defined for custom roles. + :param List[RoleAction] actions: The actions of the role. For more information, + see [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). """ def __init__( self, - type: str, - id: str, + role_id: str, + actions: List['RoleAction'], + *, + display_name: Optional[str] = None, + description: Optional[str] = None, ) -> None: """ - Initialize a AssignmentTargetDetails object. + Initialize a EnrichedRoles object. - :param str type: Assignment target type. - :param str id: ID of the target account. + :param str role_id: The role Cloud Resource Name (CRN) granted by the + policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param List[RoleAction] actions: The actions of the role. For more + information, see [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). """ - self.type = type - self.id = id + self.role_id = role_id + self.display_name = display_name + self.description = description + self.actions = actions @classmethod - def from_dict(cls, _dict: Dict) -> 'AssignmentTargetDetails': - """Initialize a AssignmentTargetDetails object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'EnrichedRoles': + """Initialize a EnrichedRoles object from a json dictionary.""" args = {} - if (type := _dict.get('type')) is not None: - args['type'] = type + if (role_id := _dict.get('role_id')) is not None: + args['role_id'] = role_id else: - raise ValueError('Required property \'type\' not present in AssignmentTargetDetails JSON') - if (id := _dict.get('id')) is not None: - args['id'] = id + raise ValueError('Required property \'role_id\' not present in EnrichedRoles JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + if (description := _dict.get('description')) is not None: + args['description'] = description + if (actions := _dict.get('actions')) is not None: + args['actions'] = [RoleAction.from_dict(v) for v in actions] else: - raise ValueError('Required property \'id\' not present in AssignmentTargetDetails JSON') + raise ValueError('Required property \'actions\' not present in EnrichedRoles JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AssignmentTargetDetails object from a json dictionary.""" + """Initialize a EnrichedRoles object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id + if hasattr(self, 'role_id') and self.role_id is not None: + _dict['role_id'] = self.role_id + if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: + _dict['display_name'] = getattr(self, 'display_name') + if hasattr(self, 'description') and getattr(self, 'description') is not None: + _dict['description'] = getattr(self, 'description') + if hasattr(self, 'actions') and self.actions is not None: + actions_list = [] + for v in self.actions: + if isinstance(v, dict): + actions_list.append(v) + else: + actions_list.append(v.to_dict()) + _dict['actions'] = actions_list return _dict def _to_dict(self): @@ -5181,72 +6786,61 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AssignmentTargetDetails object.""" + """Return a `str` version of this EnrichedRoles object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AssignmentTargetDetails') -> bool: + def __eq__(self, other: 'EnrichedRoles') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AssignmentTargetDetails') -> bool: + def __ne__(self, other: 'EnrichedRoles') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): - """ - Assignment target type. - """ - - ACCOUNT = 'Account' - -class AssignmentTemplateDetails: +class ErrorDetails: """ - policy template details. + Additional error details. - :param str id: (optional) Policy template ID. - :param str version: (optional) Policy template version. + :param ConflictsWith conflicts_with: (optional) Details of conflicting resource. """ def __init__( self, *, - id: Optional[str] = None, - version: Optional[str] = None, + conflicts_with: Optional['ConflictsWith'] = None, ) -> None: """ - Initialize a AssignmentTemplateDetails object. + Initialize a ErrorDetails object. - :param str id: (optional) Policy template ID. - :param str version: (optional) Policy template version. + :param ConflictsWith conflicts_with: (optional) Details of conflicting + resource. """ - self.id = id - self.version = version + self.conflicts_with = conflicts_with @classmethod - def from_dict(cls, _dict: Dict) -> 'AssignmentTemplateDetails': - """Initialize a AssignmentTemplateDetails object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ErrorDetails': + """Initialize a ErrorDetails object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (version := _dict.get('version')) is not None: - args['version'] = version + if (conflicts_with := _dict.get('conflicts_with')) is not None: + args['conflicts_with'] = ConflictsWith.from_dict(conflicts_with) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AssignmentTemplateDetails object from a json dictionary.""" + """Initialize a ErrorDetails object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version + if hasattr(self, 'conflicts_with') and self.conflicts_with is not None: + if isinstance(self.conflicts_with, dict): + _dict['conflicts_with'] = self.conflicts_with + else: + _dict['conflicts_with'] = self.conflicts_with.to_dict() return _dict def _to_dict(self): @@ -5254,73 +6848,88 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AssignmentTemplateDetails object.""" + """Return a `str` version of this ErrorDetails object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AssignmentTemplateDetails') -> bool: + def __eq__(self, other: 'ErrorDetails') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'AssignmentTemplateDetails') -> bool: + def __ne__(self, other: 'ErrorDetails') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ConflictsWith: +class ErrorObject: """ - Details of conflicting resource. + ErrorObject. - :param str etag: (optional) The revision number of the resource. - :param str role: (optional) The conflicting role of ID. - :param str policy: (optional) The conflicting policy ID. + :param str code: The API error code for the error. + :param str message: The error message returned by the API. + :param ErrorDetails details: (optional) Additional error details. + :param str more_info: (optional) Additional info for error. """ def __init__( self, + code: str, + message: str, *, - etag: Optional[str] = None, - role: Optional[str] = None, - policy: Optional[str] = None, + details: Optional['ErrorDetails'] = None, + more_info: Optional[str] = None, ) -> None: """ - Initialize a ConflictsWith object. + Initialize a ErrorObject object. - :param str etag: (optional) The revision number of the resource. - :param str role: (optional) The conflicting role of ID. - :param str policy: (optional) The conflicting policy ID. + :param str code: The API error code for the error. + :param str message: The error message returned by the API. + :param ErrorDetails details: (optional) Additional error details. + :param str more_info: (optional) Additional info for error. """ - self.etag = etag - self.role = role - self.policy = policy + self.code = code + self.message = message + self.details = details + self.more_info = more_info @classmethod - def from_dict(cls, _dict: Dict) -> 'ConflictsWith': - """Initialize a ConflictsWith object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ErrorObject': + """Initialize a ErrorObject object from a json dictionary.""" args = {} - if (etag := _dict.get('etag')) is not None: - args['etag'] = etag - if (role := _dict.get('role')) is not None: - args['role'] = role - if (policy := _dict.get('policy')) is not None: - args['policy'] = policy + if (code := _dict.get('code')) is not None: + args['code'] = code + else: + raise ValueError('Required property \'code\' not present in ErrorObject JSON') + if (message := _dict.get('message')) is not None: + args['message'] = message + else: + raise ValueError('Required property \'message\' not present in ErrorObject JSON') + if (details := _dict.get('details')) is not None: + args['details'] = ErrorDetails.from_dict(details) + if (more_info := _dict.get('more_info')) is not None: + args['more_info'] = more_info return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ConflictsWith object from a json dictionary.""" + """Initialize a ErrorObject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'etag') and self.etag is not None: - _dict['etag'] = self.etag - if hasattr(self, 'role') and self.role is not None: - _dict['role'] = self.role - if hasattr(self, 'policy') and self.policy is not None: - _dict['policy'] = self.policy + if hasattr(self, 'code') and self.code is not None: + _dict['code'] = self.code + if hasattr(self, 'message') and self.message is not None: + _dict['message'] = self.message + if hasattr(self, 'details') and self.details is not None: + if isinstance(self.details, dict): + _dict['details'] = self.details + else: + _dict['details'] = self.details.to_dict() + if hasattr(self, 'more_info') and self.more_info is not None: + _dict['more_info'] = self.more_info return _dict def _to_dict(self): @@ -5328,61 +6937,92 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ConflictsWith object.""" + """Return a `str` version of this ErrorObject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ConflictsWith') -> bool: + def __eq__(self, other: 'ErrorObject') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ConflictsWith') -> bool: + def __ne__(self, other: 'ErrorObject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class CodeEnum(str, Enum): + """ + The API error code for the error. + """ -class Control: + INSUFFICENT_PERMISSIONS = 'insufficent_permissions' + INVALID_BODY = 'invalid_body' + INVALID_TOKEN = 'invalid_token' + MISSING_REQUIRED_QUERY_PARAMETER = 'missing_required_query_parameter' + NOT_FOUND = 'not_found' + POLICY_CONFLICT_ERROR = 'policy_conflict_error' + POLICY_NOT_FOUND = 'policy_not_found' + REQUEST_NOT_PROCESSED = 'request_not_processed' + ROLE_CONFLICT_ERROR = 'role_conflict_error' + ROLE_NOT_FOUND = 'role_not_found' + TOO_MANY_REQUESTS = 'too_many_requests' + UNABLE_TO_PROCESS = 'unable_to_process' + UNSUPPORTED_CONTENT_TYPE = 'unsupported_content_type' + POLICY_TEMPLATE_CONFLICT_ERROR = 'policy_template_conflict_error' + POLICY_TEMPLATE_NOT_FOUND = 'policy_template_not_found' + POLICY_ASSIGNMENT_NOT_FOUND = 'policy_assignment_not_found' + POLICY_ASSIGNMENT_CONFLICT_ERROR = 'policy_assignment_conflict_error' + RESOURCE_NOT_FOUND = 'resource_not_found' + ACTION_CONTROL_TEMPLATE_NOT_FOUND = 'action_control_template_not_found' + ACTION_CONTROL_ASSIGNMENT_NOT_FOUND = 'action_control_assignment_not_found' + ROLE_TEMPLATE_CONFLICT_ERROR = 'role_template_conflict_error' + ROLE_TEMPLATE_NOT_FOUND = 'role_template_not_found' + ROLE_ASSIGNMENT_NOT_FOUND = 'role_assignment_not_found' + + +class ExternalAccountIdentityInteraction: """ - Specifies the type of access that is granted by the policy. + How external accounts can interact in relation to the requested account. - :param Grant grant: Permission is granted by the policy. + :param IdentityTypes identity_types: The settings for each identity type. """ def __init__( self, - grant: 'Grant', + identity_types: 'IdentityTypes', ) -> None: """ - Initialize a Control object. + Initialize a ExternalAccountIdentityInteraction object. - :param Grant grant: Permission is granted by the policy. + :param IdentityTypes identity_types: The settings for each identity type. """ - self.grant = grant + self.identity_types = identity_types @classmethod - def from_dict(cls, _dict: Dict) -> 'Control': - """Initialize a Control object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteraction': + """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" args = {} - if (grant := _dict.get('grant')) is not None: - args['grant'] = Grant.from_dict(grant) + if (identity_types := _dict.get('identity_types')) is not None: + args['identity_types'] = IdentityTypes.from_dict(identity_types) else: - raise ValueError('Required property \'grant\' not present in Control JSON') + raise ValueError( + 'Required property \'identity_types\' not present in ExternalAccountIdentityInteraction JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Control object from a json dictionary.""" + """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'grant') and self.grant is not None: - if isinstance(self.grant, dict): - _dict['grant'] = self.grant + if hasattr(self, 'identity_types') and self.identity_types is not None: + if isinstance(self.identity_types, dict): + _dict['identity_types'] = self.identity_types else: - _dict['grant'] = self.grant.to_dict() + _dict['identity_types'] = self.identity_types.to_dict() return _dict def _to_dict(self): @@ -5390,188 +7030,62 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Control object.""" + """Return a `str` version of this ExternalAccountIdentityInteraction object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Control') -> bool: + def __eq__(self, other: 'ExternalAccountIdentityInteraction') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Control') -> bool: + def __ne__(self, other: 'ExternalAccountIdentityInteraction') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ControlResponse: - """ - ControlResponse. - - """ - - def __init__( - self, - ) -> None: - """ - Initialize a ControlResponse object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['ControlResponseControl', 'ControlResponseControlWithEnrichedRoles']) - ) - raise Exception(msg) - - -class CustomRole: +class ExternalAccountIdentityInteractionPatch: """ - An additional set of properties associated with a role. + Update to how external accounts can interact in relation to the requested account. - :param str id: (optional) The role ID. Composed of hexadecimal characters. - :param str display_name: The display the name of the role that is shown in the - console. - :param str description: (optional) The description of the role. - :param List[str] actions: The actions of the role. For more information, see - [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: - 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. - :param str name: The name of the role that is used in the CRN. This must be - alphanumeric and capitalized. - :param str account_id: The account GUID. - :param str service_name: The service name. - :param datetime created_at: (optional) The UTC timestamp when the role was - created. - :param str created_by_id: (optional) The IAM ID of the entity that created the - role. - :param datetime last_modified_at: (optional) The UTC timestamp when the role was - last modified. - :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the policy. - :param str href: (optional) The href links back to the role. + :param IdentityTypesPatch identity_types: (optional) The settings to apply for + each identity type for a request. """ def __init__( self, - display_name: str, - actions: List[str], - name: str, - account_id: str, - service_name: str, *, - id: Optional[str] = None, - description: Optional[str] = None, - crn: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - href: Optional[str] = None, + identity_types: Optional['IdentityTypesPatch'] = None, ) -> None: """ - Initialize a CustomRole object. + Initialize a ExternalAccountIdentityInteractionPatch object. - :param str display_name: The display the name of the role that is shown in - the console. - :param List[str] actions: The actions of the role. For more information, - see [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str name: The name of the role that is used in the CRN. This must be - alphanumeric and capitalized. - :param str account_id: The account GUID. - :param str service_name: The service name. - :param str description: (optional) The description of the role. + :param IdentityTypesPatch identity_types: (optional) The settings to apply + for each identity type for a request. """ - self.id = id - self.display_name = display_name - self.description = description - self.actions = actions - self.crn = crn - self.name = name - self.account_id = account_id - self.service_name = service_name - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.href = href + self.identity_types = identity_types @classmethod - def from_dict(cls, _dict: Dict) -> 'CustomRole': - """Initialize a CustomRole object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteractionPatch': + """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - else: - raise ValueError('Required property \'display_name\' not present in CustomRole JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (actions := _dict.get('actions')) is not None: - args['actions'] = actions - else: - raise ValueError('Required property \'actions\' not present in CustomRole JSON') - if (crn := _dict.get('crn')) is not None: - args['crn'] = crn - if (name := _dict.get('name')) is not None: - args['name'] = name - else: - raise ValueError('Required property \'name\' not present in CustomRole JSON') - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - else: - raise ValueError('Required property \'account_id\' not present in CustomRole JSON') - if (service_name := _dict.get('service_name')) is not None: - args['service_name'] = service_name - else: - raise ValueError('Required property \'service_name\' not present in CustomRole JSON') - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (href := _dict.get('href')) is not None: - args['href'] = href + if (identity_types := _dict.get('identity_types')) is not None: + args['identity_types'] = IdentityTypesPatch.from_dict(identity_types) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a CustomRole object from a json dictionary.""" + """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'display_name') and self.display_name is not None: - _dict['display_name'] = self.display_name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'actions') and self.actions is not None: - _dict['actions'] = self.actions - if hasattr(self, 'crn') and getattr(self, 'crn') is not None: - _dict['crn'] = getattr(self, 'crn') - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'service_name') and self.service_name is not None: - _dict['service_name'] = self.service_name - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') + if hasattr(self, 'identity_types') and self.identity_types is not None: + if isinstance(self.identity_types, dict): + _dict['identity_types'] = self.identity_types + else: + _dict['identity_types'] = self.identity_types.to_dict() return _dict def _to_dict(self): @@ -5579,98 +7093,57 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this CustomRole object.""" + """Return a `str` version of this ExternalAccountIdentityInteractionPatch object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'CustomRole') -> bool: + def __eq__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'CustomRole') -> bool: + def __ne__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EnrichedRoles: +class First: """ - A role associated with a policy with additional information (display_name, - description, actions) when `format=display`. + Details with linking href to first page of requested collection. - :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. - Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. - :param str display_name: (optional) The display name of the role, either - service-defined or user-defined for custom roles. - :param str description: (optional) The role description, either service-defined - or user-defined for custom roles. - :param List[RoleAction] actions: The actions of the role. For more information, - see [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str href: (optional) The href linking to the page of requested + collection. """ def __init__( self, - role_id: str, - actions: List['RoleAction'], *, - display_name: Optional[str] = None, - description: Optional[str] = None, + href: Optional[str] = None, ) -> None: """ - Initialize a EnrichedRoles object. + Initialize a First object. - :param str role_id: The role Cloud Resource Name (CRN) granted by the - policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. - :param List[RoleAction] actions: The actions of the role. For more - information, see [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). """ - self.role_id = role_id - self.display_name = display_name - self.description = description - self.actions = actions + self.href = href @classmethod - def from_dict(cls, _dict: Dict) -> 'EnrichedRoles': - """Initialize a EnrichedRoles object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'First': + """Initialize a First object from a json dictionary.""" args = {} - if (role_id := _dict.get('role_id')) is not None: - args['role_id'] = role_id - else: - raise ValueError('Required property \'role_id\' not present in EnrichedRoles JSON') - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - if (description := _dict.get('description')) is not None: - args['description'] = description - if (actions := _dict.get('actions')) is not None: - args['actions'] = [RoleAction.from_dict(v) for v in actions] - else: - raise ValueError('Required property \'actions\' not present in EnrichedRoles JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a EnrichedRoles object from a json dictionary.""" + """Initialize a First object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'role_id') and self.role_id is not None: - _dict['role_id'] = self.role_id - if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: - _dict['display_name'] = getattr(self, 'display_name') - if hasattr(self, 'description') and getattr(self, 'description') is not None: - _dict['description'] = getattr(self, 'description') - if hasattr(self, 'actions') and self.actions is not None: - actions_list = [] - for v in self.actions: - if isinstance(v, dict): - actions_list.append(v) - else: - actions_list.append(v.to_dict()) - _dict['actions'] = actions_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') return _dict def _to_dict(self): @@ -5678,61 +7151,66 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this EnrichedRoles object.""" + """Return a `str` version of this First object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'EnrichedRoles') -> bool: + def __eq__(self, other: 'First') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'EnrichedRoles') -> bool: + def __ne__(self, other: 'First') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ErrorDetails: +class Grant: """ - Additional error details. + Permission is granted by the policy. - :param ConflictsWith conflicts_with: (optional) Details of conflicting resource. + :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted by + the policy. """ def __init__( self, - *, - conflicts_with: Optional['ConflictsWith'] = None, + roles: List['Roles'], ) -> None: """ - Initialize a ErrorDetails object. + Initialize a Grant object. - :param ConflictsWith conflicts_with: (optional) Details of conflicting - resource. + :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted + by the policy. """ - self.conflicts_with = conflicts_with + self.roles = roles @classmethod - def from_dict(cls, _dict: Dict) -> 'ErrorDetails': - """Initialize a ErrorDetails object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Grant': + """Initialize a Grant object from a json dictionary.""" args = {} - if (conflicts_with := _dict.get('conflicts_with')) is not None: - args['conflicts_with'] = ConflictsWith.from_dict(conflicts_with) + if (roles := _dict.get('roles')) is not None: + args['roles'] = [Roles.from_dict(v) for v in roles] + else: + raise ValueError('Required property \'roles\' not present in Grant JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ErrorDetails object from a json dictionary.""" + """Initialize a Grant object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'conflicts_with') and self.conflicts_with is not None: - if isinstance(self.conflicts_with, dict): - _dict['conflicts_with'] = self.conflicts_with - else: - _dict['conflicts_with'] = self.conflicts_with.to_dict() + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list return _dict def _to_dict(self): @@ -5740,88 +7218,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ErrorDetails object.""" + """Return a `str` version of this Grant object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ErrorDetails') -> bool: + def __eq__(self, other: 'Grant') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ErrorDetails') -> bool: + def __ne__(self, other: 'Grant') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ErrorObject: +class GrantWithEnrichedRoles: """ - ErrorObject. + Permission granted by the policy with translated roles and additional role + information. - :param str code: The API error code for the error. - :param str message: The error message returned by the API. - :param ErrorDetails details: (optional) Additional error details. - :param str more_info: (optional) Additional info for error. + :param List[EnrichedRoles] roles: A set of roles granted by the policy. """ def __init__( self, - code: str, - message: str, - *, - details: Optional['ErrorDetails'] = None, - more_info: Optional[str] = None, + roles: List['EnrichedRoles'], ) -> None: """ - Initialize a ErrorObject object. + Initialize a GrantWithEnrichedRoles object. - :param str code: The API error code for the error. - :param str message: The error message returned by the API. - :param ErrorDetails details: (optional) Additional error details. - :param str more_info: (optional) Additional info for error. + :param List[EnrichedRoles] roles: A set of roles granted by the policy. """ - self.code = code - self.message = message - self.details = details - self.more_info = more_info + self.roles = roles @classmethod - def from_dict(cls, _dict: Dict) -> 'ErrorObject': - """Initialize a ErrorObject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'GrantWithEnrichedRoles': + """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" args = {} - if (code := _dict.get('code')) is not None: - args['code'] = code - else: - raise ValueError('Required property \'code\' not present in ErrorObject JSON') - if (message := _dict.get('message')) is not None: - args['message'] = message + if (roles := _dict.get('roles')) is not None: + args['roles'] = [EnrichedRoles.from_dict(v) for v in roles] else: - raise ValueError('Required property \'message\' not present in ErrorObject JSON') - if (details := _dict.get('details')) is not None: - args['details'] = ErrorDetails.from_dict(details) - if (more_info := _dict.get('more_info')) is not None: - args['more_info'] = more_info + raise ValueError('Required property \'roles\' not present in GrantWithEnrichedRoles JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ErrorObject object from a json dictionary.""" + """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'code') and self.code is not None: - _dict['code'] = self.code - if hasattr(self, 'message') and self.message is not None: - _dict['message'] = self.message - if hasattr(self, 'details') and self.details is not None: - if isinstance(self.details, dict): - _dict['details'] = self.details - else: - _dict['details'] = self.details.to_dict() - if hasattr(self, 'more_info') and self.more_info is not None: - _dict['more_info'] = self.more_info + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list return _dict def _to_dict(self): @@ -5829,111 +7284,93 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ErrorObject object.""" + """Return a `str` version of this GrantWithEnrichedRoles object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ErrorObject') -> bool: + def __eq__(self, other: 'GrantWithEnrichedRoles') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ErrorObject') -> bool: + def __ne__(self, other: 'GrantWithEnrichedRoles') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class CodeEnum(str, Enum): - """ - The API error code for the error. - """ - - INSUFFICENT_PERMISSIONS = 'insufficent_permissions' - INVALID_BODY = 'invalid_body' - INVALID_TOKEN = 'invalid_token' - MISSING_REQUIRED_QUERY_PARAMETER = 'missing_required_query_parameter' - NOT_FOUND = 'not_found' - POLICY_CONFLICT_ERROR = 'policy_conflict_error' - POLICY_NOT_FOUND = 'policy_not_found' - REQUEST_NOT_PROCESSED = 'request_not_processed' - ROLE_CONFLICT_ERROR = 'role_conflict_error' - ROLE_NOT_FOUND = 'role_not_found' - TOO_MANY_REQUESTS = 'too_many_requests' - UNABLE_TO_PROCESS = 'unable_to_process' - UNSUPPORTED_CONTENT_TYPE = 'unsupported_content_type' - POLICY_TEMPLATE_CONFLICT_ERROR = 'policy_template_conflict_error' - POLICY_TEMPLATE_NOT_FOUND = 'policy_template_not_found' - POLICY_ASSIGNMENT_NOT_FOUND = 'policy_assignment_not_found' - POLICY_ASSIGNMENT_CONFLICT_ERROR = 'policy_assignment_conflict_error' - RESOURCE_NOT_FOUND = 'resource_not_found' - ACTION_CONTROL_TEMPLATE_NOT_FOUND = 'action_control_template_not_found' - ACTION_CONTROL_ASSIGNMENT_NOT_FOUND = 'action_control_assignment_not_found' - -class ErrorResponse: +class IdentityTypes: """ - The error response from API. + The settings for each identity type. - :param str trace: The unique transaction ID for the request. - :param List[ErrorObject] errors: The errors encountered during the response. - :param int status_code: The HTTP error code of the response. + :param IdentityTypesBase user: The core set of properties associated with an + identity type. + :param IdentityTypesBase service_id: The core set of properties associated with + an identity type. + :param IdentityTypesBase service: The core set of properties associated with an + identity type. """ def __init__( self, - trace: str, - errors: List['ErrorObject'], - status_code: int, + user: 'IdentityTypesBase', + service_id: 'IdentityTypesBase', + service: 'IdentityTypesBase', ) -> None: """ - Initialize a ErrorResponse object. + Initialize a IdentityTypes object. - :param str trace: The unique transaction ID for the request. - :param List[ErrorObject] errors: The errors encountered during the - response. - :param int status_code: The HTTP error code of the response. + :param IdentityTypesBase user: The core set of properties associated with + an identity type. + :param IdentityTypesBase service_id: The core set of properties associated + with an identity type. + :param IdentityTypesBase service: The core set of properties associated + with an identity type. """ - self.trace = trace - self.errors = errors - self.status_code = status_code + self.user = user + self.service_id = service_id + self.service = service @classmethod - def from_dict(cls, _dict: Dict) -> 'ErrorResponse': - """Initialize a ErrorResponse object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypes': + """Initialize a IdentityTypes object from a json dictionary.""" args = {} - if (trace := _dict.get('trace')) is not None: - args['trace'] = trace + if (user := _dict.get('user')) is not None: + args['user'] = IdentityTypesBase.from_dict(user) else: - raise ValueError('Required property \'trace\' not present in ErrorResponse JSON') - if (errors := _dict.get('errors')) is not None: - args['errors'] = [ErrorObject.from_dict(v) for v in errors] + raise ValueError('Required property \'user\' not present in IdentityTypes JSON') + if (service_id := _dict.get('service_id')) is not None: + args['service_id'] = IdentityTypesBase.from_dict(service_id) else: - raise ValueError('Required property \'errors\' not present in ErrorResponse JSON') - if (status_code := _dict.get('status_code')) is not None: - args['status_code'] = status_code + raise ValueError('Required property \'service_id\' not present in IdentityTypes JSON') + if (service := _dict.get('service')) is not None: + args['service'] = IdentityTypesBase.from_dict(service) else: - raise ValueError('Required property \'status_code\' not present in ErrorResponse JSON') + raise ValueError('Required property \'service\' not present in IdentityTypes JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ErrorResponse object from a json dictionary.""" + """Initialize a IdentityTypes object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'trace') and self.trace is not None: - _dict['trace'] = self.trace - if hasattr(self, 'errors') and self.errors is not None: - errors_list = [] - for v in self.errors: - if isinstance(v, dict): - errors_list.append(v) - else: - errors_list.append(v.to_dict()) - _dict['errors'] = errors_list - if hasattr(self, 'status_code') and self.status_code is not None: - _dict['status_code'] = self.status_code + if hasattr(self, 'user') and self.user is not None: + if isinstance(self.user, dict): + _dict['user'] = self.user + else: + _dict['user'] = self.user.to_dict() + if hasattr(self, 'service_id') and self.service_id is not None: + if isinstance(self.service_id, dict): + _dict['service_id'] = self.service_id + else: + _dict['service_id'] = self.service_id.to_dict() + if hasattr(self, 'service') and self.service is not None: + if isinstance(self.service, dict): + _dict['service'] = self.service + else: + _dict['service'] = self.service.to_dict() return _dict def _to_dict(self): @@ -5941,63 +7378,70 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ErrorResponse object.""" + """Return a `str` version of this IdentityTypes object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ErrorResponse') -> bool: + def __eq__(self, other: 'IdentityTypes') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ErrorResponse') -> bool: + def __ne__(self, other: 'IdentityTypes') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ExternalAccountIdentityInteraction: +class IdentityTypesBase: """ - How external accounts can interact in relation to the requested account. + The core set of properties associated with an identity type. - :param IdentityTypes identity_types: The settings for each identity type. + :param str state: The state of the identity type. + :param List[str] external_allowed_accounts: List of accounts that the state + applies to for a given identity. """ def __init__( self, - identity_types: 'IdentityTypes', + state: str, + external_allowed_accounts: List[str], ) -> None: """ - Initialize a ExternalAccountIdentityInteraction object. + Initialize a IdentityTypesBase object. - :param IdentityTypes identity_types: The settings for each identity type. + :param str state: The state of the identity type. + :param List[str] external_allowed_accounts: List of accounts that the state + applies to for a given identity. """ - self.identity_types = identity_types + self.state = state + self.external_allowed_accounts = external_allowed_accounts @classmethod - def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteraction': - """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypesBase': + """Initialize a IdentityTypesBase object from a json dictionary.""" args = {} - if (identity_types := _dict.get('identity_types')) is not None: - args['identity_types'] = IdentityTypes.from_dict(identity_types) + if (state := _dict.get('state')) is not None: + args['state'] = state else: - raise ValueError( - 'Required property \'identity_types\' not present in ExternalAccountIdentityInteraction JSON' - ) + raise ValueError('Required property \'state\' not present in IdentityTypesBase JSON') + if (external_allowed_accounts := _dict.get('external_allowed_accounts')) is not None: + args['external_allowed_accounts'] = external_allowed_accounts + else: + raise ValueError('Required property \'external_allowed_accounts\' not present in IdentityTypesBase JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" + """Initialize a IdentityTypesBase object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'identity_types') and self.identity_types is not None: - if isinstance(self.identity_types, dict): - _dict['identity_types'] = self.identity_types - else: - _dict['identity_types'] = self.identity_types.to_dict() + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'external_allowed_accounts') and self.external_allowed_accounts is not None: + _dict['external_allowed_accounts'] = self.external_allowed_accounts return _dict def _to_dict(self): @@ -6005,62 +7449,97 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ExternalAccountIdentityInteraction object.""" + """Return a `str` version of this IdentityTypesBase object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ExternalAccountIdentityInteraction') -> bool: + def __eq__(self, other: 'IdentityTypesBase') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ExternalAccountIdentityInteraction') -> bool: + def __ne__(self, other: 'IdentityTypesBase') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + The state of the identity type. + """ -class ExternalAccountIdentityInteractionPatch: + ENABLED = 'enabled' + MONITOR = 'monitor' + LIMITED = 'limited' + + +class IdentityTypesPatch: """ - Update to how external accounts can interact in relation to the requested account. + The settings to apply for each identity type for a request. - :param IdentityTypesPatch identity_types: (optional) The settings to apply for - each identity type for a request. + :param IdentityTypesBase user: (optional) The core set of properties associated + with an identity type. + :param IdentityTypesBase service_id: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service: (optional) The core set of properties + associated with an identity type. """ def __init__( self, *, - identity_types: Optional['IdentityTypesPatch'] = None, + user: Optional['IdentityTypesBase'] = None, + service_id: Optional['IdentityTypesBase'] = None, + service: Optional['IdentityTypesBase'] = None, ) -> None: """ - Initialize a ExternalAccountIdentityInteractionPatch object. + Initialize a IdentityTypesPatch object. - :param IdentityTypesPatch identity_types: (optional) The settings to apply - for each identity type for a request. + :param IdentityTypesBase user: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service_id: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service: (optional) The core set of properties + associated with an identity type. """ - self.identity_types = identity_types + self.user = user + self.service_id = service_id + self.service = service @classmethod - def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteractionPatch': - """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypesPatch': + """Initialize a IdentityTypesPatch object from a json dictionary.""" args = {} - if (identity_types := _dict.get('identity_types')) is not None: - args['identity_types'] = IdentityTypesPatch.from_dict(identity_types) + if (user := _dict.get('user')) is not None: + args['user'] = IdentityTypesBase.from_dict(user) + if (service_id := _dict.get('service_id')) is not None: + args['service_id'] = IdentityTypesBase.from_dict(service_id) + if (service := _dict.get('service')) is not None: + args['service'] = IdentityTypesBase.from_dict(service) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" + """Initialize a IdentityTypesPatch object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'identity_types') and self.identity_types is not None: - if isinstance(self.identity_types, dict): - _dict['identity_types'] = self.identity_types + if hasattr(self, 'user') and self.user is not None: + if isinstance(self.user, dict): + _dict['user'] = self.user else: - _dict['identity_types'] = self.identity_types.to_dict() + _dict['user'] = self.user.to_dict() + if hasattr(self, 'service_id') and self.service_id is not None: + if isinstance(self.service_id, dict): + _dict['service_id'] = self.service_id + else: + _dict['service_id'] = self.service_id.to_dict() + if hasattr(self, 'service') and self.service is not None: + if isinstance(self.service, dict): + _dict['service'] = self.service + else: + _dict['service'] = self.service.to_dict() return _dict def _to_dict(self): @@ -6068,57 +7547,63 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ExternalAccountIdentityInteractionPatch object.""" + """Return a `str` version of this IdentityTypesPatch object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: + def __eq__(self, other: 'IdentityTypesPatch') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: + def __ne__(self, other: 'IdentityTypesPatch') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class First: +class LimitData: """ - Details with linking href to first page of requested collection. + policy template current and limit details with in an account. - :param str href: (optional) The href linking to the page of requested - collection. + :param int current: (optional) policy template current count. + :param int limit: (optional) policy template limit count. """ def __init__( self, *, - href: Optional[str] = None, + current: Optional[int] = None, + limit: Optional[int] = None, ) -> None: """ - Initialize a First object. + Initialize a LimitData object. """ - self.href = href + self.current = current + self.limit = limit @classmethod - def from_dict(cls, _dict: Dict) -> 'First': - """Initialize a First object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'LimitData': + """Initialize a LimitData object from a json dictionary.""" args = {} - if (href := _dict.get('href')) is not None: - args['href'] = href + if (current := _dict.get('current')) is not None: + args['current'] = current + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a First object from a json dictionary.""" + """Initialize a LimitData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') + if hasattr(self, 'current') and getattr(self, 'current') is not None: + _dict['current'] = getattr(self, 'current') + if hasattr(self, 'limit') and getattr(self, 'limit') is not None: + _dict['limit'] = getattr(self, 'limit') return _dict def _to_dict(self): @@ -6126,132 +7611,86 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this First object.""" + """Return a `str` version of this LimitData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'First') -> bool: + def __eq__(self, other: 'LimitData') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'First') -> bool: + def __ne__(self, other: 'LimitData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Grant: +class NestedCondition: """ - Permission is granted by the policy. + Condition that specifies additional conditions or RuleAttribute to grant access. - :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted by - the policy. """ def __init__( self, - roles: List['Roles'], ) -> None: """ - Initialize a Grant object. + Initialize a NestedCondition object. - :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted - by the policy. """ - self.roles = roles - - @classmethod - def from_dict(cls, _dict: Dict) -> 'Grant': - """Initialize a Grant object from a json dictionary.""" - args = {} - if (roles := _dict.get('roles')) is not None: - args['roles'] = [Roles.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in Grant JSON') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a Grant object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this Grant object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'Grant') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'Grant') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['NestedConditionRuleAttribute', 'NestedConditionRuleWithConditions']) + ) + raise Exception(msg) -class GrantWithEnrichedRoles: +class Next: """ - Permission granted by the policy with translated roles and additional role - information. + Details with href linking to the following page of requested collection. - :param List[EnrichedRoles] roles: A set of roles granted by the policy. + :param str href: (optional) The href linking to the page of requested + collection. + :param str start: (optional) Page token that refers to the page of the + collection. """ def __init__( self, - roles: List['EnrichedRoles'], + *, + href: Optional[str] = None, + start: Optional[str] = None, ) -> None: """ - Initialize a GrantWithEnrichedRoles object. + Initialize a Next object. - :param List[EnrichedRoles] roles: A set of roles granted by the policy. + :param str start: (optional) Page token that refers to the page of the + collection. """ - self.roles = roles + self.href = href + self.start = start @classmethod - def from_dict(cls, _dict: Dict) -> 'GrantWithEnrichedRoles': - """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Next': + """Initialize a Next object from a json dictionary.""" args = {} - if (roles := _dict.get('roles')) is not None: - args['roles'] = [EnrichedRoles.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in GrantWithEnrichedRoles JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (start := _dict.get('start')) is not None: + args['start'] = start return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" + """Initialize a Next object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start return _dict def _to_dict(self): @@ -6259,93 +7698,172 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GrantWithEnrichedRoles object.""" + """Return a `str` version of this Next object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GrantWithEnrichedRoles') -> bool: + def __eq__(self, other: 'Next') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'GrantWithEnrichedRoles') -> bool: + def __ne__(self, other: 'Next') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class IdentityTypes: +class Policy: """ - The settings for each identity type. + The core set of properties associated with a policy. - :param IdentityTypesBase user: The core set of properties associated with an - identity type. - :param IdentityTypesBase service_id: The core set of properties associated with - an identity type. - :param IdentityTypesBase service: The core set of properties associated with an - identity type. + :param str id: (optional) The policy ID. + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Customer-defined description. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) granted + by the policy. + :param List[PolicyResource] resources: The resources associated with a policy. + :param str href: (optional) The href links back to the policy. + :param datetime created_at: (optional) The UTC timestamp when the policy was + created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + policy. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the policy. + :param str state: (optional) The policy state. """ def __init__( self, - user: 'IdentityTypesBase', - service_id: 'IdentityTypesBase', - service: 'IdentityTypesBase', + type: str, + subjects: List['PolicySubject'], + roles: List['PolicyRole'], + resources: List['PolicyResource'], + *, + id: Optional[str] = None, + description: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + state: Optional[str] = None, ) -> None: """ - Initialize a IdentityTypes object. + Initialize a Policy object. - :param IdentityTypesBase user: The core set of properties associated with - an identity type. - :param IdentityTypesBase service_id: The core set of properties associated - with an identity type. - :param IdentityTypesBase service: The core set of properties associated - with an identity type. + :param str type: The policy type; either 'access' or 'authorization'. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) + granted by the policy. + :param List[PolicyResource] resources: The resources associated with a + policy. + :param str description: (optional) Customer-defined description. + :param str state: (optional) The policy state. """ - self.user = user - self.service_id = service_id - self.service = service + self.id = id + self.type = type + self.description = description + self.subjects = subjects + self.roles = roles + self.resources = resources + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'IdentityTypes': - """Initialize a IdentityTypes object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Policy': + """Initialize a Policy object from a json dictionary.""" args = {} - if (user := _dict.get('user')) is not None: - args['user'] = IdentityTypesBase.from_dict(user) + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type else: - raise ValueError('Required property \'user\' not present in IdentityTypes JSON') - if (service_id := _dict.get('service_id')) is not None: - args['service_id'] = IdentityTypesBase.from_dict(service_id) + raise ValueError('Required property \'type\' not present in Policy JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (subjects := _dict.get('subjects')) is not None: + args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] else: - raise ValueError('Required property \'service_id\' not present in IdentityTypes JSON') - if (service := _dict.get('service')) is not None: - args['service'] = IdentityTypesBase.from_dict(service) + raise ValueError('Required property \'subjects\' not present in Policy JSON') + if (roles := _dict.get('roles')) is not None: + args['roles'] = [PolicyRole.from_dict(v) for v in roles] else: - raise ValueError('Required property \'service\' not present in IdentityTypes JSON') + raise ValueError('Required property \'roles\' not present in Policy JSON') + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyResource.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in Policy JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (state := _dict.get('state')) is not None: + args['state'] = state return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a IdentityTypes object from a json dictionary.""" + """Initialize a Policy object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'user') and self.user is not None: - if isinstance(self.user, dict): - _dict['user'] = self.user - else: - _dict['user'] = self.user.to_dict() - if hasattr(self, 'service_id') and self.service_id is not None: - if isinstance(self.service_id, dict): - _dict['service_id'] = self.service_id - else: - _dict['service_id'] = self.service_id.to_dict() - if hasattr(self, 'service') and self.service is not None: - if isinstance(self.service, dict): - _dict['service'] = self.service - else: - _dict['service'] = self.service.to_dict() + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'subjects') and self.subjects is not None: + subjects_list = [] + for v in self.subjects: + if isinstance(v, dict): + subjects_list.append(v) + else: + subjects_list.append(v.to_dict()) + _dict['subjects'] = subjects_list + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state return _dict def _to_dict(self): @@ -6353,70 +7871,91 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this IdentityTypes object.""" + """Return a `str` version of this Policy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'IdentityTypes') -> bool: + def __eq__(self, other: 'Policy') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'IdentityTypes') -> bool: + def __ne__(self, other: 'Policy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + The policy state. + """ -class IdentityTypesBase: + ACTIVE = 'active' + DELETED = 'deleted' + + +class PolicyAssignmentResourcePolicy: """ - The core set of properties associated with an identity type. + Set of properties for the assigned resource. - :param str state: The state of the identity type. - :param List[str] external_allowed_accounts: List of accounts that the state - applies to for a given identity. + :param AssignmentResourceCreated resource_created: (optional) On success, + includes the policy that is assigned. + :param str status: (optional) policy status. + :param AssignmentResourceError error_message: (optional) Body parameters for + assignment error. """ def __init__( self, - state: str, - external_allowed_accounts: List[str], + *, + resource_created: Optional['AssignmentResourceCreated'] = None, + status: Optional[str] = None, + error_message: Optional['AssignmentResourceError'] = None, ) -> None: """ - Initialize a IdentityTypesBase object. + Initialize a PolicyAssignmentResourcePolicy object. - :param str state: The state of the identity type. - :param List[str] external_allowed_accounts: List of accounts that the state - applies to for a given identity. + :param AssignmentResourceCreated resource_created: (optional) On success, + includes the policy that is assigned. + :param str status: (optional) policy status. + :param AssignmentResourceError error_message: (optional) Body parameters + for assignment error. """ - self.state = state - self.external_allowed_accounts = external_allowed_accounts + self.resource_created = resource_created + self.status = status + self.error_message = error_message @classmethod - def from_dict(cls, _dict: Dict) -> 'IdentityTypesBase': - """Initialize a IdentityTypesBase object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResourcePolicy': + """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" args = {} - if (state := _dict.get('state')) is not None: - args['state'] = state - else: - raise ValueError('Required property \'state\' not present in IdentityTypesBase JSON') - if (external_allowed_accounts := _dict.get('external_allowed_accounts')) is not None: - args['external_allowed_accounts'] = external_allowed_accounts - else: - raise ValueError('Required property \'external_allowed_accounts\' not present in IdentityTypesBase JSON') + if (resource_created := _dict.get('resource_created')) is not None: + args['resource_created'] = AssignmentResourceCreated.from_dict(resource_created) + if (status := _dict.get('status')) is not None: + args['status'] = status + if (error_message := _dict.get('error_message')) is not None: + args['error_message'] = AssignmentResourceError.from_dict(error_message) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a IdentityTypesBase object from a json dictionary.""" + """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'external_allowed_accounts') and self.external_allowed_accounts is not None: - _dict['external_allowed_accounts'] = self.external_allowed_accounts + if hasattr(self, 'resource_created') and self.resource_created is not None: + if isinstance(self.resource_created, dict): + _dict['resource_created'] = self.resource_created + else: + _dict['resource_created'] = self.resource_created.to_dict() + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'error_message') and self.error_message is not None: + if isinstance(self.error_message, dict): + _dict['error_message'] = self.error_message + else: + _dict['error_message'] = self.error_message.to_dict() return _dict def _to_dict(self): @@ -6424,97 +7963,70 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this IdentityTypesBase object.""" + """Return a `str` version of this PolicyAssignmentResourcePolicy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'IdentityTypesBase') -> bool: + def __eq__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'IdentityTypesBase') -> bool: + def __ne__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - The state of the identity type. - """ - - ENABLED = 'enabled' - MONITOR = 'monitor' - LIMITED = 'limited' - -class IdentityTypesPatch: +class PolicyAssignmentResources: """ - The settings to apply for each identity type for a request. + The policy assignment resources. - :param IdentityTypesBase user: (optional) The core set of properties associated - with an identity type. - :param IdentityTypesBase service_id: (optional) The core set of properties - associated with an identity type. - :param IdentityTypesBase service: (optional) The core set of properties - associated with an identity type. + :param str target: (optional) Account ID where resources are assigned. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for + the assigned resource. """ def __init__( self, *, - user: Optional['IdentityTypesBase'] = None, - service_id: Optional['IdentityTypesBase'] = None, - service: Optional['IdentityTypesBase'] = None, + target: Optional[str] = None, + policy: Optional['PolicyAssignmentResourcePolicy'] = None, ) -> None: """ - Initialize a IdentityTypesPatch object. + Initialize a PolicyAssignmentResources object. - :param IdentityTypesBase user: (optional) The core set of properties - associated with an identity type. - :param IdentityTypesBase service_id: (optional) The core set of properties - associated with an identity type. - :param IdentityTypesBase service: (optional) The core set of properties - associated with an identity type. + :param str target: (optional) Account ID where resources are assigned. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties + for the assigned resource. """ - self.user = user - self.service_id = service_id - self.service = service + self.target = target + self.policy = policy @classmethod - def from_dict(cls, _dict: Dict) -> 'IdentityTypesPatch': - """Initialize a IdentityTypesPatch object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResources': + """Initialize a PolicyAssignmentResources object from a json dictionary.""" args = {} - if (user := _dict.get('user')) is not None: - args['user'] = IdentityTypesBase.from_dict(user) - if (service_id := _dict.get('service_id')) is not None: - args['service_id'] = IdentityTypesBase.from_dict(service_id) - if (service := _dict.get('service')) is not None: - args['service'] = IdentityTypesBase.from_dict(service) + if (target := _dict.get('target')) is not None: + args['target'] = target + if (policy := _dict.get('policy')) is not None: + args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a IdentityTypesPatch object from a json dictionary.""" + """Initialize a PolicyAssignmentResources object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'user') and self.user is not None: - if isinstance(self.user, dict): - _dict['user'] = self.user - else: - _dict['user'] = self.user.to_dict() - if hasattr(self, 'service_id') and self.service_id is not None: - if isinstance(self.service_id, dict): - _dict['service_id'] = self.service_id - else: - _dict['service_id'] = self.service_id.to_dict() - if hasattr(self, 'service') and self.service is not None: - if isinstance(self.service, dict): - _dict['service'] = self.service + if hasattr(self, 'target') and self.target is not None: + _dict['target'] = self.target + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy else: - _dict['service'] = self.service.to_dict() + _dict['policy'] = self.policy.to_dict() return _dict def _to_dict(self): @@ -6522,63 +8034,171 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this IdentityTypesPatch object.""" + """Return a `str` version of this PolicyAssignmentResources object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'IdentityTypesPatch') -> bool: + def __eq__(self, other: 'PolicyAssignmentResources') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'IdentityTypesPatch') -> bool: + def __ne__(self, other: 'PolicyAssignmentResources') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class LimitData: +class PolicyAssignmentV1: """ - policy template current and limit details with in an account. + The set of properties associated with the policy template assignment. - :param int current: (optional) policy template current count. - :param int limit: (optional) policy template limit count. + :param AssignmentTargetDetails target: assignment target account and type. + :param str id: (optional) Policy assignment ID. + :param str account_id: (optional) The account GUID that the policies assignments + belong to. + :param str href: (optional) The href URL that links to the policies assignments + API by policy assignment ID. + :param datetime created_at: (optional) The UTC timestamp when the policy + assignment was created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + policy assignment. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + assignment was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the policy assignment. + :param List[PolicyAssignmentV1Resources] resources: Object for each account + assigned. + :param PolicyAssignmentV1Subject subject: (optional) Subject details of access + type assignment. + :param AssignmentTemplateDetails template: policy template details. + :param str status: The policy assignment status. """ def __init__( self, + target: 'AssignmentTargetDetails', + resources: List['PolicyAssignmentV1Resources'], + template: 'AssignmentTemplateDetails', + status: str, *, - current: Optional[int] = None, - limit: Optional[int] = None, + id: Optional[str] = None, + account_id: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + subject: Optional['PolicyAssignmentV1Subject'] = None, ) -> None: """ - Initialize a LimitData object. + Initialize a PolicyAssignmentV1 object. + :param AssignmentTargetDetails target: assignment target account and type. + :param List[PolicyAssignmentV1Resources] resources: Object for each account + assigned. + :param AssignmentTemplateDetails template: policy template details. + :param str status: The policy assignment status. + :param PolicyAssignmentV1Subject subject: (optional) Subject details of + access type assignment. """ - self.current = current - self.limit = limit + self.target = target + self.id = id + self.account_id = account_id + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.resources = resources + self.subject = subject + self.template = template + self.status = status @classmethod - def from_dict(cls, _dict: Dict) -> 'LimitData': - """Initialize a LimitData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1': + """Initialize a PolicyAssignmentV1 object from a json dictionary.""" args = {} - if (current := _dict.get('current')) is not None: - args['current'] = current - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + else: + raise ValueError('Required property \'target\' not present in PolicyAssignmentV1 JSON') + if (id := _dict.get('id')) is not None: + args['id'] = id + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyAssignmentV1Resources.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in PolicyAssignmentV1 JSON') + if (subject := _dict.get('subject')) is not None: + args['subject'] = PolicyAssignmentV1Subject.from_dict(subject) + if (template := _dict.get('template')) is not None: + args['template'] = AssignmentTemplateDetails.from_dict(template) + else: + raise ValueError('Required property \'template\' not present in PolicyAssignmentV1 JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + else: + raise ValueError('Required property \'status\' not present in PolicyAssignmentV1 JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a LimitData object from a json dictionary.""" + """Initialize a PolicyAssignmentV1 object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'current') and getattr(self, 'current') is not None: - _dict['current'] = getattr(self, 'current') - if hasattr(self, 'limit') and getattr(self, 'limit') is not None: - _dict['limit'] = getattr(self, 'limit') + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: + _dict['account_id'] = getattr(self, 'account_id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'subject') and self.subject is not None: + if isinstance(self.subject, dict): + _dict['subject'] = self.subject + else: + _dict['subject'] = self.subject.to_dict() + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status return _dict def _to_dict(self): @@ -6586,86 +8206,125 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this LimitData object.""" + """Return a `str` version of this PolicyAssignmentV1 object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'LimitData') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'LimitData') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - -class NestedCondition: - """ - Condition that specifies additional conditions or RuleAttribute to grant access. - - """ - - def __init__( - self, - ) -> None: + class StatusEnum(str, Enum): """ - Initialize a NestedCondition object. - + The policy assignment status. """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['NestedConditionRuleAttribute', 'NestedConditionRuleWithConditions']) - ) - raise Exception(msg) + + IN_PROGRESS = 'in_progress' + SUCCEEDED = 'succeeded' + SUCCEED_WITH_ERRORS = 'succeed_with_errors' + FAILED = 'failed' -class Next: +class PolicyAssignmentV1Collection: """ - Details with href linking to the following page of requested collection. + Policy assignment response. - :param str href: (optional) The href linking to the page of requested - collection. - :param str start: (optional) Page token that refers to the page of the - collection. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[PolicyAssignmentV1] assignments: Response of policy assignments. """ def __init__( self, + assignments: List['PolicyAssignmentV1'], *, - href: Optional[str] = None, - start: Optional[str] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a Next object. + Initialize a PolicyAssignmentV1Collection object. - :param str start: (optional) Page token that refers to the page of the - collection. + :param List[PolicyAssignmentV1] assignments: Response of policy + assignments. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ - self.href = href - self.start = start + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.assignments = assignments @classmethod - def from_dict(cls, _dict: Dict) -> 'Next': - """Initialize a Next object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Collection': + """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" args = {} - if (href := _dict.get('href')) is not None: - args['href'] = href - if (start := _dict.get('start')) is not None: - args['start'] = start + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (assignments := _dict.get('assignments')) is not None: + args['assignments'] = [PolicyAssignmentV1.from_dict(v) for v in assignments] + else: + raise ValueError('Required property \'assignments\' not present in PolicyAssignmentV1Collection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Next object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'start') and self.start is not None: - _dict['start'] = self.start + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: + if isinstance(v, dict): + assignments_list.append(v) + else: + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list return _dict def _to_dict(self): @@ -6673,172 +8332,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Next object.""" + """Return a `str` version of this PolicyAssignmentV1Collection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Next') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Collection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Next') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Collection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Policy: - """ - The core set of properties associated with a policy. - - :param str id: (optional) The policy ID. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Customer-defined description. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) granted - by the policy. - :param List[PolicyResource] resources: The resources associated with a policy. - :param str href: (optional) The href links back to the policy. - :param datetime created_at: (optional) The UTC timestamp when the policy was - created. - :param str created_by_id: (optional) The IAM ID of the entity that created the - policy. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - was last modified. - :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the policy. - :param str state: (optional) The policy state. +class PolicyAssignmentV1Resources: """ + The policy assignment resources. - def __init__( - self, - type: str, - subjects: List['PolicySubject'], - roles: List['PolicyRole'], - resources: List['PolicyResource'], - *, - id: Optional[str] = None, - description: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - state: Optional[str] = None, - ) -> None: - """ - Initialize a Policy object. - - :param str type: The policy type; either 'access' or 'authorization'. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) - granted by the policy. - :param List[PolicyResource] resources: The resources associated with a - policy. - :param str description: (optional) Customer-defined description. - :param str state: (optional) The policy state. - """ - self.id = id - self.type = type - self.description = description - self.subjects = subjects - self.roles = roles - self.resources = resources - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.state = state - - @classmethod - def from_dict(cls, _dict: Dict) -> 'Policy': - """Initialize a Policy object from a json dictionary.""" - args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type - else: - raise ValueError('Required property \'type\' not present in Policy JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (subjects := _dict.get('subjects')) is not None: - args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] - else: - raise ValueError('Required property \'subjects\' not present in Policy JSON') - if (roles := _dict.get('roles')) is not None: - args['roles'] = [PolicyRole.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in Policy JSON') - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyResource.from_dict(v) for v in resources] - else: - raise ValueError('Required property \'resources\' not present in Policy JSON') - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (state := _dict.get('state')) is not None: - args['state'] = state + :param AssignmentTargetDetails target: (optional) assignment target account and + type. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for + the assigned resource. + """ + + def __init__( + self, + *, + target: Optional['AssignmentTargetDetails'] = None, + policy: Optional['PolicyAssignmentResourcePolicy'] = None, + ) -> None: + """ + Initialize a PolicyAssignmentV1Resources object. + + :param AssignmentTargetDetails target: (optional) assignment target account + and type. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties + for the assigned resource. + """ + self.target = target + self.policy = policy + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Resources': + """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" + args = {} + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + if (policy := _dict.get('policy')) is not None: + args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Policy object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'subjects') and self.subjects is not None: - subjects_list = [] - for v in self.subjects: - if isinstance(v, dict): - subjects_list.append(v) - else: - subjects_list.append(v.to_dict()) - _dict['subjects'] = subjects_list - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy + else: + _dict['policy'] = self.policy.to_dict() return _dict def _to_dict(self): @@ -6846,89 +8408,64 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Policy object.""" + """Return a `str` version of this PolicyAssignmentV1Resources object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Policy') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Resources') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Policy') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Resources') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - The policy state. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class PolicyAssignmentResourcePolicy: +class PolicyAssignmentV1Subject: """ - Set of properties for the assigned resource. + Subject details of access type assignment. - :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy that is assigned. - :param str status: (optional) policy status. - :param ErrorResponse error_message: (optional) The error response from API. + :param str id: (optional) The unique identifier of the subject of the + assignment. + :param str type: (optional) The identity type of the subject of the assignment. """ def __init__( self, *, - resource_created: Optional['AssignmentResourceCreated'] = None, - status: Optional[str] = None, - error_message: Optional['ErrorResponse'] = None, + id: Optional[str] = None, + type: Optional[str] = None, ) -> None: """ - Initialize a PolicyAssignmentResourcePolicy object. + Initialize a PolicyAssignmentV1Subject object. - :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy that is assigned. - :param str status: (optional) policy status. - :param ErrorResponse error_message: (optional) The error response from API. """ - self.resource_created = resource_created - self.status = status - self.error_message = error_message + self.id = id + self.type = type @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResourcePolicy': - """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Subject': + """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" args = {} - if (resource_created := _dict.get('resource_created')) is not None: - args['resource_created'] = AssignmentResourceCreated.from_dict(resource_created) - if (status := _dict.get('status')) is not None: - args['status'] = status - if (error_message := _dict.get('error_message')) is not None: - args['error_message'] = ErrorResponse.from_dict(error_message) + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'resource_created') and self.resource_created is not None: - if isinstance(self.resource_created, dict): - _dict['resource_created'] = self.resource_created - else: - _dict['resource_created'] = self.resource_created.to_dict() - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status - if hasattr(self, 'error_message') and self.error_message is not None: - if isinstance(self.error_message, dict): - _dict['error_message'] = self.error_message - else: - _dict['error_message'] = self.error_message.to_dict() + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'type') and getattr(self, 'type') is not None: + _dict['type'] = getattr(self, 'type') return _dict def _to_dict(self): @@ -6936,70 +8473,122 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentResourcePolicy object.""" + """Return a `str` version of this PolicyAssignmentV1Subject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Subject') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Subject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TypeEnum(str, Enum): + """ + The identity type of the subject of the assignment. + """ + + IAM_ID = 'iam_id' + ACCESS_GROUP_ID = 'access_group_id' + -class PolicyAssignmentResources: +class PolicyCollection: """ - The policy assignment resources. + A collection of policies. - :param str target: (optional) Account ID where resources are assigned. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for - the assigned resource. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[PolicyTemplateMetaData] policies: List of policies. """ def __init__( self, + policies: List['PolicyTemplateMetaData'], *, - target: Optional[str] = None, - policy: Optional['PolicyAssignmentResourcePolicy'] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a PolicyAssignmentResources object. + Initialize a PolicyCollection object. - :param str target: (optional) Account ID where resources are assigned. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties - for the assigned resource. + :param List[PolicyTemplateMetaData] policies: List of policies. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ - self.target = target - self.policy = policy + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.policies = policies @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResources': - """Initialize a PolicyAssignmentResources object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyCollection': + """Initialize a PolicyCollection object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = target - if (policy := _dict.get('policy')) is not None: - args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (policies := _dict.get('policies')) is not None: + args['policies'] = [PolicyTemplateMetaData.from_dict(v) for v in policies] + else: + raise ValueError('Required property \'policies\' not present in PolicyCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentResources object from a json dictionary.""" + """Initialize a PolicyCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - _dict['target'] = self.target - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first else: - _dict['policy'] = self.policy.to_dict() + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'policies') and self.policies is not None: + policies_list = [] + for v in self.policies: + if isinstance(v, dict): + policies_list.append(v) + else: + policies_list.append(v.to_dict()) + _dict['policies'] = policies_list return _dict def _to_dict(self): @@ -7007,171 +8596,79 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentResources object.""" + """Return a `str` version of this PolicyCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentResources') -> bool: + def __eq__(self, other: 'PolicyCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentResources') -> bool: + def __ne__(self, other: 'PolicyCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentV1: +class PolicyResource: """ - The set of properties associated with the policy template assignment. + The attributes of the resource. Note that only one resource is allowed in a policy. - :param AssignmentTargetDetails target: assignment target account and type. - :param str id: (optional) Policy assignment ID. - :param str account_id: (optional) The account GUID that the policies assignments - belong to. - :param str href: (optional) The href URL that links to the policies assignments - API by policy assignment ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - assignment was created. - :param str created_by_id: (optional) The IAM ID of the entity that created the - policy assignment. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - assignment was last modified. - :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the policy assignment. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param PolicyAssignmentV1Subject subject: (optional) Subject details of access - type assignment. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. + :param List[ResourceAttribute] attributes: List of resource attributes. + :param List[ResourceTag] tags: (optional) List of access management tags. """ def __init__( self, - target: 'AssignmentTargetDetails', - resources: List['PolicyAssignmentV1Resources'], - template: 'AssignmentTemplateDetails', - status: str, + attributes: List['ResourceAttribute'], *, - id: Optional[str] = None, - account_id: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - subject: Optional['PolicyAssignmentV1Subject'] = None, + tags: Optional[List['ResourceTag']] = None, ) -> None: """ - Initialize a PolicyAssignmentV1 object. + Initialize a PolicyResource object. - :param AssignmentTargetDetails target: assignment target account and type. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. - :param PolicyAssignmentV1Subject subject: (optional) Subject details of - access type assignment. + :param List[ResourceAttribute] attributes: List of resource attributes. + :param List[ResourceTag] tags: (optional) List of access management tags. """ - self.target = target - self.id = id - self.account_id = account_id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.resources = resources - self.subject = subject - self.template = template - self.status = status + self.attributes = attributes + self.tags = tags @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1': - """Initialize a PolicyAssignmentV1 object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyResource': + """Initialize a PolicyResource object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) - else: - raise ValueError('Required property \'target\' not present in PolicyAssignmentV1 JSON') - if (id := _dict.get('id')) is not None: - args['id'] = id - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyAssignmentV1Resources.from_dict(v) for v in resources] - else: - raise ValueError('Required property \'resources\' not present in PolicyAssignmentV1 JSON') - if (subject := _dict.get('subject')) is not None: - args['subject'] = PolicyAssignmentV1Subject.from_dict(subject) - if (template := _dict.get('template')) is not None: - args['template'] = AssignmentTemplateDetails.from_dict(template) - else: - raise ValueError('Required property \'template\' not present in PolicyAssignmentV1 JSON') - if (status := _dict.get('status')) is not None: - args['status'] = status + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [ResourceAttribute.from_dict(v) for v in attributes] else: - raise ValueError('Required property \'status\' not present in PolicyAssignmentV1 JSON') + raise ValueError('Required property \'attributes\' not present in PolicyResource JSON') + if (tags := _dict.get('tags')) is not None: + args['tags'] = [ResourceTag.from_dict(v) for v in tags] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1 object from a json dictionary.""" + """Initialize a PolicyResource object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target - else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: if isinstance(v, dict): - resources_list.append(v) + attributes_list.append(v) else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'subject') and self.subject is not None: - if isinstance(self.subject, dict): - _dict['subject'] = self.subject - else: - _dict['subject'] = self.subject.to_dict() - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template - else: - _dict['template'] = self.template.to_dict() - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list + if hasattr(self, 'tags') and self.tags is not None: + tags_list = [] + for v in self.tags: + if isinstance(v, dict): + tags_list.append(v) + else: + tags_list.append(v.to_dict()) + _dict['tags'] = tags_list return _dict def _to_dict(self): @@ -7179,125 +8676,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1 object.""" + """Return a `str` version of this PolicyResource object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1') -> bool: + def __eq__(self, other: 'PolicyResource') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1') -> bool: + def __ne__(self, other: 'PolicyResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StatusEnum(str, Enum): - """ - The policy assignment status. - """ - - IN_PROGRESS = 'in_progress' - SUCCEEDED = 'succeeded' - SUCCEED_WITH_ERRORS = 'succeed_with_errors' - FAILED = 'failed' - -class PolicyAssignmentV1Collection: +class PolicyRole: """ - Policy assignment response. + A role associated with a policy. - :param int limit: (optional) The number of documents to include per each page of - the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following page of - requested collection. - :param Previous previous: (optional) Details with linking href to previous page - of requested collection. - :param List[PolicyAssignmentV1] assignments: Response of policy assignments. + :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. + Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param str display_name: (optional) The display name of the role. + :param str description: (optional) The description of the role. """ def __init__( self, - assignments: List['PolicyAssignmentV1'], + role_id: str, *, - limit: Optional[int] = None, - first: Optional['First'] = None, - next: Optional['Next'] = None, - previous: Optional['Previous'] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, ) -> None: """ - Initialize a PolicyAssignmentV1Collection object. + Initialize a PolicyRole object. - :param List[PolicyAssignmentV1] assignments: Response of policy - assignments. - :param int limit: (optional) The number of documents to include per each - page of the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following - page of requested collection. - :param Previous previous: (optional) Details with linking href to previous - page of requested collection. + :param str role_id: The role Cloud Resource Name (CRN) granted by the + policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. """ - self.limit = limit - self.first = first - self.next = next - self.previous = previous - self.assignments = assignments + self.role_id = role_id + self.display_name = display_name + self.description = description @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Collection': - """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyRole': + """Initialize a PolicyRole object from a json dictionary.""" args = {} - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit - if (first := _dict.get('first')) is not None: - args['first'] = First.from_dict(first) - if (next := _dict.get('next')) is not None: - args['next'] = Next.from_dict(next) - if (previous := _dict.get('previous')) is not None: - args['previous'] = Previous.from_dict(previous) - if (assignments := _dict.get('assignments')) is not None: - args['assignments'] = [PolicyAssignmentV1.from_dict(v) for v in assignments] + if (role_id := _dict.get('role_id')) is not None: + args['role_id'] = role_id else: - raise ValueError('Required property \'assignments\' not present in PolicyAssignmentV1Collection JSON') + raise ValueError('Required property \'role_id\' not present in PolicyRole JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + if (description := _dict.get('description')) is not None: + args['description'] = description return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" + """Initialize a PolicyRole object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'previous') and self.previous is not None: - if isinstance(self.previous, dict): - _dict['previous'] = self.previous - else: - _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'assignments') and self.assignments is not None: - assignments_list = [] - for v in self.assignments: - if isinstance(v, dict): - assignments_list.append(v) - else: - assignments_list.append(v.to_dict()) - _dict['assignments'] = assignments_list + if hasattr(self, 'role_id') and self.role_id is not None: + _dict['role_id'] = self.role_id + if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: + _dict['display_name'] = getattr(self, 'display_name') + if hasattr(self, 'description') and getattr(self, 'description') is not None: + _dict['description'] = getattr(self, 'description') return _dict def _to_dict(self): @@ -7305,75 +8752,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Collection object.""" + """Return a `str` version of this PolicyRole object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Collection') -> bool: + def __eq__(self, other: 'PolicyRole') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Collection') -> bool: + def __ne__(self, other: 'PolicyRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentV1Resources: +class PolicySubject: """ - The policy assignment resources. + The subject attribute values that must match in order for this policy to apply in a + permission decision. - :param AssignmentTargetDetails target: (optional) assignment target account and - type. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for - the assigned resource. + :param List[SubjectAttribute] attributes: List of subject attributes. """ def __init__( self, - *, - target: Optional['AssignmentTargetDetails'] = None, - policy: Optional['PolicyAssignmentResourcePolicy'] = None, + attributes: List['SubjectAttribute'], ) -> None: """ - Initialize a PolicyAssignmentV1Resources object. + Initialize a PolicySubject object. - :param AssignmentTargetDetails target: (optional) assignment target account - and type. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties - for the assigned resource. + :param List[SubjectAttribute] attributes: List of subject attributes. """ - self.target = target - self.policy = policy + self.attributes = attributes @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Resources': - """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicySubject': + """Initialize a PolicySubject object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) - if (policy := _dict.get('policy')) is not None: - args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [SubjectAttribute.from_dict(v) for v in attributes] + else: + raise ValueError('Required property \'attributes\' not present in PolicySubject JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" + """Initialize a PolicySubject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target - else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy - else: - _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: + if isinstance(v, dict): + attributes_list.append(v) + else: + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list return _dict def _to_dict(self): @@ -7381,64 +8818,177 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Resources object.""" + """Return a `str` version of this PolicySubject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Resources') -> bool: + def __eq__(self, other: 'PolicySubject') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Resources') -> bool: + def __ne__(self, other: 'PolicySubject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentV1Subject: +class PolicyTemplate: """ - Subject details of access type assignment. + The core set of properties associated with the policy template. - :param str id: (optional) The unique identifier of the subject of the - assignment. - :param str type: (optional) The identity type of the subject of the assignment. + :param str name: Required field when creating a new template. Otherwise, this + field is optional. If the field is included, it changes the name value for all + existing versions of the template. + :param str description: (optional) Description of the policy template. This is + shown to users in the enterprise account. Use this to describe the purpose or + context of the policy for enterprise users managing IAM templates. + :param str account_id: Enterprise account ID where this template is created. + :param str version: Template version. + :param bool committed: (optional) Committed status of the template version. + :param TemplatePolicy policy: The core set of properties associated with the + template's policy object. + :param str state: State of policy template. + :param str id: (optional) The policy template ID. + :param str href: (optional) The href URL that links to the policy templates API + by policy template ID. + :param datetime created_at: (optional) The UTC timestamp when the policy + template was created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + policy template. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + template was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the policy template. """ def __init__( self, + name: str, + account_id: str, + version: str, + policy: 'TemplatePolicy', + state: str, *, + description: Optional[str] = None, + committed: Optional[bool] = None, id: Optional[str] = None, - type: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, ) -> None: """ - Initialize a PolicyAssignmentV1Subject object. + Initialize a PolicyTemplate object. + :param str name: Required field when creating a new template. Otherwise, + this field is optional. If the field is included, it changes the name value + for all existing versions of the template. + :param str account_id: Enterprise account ID where this template is + created. + :param str version: Template version. + :param TemplatePolicy policy: The core set of properties associated with + the template's policy object. + :param str state: State of policy template. + :param str description: (optional) Description of the policy template. This + is shown to users in the enterprise account. Use this to describe the + purpose or context of the policy for enterprise users managing IAM + templates. + :param bool committed: (optional) Committed status of the template version. """ + self.name = name + self.description = description + self.account_id = account_id + self.version = version + self.committed = committed + self.policy = policy + self.state = state self.id = id - self.type = type + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Subject': - """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': + """Initialize a PolicyTemplate object from a json dictionary.""" args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in PolicyTemplate JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + else: + raise ValueError('Required property \'account_id\' not present in PolicyTemplate JSON') + if (version := _dict.get('version')) is not None: + args['version'] = version + else: + raise ValueError('Required property \'version\' not present in PolicyTemplate JSON') + if (committed := _dict.get('committed')) is not None: + args['committed'] = committed + if (policy := _dict.get('policy')) is not None: + args['policy'] = TemplatePolicy.from_dict(policy) + else: + raise ValueError('Required property \'policy\' not present in PolicyTemplate JSON') + if (state := _dict.get('state')) is not None: + args['state'] = state + else: + raise ValueError('Required property \'state\' not present in PolicyTemplate JSON') if (id := _dict.get('id')) is not None: args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" + """Initialize a PolicyTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'committed') and self.committed is not None: + _dict['committed'] = self.committed + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy + else: + _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and getattr(self, 'type') is not None: - _dict['type'] = getattr(self, 'type') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') return _dict def _to_dict(self): @@ -7446,31 +8996,31 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Subject object.""" + """Return a `str` version of this PolicyTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Subject') -> bool: + def __eq__(self, other: 'PolicyTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Subject') -> bool: + def __ne__(self, other: 'PolicyTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): + class StateEnum(str, Enum): """ - The identity type of the subject of the assignment. + State of policy template. """ - IAM_ID = 'iam_id' - ACCESS_GROUP_ID = 'access_group_id' - + ACTIVE = 'active' + DELETED = 'deleted' -class PolicyCollection: + +class PolicyTemplateAssignmentCollection: """ - A collection of policies. + A collection of policies assignments. :param int limit: (optional) The number of documents to include per each page of the collection. @@ -7480,12 +9030,13 @@ class PolicyCollection: requested collection. :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplateMetaData] policies: List of policies. + :param List[PolicyTemplateAssignmentItems] assignments: List of policy + assignments. """ def __init__( self, - policies: List['PolicyTemplateMetaData'], + assignments: List['PolicyTemplateAssignmentItems'], *, limit: Optional[int] = None, first: Optional['First'] = None, @@ -7493,9 +9044,10 @@ def __init__( previous: Optional['Previous'] = None, ) -> None: """ - Initialize a PolicyCollection object. + Initialize a PolicyTemplateAssignmentCollection object. - :param List[PolicyTemplateMetaData] policies: List of policies. + :param List[PolicyTemplateAssignmentItems] assignments: List of policy + assignments. :param int limit: (optional) The number of documents to include per each page of the collection. :param First first: (optional) Details with linking href to first page of @@ -7509,11 +9061,11 @@ def __init__( self.first = first self.next = next self.previous = previous - self.policies = policies + self.assignments = assignments @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyCollection': - """Initialize a PolicyCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': + """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" args = {} if (limit := _dict.get('limit')) is not None: args['limit'] = limit @@ -7523,15 +9075,15 @@ def from_dict(cls, _dict: Dict) -> 'PolicyCollection': args['next'] = Next.from_dict(next) if (previous := _dict.get('previous')) is not None: args['previous'] = Previous.from_dict(previous) - if (policies := _dict.get('policies')) is not None: - args['policies'] = [PolicyTemplateMetaData.from_dict(v) for v in policies] + if (assignments := _dict.get('assignments')) is not None: + args['assignments'] = assignments else: - raise ValueError('Required property \'policies\' not present in PolicyCollection JSON') + raise ValueError('Required property \'assignments\' not present in PolicyTemplateAssignmentCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyCollection object from a json dictionary.""" + """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -7554,14 +9106,14 @@ def to_dict(self) -> Dict: _dict['previous'] = self.previous else: _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'policies') and self.policies is not None: - policies_list = [] - for v in self.policies: + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: if isinstance(v, dict): - policies_list.append(v) + assignments_list.append(v) else: - policies_list.append(v.to_dict()) - _dict['policies'] = policies_list + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list return _dict def _to_dict(self): @@ -7569,221 +9121,135 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyCollection object.""" + """Return a `str` version of this PolicyTemplateAssignmentCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyCollection') -> bool: + def __eq__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyCollection') -> bool: + def __ne__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyResource: +class PolicyTemplateAssignmentItems: """ - The attributes of the resource. Note that only one resource is allowed in a policy. + PolicyTemplateAssignmentItems. - :param List[ResourceAttribute] attributes: List of resource attributes. - :param List[ResourceTag] tags: (optional) List of access management tags. """ def __init__( self, - attributes: List['ResourceAttribute'], - *, - tags: Optional[List['ResourceTag']] = None, ) -> None: """ - Initialize a PolicyResource object. + Initialize a PolicyTemplateAssignmentItems object. - :param List[ResourceAttribute] attributes: List of resource attributes. - :param List[ResourceTag] tags: (optional) List of access management tags. """ - self.attributes = attributes - self.tags = tags - - @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyResource': - """Initialize a PolicyResource object from a json dictionary.""" - args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [ResourceAttribute.from_dict(v) for v in attributes] - else: - raise ValueError('Required property \'attributes\' not present in PolicyResource JSON') - if (tags := _dict.get('tags')) is not None: - args['tags'] = [ResourceTag.from_dict(v) for v in tags] - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a PolicyResource object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: - if isinstance(v, dict): - attributes_list.append(v) - else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list - if hasattr(self, 'tags') and self.tags is not None: - tags_list = [] - for v in self.tags: - if isinstance(v, dict): - tags_list.append(v) - else: - tags_list.append(v.to_dict()) - _dict['tags'] = tags_list - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this PolicyResource object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'PolicyResource') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'PolicyResource') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join( + ['PolicyTemplateAssignmentItemsPolicyAssignmentV1', 'PolicyTemplateAssignmentItemsPolicyAssignment'] + ) + ) + raise Exception(msg) -class PolicyRole: +class PolicyTemplateCollection: """ - A role associated with a policy. + A collection of policy Templates. - :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. - Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. - :param str display_name: (optional) The display name of the role. - :param str description: (optional) The description of the role. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[PolicyTemplate] policy_templates: List of policy templates. """ def __init__( self, - role_id: str, + policy_templates: List['PolicyTemplate'], *, - display_name: Optional[str] = None, - description: Optional[str] = None, - ) -> None: - """ - Initialize a PolicyRole object. - - :param str role_id: The role Cloud Resource Name (CRN) granted by the - policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. - """ - self.role_id = role_id - self.display_name = display_name - self.description = description - - @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyRole': - """Initialize a PolicyRole object from a json dictionary.""" - args = {} - if (role_id := _dict.get('role_id')) is not None: - args['role_id'] = role_id - else: - raise ValueError('Required property \'role_id\' not present in PolicyRole JSON') - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - if (description := _dict.get('description')) is not None: - args['description'] = description - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a PolicyRole object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'role_id') and self.role_id is not None: - _dict['role_id'] = self.role_id - if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: - _dict['display_name'] = getattr(self, 'display_name') - if hasattr(self, 'description') and getattr(self, 'description') is not None: - _dict['description'] = getattr(self, 'description') - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this PolicyRole object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'PolicyRole') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ - - def __ne__(self, other: 'PolicyRole') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - - -class PolicySubject: - """ - The subject attribute values that must match in order for this policy to apply in a - permission decision. - - :param List[SubjectAttribute] attributes: List of subject attributes. - """ - - def __init__( - self, - attributes: List['SubjectAttribute'], + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a PolicySubject object. + Initialize a PolicyTemplateCollection object. - :param List[SubjectAttribute] attributes: List of subject attributes. + :param List[PolicyTemplate] policy_templates: List of policy templates. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ - self.attributes = attributes + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.policy_templates = policy_templates @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicySubject': - """Initialize a PolicySubject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateCollection': + """Initialize a PolicyTemplateCollection object from a json dictionary.""" args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [SubjectAttribute.from_dict(v) for v in attributes] + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (policy_templates := _dict.get('policy_templates')) is not None: + args['policy_templates'] = [PolicyTemplate.from_dict(v) for v in policy_templates] else: - raise ValueError('Required property \'attributes\' not present in PolicySubject JSON') + raise ValueError('Required property \'policy_templates\' not present in PolicyTemplateCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicySubject object from a json dictionary.""" + """Initialize a PolicyTemplateCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'policy_templates') and self.policy_templates is not None: + policy_templates_list = [] + for v in self.policy_templates: if isinstance(v, dict): - attributes_list.append(v) + policy_templates_list.append(v) else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list + policy_templates_list.append(v.to_dict()) + _dict['policy_templates'] = policy_templates_list return _dict def _to_dict(self): @@ -7791,21 +9257,21 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicySubject object.""" + """Return a `str` version of this PolicyTemplateCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicySubject') -> bool: + def __eq__(self, other: 'PolicyTemplateCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicySubject') -> bool: + def __ne__(self, other: 'PolicyTemplateCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyTemplate: +class PolicyTemplateLimitData: """ The core set of properties associated with the policy template. @@ -7832,6 +9298,7 @@ class PolicyTemplate: template was last modified. :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy template. + :param TemplateCountData counts: (optional) policy template count details. """ def __init__( @@ -7850,9 +9317,10 @@ def __init__( created_by_id: Optional[str] = None, last_modified_at: Optional[datetime] = None, last_modified_by_id: Optional[str] = None, + counts: Optional['TemplateCountData'] = None, ) -> None: """ - Initialize a PolicyTemplate object. + Initialize a PolicyTemplateLimitData object. :param str name: Required field when creating a new template. Otherwise, this field is optional. If the field is included, it changes the name value @@ -7868,6 +9336,7 @@ def __init__( purpose or context of the policy for enterprise users managing IAM templates. :param bool committed: (optional) Committed status of the template version. + :param TemplateCountData counts: (optional) policy template count details. """ self.name = name self.description = description @@ -7882,35 +9351,36 @@ def __init__( self.created_by_id = created_by_id self.last_modified_at = last_modified_at self.last_modified_by_id = last_modified_by_id + self.counts = counts @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': - """Initialize a PolicyTemplate object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData': + """Initialize a PolicyTemplateLimitData object from a json dictionary.""" args = {} if (name := _dict.get('name')) is not None: args['name'] = name else: - raise ValueError('Required property \'name\' not present in PolicyTemplate JSON') + raise ValueError('Required property \'name\' not present in PolicyTemplateLimitData JSON') if (description := _dict.get('description')) is not None: args['description'] = description if (account_id := _dict.get('account_id')) is not None: args['account_id'] = account_id else: - raise ValueError('Required property \'account_id\' not present in PolicyTemplate JSON') + raise ValueError('Required property \'account_id\' not present in PolicyTemplateLimitData JSON') if (version := _dict.get('version')) is not None: args['version'] = version else: - raise ValueError('Required property \'version\' not present in PolicyTemplate JSON') + raise ValueError('Required property \'version\' not present in PolicyTemplateLimitData JSON') if (committed := _dict.get('committed')) is not None: args['committed'] = committed if (policy := _dict.get('policy')) is not None: args['policy'] = TemplatePolicy.from_dict(policy) else: - raise ValueError('Required property \'policy\' not present in PolicyTemplate JSON') + raise ValueError('Required property \'policy\' not present in PolicyTemplateLimitData JSON') if (state := _dict.get('state')) is not None: args['state'] = state else: - raise ValueError('Required property \'state\' not present in PolicyTemplate JSON') + raise ValueError('Required property \'state\' not present in PolicyTemplateLimitData JSON') if (id := _dict.get('id')) is not None: args['id'] = id if (href := _dict.get('href')) is not None: @@ -7923,11 +9393,13 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': args['last_modified_at'] = string_to_datetime(last_modified_at) if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: args['last_modified_by_id'] = last_modified_by_id + if (counts := _dict.get('counts')) is not None: + args['counts'] = TemplateCountData.from_dict(counts) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplate object from a json dictionary.""" + """Initialize a PolicyTemplateLimitData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -7962,6 +9434,209 @@ def to_dict(self) -> Dict: _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'counts') and self.counts is not None: + if isinstance(self.counts, dict): + _dict['counts'] = self.counts + else: + _dict['counts'] = self.counts.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this PolicyTemplateLimitData object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyTemplateLimitData') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'PolicyTemplateLimitData') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class StateEnum(str, Enum): + """ + State of policy template. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + + +class PolicyTemplateMetaData: + """ + The core set of properties associated with a policy. + + :param str id: (optional) The policy ID. + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Customer-defined description. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) granted + by the policy. + :param List[PolicyResource] resources: The resources associated with a policy. + :param str href: (optional) The href links back to the policy. + :param datetime created_at: (optional) The UTC timestamp when the policy was + created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + policy. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the policy. + :param str state: (optional) The policy state. + :param TemplateMetadata template: (optional) The details of the IAM template + that was used to create an enterprise-managed policy in your account. When + returned, this indicates that the policy is created from and managed by a + template in the root enterprise account. + """ + + def __init__( + self, + type: str, + subjects: List['PolicySubject'], + roles: List['PolicyRole'], + resources: List['PolicyResource'], + *, + id: Optional[str] = None, + description: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + state: Optional[str] = None, + template: Optional['TemplateMetadata'] = None, + ) -> None: + """ + Initialize a PolicyTemplateMetaData object. + + :param str type: The policy type; either 'access' or 'authorization'. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) + granted by the policy. + :param List[PolicyResource] resources: The resources associated with a + policy. + :param str description: (optional) Customer-defined description. + :param str state: (optional) The policy state. + :param TemplateMetadata template: (optional) The details of the IAM + template that was used to create an enterprise-managed policy in your + account. When returned, this indicates that the policy is created from and + managed by a template in the root enterprise account. + """ + self.id = id + self.type = type + self.description = description + self.subjects = subjects + self.roles = roles + self.resources = resources + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.state = state + self.template = template + + @classmethod + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateMetaData': + """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type + else: + raise ValueError('Required property \'type\' not present in PolicyTemplateMetaData JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (subjects := _dict.get('subjects')) is not None: + args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] + else: + raise ValueError('Required property \'subjects\' not present in PolicyTemplateMetaData JSON') + if (roles := _dict.get('roles')) is not None: + args['roles'] = [PolicyRole.from_dict(v) for v in roles] + else: + raise ValueError('Required property \'roles\' not present in PolicyTemplateMetaData JSON') + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyResource.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in PolicyTemplateMetaData JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (state := _dict.get('state')) is not None: + args['state'] = state + if (template := _dict.get('template')) is not None: + args['template'] = TemplateMetadata.from_dict(template) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'subjects') and self.subjects is not None: + subjects_list = [] + for v in self.subjects: + if isinstance(v, dict): + subjects_list.append(v) + else: + subjects_list.append(v.to_dict()) + _dict['subjects'] = subjects_list + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() return _dict def _to_dict(self): @@ -7969,31 +9644,31 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplate object.""" + """Return a `str` version of this PolicyTemplateMetaData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplate') -> bool: + def __eq__(self, other: 'PolicyTemplateMetaData') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplate') -> bool: + def __ne__(self, other: 'PolicyTemplateMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class StateEnum(str, Enum): """ - State of policy template. + The policy state. """ ACTIVE = 'active' DELETED = 'deleted' -class PolicyTemplateAssignmentCollection: +class PolicyTemplateVersionsCollection: """ - A collection of policies assignments. + A collection of versions for a specific policy template. :param int limit: (optional) The number of documents to include per each page of the collection. @@ -8003,13 +9678,12 @@ class PolicyTemplateAssignmentCollection: requested collection. :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplateAssignmentItems] assignments: List of policy - assignments. + :param List[PolicyTemplate] versions: List of policy templates versions. """ def __init__( self, - assignments: List['PolicyTemplateAssignmentItems'], + versions: List['PolicyTemplate'], *, limit: Optional[int] = None, first: Optional['First'] = None, @@ -8017,10 +9691,9 @@ def __init__( previous: Optional['Previous'] = None, ) -> None: """ - Initialize a PolicyTemplateAssignmentCollection object. + Initialize a PolicyTemplateVersionsCollection object. - :param List[PolicyTemplateAssignmentItems] assignments: List of policy - assignments. + :param List[PolicyTemplate] versions: List of policy templates versions. :param int limit: (optional) The number of documents to include per each page of the collection. :param First first: (optional) Details with linking href to first page of @@ -8034,11 +9707,11 @@ def __init__( self.first = first self.next = next self.previous = previous - self.assignments = assignments + self.versions = versions @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': - """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': + """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" args = {} if (limit := _dict.get('limit')) is not None: args['limit'] = limit @@ -8048,15 +9721,15 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': args['next'] = Next.from_dict(next) if (previous := _dict.get('previous')) is not None: args['previous'] = Previous.from_dict(previous) - if (assignments := _dict.get('assignments')) is not None: - args['assignments'] = assignments + if (versions := _dict.get('versions')) is not None: + args['versions'] = [PolicyTemplate.from_dict(v) for v in versions] else: - raise ValueError('Required property \'assignments\' not present in PolicyTemplateAssignmentCollection JSON') + raise ValueError('Required property \'versions\' not present in PolicyTemplateVersionsCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" + """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -8079,14 +9752,238 @@ def to_dict(self) -> Dict: _dict['previous'] = self.previous else: _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'assignments') and self.assignments is not None: - assignments_list = [] - for v in self.assignments: + if hasattr(self, 'versions') and self.versions is not None: + versions_list = [] + for v in self.versions: if isinstance(v, dict): - assignments_list.append(v) + versions_list.append(v) else: - assignments_list.append(v.to_dict()) - _dict['assignments'] = assignments_list + versions_list.append(v.to_dict()) + _dict['versions'] = versions_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this PolicyTemplateVersionsCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Previous: + """ + Details with linking href to previous page of requested collection. + + :param str href: (optional) The href linking to the page of requested + collection. + :param str start: (optional) Page token that refers to the page of the + collection. + """ + + def __init__( + self, + *, + href: Optional[str] = None, + start: Optional[str] = None, + ) -> None: + """ + Initialize a Previous object. + + :param str start: (optional) Page token that refers to the page of the + collection. + """ + self.href = href + self.start = start + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Previous': + """Initialize a Previous object from a json dictionary.""" + args = {} + if (href := _dict.get('href')) is not None: + args['href'] = href + if (start := _dict.get('start')) is not None: + args['start'] = start + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Previous object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this Previous object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Previous') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'Previous') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ResourceAttribute: + """ + An attribute associated with a resource. + + :param str name: The name of an attribute. + :param str value: The value of an attribute. + :param str operator: (optional) The operator of an attribute. + """ + + def __init__( + self, + name: str, + value: str, + *, + operator: Optional[str] = None, + ) -> None: + """ + Initialize a ResourceAttribute object. + + :param str name: The name of an attribute. + :param str value: The value of an attribute. + :param str operator: (optional) The operator of an attribute. + """ + self.name = name + self.value = value + self.operator = operator + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ResourceAttribute': + """Initialize a ResourceAttribute object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ResourceAttribute JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in ResourceAttribute JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ResourceAttribute object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ResourceAttribute object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ResourceAttribute') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'ResourceAttribute') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ResourceTag: + """ + A tag associated with a resource. + + :param str name: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: (optional) The operator of an access management tag. + """ + + def __init__( + self, + name: str, + value: str, + *, + operator: Optional[str] = None, + ) -> None: + """ + Initialize a ResourceTag object. + + :param str name: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: (optional) The operator of an access management tag. + """ + self.name = name + self.value = value + self.operator = operator + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ResourceTag': + """Initialize a ResourceTag object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ResourceTag JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in ResourceTag JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ResourceTag object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator return _dict def _to_dict(self): @@ -8094,135 +9991,91 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateAssignmentCollection object.""" + """Return a `str` version of this ResourceTag object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: + def __eq__(self, other: 'ResourceTag') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: + def __ne__(self, other: 'ResourceTag') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyTemplateAssignmentItems: - """ - PolicyTemplateAssignmentItems. - - """ - - def __init__( - self, - ) -> None: - """ - Initialize a PolicyTemplateAssignmentItems object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join( - ['PolicyTemplateAssignmentItemsPolicyAssignmentV1', 'PolicyTemplateAssignmentItemsPolicyAssignment'] - ) - ) - raise Exception(msg) - - -class PolicyTemplateCollection: +class Role: """ - A collection of policy Templates. + A role resource. - :param int limit: (optional) The number of documents to include per each page of - the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following page of - requested collection. - :param Previous previous: (optional) Details with linking href to previous page - of requested collection. - :param List[PolicyTemplate] policy_templates: List of policy templates. + :param str display_name: The display the name of the role that is shown in the + console. + :param str description: (optional) The description of the role. + :param List[str] actions: The actions of the role. For more information, see + [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: + 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. """ def __init__( self, - policy_templates: List['PolicyTemplate'], + display_name: str, + actions: List[str], *, - limit: Optional[int] = None, - first: Optional['First'] = None, - next: Optional['Next'] = None, - previous: Optional['Previous'] = None, + description: Optional[str] = None, + crn: Optional[str] = None, ) -> None: """ - Initialize a PolicyTemplateCollection object. + Initialize a Role object. - :param List[PolicyTemplate] policy_templates: List of policy templates. - :param int limit: (optional) The number of documents to include per each - page of the collection. - :param First first: (optional) Details with linking href to first page of - requested collection. - :param Next next: (optional) Details with href linking to the following - page of requested collection. - :param Previous previous: (optional) Details with linking href to previous - page of requested collection. + :param str display_name: The display the name of the role that is shown in + the console. + :param List[str] actions: The actions of the role. For more information, + see [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str description: (optional) The description of the role. """ - self.limit = limit - self.first = first - self.next = next - self.previous = previous - self.policy_templates = policy_templates + self.display_name = display_name + self.description = description + self.actions = actions + self.crn = crn @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateCollection': - """Initialize a PolicyTemplateCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Role': + """Initialize a Role object from a json dictionary.""" args = {} - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit - if (first := _dict.get('first')) is not None: - args['first'] = First.from_dict(first) - if (next := _dict.get('next')) is not None: - args['next'] = Next.from_dict(next) - if (previous := _dict.get('previous')) is not None: - args['previous'] = Previous.from_dict(previous) - if (policy_templates := _dict.get('policy_templates')) is not None: - args['policy_templates'] = [PolicyTemplate.from_dict(v) for v in policy_templates] + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name else: - raise ValueError('Required property \'policy_templates\' not present in PolicyTemplateCollection JSON') + raise ValueError('Required property \'display_name\' not present in Role JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (actions := _dict.get('actions')) is not None: + args['actions'] = actions + else: + raise ValueError('Required property \'actions\' not present in Role JSON') + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateCollection object from a json dictionary.""" + """Initialize a Role object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'limit') and self.limit is not None: - _dict['limit'] = self.limit - if hasattr(self, 'first') and self.first is not None: - if isinstance(self.first, dict): - _dict['first'] = self.first - else: - _dict['first'] = self.first.to_dict() - if hasattr(self, 'next') and self.next is not None: - if isinstance(self.next, dict): - _dict['next'] = self.next - else: - _dict['next'] = self.next.to_dict() - if hasattr(self, 'previous') and self.previous is not None: - if isinstance(self.previous, dict): - _dict['previous'] = self.previous - else: - _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'policy_templates') and self.policy_templates is not None: - policy_templates_list = [] - for v in self.policy_templates: - if isinstance(v, dict): - policy_templates_list.append(v) - else: - policy_templates_list.append(v.to_dict()) - _dict['policy_templates'] = policy_templates_list + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'actions') and self.actions is not None: + _dict['actions'] = self.actions + if hasattr(self, 'crn') and getattr(self, 'crn') is not None: + _dict['crn'] = getattr(self, 'crn') return _dict def _to_dict(self): @@ -8230,188 +10083,80 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateCollection object.""" + """Return a `str` version of this Role object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateCollection') -> bool: + def __eq__(self, other: 'Role') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateCollection') -> bool: + def __ne__(self, other: 'Role') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyTemplateLimitData: +class RoleAction: """ - The core set of properties associated with the policy template. + An action that can be performed by the policy subject when assigned a role. - :param str name: Required field when creating a new template. Otherwise, this - field is optional. If the field is included, it changes the name value for all - existing versions of the template. - :param str description: (optional) Description of the policy template. This is - shown to users in the enterprise account. Use this to describe the purpose or - context of the policy for enterprise users managing IAM templates. - :param str account_id: Enterprise account ID where this template is created. - :param str version: Template version. - :param bool committed: (optional) Committed status of the template version. - :param TemplatePolicy policy: The core set of properties associated with the - template's policy object. - :param str state: State of policy template. - :param str id: (optional) The policy template ID. - :param str href: (optional) The href URL that links to the policy templates API - by policy template ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - template was created. - :param str created_by_id: (optional) The IAM ID of the entity that created the - policy template. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - template was last modified. - :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the policy template. - :param TemplateCountData counts: (optional) policy template count details. + :param str id: Unique identifier for action with structure + service.resource.action. For example, cbr.rule.read. + :param str display_name: Services defined display name for action. + :param str description: Service defined description for action. """ def __init__( self, - name: str, - account_id: str, - version: str, - policy: 'TemplatePolicy', - state: str, - *, - description: Optional[str] = None, - committed: Optional[bool] = None, - id: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - counts: Optional['TemplateCountData'] = None, + id: str, + display_name: str, + description: str, ) -> None: """ - Initialize a PolicyTemplateLimitData object. + Initialize a RoleAction object. - :param str name: Required field when creating a new template. Otherwise, - this field is optional. If the field is included, it changes the name value - for all existing versions of the template. - :param str account_id: Enterprise account ID where this template is - created. - :param str version: Template version. - :param TemplatePolicy policy: The core set of properties associated with - the template's policy object. - :param str state: State of policy template. - :param str description: (optional) Description of the policy template. This - is shown to users in the enterprise account. Use this to describe the - purpose or context of the policy for enterprise users managing IAM - templates. - :param bool committed: (optional) Committed status of the template version. - :param TemplateCountData counts: (optional) policy template count details. - """ - self.name = name - self.description = description - self.account_id = account_id - self.version = version - self.committed = committed - self.policy = policy - self.state = state + :param str id: Unique identifier for action with structure + service.resource.action. For example, cbr.rule.read. + :param str display_name: Services defined display name for action. + :param str description: Service defined description for action. + """ self.id = id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.counts = counts + self.display_name = display_name + self.description = description @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData': - """Initialize a PolicyTemplateLimitData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAction': + """Initialize a RoleAction object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name + if (id := _dict.get('id')) is not None: + args['id'] = id else: - raise ValueError('Required property \'name\' not present in PolicyTemplateLimitData JSON') + raise ValueError('Required property \'id\' not present in RoleAction JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + else: + raise ValueError('Required property \'display_name\' not present in RoleAction JSON') if (description := _dict.get('description')) is not None: args['description'] = description - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - else: - raise ValueError('Required property \'account_id\' not present in PolicyTemplateLimitData JSON') - if (version := _dict.get('version')) is not None: - args['version'] = version - else: - raise ValueError('Required property \'version\' not present in PolicyTemplateLimitData JSON') - if (committed := _dict.get('committed')) is not None: - args['committed'] = committed - if (policy := _dict.get('policy')) is not None: - args['policy'] = TemplatePolicy.from_dict(policy) - else: - raise ValueError('Required property \'policy\' not present in PolicyTemplateLimitData JSON') - if (state := _dict.get('state')) is not None: - args['state'] = state else: - raise ValueError('Required property \'state\' not present in PolicyTemplateLimitData JSON') - if (id := _dict.get('id')) is not None: - args['id'] = id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (counts := _dict.get('counts')) is not None: - args['counts'] = TemplateCountData.from_dict(counts) + raise ValueError('Required property \'description\' not present in RoleAction JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateLimitData object from a json dictionary.""" + """Initialize a RoleAction object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name if hasattr(self, 'description') and self.description is not None: _dict['description'] = self.description - if hasattr(self, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version - if hasattr(self, 'committed') and self.committed is not None: - _dict['committed'] = self.committed - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy - else: - _dict['policy'] = self.policy.to_dict() - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'counts') and self.counts is not None: - if isinstance(self.counts, dict): - _dict['counts'] = self.counts - else: - _dict['counts'] = self.counts.to_dict() return _dict def _to_dict(self): @@ -8419,126 +10164,90 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateLimitData object.""" + """Return a `str` version of this RoleAction object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateLimitData') -> bool: + def __eq__(self, other: 'RoleAction') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateLimitData') -> bool: + def __ne__(self, other: 'RoleAction') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - State of policy template. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class PolicyTemplateMetaData: +class RoleAssignment: """ - The core set of properties associated with a policy. + The set of properties associated with the assigned role template. - :param str id: (optional) The policy ID. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Customer-defined description. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) granted - by the policy. - :param List[PolicyResource] resources: The resources associated with a policy. - :param str href: (optional) The href links back to the policy. - :param datetime created_at: (optional) The UTC timestamp when the policy was - created. + :param str id: (optional) Action control assignment ID. + :param str account_id: (optional) The account GUID that the role assignments + belong to. + :param str href: (optional) The href URL that links to the role assignments API + by role assignment ID. + :param datetime created_at: (optional) The UTC timestamp when the role + assignment was created. :param str created_by_id: (optional) The IAM ID of the entity that created the - policy. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - was last modified. + role assignment. + :param datetime last_modified_at: (optional) The UTC timestamp when the role + assignment was last modified. :param str last_modified_by_id: (optional) The IAM ID of the entity that last - modified the policy. - :param str state: (optional) The policy state. - :param TemplateMetadata template: (optional) The details of the IAM template - that was used to create an enterprise-managed policy in your account. When - returned, this indicates that the policy is created from and managed by a - template in the root enterprise account. + modified the role assignment. + :param str operation: (optional) The current operation of the role assignment. + :param List[RoleAssignmentResource] resources: (optional) Resources created when + role template is assigned. + :param RoleAssignmentTemplate template: The role template id and version that + will be assigned. + :param AssignmentTargetDetails target: assignment target account and type. + :param str status: (optional) The role assignment status. """ def __init__( self, - type: str, - subjects: List['PolicySubject'], - roles: List['PolicyRole'], - resources: List['PolicyResource'], + template: 'RoleAssignmentTemplate', + target: 'AssignmentTargetDetails', *, id: Optional[str] = None, - description: Optional[str] = None, + account_id: Optional[str] = None, href: Optional[str] = None, created_at: Optional[datetime] = None, created_by_id: Optional[str] = None, last_modified_at: Optional[datetime] = None, last_modified_by_id: Optional[str] = None, - state: Optional[str] = None, - template: Optional['TemplateMetadata'] = None, + operation: Optional[str] = None, + resources: Optional[List['RoleAssignmentResource']] = None, + status: Optional[str] = None, ) -> None: """ - Initialize a PolicyTemplateMetaData object. + Initialize a RoleAssignment object. - :param str type: The policy type; either 'access' or 'authorization'. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role Cloud Resource Names (CRNs) - granted by the policy. - :param List[PolicyResource] resources: The resources associated with a - policy. - :param str description: (optional) Customer-defined description. - :param str state: (optional) The policy state. - :param TemplateMetadata template: (optional) The details of the IAM - template that was used to create an enterprise-managed policy in your - account. When returned, this indicates that the policy is created from and - managed by a template in the root enterprise account. + :param RoleAssignmentTemplate template: The role template id and version + that will be assigned. + :param AssignmentTargetDetails target: assignment target account and type. """ self.id = id - self.type = type - self.description = description - self.subjects = subjects - self.roles = roles - self.resources = resources + self.account_id = account_id self.href = href self.created_at = created_at self.created_by_id = created_by_id self.last_modified_at = last_modified_at self.last_modified_by_id = last_modified_by_id - self.state = state + self.operation = operation + self.resources = resources self.template = template + self.target = target + self.status = status @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateMetaData': - """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAssignment': + """Initialize a RoleAssignment object from a json dictionary.""" args = {} if (id := _dict.get('id')) is not None: args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type - else: - raise ValueError('Required property \'type\' not present in PolicyTemplateMetaData JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (subjects := _dict.get('subjects')) is not None: - args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] - else: - raise ValueError('Required property \'subjects\' not present in PolicyTemplateMetaData JSON') - if (roles := _dict.get('roles')) is not None: - args['roles'] = [PolicyRole.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in PolicyTemplateMetaData JSON') - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyResource.from_dict(v) for v in resources] - else: - raise ValueError('Required property \'resources\' not present in PolicyTemplateMetaData JSON') + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id if (href := _dict.get('href')) is not None: args['href'] = href if (created_at := _dict.get('created_at')) is not None: @@ -8549,15 +10258,25 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateMetaData': args['last_modified_at'] = string_to_datetime(last_modified_at) if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: args['last_modified_by_id'] = last_modified_by_id - if (state := _dict.get('state')) is not None: - args['state'] = state + if (operation := _dict.get('operation')) is not None: + args['operation'] = operation + if (resources := _dict.get('resources')) is not None: + args['resources'] = [RoleAssignmentResource.from_dict(v) for v in resources] if (template := _dict.get('template')) is not None: - args['template'] = TemplateMetadata.from_dict(template) + args['template'] = RoleAssignmentTemplate.from_dict(template) + else: + raise ValueError('Required property \'template\' not present in RoleAssignment JSON') + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + else: + raise ValueError('Required property \'target\' not present in RoleAssignment JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + """Initialize a RoleAssignment object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -8565,34 +10284,8 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'subjects') and self.subjects is not None: - subjects_list = [] - for v in self.subjects: - if isinstance(v, dict): - subjects_list.append(v) - else: - subjects_list.append(v.to_dict()) - _dict['subjects'] = subjects_list - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list + if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: + _dict['account_id'] = getattr(self, 'account_id') if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: @@ -8603,13 +10296,28 @@ def to_dict(self) -> Dict: _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state + if hasattr(self, 'operation') and getattr(self, 'operation') is not None: + _dict['operation'] = getattr(self, 'operation') + if hasattr(self, 'resources') and getattr(self, 'resources') is not None: + resources_list = [] + for v in getattr(self, 'resources'): + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list if hasattr(self, 'template') and self.template is not None: if isinstance(self.template, dict): _dict['template'] = self.template else: _dict['template'] = self.template.to_dict() + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'status') and getattr(self, 'status') is not None: + _dict['status'] = getattr(self, 'status') return _dict def _to_dict(self): @@ -8617,31 +10325,43 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateMetaData object.""" + """Return a `str` version of this RoleAssignment object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateMetaData') -> bool: + def __eq__(self, other: 'RoleAssignment') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateMetaData') -> bool: + def __ne__(self, other: 'RoleAssignment') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): + class OperationEnum(str, Enum): """ - The policy state. + The current operation of the role assignment. """ - ACTIVE = 'active' - DELETED = 'deleted' + CREATE = 'create' + APPLY = 'apply' + UPDATE = 'update' + REMOVE = 'remove' + class StatusEnum(str, Enum): + """ + The role assignment status. + """ -class PolicyTemplateVersionsCollection: + ACCEPTED = 'accepted' + FAILURE = 'failure' + IN_PROGRESS = 'in_progress' + SUPERSEDED = 'superseded' + + +class RoleAssignmentCollection: """ - A collection of versions for a specific policy template. + A collection of role assignments. :param int limit: (optional) The number of documents to include per each page of the collection. @@ -8651,12 +10371,12 @@ class PolicyTemplateVersionsCollection: requested collection. :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplate] versions: List of policy templates versions. + :param List[RoleAssignment] assignments: List of role assignments. """ def __init__( self, - versions: List['PolicyTemplate'], + assignments: List['RoleAssignment'], *, limit: Optional[int] = None, first: Optional['First'] = None, @@ -8664,9 +10384,9 @@ def __init__( previous: Optional['Previous'] = None, ) -> None: """ - Initialize a PolicyTemplateVersionsCollection object. + Initialize a RoleAssignmentCollection object. - :param List[PolicyTemplate] versions: List of policy templates versions. + :param List[RoleAssignment] assignments: List of role assignments. :param int limit: (optional) The number of documents to include per each page of the collection. :param First first: (optional) Details with linking href to first page of @@ -8680,11 +10400,11 @@ def __init__( self.first = first self.next = next self.previous = previous - self.versions = versions + self.assignments = assignments @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': - """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAssignmentCollection': + """Initialize a RoleAssignmentCollection object from a json dictionary.""" args = {} if (limit := _dict.get('limit')) is not None: args['limit'] = limit @@ -8694,15 +10414,15 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': args['next'] = Next.from_dict(next) if (previous := _dict.get('previous')) is not None: args['previous'] = Previous.from_dict(previous) - if (versions := _dict.get('versions')) is not None: - args['versions'] = [PolicyTemplate.from_dict(v) for v in versions] + if (assignments := _dict.get('assignments')) is not None: + args['assignments'] = [RoleAssignment.from_dict(v) for v in assignments] else: - raise ValueError('Required property \'versions\' not present in PolicyTemplateVersionsCollection JSON') + raise ValueError('Required property \'assignments\' not present in RoleAssignmentCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" + """Initialize a RoleAssignmentCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -8725,14 +10445,14 @@ def to_dict(self) -> Dict: _dict['previous'] = self.previous else: _dict['previous'] = self.previous.to_dict() - if hasattr(self, 'versions') and self.versions is not None: - versions_list = [] - for v in self.versions: + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: if isinstance(v, dict): - versions_list.append(v) + assignments_list.append(v) else: - versions_list.append(v.to_dict()) - _dict['versions'] = versions_list + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list return _dict def _to_dict(self): @@ -8740,67 +10460,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateVersionsCollection object.""" + """Return a `str` version of this RoleAssignmentCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + def __eq__(self, other: 'RoleAssignmentCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + def __ne__(self, other: 'RoleAssignmentCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Previous: +class RoleAssignmentResource: """ - Details with linking href to previous page of requested collection. + The role assignment resources and target where the template is assigned. - :param str href: (optional) The href linking to the page of requested - collection. - :param str start: (optional) Page token that refers to the page of the - collection. + :param AssignmentTargetDetails target: assignment target account and type. + :param RoleAssignmentResourceRole role: (optional) Set of properties of the + assigned resource or error message if assignment failed. """ def __init__( self, + target: 'AssignmentTargetDetails', *, - href: Optional[str] = None, - start: Optional[str] = None, + role: Optional['RoleAssignmentResourceRole'] = None, ) -> None: """ - Initialize a Previous object. + Initialize a RoleAssignmentResource object. - :param str start: (optional) Page token that refers to the page of the - collection. + :param AssignmentTargetDetails target: assignment target account and type. + :param RoleAssignmentResourceRole role: (optional) Set of properties of the + assigned resource or error message if assignment failed. """ - self.href = href - self.start = start + self.target = target + self.role = role @classmethod - def from_dict(cls, _dict: Dict) -> 'Previous': - """Initialize a Previous object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAssignmentResource': + """Initialize a RoleAssignmentResource object from a json dictionary.""" args = {} - if (href := _dict.get('href')) is not None: - args['href'] = href - if (start := _dict.get('start')) is not None: - args['start'] = start + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) + else: + raise ValueError('Required property \'target\' not present in RoleAssignmentResource JSON') + if (role := _dict.get('role')) is not None: + args['role'] = RoleAssignmentResourceRole.from_dict(role) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Previous object from a json dictionary.""" + """Initialize a RoleAssignmentResource object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'start') and self.start is not None: - _dict['start'] = self.start + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'role') and self.role is not None: + if isinstance(self.role, dict): + _dict['role'] = self.role + else: + _dict['role'] = self.role.to_dict() return _dict def _to_dict(self): @@ -8808,77 +10536,202 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Previous object.""" + """Return a `str` version of this RoleAssignmentResource object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Previous') -> bool: + def __eq__(self, other: 'RoleAssignmentResource') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Previous') -> bool: + def __ne__(self, other: 'RoleAssignmentResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAttribute: +class RoleAssignmentResourceCreated: """ - An attribute associated with a resource. + On success, it includes the action control assigned. - :param str name: The name of an attribute. - :param str value: The value of an attribute. - :param str operator: (optional) The operator of an attribute. + :param str id: (optional) role id. """ def __init__( self, - name: str, - value: str, *, - operator: Optional[str] = None, + id: Optional[str] = None, ) -> None: """ - Initialize a ResourceAttribute object. + Initialize a RoleAssignmentResourceCreated object. - :param str name: The name of an attribute. - :param str value: The value of an attribute. - :param str operator: (optional) The operator of an attribute. + :param str id: (optional) role id. """ - self.name = name - self.value = value - self.operator = operator + self.id = id @classmethod - def from_dict(cls, _dict: Dict) -> 'ResourceAttribute': - """Initialize a ResourceAttribute object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAssignmentResourceCreated': + """Initialize a RoleAssignmentResourceCreated object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name + if (id := _dict.get('id')) is not None: + args['id'] = id + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a RoleAssignmentResourceCreated object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this RoleAssignmentResourceCreated object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'RoleAssignmentResourceCreated') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'RoleAssignmentResourceCreated') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class RoleAssignmentResourceRole: + """ + Set of properties of the assigned resource or error message if assignment failed. + + :param RoleAssignmentResourceCreated resource_created: (optional) On success, it + includes the action control assigned. + :param AssignmentResourceError error_message: (optional) Body parameters for + assignment error. + """ + + def __init__( + self, + *, + resource_created: Optional['RoleAssignmentResourceCreated'] = None, + error_message: Optional['AssignmentResourceError'] = None, + ) -> None: + """ + Initialize a RoleAssignmentResourceRole object. + + :param RoleAssignmentResourceCreated resource_created: (optional) On + success, it includes the action control assigned. + :param AssignmentResourceError error_message: (optional) Body parameters + for assignment error. + """ + self.resource_created = resource_created + self.error_message = error_message + + @classmethod + def from_dict(cls, _dict: Dict) -> 'RoleAssignmentResourceRole': + """Initialize a RoleAssignmentResourceRole object from a json dictionary.""" + args = {} + if (resource_created := _dict.get('resource_created')) is not None: + args['resource_created'] = RoleAssignmentResourceCreated.from_dict(resource_created) + if (error_message := _dict.get('error_message')) is not None: + args['error_message'] = AssignmentResourceError.from_dict(error_message) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a RoleAssignmentResourceRole object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'resource_created') and self.resource_created is not None: + if isinstance(self.resource_created, dict): + _dict['resource_created'] = self.resource_created + else: + _dict['resource_created'] = self.resource_created.to_dict() + if hasattr(self, 'error_message') and self.error_message is not None: + if isinstance(self.error_message, dict): + _dict['error_message'] = self.error_message + else: + _dict['error_message'] = self.error_message.to_dict() + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this RoleAssignmentResourceRole object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'RoleAssignmentResourceRole') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'RoleAssignmentResourceRole') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class RoleAssignmentTemplate: + """ + The role template id and version that will be assigned. + + :param str id: Action control template ID. + :param str version: Action control template version. + """ + + def __init__( + self, + id: str, + version: str, + ) -> None: + """ + Initialize a RoleAssignmentTemplate object. + + :param str id: Action control template ID. + :param str version: Action control template version. + """ + self.id = id + self.version = version + + @classmethod + def from_dict(cls, _dict: Dict) -> 'RoleAssignmentTemplate': + """Initialize a RoleAssignmentTemplate object from a json dictionary.""" + args = {} + if (id := _dict.get('id')) is not None: + args['id'] = id else: - raise ValueError('Required property \'name\' not present in ResourceAttribute JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value + raise ValueError('Required property \'id\' not present in RoleAssignmentTemplate JSON') + if (version := _dict.get('version')) is not None: + args['version'] = version else: - raise ValueError('Required property \'value\' not present in ResourceAttribute JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator + raise ValueError('Required property \'version\' not present in RoleAssignmentTemplate JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ResourceAttribute object from a json dictionary.""" + """Initialize a RoleAssignmentTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version return _dict def _to_dict(self): @@ -8886,77 +10739,96 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ResourceAttribute object.""" + """Return a `str` version of this RoleAssignmentTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ResourceAttribute') -> bool: + def __eq__(self, other: 'RoleAssignmentTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ResourceAttribute') -> bool: + def __ne__(self, other: 'RoleAssignmentTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceTag: +class RoleCollection: """ - A tag associated with a resource. + A collection of roles returned by the 'list roles' operation. - :param str name: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: (optional) The operator of an access management tag. + :param List[CustomRole] custom_roles: List of custom roles. + :param List[Role] service_roles: List of service roles. + :param List[Role] system_roles: List of system roles. """ def __init__( self, - name: str, - value: str, - *, - operator: Optional[str] = None, + custom_roles: List['CustomRole'], + service_roles: List['Role'], + system_roles: List['Role'], ) -> None: """ - Initialize a ResourceTag object. + Initialize a RoleCollection object. - :param str name: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: (optional) The operator of an access management tag. + :param List[CustomRole] custom_roles: List of custom roles. + :param List[Role] service_roles: List of service roles. + :param List[Role] system_roles: List of system roles. """ - self.name = name - self.value = value - self.operator = operator + self.custom_roles = custom_roles + self.service_roles = service_roles + self.system_roles = system_roles @classmethod - def from_dict(cls, _dict: Dict) -> 'ResourceTag': - """Initialize a ResourceTag object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleCollection': + """Initialize a RoleCollection object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name + if (custom_roles := _dict.get('custom_roles')) is not None: + args['custom_roles'] = [CustomRole.from_dict(v) for v in custom_roles] else: - raise ValueError('Required property \'name\' not present in ResourceTag JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value + raise ValueError('Required property \'custom_roles\' not present in RoleCollection JSON') + if (service_roles := _dict.get('service_roles')) is not None: + args['service_roles'] = [Role.from_dict(v) for v in service_roles] else: - raise ValueError('Required property \'value\' not present in ResourceTag JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator + raise ValueError('Required property \'service_roles\' not present in RoleCollection JSON') + if (system_roles := _dict.get('system_roles')) is not None: + args['system_roles'] = [Role.from_dict(v) for v in system_roles] + else: + raise ValueError('Required property \'system_roles\' not present in RoleCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ResourceTag object from a json dictionary.""" + """Initialize a RoleCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator + if hasattr(self, 'custom_roles') and self.custom_roles is not None: + custom_roles_list = [] + for v in self.custom_roles: + if isinstance(v, dict): + custom_roles_list.append(v) + else: + custom_roles_list.append(v.to_dict()) + _dict['custom_roles'] = custom_roles_list + if hasattr(self, 'service_roles') and self.service_roles is not None: + service_roles_list = [] + for v in self.service_roles: + if isinstance(v, dict): + service_roles_list.append(v) + else: + service_roles_list.append(v.to_dict()) + _dict['service_roles'] = service_roles_list + if hasattr(self, 'system_roles') and self.system_roles is not None: + system_roles_list = [] + for v in self.system_roles: + if isinstance(v, dict): + system_roles_list.append(v) + else: + system_roles_list.append(v.to_dict()) + _dict['system_roles'] = system_roles_list return _dict def _to_dict(self): @@ -8964,91 +10836,181 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ResourceTag object.""" + """Return a `str` version of this RoleCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ResourceTag') -> bool: + def __eq__(self, other: 'RoleCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ResourceTag') -> bool: + def __ne__(self, other: 'RoleCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Role: +class RoleTemplate: """ - A role resource. + The set of properties associated with the role template. - :param str display_name: The display the name of the role that is shown in the - console. - :param str description: (optional) The description of the role. - :param List[str] actions: The actions of the role. For more information, see - [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: - 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. + :param str name: Required field when creating a new template. Otherwise, this + field is optional. If the field is included, it changes the name value for all + existing versions of the template. + :param str description: Description of the role template. This is shown to users + in the enterprise account. Use this to describe the purpose or context of the + role for enterprise users managing IAM templates. + :param str account_id: Enterprise account ID where this template is created. + :param bool committed: (optional) Committed status of the template. If committed + is set to true, then the template version can no longer be updated. + :param TemplateRole role: (optional) The role properties that are created in an + action resource when the template is assigned. + :param str id: (optional) The role template ID. + :param str href: (optional) The href URL that links to the role templates API by + role template ID. + :param datetime created_at: (optional) The UTC timestamp when the role template + was created. + :param str created_by_id: (optional) The IAM ID of the entity that created the + role template. + :param datetime last_modified_at: (optional) The UTC timestamp when the role + template was last modified. + :param str last_modified_by_id: (optional) The IAM ID of the entity that last + modified the role template. + :param str version: The version number of the template used to identify + different versions of same template. + :param str state: State of role template. """ def __init__( self, - display_name: str, - actions: List[str], + name: str, + description: str, + account_id: str, + version: str, + state: str, *, - description: Optional[str] = None, - crn: Optional[str] = None, + committed: Optional[bool] = None, + role: Optional['TemplateRole'] = None, + id: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, ) -> None: """ - Initialize a Role object. + Initialize a RoleTemplate object. - :param str display_name: The display the name of the role that is shown in - the console. - :param List[str] actions: The actions of the role. For more information, - see [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str description: (optional) The description of the role. + :param str name: Required field when creating a new template. Otherwise, + this field is optional. If the field is included, it changes the name value + for all existing versions of the template. + :param str description: Description of the role template. This is shown to + users in the enterprise account. Use this to describe the purpose or + context of the role for enterprise users managing IAM templates. + :param str account_id: Enterprise account ID where this template is + created. + :param str version: The version number of the template used to identify + different versions of same template. + :param str state: State of role template. + :param bool committed: (optional) Committed status of the template. If + committed is set to true, then the template version can no longer be + updated. + :param TemplateRole role: (optional) The role properties that are created + in an action resource when the template is assigned. """ - self.display_name = display_name + self.name = name self.description = description - self.actions = actions - self.crn = crn + self.account_id = account_id + self.committed = committed + self.role = role + self.id = id + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.version = version + self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'Role': - """Initialize a Role object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleTemplate': + """Initialize a RoleTemplate object from a json dictionary.""" args = {} - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'display_name\' not present in Role JSON') + raise ValueError('Required property \'name\' not present in RoleTemplate JSON') if (description := _dict.get('description')) is not None: args['description'] = description - if (actions := _dict.get('actions')) is not None: - args['actions'] = actions else: - raise ValueError('Required property \'actions\' not present in Role JSON') - if (crn := _dict.get('crn')) is not None: - args['crn'] = crn + raise ValueError('Required property \'description\' not present in RoleTemplate JSON') + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + else: + raise ValueError('Required property \'account_id\' not present in RoleTemplate JSON') + if (committed := _dict.get('committed')) is not None: + args['committed'] = committed + if (role := _dict.get('role')) is not None: + args['role'] = TemplateRole.from_dict(role) + if (id := _dict.get('id')) is not None: + args['id'] = id + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (version := _dict.get('version')) is not None: + args['version'] = version + else: + raise ValueError('Required property \'version\' not present in RoleTemplate JSON') + if (state := _dict.get('state')) is not None: + args['state'] = state + else: + raise ValueError('Required property \'state\' not present in RoleTemplate JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Role object from a json dictionary.""" + """Initialize a RoleTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'display_name') and self.display_name is not None: - _dict['display_name'] = self.display_name + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'description') and self.description is not None: _dict['description'] = self.description - if hasattr(self, 'actions') and self.actions is not None: - _dict['actions'] = self.actions - if hasattr(self, 'crn') and getattr(self, 'crn') is not None: - _dict['crn'] = getattr(self, 'crn') + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'committed') and self.committed is not None: + _dict['committed'] = self.committed + if hasattr(self, 'role') and self.role is not None: + if isinstance(self.role, dict): + _dict['role'] = self.role + else: + _dict['role'] = self.role.to_dict() + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state return _dict def _to_dict(self): @@ -9056,80 +11018,122 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Role object.""" + """Return a `str` version of this RoleTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Role') -> bool: + def __eq__(self, other: 'RoleTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Role') -> bool: + def __ne__(self, other: 'RoleTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + State of role template. + """ -class RoleAction: + ACTIVE = 'active' + DELETED = 'deleted' + + +class RoleTemplateCollection: """ - An action that can be performed by the policy subject when assigned a role. + A collection of role templates. - :param str id: Unique identifier for action with structure - service.resource.action. For example, cbr.rule.read. - :param str display_name: Services defined display name for action. - :param str description: Service defined description for action. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[RoleTemplate] role_templates: List of role templates. """ def __init__( self, - id: str, - display_name: str, - description: str, + role_templates: List['RoleTemplate'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a RoleAction object. - - :param str id: Unique identifier for action with structure - service.resource.action. For example, cbr.rule.read. - :param str display_name: Services defined display name for action. - :param str description: Service defined description for action. - """ - self.id = id - self.display_name = display_name - self.description = description + Initialize a RoleTemplateCollection object. + + :param List[RoleTemplate] role_templates: List of role templates. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. + """ + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.role_templates = role_templates @classmethod - def from_dict(cls, _dict: Dict) -> 'RoleAction': - """Initialize a RoleAction object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleTemplateCollection': + """Initialize a RoleTemplateCollection object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - else: - raise ValueError('Required property \'id\' not present in RoleAction JSON') - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - else: - raise ValueError('Required property \'display_name\' not present in RoleAction JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (role_templates := _dict.get('role_templates')) is not None: + args['role_templates'] = [RoleTemplate.from_dict(v) for v in role_templates] else: - raise ValueError('Required property \'description\' not present in RoleAction JSON') + raise ValueError('Required property \'role_templates\' not present in RoleTemplateCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RoleAction object from a json dictionary.""" + """Initialize a RoleTemplateCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id - if hasattr(self, 'display_name') and self.display_name is not None: - _dict['display_name'] = self.display_name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'role_templates') and self.role_templates is not None: + role_templates_list = [] + for v in self.role_templates: + if isinstance(v, dict): + role_templates_list.append(v) + else: + role_templates_list.append(v.to_dict()) + _dict['role_templates'] = role_templates_list return _dict def _to_dict(self): @@ -9137,96 +11141,114 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RoleAction object.""" + """Return a `str` version of this RoleTemplateCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RoleAction') -> bool: + def __eq__(self, other: 'RoleTemplateCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'RoleAction') -> bool: + def __ne__(self, other: 'RoleTemplateCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RoleCollection: +class RoleTemplateVersionsCollection: """ - A collection of roles returned by the 'list roles' operation. + A collection of versions for a specific role template. - :param List[CustomRole] custom_roles: List of custom roles. - :param List[Role] service_roles: List of service roles. - :param List[Role] system_roles: List of system roles. + :param int limit: (optional) The number of documents to include per each page of + the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following page of + requested collection. + :param Previous previous: (optional) Details with linking href to previous page + of requested collection. + :param List[RoleTemplate] versions: List of role templates versions. """ def __init__( self, - custom_roles: List['CustomRole'], - service_roles: List['Role'], - system_roles: List['Role'], + versions: List['RoleTemplate'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a RoleCollection object. + Initialize a RoleTemplateVersionsCollection object. - :param List[CustomRole] custom_roles: List of custom roles. - :param List[Role] service_roles: List of service roles. - :param List[Role] system_roles: List of system roles. + :param List[RoleTemplate] versions: List of role templates versions. + :param int limit: (optional) The number of documents to include per each + page of the collection. + :param First first: (optional) Details with linking href to first page of + requested collection. + :param Next next: (optional) Details with href linking to the following + page of requested collection. + :param Previous previous: (optional) Details with linking href to previous + page of requested collection. """ - self.custom_roles = custom_roles - self.service_roles = service_roles - self.system_roles = system_roles + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.versions = versions @classmethod - def from_dict(cls, _dict: Dict) -> 'RoleCollection': - """Initialize a RoleCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleTemplateVersionsCollection': + """Initialize a RoleTemplateVersionsCollection object from a json dictionary.""" args = {} - if (custom_roles := _dict.get('custom_roles')) is not None: - args['custom_roles'] = [CustomRole.from_dict(v) for v in custom_roles] - else: - raise ValueError('Required property \'custom_roles\' not present in RoleCollection JSON') - if (service_roles := _dict.get('service_roles')) is not None: - args['service_roles'] = [Role.from_dict(v) for v in service_roles] - else: - raise ValueError('Required property \'service_roles\' not present in RoleCollection JSON') - if (system_roles := _dict.get('system_roles')) is not None: - args['system_roles'] = [Role.from_dict(v) for v in system_roles] + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (versions := _dict.get('versions')) is not None: + args['versions'] = [RoleTemplate.from_dict(v) for v in versions] else: - raise ValueError('Required property \'system_roles\' not present in RoleCollection JSON') + raise ValueError('Required property \'versions\' not present in RoleTemplateVersionsCollection JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RoleCollection object from a json dictionary.""" + """Initialize a RoleTemplateVersionsCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'custom_roles') and self.custom_roles is not None: - custom_roles_list = [] - for v in self.custom_roles: - if isinstance(v, dict): - custom_roles_list.append(v) - else: - custom_roles_list.append(v.to_dict()) - _dict['custom_roles'] = custom_roles_list - if hasattr(self, 'service_roles') and self.service_roles is not None: - service_roles_list = [] - for v in self.service_roles: - if isinstance(v, dict): - service_roles_list.append(v) - else: - service_roles_list.append(v.to_dict()) - _dict['service_roles'] = service_roles_list - if hasattr(self, 'system_roles') and self.system_roles is not None: - system_roles_list = [] - for v in self.system_roles: + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'versions') and self.versions is not None: + versions_list = [] + for v in self.versions: if isinstance(v, dict): - system_roles_list.append(v) + versions_list.append(v) else: - system_roles_list.append(v.to_dict()) - _dict['system_roles'] = system_roles_list + versions_list.append(v.to_dict()) + _dict['versions'] = versions_list return _dict def _to_dict(self): @@ -9234,16 +11256,16 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RoleCollection object.""" + """Return a `str` version of this RoleTemplateVersionsCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RoleCollection') -> bool: + def __eq__(self, other: 'RoleTemplateVersionsCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'RoleCollection') -> bool: + def __ne__(self, other: 'RoleTemplateVersionsCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -9858,27 +11880,130 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TemplatePolicy object.""" + """Return a `str` version of this TemplatePolicy object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TemplatePolicy') -> bool: + """Return `true` when self and other are equal, false otherwise.""" + if not isinstance(other, self.__class__): + return False + return self.__dict__ == other.__dict__ + + def __ne__(self, other: 'TemplatePolicy') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class TypeEnum(str, Enum): + """ + The policy type; either 'access' or 'authorization'. + """ + + ACCESS = 'access' + AUTHORIZATION = 'authorization' + + +class TemplateRole: + """ + The role properties that are created in an action resource when the template is + assigned. + + :param str name: The name of the role that is used in the CRN. This must be + alphanumeric and capitalized. + :param str display_name: The display the name of the role that is shown in the + console. + :param str service_name: The service name that the role refers. + :param str description: (optional) Description of the role. + :param List[str] actions: The actions of the role. + """ + + def __init__( + self, + name: str, + display_name: str, + service_name: str, + actions: List[str], + *, + description: Optional[str] = None, + ) -> None: + """ + Initialize a TemplateRole object. + + :param str name: The name of the role that is used in the CRN. This must be + alphanumeric and capitalized. + :param str display_name: The display the name of the role that is shown in + the console. + :param str service_name: The service name that the role refers. + :param List[str] actions: The actions of the role. + :param str description: (optional) Description of the role. + """ + self.name = name + self.display_name = display_name + self.service_name = service_name + self.description = description + self.actions = actions + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TemplateRole': + """Initialize a TemplateRole object from a json dictionary.""" + args = {} + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in TemplateRole JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + else: + raise ValueError('Required property \'display_name\' not present in TemplateRole JSON') + if (service_name := _dict.get('service_name')) is not None: + args['service_name'] = service_name + else: + raise ValueError('Required property \'service_name\' not present in TemplateRole JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (actions := _dict.get('actions')) is not None: + args['actions'] = actions + else: + raise ValueError('Required property \'actions\' not present in TemplateRole JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TemplateRole object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name + if hasattr(self, 'service_name') and self.service_name is not None: + _dict['service_name'] = self.service_name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'actions') and self.actions is not None: + _dict['actions'] = self.actions + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this TemplateRole object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TemplatePolicy') -> bool: + def __eq__(self, other: 'TemplateRole') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'TemplatePolicy') -> bool: + def __ne__(self, other: 'TemplateRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): - """ - The policy type; either 'access' or 'authorization'. - """ - - ACCESS = 'access' - AUTHORIZATION = 'authorization' - class V2Policy: """ @@ -12657,3 +14782,269 @@ def get_all(self) -> List[dict]: next_page = self.get_next() results.extend(next_page) return results + + +class RoleTemplatesPager: + """ + RoleTemplatesPager can be used to simplify the use of the "list_role_templates" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + name: str = None, + role_name: str = None, + role_service_name: str = None, + state: str = None, + limit: int = None, + ) -> None: + """ + Initialize a RoleTemplatesPager object. + :param str account_id: The account GUID that the role templates belong to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str name: (optional) The role template name. + :param str role_name: (optional) The template role name. + :param str role_service_name: (optional) The template role service name. + :param str state: (optional) The role template state. + :param int limit: (optional) The number of documents to include in the + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._accept_language = accept_language + self._name = name + self._role_name = role_name + self._role_service_name = role_service_name + self._state = state + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of RoleTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_role_templates( + account_id=self._account_id, + accept_language=self._accept_language, + name=self._name, + role_name=self._role_name, + role_service_name=self._role_service_name, + state=self._state, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('role_templates') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of RoleTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class RoleTemplateVersionsPager: + """ + RoleTemplateVersionsPager can be used to simplify the use of the "list_role_template_versions" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + role_template_id: str, + state: str = None, + limit: int = None, + ) -> None: + """ + Initialize a RoleTemplateVersionsPager object. + :param str role_template_id: The role template ID. + :param str state: (optional) Role template state. + :param int limit: (optional) The number of documents to include in the + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._role_template_id = role_template_id + self._state = state + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of RoleTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_role_template_versions( + role_template_id=self._role_template_id, + state=self._state, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('versions') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of RoleTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class RoleAssignmentsPager: + """ + RoleAssignmentsPager can be used to simplify the use of the "list_role_assignments" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + template_id: str = None, + template_version: str = None, + limit: int = None, + ) -> None: + """ + Initialize a RoleAssignmentsPager object. + :param str account_id: The account GUID in which the role assignment + belongs to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str template_id: (optional) Optional template ID. + :param str template_version: (optional) Optional role template version. + :param int limit: (optional) The number of documents to include in the + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._accept_language = accept_language + self._template_id = template_id + self._template_version = template_version + self._limit = limit + + def has_next(self) -> bool: + """ + Returns true if there are potentially more results to be retrieved. + """ + return self._has_next + + def get_next(self) -> List[dict]: + """ + Returns the next page of results. + :return: A List[dict], where each element is a dict that represents an instance of RoleAssignment. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_role_assignments( + account_id=self._account_id, + accept_language=self._accept_language, + template_id=self._template_id, + template_version=self._template_version, + limit=self._limit, + start=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = next_page_link.get('start') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('assignments') + + def get_all(self) -> List[dict]: + """ + Returns all results by invoking get_next() repeatedly + until all pages of results have been retrieved. + :return: A List[dict], where each element is a dict that represents an instance of RoleAssignment. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results diff --git a/test/integration/test_iam_policy_management_v1.py b/test/integration/test_iam_policy_management_v1.py index 5a762fc..6f4908f 100644 --- a/test/integration/test_iam_policy_management_v1.py +++ b/test/integration/test_iam_policy_management_v1.py @@ -152,6 +152,12 @@ def setUpClass(cls): cls.testActionControlTemplateUpdateVersion = "" cls.testActionControlTemplateETag = "" cls.testActionControlAssignmentEtag = "" + cls.testRoleTemplateName = 'TestRole' + cls.testTemplatePrefix + str(random.randint(0, 99999)) + cls.testRoleTemplateId = "" + cls.testRoleTemplateVersion = "" + cls.testRoleTemplateEtag = "" + cls.testRoleTemplateAssignmentId = "" + cls.testRoleTemplateAssignmentEtag = "" print('\nSetup complete.') @@ -1317,3 +1323,318 @@ def test_51_delete_action_control_template(self): action_control_template_id=self.testActionControlTemplateId, ) assert response.get_status_code() == 204 + + def test_52_create_role_template(self): + # Construct a dict representation of a TemplateRole model + template_role_model = { + 'name': self.testCustomRoleName, + 'display_name': 'SDK Test Custom Role', + 'service_name': 'iam-groups', + 'description': 'SDK Test Custom Role', + 'actions': ['iam-groups.groups.read'], + } + + response = self.service.create_role_template( + name=self.testRoleTemplateName, + account_id=self.testAccountId, + description='SDK Role Template Desc', + role=template_role_model, + ) + + assert response is not None + + assert response.get_status_code() == 201 + + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplate.from_dict(result_dict) + print("Create Role Template: ", result) + + assert result is not None + + self.__class__.testRoleTemplateId = result.id + self.__class__.testRoleTemplateVersion = result.version + + def test_53_get_role_template(self): + response = self.service.get_role_template( + role_template_id=self.testRoleTemplateId, + state='active', + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplate.from_dict(result_dict) + print("Get Role Template: ", result) + + self.__class__.testRoleTemplateEtag = response.get_headers().get(self.etagHeader) + + def test_54_replace_role_template(self): + # Construct a dict representation of a TemplateRole model + template_role_model = { + 'name': self.testCustomRoleName, + 'display_name': 'SDK Test Custom Role', + 'service_name': 'iam-groups', + 'description': 'SDK Test Custom Role', + 'actions': ['iam-groups.groups.delete'], + } + + response = self.service.replace_role_template( + role_template_id=self.testRoleTemplateId, + version=self.testRoleTemplateVersion, + if_match=self.testRoleTemplateEtag, + role=template_role_model, + description='SDK Replace Role Template Desc', + committed=True, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplate.from_dict(result_dict) + assert result is not None + print("Replace Role Template: ", result) + + def test_55_list_role_templates(self): + response = self.service.list_role_templates( + account_id=self.testAccountId, + state='active', + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplateCollection.from_dict(result_dict) + assert result is not None + print("List Role Template: ", result) + + def test_56_list_role_templates_with_pager(self): + all_results = [] + + # Test get_next(). + pager = RoleTemplatesPager( + client=self.service, + account_id=self.testAccountId, + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + # Test get_all(). + pager = RoleTemplatesPager( + client=self.service, + account_id=self.testAccountId, + state='active', + limit=10, + ) + all_items = pager.get_all() + assert all_items is not None + + assert len(all_results) == len(all_items) + print(f'\nlist_role_templates() returned a total of {len(all_results)} items(s) using RoleTemplatesPager.') + + def test_57_create_role_template_version(self): + # Construct a dict representation of a TemplateRole model + template_role_model = { + 'name': 'SDKTestRoleVer', + 'display_name': 'SDK Test Custom Role ver', + 'service_name': 'iam-groups', + 'description': 'SDK Test Custom Role ver', + 'actions': ['iam-groups.groups.delete', 'iam-groups.groups.create'], + } + + response = self.service.create_role_template_version( + role_template_id=self.testRoleTemplateId, + role=template_role_model, + description='iam-groups role version test', + ) + + assert response.get_status_code() == 201 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplate.from_dict(result_dict) + assert result is not None + + self.__class__.testRoleTemplateVersion = result.version + print("Create Role Template Version: ", result) + + def test_58_list_role_template_versions(self): + response = self.service.list_role_template_versions( + role_template_id=self.testRoleTemplateId, + state='active', + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplateVersionsCollection.from_dict(result_dict) + assert result is not None + print("List Role Template Versions: ", result) + + def test_59_list_role_template_versions_with_pager(self): + all_results = [] + + # Test get_next(). + pager = RoleTemplateVersionsPager( + client=self.service, + role_template_id=self.testRoleTemplateId, + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + # Test get_all(). + pager = RoleTemplateVersionsPager( + client=self.service, + role_template_id=self.testRoleTemplateId, + state='active', + limit=10, + ) + all_items = pager.get_all() + assert all_items is not None + + assert len(all_results) == len(all_items) + print( + f'\nlist_role_template_versions() returned a total of {len(all_results)} items(s) using RoleTemplateVersionsPager.' + ) + + def test_60_get_role_template_version(self): + response = self.service.get_role_template_version( + role_template_id=self.testRoleTemplateId, + version=self.testRoleTemplateVersion, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleTemplate.from_dict(result_dict) + assert result is not None + print("List Role Template Versions: ", result) + + def test_61_commit_role_template(self): + response = self.service.commit_role_template( + role_template_id=self.testRoleTemplateId, + version=self.testRoleTemplateVersion, + ) + + assert response.get_status_code() == 204 + + def test_62_create_role_template_assignment(self): + # Construct a dict representation of a AssignmentTargetDetails model + assignment_target_details_model = { + 'type': 'Account', + 'id': self.testTargetAccountId, + } + # Construct a dict representation of a RoleAssignmentTemplate model + role_assignment_template_model = { + 'id': self.testRoleTemplateId, + 'version': self.testRoleTemplateVersion, + } + + response = self.service.create_role_template_assignment( + target=assignment_target_details_model, + templates=[role_assignment_template_model], + ) + + assert response.get_status_code() == 201 + result_dict = response.get_result() + assert result_dict is not None + + result = RoleAssignmentCollection.from_dict(result_dict) + assert result is not None + self.__class__.testRoleTemplateAssignmentId = result.assignments[0].id + self.__class__.testRoleTemplateAssignmentEtag = response.get_headers().get(self.etagHeader) + + print("Create Role Template Assignment: ", result) + + def test_63_get_role_assignment(self): + assert self.testRoleTemplateAssignmentId + print("Assignment ID: ", self.testRoleTemplateAssignmentId) + response = self.service.get_role_assignment( + assignment_id=self.testRoleTemplateAssignmentId, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + def test_64_list_role_assignments(self): + response = self.service.list_role_assignments( + account_id=self.testAccountId, + ) + + assert response.get_status_code() == 200 + role_assignment_collection = response.get_result() + assert role_assignment_collection is not None + + def test_65_list_role_assignments_with_pager(self): + all_results = [] + + # Test get_next(). + pager = RoleAssignmentsPager( + client=self.service, + account_id=self.testAccountId, + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + # Test get_all(). + pager = RoleAssignmentsPager( + client=self.service, + account_id=self.testAccountId, + limit=10, + ) + all_items = pager.get_all() + assert all_items is not None + + assert len(all_results) == len(all_items) + print(f'\nlist_role_assignments() returned a total of {len(all_results)} items(s) using RoleAssignmentsPager.') + + def test_66_update_role_assignment(self): + response = self.service.update_role_assignment( + assignment_id=self.testRoleTemplateAssignmentId, + if_match=self.testRoleTemplateAssignmentEtag, + template_version=self.testRoleTemplateVersion, + ) + + assert response.get_status_code() == 200 + role_assignment = response.get_result() + assert role_assignment is not None + + def test_67_delete_role_assignment(self): + response = self.service.delete_role_assignment( + assignment_id=self.testRoleTemplateAssignmentId, + ) + + assert response.get_status_code() == 204 + + def test_68_delete_role_template_version(self): + response = self.service.delete_role_template_version( + role_template_id=self.testRoleTemplateId, + version=self.testRoleTemplateVersion, + ) + + assert response.get_status_code() == 204 + + def test_69_delete_role_template(self): + response = self.service.delete_role_template( + role_template_id=self.testRoleTemplateId, + ) + + assert response.get_status_code() == 204 diff --git a/test/unit/test_iam_policy_management_v1.py b/test/unit/test_iam_policy_management_v1.py index 3fd2919..5371653 100644 --- a/test/unit/test_iam_policy_management_v1.py +++ b/test/unit/test_iam_policy_management_v1.py @@ -4293,7 +4293,7 @@ def test_list_policy_assignments_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -4352,7 +4352,7 @@ def test_list_policy_assignments_required_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -4397,7 +4397,7 @@ def test_list_policy_assignments_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -4436,8 +4436,8 @@ def test_list_policy_assignments_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/v1/policy_assignments') - mock_response1 = '{"next":{"start":"1"},"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' - mock_response2 = '{"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' + mock_response1 = '{"next":{"start":"1"},"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' responses.add( responses.GET, url, @@ -4477,8 +4477,8 @@ def test_list_policy_assignments_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/v1/policy_assignments') - mock_response1 = '{"next":{"start":"1"},"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' - mock_response2 = '{"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' + mock_response1 = '{"next":{"start":"1"},"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"target":{"type":"Account","id":"id"},"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","resources":[{"target":{"type":"Account","id":"id"},"policy":{"resource_created":{"id":"id"},"status":"status","error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"subject":{"id":"id","type":"iam_id"},"template":{"id":"id","version":"version"},"status":"in_progress"}],"total_count":2,"limit":1}' responses.add( responses.GET, url, @@ -4521,7 +4521,7 @@ def test_create_policy_template_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.POST, url, @@ -4583,7 +4583,7 @@ def test_create_policy_template_assignment_required_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.POST, url, @@ -4643,7 +4643,7 @@ def test_create_policy_template_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.POST, url, @@ -4700,7 +4700,7 @@ def test_get_policy_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments/testString') - mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' + mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' responses.add( responses.GET, url, @@ -4744,7 +4744,7 @@ def test_get_policy_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments/testString') - mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' + mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' responses.add( responses.GET, url, @@ -4789,7 +4789,7 @@ def test_update_policy_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments/testString') - mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' + mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' responses.add( responses.PATCH, url, @@ -4840,7 +4840,7 @@ def test_update_policy_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_assignments/testString') - mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' + mock_response = '{"target": {"type": "Account", "id": "id"}, "id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "resources": [{"target": {"type": "Account", "id": "id"}, "policy": {"resource_created": {"id": "id"}, "status": "status", "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}' responses.add( responses.PATCH, url, @@ -6644,7 +6644,7 @@ def test_list_action_control_assignments_all_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.GET, url, @@ -6700,7 +6700,7 @@ def test_list_action_control_assignments_required_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.GET, url, @@ -6742,7 +6742,7 @@ def test_list_action_control_assignments_value_error(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.GET, url, @@ -6779,8 +6779,8 @@ def test_list_action_control_assignments_with_pager_get_next(self): """ # Set up a two-page mock response url = preprocess_url('/v1/action_control_assignments') - mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' - mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' responses.add( responses.GET, url, @@ -6819,8 +6819,8 @@ def test_list_action_control_assignments_with_pager_get_all(self): """ # Set up a two-page mock response url = preprocess_url('/v1/action_control_assignments') - mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' - mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"trace":"trace","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}],"status_code":0}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"action_control":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' responses.add( responses.GET, url, @@ -6862,7 +6862,7 @@ def test_create_action_control_template_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.POST, url, @@ -6918,7 +6918,7 @@ def test_create_action_control_template_assignment_required_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.POST, url, @@ -6972,7 +6972,7 @@ def test_create_action_control_template_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments') - mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' responses.add( responses.POST, url, @@ -7027,7 +7027,7 @@ def test_get_action_control_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments/testString') - mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' responses.add( responses.GET, url, @@ -7065,7 +7065,7 @@ def test_get_action_control_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments/testString') - mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' responses.add( responses.GET, url, @@ -7108,7 +7108,7 @@ def test_update_action_control_assignment_all_params(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments/testString') - mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' responses.add( responses.PATCH, url, @@ -7153,7 +7153,7 @@ def test_update_action_control_assignment_value_error(self): """ # Set up mock url = preprocess_url('/v1/action_control_assignments/testString') - mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"trace": "trace", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}], "status_code": 0}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "action_control": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' responses.add( responses.PATCH, url, @@ -7268,6 +7268,2010 @@ def test_delete_action_control_assignment_value_error_with_retries(self): # End of Service: ActionControlAssignments ############################################################################## +############################################################################## +# Start of Service: RoleTemplates +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = IamPolicyManagementV1.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, IamPolicyManagementV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = IamPolicyManagementV1.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestListRoleTemplates: + """ + Test Class for list_role_templates + """ + + @responses.activate + def test_list_role_templates_all_params(self): + """ + list_role_templates() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "role_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + accept_language = 'default' + name = 'testString' + role_name = 'testString' + role_service_name = 'testString' + state = 'active' + limit = 50 + start = 'testString' + + # Invoke method + response = _service.list_role_templates( + account_id, + accept_language=accept_language, + name=name, + role_name=role_name, + role_service_name=role_service_name, + state=state, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + assert 'name={}'.format(name) in query_string + assert 'role_name={}'.format(role_name) in query_string + assert 'role_service_name={}'.format(role_service_name) in query_string + assert 'state={}'.format(state) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_role_templates_all_params_with_retries(self): + # Enable retries and run test_list_role_templates_all_params. + _service.enable_retries() + self.test_list_role_templates_all_params() + + # Disable retries and run test_list_role_templates_all_params. + _service.disable_retries() + self.test_list_role_templates_all_params() + + @responses.activate + def test_list_role_templates_required_params(self): + """ + test_list_role_templates_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "role_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + + # Invoke method + response = _service.list_role_templates( + account_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + + def test_list_role_templates_required_params_with_retries(self): + # Enable retries and run test_list_role_templates_required_params. + _service.enable_retries() + self.test_list_role_templates_required_params() + + # Disable retries and run test_list_role_templates_required_params. + _service.disable_retries() + self.test_list_role_templates_required_params() + + @responses.activate + def test_list_role_templates_value_error(self): + """ + test_list_role_templates_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "role_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_role_templates(**req_copy) + + def test_list_role_templates_value_error_with_retries(self): + # Enable retries and run test_list_role_templates_value_error. + _service.enable_retries() + self.test_list_role_templates_value_error() + + # Disable retries and run test_list_role_templates_value_error. + _service.disable_retries() + self.test_list_role_templates_value_error() + + @responses.activate + def test_list_role_templates_with_pager_get_next(self): + """ + test_list_role_templates_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_templates') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"role_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}]}' + mock_response2 = '{"total_count":2,"limit":1,"role_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = RoleTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + name='testString', + role_name='testString', + role_service_name='testString', + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_role_templates_with_pager_get_all(self): + """ + test_list_role_templates_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_templates') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"role_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}]}' + mock_response2 = '{"total_count":2,"limit":1,"role_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}]}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = RoleTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + name='testString', + role_name='testString', + role_service_name='testString', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateRoleTemplate: + """ + Test Class for create_role_template + """ + + @responses.activate + def test_create_role_template_all_params(self): + """ + create_role_template() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + role = template_role_model + accept_language = 'default' + + # Invoke method + response = _service.create_role_template( + name, + account_id, + description=description, + committed=committed, + role=role, + accept_language=accept_language, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'testString' + assert req_body['account_id'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['committed'] == True + assert req_body['role'] == template_role_model + + def test_create_role_template_all_params_with_retries(self): + # Enable retries and run test_create_role_template_all_params. + _service.enable_retries() + self.test_create_role_template_all_params() + + # Disable retries and run test_create_role_template_all_params. + _service.disable_retries() + self.test_create_role_template_all_params() + + @responses.activate + def test_create_role_template_required_params(self): + """ + test_create_role_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + role = template_role_model + + # Invoke method + response = _service.create_role_template( + name, + account_id, + description=description, + committed=committed, + role=role, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'testString' + assert req_body['account_id'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['committed'] == True + assert req_body['role'] == template_role_model + + def test_create_role_template_required_params_with_retries(self): + # Enable retries and run test_create_role_template_required_params. + _service.enable_retries() + self.test_create_role_template_required_params() + + # Disable retries and run test_create_role_template_required_params. + _service.disable_retries() + self.test_create_role_template_required_params() + + @responses.activate + def test_create_role_template_value_error(self): + """ + test_create_role_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + role = template_role_model + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "name": name, + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_role_template(**req_copy) + + def test_create_role_template_value_error_with_retries(self): + # Enable retries and run test_create_role_template_value_error. + _service.enable_retries() + self.test_create_role_template_value_error() + + # Disable retries and run test_create_role_template_value_error. + _service.disable_retries() + self.test_create_role_template_value_error() + + +class TestGetRoleTemplate: + """ + Test Class for get_role_template + """ + + @responses.activate + def test_get_role_template_all_params(self): + """ + get_role_template() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + state = 'active' + + # Invoke method + response = _service.get_role_template( + role_template_id, + state=state, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'state={}'.format(state) in query_string + + def test_get_role_template_all_params_with_retries(self): + # Enable retries and run test_get_role_template_all_params. + _service.enable_retries() + self.test_get_role_template_all_params() + + # Disable retries and run test_get_role_template_all_params. + _service.disable_retries() + self.test_get_role_template_all_params() + + @responses.activate + def test_get_role_template_required_params(self): + """ + test_get_role_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Invoke method + response = _service.get_role_template( + role_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_role_template_required_params_with_retries(self): + # Enable retries and run test_get_role_template_required_params. + _service.enable_retries() + self.test_get_role_template_required_params() + + # Disable retries and run test_get_role_template_required_params. + _service.disable_retries() + self.test_get_role_template_required_params() + + @responses.activate + def test_get_role_template_value_error(self): + """ + test_get_role_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_role_template(**req_copy) + + def test_get_role_template_value_error_with_retries(self): + # Enable retries and run test_get_role_template_value_error. + _service.enable_retries() + self.test_get_role_template_value_error() + + # Disable retries and run test_get_role_template_value_error. + _service.disable_retries() + self.test_get_role_template_value_error() + + +class TestDeleteRoleTemplate: + """ + Test Class for delete_role_template + """ + + @responses.activate + def test_delete_role_template_all_params(self): + """ + delete_role_template() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Invoke method + response = _service.delete_role_template( + role_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_role_template_all_params_with_retries(self): + # Enable retries and run test_delete_role_template_all_params. + _service.enable_retries() + self.test_delete_role_template_all_params() + + # Disable retries and run test_delete_role_template_all_params. + _service.disable_retries() + self.test_delete_role_template_all_params() + + @responses.activate + def test_delete_role_template_value_error(self): + """ + test_delete_role_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_role_template(**req_copy) + + def test_delete_role_template_value_error_with_retries(self): + # Enable retries and run test_delete_role_template_value_error. + _service.enable_retries() + self.test_delete_role_template_value_error() + + # Disable retries and run test_delete_role_template_value_error. + _service.disable_retries() + self.test_delete_role_template_value_error() + + +class TestCreateRoleTemplateVersion: + """ + Test Class for create_role_template_version + """ + + @responses.activate + def test_create_role_template_version_all_params(self): + """ + create_role_template_version() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + role_template_id = 'testString' + role = template_role_model + name = 'testString' + description = 'testString' + committed = True + + # Invoke method + response = _service.create_role_template_version( + role_template_id, + role, + name=name, + description=description, + committed=committed, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['role'] == template_role_model + assert req_body['name'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['committed'] == True + + def test_create_role_template_version_all_params_with_retries(self): + # Enable retries and run test_create_role_template_version_all_params. + _service.enable_retries() + self.test_create_role_template_version_all_params() + + # Disable retries and run test_create_role_template_version_all_params. + _service.disable_retries() + self.test_create_role_template_version_all_params() + + @responses.activate + def test_create_role_template_version_value_error(self): + """ + test_create_role_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + role_template_id = 'testString' + role = template_role_model + name = 'testString' + description = 'testString' + committed = True + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + "role": role, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_role_template_version(**req_copy) + + def test_create_role_template_version_value_error_with_retries(self): + # Enable retries and run test_create_role_template_version_value_error. + _service.enable_retries() + self.test_create_role_template_version_value_error() + + # Disable retries and run test_create_role_template_version_value_error. + _service.disable_retries() + self.test_create_role_template_version_value_error() + + +class TestListRoleTemplateVersions: + """ + Test Class for list_role_template_versions + """ + + @responses.activate + def test_list_role_template_versions_all_params(self): + """ + list_role_template_versions() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "versions": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + state = 'active' + limit = 50 + start = 'testString' + + # Invoke method + response = _service.list_role_template_versions( + role_template_id, + state=state, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'state={}'.format(state) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_role_template_versions_all_params_with_retries(self): + # Enable retries and run test_list_role_template_versions_all_params. + _service.enable_retries() + self.test_list_role_template_versions_all_params() + + # Disable retries and run test_list_role_template_versions_all_params. + _service.disable_retries() + self.test_list_role_template_versions_all_params() + + @responses.activate + def test_list_role_template_versions_required_params(self): + """ + test_list_role_template_versions_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "versions": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Invoke method + response = _service.list_role_template_versions( + role_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_role_template_versions_required_params_with_retries(self): + # Enable retries and run test_list_role_template_versions_required_params. + _service.enable_retries() + self.test_list_role_template_versions_required_params() + + # Disable retries and run test_list_role_template_versions_required_params. + _service.disable_retries() + self.test_list_role_template_versions_required_params() + + @responses.activate + def test_list_role_template_versions_value_error(self): + """ + test_list_role_template_versions_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "versions": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_role_template_versions(**req_copy) + + def test_list_role_template_versions_value_error_with_retries(self): + # Enable retries and run test_list_role_template_versions_value_error. + _service.enable_retries() + self.test_list_role_template_versions_value_error() + + # Disable retries and run test_list_role_template_versions_value_error. + _service.disable_retries() + self.test_list_role_template_versions_value_error() + + @responses.activate + def test_list_role_template_versions_with_pager_get_next(self): + """ + test_list_role_template_versions_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}],"total_count":2,"limit":1}' + mock_response2 = '{"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = RoleTemplateVersionsPager( + client=_service, + role_template_id='testString', + state='active', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_role_template_versions_with_pager_get_all(self): + """ + test_list_role_template_versions_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}],"total_count":2,"limit":1}' + mock_response2 = '{"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"role":{"name":"name","display_name":"display_name","service_name":"service_name","description":"description","actions":["actions"]},"id":"id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","version":"version","state":"active"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = RoleTemplateVersionsPager( + client=_service, + role_template_id='testString', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestReplaceRoleTemplate: + """ + Test Class for replace_role_template + """ + + @responses.activate + def test_replace_role_template_all_params(self): + """ + replace_role_template() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + if_match = 'testString' + role = template_role_model + name = 'testString' + description = 'testString' + committed = True + + # Invoke method + response = _service.replace_role_template( + role_template_id, + version, + if_match, + role, + name=name, + description=description, + committed=committed, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['role'] == template_role_model + assert req_body['name'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['committed'] == True + + def test_replace_role_template_all_params_with_retries(self): + # Enable retries and run test_replace_role_template_all_params. + _service.enable_retries() + self.test_replace_role_template_all_params() + + # Disable retries and run test_replace_role_template_all_params. + _service.disable_retries() + self.test_replace_role_template_all_params() + + @responses.activate + def test_replace_role_template_value_error(self): + """ + test_replace_role_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.PUT, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a TemplateRole model + template_role_model = {} + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + if_match = 'testString' + role = template_role_model + name = 'testString' + description = 'testString' + committed = True + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + "version": version, + "if_match": if_match, + "role": role, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.replace_role_template(**req_copy) + + def test_replace_role_template_value_error_with_retries(self): + # Enable retries and run test_replace_role_template_value_error. + _service.enable_retries() + self.test_replace_role_template_value_error() + + # Disable retries and run test_replace_role_template_value_error. + _service.disable_retries() + self.test_replace_role_template_value_error() + + +class TestDeleteRoleTemplateVersion: + """ + Test Class for delete_role_template_version + """ + + @responses.activate + def test_delete_role_template_version_all_params(self): + """ + delete_role_template_version() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.delete_role_template_version( + role_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_role_template_version_all_params_with_retries(self): + # Enable retries and run test_delete_role_template_version_all_params. + _service.enable_retries() + self.test_delete_role_template_version_all_params() + + # Disable retries and run test_delete_role_template_version_all_params. + _service.disable_retries() + self.test_delete_role_template_version_all_params() + + @responses.activate + def test_delete_role_template_version_value_error(self): + """ + test_delete_role_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + "version": version, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_role_template_version(**req_copy) + + def test_delete_role_template_version_value_error_with_retries(self): + # Enable retries and run test_delete_role_template_version_value_error. + _service.enable_retries() + self.test_delete_role_template_version_value_error() + + # Disable retries and run test_delete_role_template_version_value_error. + _service.disable_retries() + self.test_delete_role_template_version_value_error() + + +class TestGetRoleTemplateVersion: + """ + Test Class for get_role_template_version + """ + + @responses.activate + def test_get_role_template_version_all_params(self): + """ + get_role_template_version() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.get_role_template_version( + role_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_role_template_version_all_params_with_retries(self): + # Enable retries and run test_get_role_template_version_all_params. + _service.enable_retries() + self.test_get_role_template_version_all_params() + + # Disable retries and run test_get_role_template_version_all_params. + _service.disable_retries() + self.test_get_role_template_version_all_params() + + @responses.activate + def test_get_role_template_version_value_error(self): + """ + test_get_role_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "role": {"name": "name", "display_name": "display_name", "service_name": "service_name", "description": "description", "actions": ["actions"]}, "id": "id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "version": "version", "state": "active"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + "version": version, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_role_template_version(**req_copy) + + def test_get_role_template_version_value_error_with_retries(self): + # Enable retries and run test_get_role_template_version_value_error. + _service.enable_retries() + self.test_get_role_template_version_value_error() + + # Disable retries and run test_get_role_template_version_value_error. + _service.disable_retries() + self.test_get_role_template_version_value_error() + + +class TestCommitRoleTemplate: + """ + Test Class for commit_role_template + """ + + @responses.activate + def test_commit_role_template_all_params(self): + """ + commit_role_template() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.commit_role_template( + role_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_commit_role_template_all_params_with_retries(self): + # Enable retries and run test_commit_role_template_all_params. + _service.enable_retries() + self.test_commit_role_template_all_params() + + # Disable retries and run test_commit_role_template_all_params. + _service.disable_retries() + self.test_commit_role_template_all_params() + + @responses.activate + def test_commit_role_template_value_error(self): + """ + test_commit_role_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + role_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "role_template_id": role_template_id, + "version": version, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.commit_role_template(**req_copy) + + def test_commit_role_template_value_error_with_retries(self): + # Enable retries and run test_commit_role_template_value_error. + _service.enable_retries() + self.test_commit_role_template_value_error() + + # Disable retries and run test_commit_role_template_value_error. + _service.disable_retries() + self.test_commit_role_template_value_error() + + +# endregion +############################################################################## +# End of Service: RoleTemplates +############################################################################## + +############################################################################## +# Start of Service: RoleAssignments +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = IamPolicyManagementV1.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, IamPolicyManagementV1) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = IamPolicyManagementV1.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestListRoleAssignments: + """ + Test Class for list_role_assignments + """ + + @responses.activate + def test_list_role_assignments_all_params(self): + """ + list_role_assignments() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + accept_language = 'default' + template_id = 'testString' + template_version = 'testString' + limit = 50 + start = 'testString' + + # Invoke method + response = _service.list_role_assignments( + account_id, + accept_language=accept_language, + template_id=template_id, + template_version=template_version, + limit=limit, + start=start, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + assert 'template_id={}'.format(template_id) in query_string + assert 'template_version={}'.format(template_version) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_role_assignments_all_params_with_retries(self): + # Enable retries and run test_list_role_assignments_all_params. + _service.enable_retries() + self.test_list_role_assignments_all_params() + + # Disable retries and run test_list_role_assignments_all_params. + _service.disable_retries() + self.test_list_role_assignments_all_params() + + @responses.activate + def test_list_role_assignments_required_params(self): + """ + test_list_role_assignments_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + + # Invoke method + response = _service.list_role_assignments( + account_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + + def test_list_role_assignments_required_params_with_retries(self): + # Enable retries and run test_list_role_assignments_required_params. + _service.enable_retries() + self.test_list_role_assignments_required_params() + + # Disable retries and run test_list_role_assignments_required_params. + _service.disable_retries() + self.test_list_role_assignments_required_params() + + @responses.activate + def test_list_role_assignments_value_error(self): + """ + test_list_role_assignments_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_role_assignments(**req_copy) + + def test_list_role_assignments_value_error_with_retries(self): + # Enable retries and run test_list_role_assignments_value_error. + _service.enable_retries() + self.test_list_role_assignments_value_error() + + # Disable retries and run test_list_role_assignments_value_error. + _service.disable_retries() + self.test_list_role_assignments_value_error() + + @responses.activate + def test_list_role_assignments_with_pager_get_next(self): + """ + test_list_role_assignments_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_assignments') + mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"role":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"role":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + all_results = [] + pager = RoleAssignmentsPager( + client=_service, + account_id='testString', + accept_language='default', + template_id='testString', + template_version='testString', + limit=10, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + assert len(all_results) == 2 + + @responses.activate + def test_list_role_assignments_with_pager_get_all(self): + """ + test_list_role_assignments_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/role_assignments') + mock_response1 = '{"next":{"start":"1"},"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"role":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + mock_response2 = '{"assignments":[{"id":"id","account_id":"account_id","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","operation":"create","resources":[{"target":{"type":"Account","id":"id"},"role":{"resource_created":{"id":"id"},"error_message":{"name":"name","errorCode":"error_code","message":"message","code":"code","errors":[{"code":"insufficent_permissions","message":"message","details":{"conflicts_with":{"etag":"etag","role":"role","policy":"policy"}},"more_info":"more_info"}]}}}],"template":{"id":"id","version":"version"},"target":{"type":"Account","id":"id"},"status":"accepted"}],"total_count":2,"limit":1}' + responses.add( + responses.GET, + url, + body=mock_response1, + content_type='application/json', + status=200, + ) + responses.add( + responses.GET, + url, + body=mock_response2, + content_type='application/json', + status=200, + ) + + # Exercise the pager class for this operation + pager = RoleAssignmentsPager( + client=_service, + account_id='testString', + accept_language='default', + template_id='testString', + template_version='testString', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateRoleTemplateAssignment: + """ + Test Class for create_role_template_assignment + """ + + @responses.activate + def test_create_role_template_assignment_all_params(self): + """ + create_role_template_assignment() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a AssignmentTargetDetails model + assignment_target_details_model = {} + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + # Construct a dict representation of a RoleAssignmentTemplate model + role_assignment_template_model = {} + role_assignment_template_model['id'] = 'testString' + role_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [role_assignment_template_model] + accept_language = 'default' + + # Invoke method + response = _service.create_role_template_assignment( + target, + templates, + accept_language=accept_language, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['target'] == assignment_target_details_model + assert req_body['templates'] == [role_assignment_template_model] + + def test_create_role_template_assignment_all_params_with_retries(self): + # Enable retries and run test_create_role_template_assignment_all_params. + _service.enable_retries() + self.test_create_role_template_assignment_all_params() + + # Disable retries and run test_create_role_template_assignment_all_params. + _service.disable_retries() + self.test_create_role_template_assignment_all_params() + + @responses.activate + def test_create_role_template_assignment_required_params(self): + """ + test_create_role_template_assignment_required_params() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a AssignmentTargetDetails model + assignment_target_details_model = {} + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + # Construct a dict representation of a RoleAssignmentTemplate model + role_assignment_template_model = {} + role_assignment_template_model['id'] = 'testString' + role_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [role_assignment_template_model] + + # Invoke method + response = _service.create_role_template_assignment( + target, + templates, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['target'] == assignment_target_details_model + assert req_body['templates'] == [role_assignment_template_model] + + def test_create_role_template_assignment_required_params_with_retries(self): + # Enable retries and run test_create_role_template_assignment_required_params. + _service.enable_retries() + self.test_create_role_template_assignment_required_params() + + # Disable retries and run test_create_role_template_assignment_required_params. + _service.disable_retries() + self.test_create_role_template_assignment_required_params() + + @responses.activate + def test_create_role_template_assignment_value_error(self): + """ + test_create_role_template_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "assignments": [{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}]}' + responses.add( + responses.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a AssignmentTargetDetails model + assignment_target_details_model = {} + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + # Construct a dict representation of a RoleAssignmentTemplate model + role_assignment_template_model = {} + role_assignment_template_model['id'] = 'testString' + role_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [role_assignment_template_model] + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "target": target, + "templates": templates, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_role_template_assignment(**req_copy) + + def test_create_role_template_assignment_value_error_with_retries(self): + # Enable retries and run test_create_role_template_assignment_value_error. + _service.enable_retries() + self.test_create_role_template_assignment_value_error() + + # Disable retries and run test_create_role_template_assignment_value_error. + _service.disable_retries() + self.test_create_role_template_assignment_value_error() + + +class TestGetRoleAssignment: + """ + Test Class for get_role_assignment + """ + + @responses.activate + def test_get_role_assignment_all_params(self): + """ + get_role_assignment() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Invoke method + response = _service.get_role_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_role_assignment_all_params_with_retries(self): + # Enable retries and run test_get_role_assignment_all_params. + _service.enable_retries() + self.test_get_role_assignment_all_params() + + # Disable retries and run test_get_role_assignment_all_params. + _service.disable_retries() + self.test_get_role_assignment_all_params() + + @responses.activate + def test_get_role_assignment_value_error(self): + """ + test_get_role_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_role_assignment(**req_copy) + + def test_get_role_assignment_value_error_with_retries(self): + # Enable retries and run test_get_role_assignment_value_error. + _service.enable_retries() + self.test_get_role_assignment_value_error() + + # Disable retries and run test_get_role_assignment_value_error. + _service.disable_retries() + self.test_get_role_assignment_value_error() + + +class TestUpdateRoleAssignment: + """ + Test Class for update_role_assignment + """ + + @responses.activate + def test_update_role_assignment_all_params(self): + """ + update_role_assignment() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + if_match = 'testString' + template_version = 'testString' + + # Invoke method + response = _service.update_role_assignment( + assignment_id, + if_match, + template_version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['template_version'] == 'testString' + + def test_update_role_assignment_all_params_with_retries(self): + # Enable retries and run test_update_role_assignment_all_params. + _service.enable_retries() + self.test_update_role_assignment_all_params() + + # Disable retries and run test_update_role_assignment_all_params. + _service.disable_retries() + self.test_update_role_assignment_all_params() + + @responses.activate + def test_update_role_assignment_value_error(self): + """ + test_update_role_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "operation": "create", "resources": [{"target": {"type": "Account", "id": "id"}, "role": {"resource_created": {"id": "id"}, "error_message": {"name": "name", "errorCode": "error_code", "message": "message", "code": "code", "errors": [{"code": "insufficent_permissions", "message": "message", "details": {"conflicts_with": {"etag": "etag", "role": "role", "policy": "policy"}}, "more_info": "more_info"}]}}}], "template": {"id": "id", "version": "version"}, "target": {"type": "Account", "id": "id"}, "status": "accepted"}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + if_match = 'testString' + template_version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + "if_match": if_match, + "template_version": template_version, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_role_assignment(**req_copy) + + def test_update_role_assignment_value_error_with_retries(self): + # Enable retries and run test_update_role_assignment_value_error. + _service.enable_retries() + self.test_update_role_assignment_value_error() + + # Disable retries and run test_update_role_assignment_value_error. + _service.disable_retries() + self.test_update_role_assignment_value_error() + + +class TestDeleteRoleAssignment: + """ + Test Class for delete_role_assignment + """ + + @responses.activate + def test_delete_role_assignment_all_params(self): + """ + delete_role_assignment() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Invoke method + response = _service.delete_role_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_role_assignment_all_params_with_retries(self): + # Enable retries and run test_delete_role_assignment_all_params. + _service.enable_retries() + self.test_delete_role_assignment_all_params() + + # Disable retries and run test_delete_role_assignment_all_params. + _service.disable_retries() + self.test_delete_role_assignment_all_params() + + @responses.activate + def test_delete_role_assignment_value_error(self): + """ + test_delete_role_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/role_assignments/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_role_assignment(**req_copy) + + def test_delete_role_assignment_value_error_with_retries(self): + # Enable retries and run test_delete_role_assignment_value_error. + _service.enable_retries() + self.test_delete_role_assignment_value_error() + + # Disable retries and run test_delete_role_assignment_value_error. + _service.disable_retries() + self.test_delete_role_assignment_value_error() + + +# endregion +############################################################################## +# End of Service: RoleAssignments +############################################################################## + ############################################################################## # Start of Model Tests @@ -7465,16 +9469,18 @@ def test_action_control_assignment_resource_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] action_control_assignment_resource_action_control_model = {} # ActionControlAssignmentResourceActionControl action_control_assignment_resource_action_control_model['resource_created'] = ( action_control_assignment_resource_created_model ) - action_control_assignment_resource_action_control_model['error_message'] = error_response_model + action_control_assignment_resource_action_control_model['error_message'] = assignment_resource_error_model # Construct a json representation of a ActionControlAssignmentResource model action_control_assignment_resource_model_json = {} @@ -7534,17 +9540,19 @@ def test_action_control_assignment_resource_action_control_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] # Construct a json representation of a ActionControlAssignmentResourceActionControl model action_control_assignment_resource_action_control_model_json = {} action_control_assignment_resource_action_control_model_json['resource_created'] = ( action_control_assignment_resource_created_model ) - action_control_assignment_resource_action_control_model_json['error_message'] = error_response_model + action_control_assignment_resource_action_control_model_json['error_message'] = assignment_resource_error_model # Construct a model instance of ActionControlAssignmentResourceActionControl by calling from_dict on the json representation action_control_assignment_resource_action_control_model = ( @@ -7864,8 +9872,60 @@ def test_assignment_resource_created_serialization(self): assert assignment_resource_created_model == assignment_resource_created_model2 # Convert model instance back to dict and verify no loss of data - assignment_resource_created_model_json2 = assignment_resource_created_model.to_dict() - assert assignment_resource_created_model_json2 == assignment_resource_created_model_json + assignment_resource_created_model_json2 = assignment_resource_created_model.to_dict() + assert assignment_resource_created_model_json2 == assignment_resource_created_model_json + + +class TestModel_AssignmentResourceError: + """ + Test Class for AssignmentResourceError + """ + + def test_assignment_resource_error_serialization(self): + """ + Test serialization/deserialization for AssignmentResourceError + """ + + # Construct dict forms of any model objects needed in order to build this model. + + conflicts_with_model = {} # ConflictsWith + conflicts_with_model['etag'] = 'testString' + conflicts_with_model['role'] = 'testString' + conflicts_with_model['policy'] = 'testString' + + error_details_model = {} # ErrorDetails + error_details_model['conflicts_with'] = conflicts_with_model + + error_object_model = {} # ErrorObject + error_object_model['code'] = 'insufficent_permissions' + error_object_model['message'] = 'testString' + error_object_model['details'] = error_details_model + error_object_model['more_info'] = 'testString' + + # Construct a json representation of a AssignmentResourceError model + assignment_resource_error_model_json = {} + assignment_resource_error_model_json['name'] = 'testString' + assignment_resource_error_model_json['errorCode'] = 'testString' + assignment_resource_error_model_json['message'] = 'testString' + assignment_resource_error_model_json['code'] = 'testString' + assignment_resource_error_model_json['errors'] = [error_object_model] + + # Construct a model instance of AssignmentResourceError by calling from_dict on the json representation + assignment_resource_error_model = AssignmentResourceError.from_dict(assignment_resource_error_model_json) + assert assignment_resource_error_model != False + + # Construct a model instance of AssignmentResourceError by calling from_dict on the json representation + assignment_resource_error_model_dict = AssignmentResourceError.from_dict( + assignment_resource_error_model_json + ).__dict__ + assignment_resource_error_model2 = AssignmentResourceError(**assignment_resource_error_model_dict) + + # Verify the model instances are equivalent + assert assignment_resource_error_model == assignment_resource_error_model2 + + # Convert model instance back to dict and verify no loss of data + assignment_resource_error_model_json2 = assignment_resource_error_model.to_dict() + assert assignment_resource_error_model_json2 == assignment_resource_error_model_json class TestModel_AssignmentTargetDetails: @@ -8157,54 +10217,6 @@ def test_error_object_serialization(self): assert error_object_model_json2 == error_object_model_json -class TestModel_ErrorResponse: - """ - Test Class for ErrorResponse - """ - - def test_error_response_serialization(self): - """ - Test serialization/deserialization for ErrorResponse - """ - - # Construct dict forms of any model objects needed in order to build this model. - - conflicts_with_model = {} # ConflictsWith - conflicts_with_model['etag'] = 'testString' - conflicts_with_model['role'] = 'testString' - conflicts_with_model['policy'] = 'testString' - - error_details_model = {} # ErrorDetails - error_details_model['conflicts_with'] = conflicts_with_model - - error_object_model = {} # ErrorObject - error_object_model['code'] = 'insufficent_permissions' - error_object_model['message'] = 'testString' - error_object_model['details'] = error_details_model - error_object_model['more_info'] = 'testString' - - # Construct a json representation of a ErrorResponse model - error_response_model_json = {} - error_response_model_json['trace'] = 'testString' - error_response_model_json['errors'] = [error_object_model] - error_response_model_json['status_code'] = 0 - - # Construct a model instance of ErrorResponse by calling from_dict on the json representation - error_response_model = ErrorResponse.from_dict(error_response_model_json) - assert error_response_model != False - - # Construct a model instance of ErrorResponse by calling from_dict on the json representation - error_response_model_dict = ErrorResponse.from_dict(error_response_model_json).__dict__ - error_response_model2 = ErrorResponse(**error_response_model_dict) - - # Verify the model instances are equivalent - assert error_response_model == error_response_model2 - - # Convert model instance back to dict and verify no loss of data - error_response_model_json2 = error_response_model.to_dict() - assert error_response_model_json2 == error_response_model_json - - class TestModel_ExternalAccountIdentityInteraction: """ Test Class for ExternalAccountIdentityInteraction @@ -8667,16 +10679,18 @@ def test_policy_assignment_resource_policy_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] # Construct a json representation of a PolicyAssignmentResourcePolicy model policy_assignment_resource_policy_model_json = {} policy_assignment_resource_policy_model_json['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model_json['status'] = 'testString' - policy_assignment_resource_policy_model_json['error_message'] = error_response_model + policy_assignment_resource_policy_model_json['error_message'] = assignment_resource_error_model # Construct a model instance of PolicyAssignmentResourcePolicy by calling from_dict on the json representation policy_assignment_resource_policy_model = PolicyAssignmentResourcePolicy.from_dict( @@ -8729,15 +10743,17 @@ def test_policy_assignment_resources_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model # Construct a json representation of a PolicyAssignmentResources model policy_assignment_resources_model_json = {} @@ -8795,15 +10811,17 @@ def test_policy_assignment_v1_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model policy_assignment_v1_resources_model = {} # PolicyAssignmentV1Resources policy_assignment_v1_resources_model['target'] = assignment_target_details_model @@ -8880,15 +10898,17 @@ def test_policy_assignment_v1_collection_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model policy_assignment_v1_resources_model = {} # PolicyAssignmentV1Resources policy_assignment_v1_resources_model['target'] = assignment_target_details_model @@ -8970,15 +10990,17 @@ def test_policy_assignment_v1_resources_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model # Construct a json representation of a PolicyAssignmentV1Resources model policy_assignment_v1_resources_model_json = {} @@ -9355,15 +11377,17 @@ def test_policy_template_assignment_collection_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model policy_assignment_v1_resources_model = {} # PolicyAssignmentV1Resources policy_assignment_v1_resources_model['target'] = assignment_target_details_model @@ -9937,6 +11961,302 @@ def test_role_action_serialization(self): assert role_action_model_json2 == role_action_model_json +class TestModel_RoleAssignment: + """ + Test Class for RoleAssignment + """ + + def test_role_assignment_serialization(self): + """ + Test serialization/deserialization for RoleAssignment + """ + + # Construct dict forms of any model objects needed in order to build this model. + + role_assignment_template_model = {} # RoleAssignmentTemplate + role_assignment_template_model['id'] = 'testString' + role_assignment_template_model['version'] = 'testString' + + assignment_target_details_model = {} # AssignmentTargetDetails + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + # Construct a json representation of a RoleAssignment model + role_assignment_model_json = {} + role_assignment_model_json['template'] = role_assignment_template_model + role_assignment_model_json['target'] = assignment_target_details_model + + # Construct a model instance of RoleAssignment by calling from_dict on the json representation + role_assignment_model = RoleAssignment.from_dict(role_assignment_model_json) + assert role_assignment_model != False + + # Construct a model instance of RoleAssignment by calling from_dict on the json representation + role_assignment_model_dict = RoleAssignment.from_dict(role_assignment_model_json).__dict__ + role_assignment_model2 = RoleAssignment(**role_assignment_model_dict) + + # Verify the model instances are equivalent + assert role_assignment_model == role_assignment_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_model_json2 = role_assignment_model.to_dict() + assert role_assignment_model_json2 == role_assignment_model_json + + +class TestModel_RoleAssignmentCollection: + """ + Test Class for RoleAssignmentCollection + """ + + def test_role_assignment_collection_serialization(self): + """ + Test serialization/deserialization for RoleAssignmentCollection + """ + + # Construct dict forms of any model objects needed in order to build this model. + + first_model = {} # First + + next_model = {} # Next + next_model['start'] = 'testString' + + previous_model = {} # Previous + previous_model['start'] = 'testString' + + role_assignment_template_model = {} # RoleAssignmentTemplate + role_assignment_template_model['id'] = 'testString' + role_assignment_template_model['version'] = 'testString' + + assignment_target_details_model = {} # AssignmentTargetDetails + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + role_assignment_model = {} # RoleAssignment + role_assignment_model['template'] = role_assignment_template_model + role_assignment_model['target'] = assignment_target_details_model + + # Construct a json representation of a RoleAssignmentCollection model + role_assignment_collection_model_json = {} + role_assignment_collection_model_json['limit'] = 1 + role_assignment_collection_model_json['first'] = first_model + role_assignment_collection_model_json['next'] = next_model + role_assignment_collection_model_json['previous'] = previous_model + role_assignment_collection_model_json['assignments'] = [role_assignment_model] + + # Construct a model instance of RoleAssignmentCollection by calling from_dict on the json representation + role_assignment_collection_model = RoleAssignmentCollection.from_dict(role_assignment_collection_model_json) + assert role_assignment_collection_model != False + + # Construct a model instance of RoleAssignmentCollection by calling from_dict on the json representation + role_assignment_collection_model_dict = RoleAssignmentCollection.from_dict( + role_assignment_collection_model_json + ).__dict__ + role_assignment_collection_model2 = RoleAssignmentCollection(**role_assignment_collection_model_dict) + + # Verify the model instances are equivalent + assert role_assignment_collection_model == role_assignment_collection_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_collection_model_json2 = role_assignment_collection_model.to_dict() + assert role_assignment_collection_model_json2 == role_assignment_collection_model_json + + +class TestModel_RoleAssignmentResource: + """ + Test Class for RoleAssignmentResource + """ + + def test_role_assignment_resource_serialization(self): + """ + Test serialization/deserialization for RoleAssignmentResource + """ + + # Construct dict forms of any model objects needed in order to build this model. + + assignment_target_details_model = {} # AssignmentTargetDetails + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + role_assignment_resource_created_model = {} # RoleAssignmentResourceCreated + role_assignment_resource_created_model['id'] = 'testString' + + conflicts_with_model = {} # ConflictsWith + conflicts_with_model['etag'] = 'testString' + conflicts_with_model['role'] = 'testString' + conflicts_with_model['policy'] = 'testString' + + error_details_model = {} # ErrorDetails + error_details_model['conflicts_with'] = conflicts_with_model + + error_object_model = {} # ErrorObject + error_object_model['code'] = 'insufficent_permissions' + error_object_model['message'] = 'testString' + error_object_model['details'] = error_details_model + error_object_model['more_info'] = 'testString' + + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] + + role_assignment_resource_role_model = {} # RoleAssignmentResourceRole + role_assignment_resource_role_model['resource_created'] = role_assignment_resource_created_model + role_assignment_resource_role_model['error_message'] = assignment_resource_error_model + + # Construct a json representation of a RoleAssignmentResource model + role_assignment_resource_model_json = {} + role_assignment_resource_model_json['target'] = assignment_target_details_model + role_assignment_resource_model_json['role'] = role_assignment_resource_role_model + + # Construct a model instance of RoleAssignmentResource by calling from_dict on the json representation + role_assignment_resource_model = RoleAssignmentResource.from_dict(role_assignment_resource_model_json) + assert role_assignment_resource_model != False + + # Construct a model instance of RoleAssignmentResource by calling from_dict on the json representation + role_assignment_resource_model_dict = RoleAssignmentResource.from_dict( + role_assignment_resource_model_json + ).__dict__ + role_assignment_resource_model2 = RoleAssignmentResource(**role_assignment_resource_model_dict) + + # Verify the model instances are equivalent + assert role_assignment_resource_model == role_assignment_resource_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_resource_model_json2 = role_assignment_resource_model.to_dict() + assert role_assignment_resource_model_json2 == role_assignment_resource_model_json + + +class TestModel_RoleAssignmentResourceCreated: + """ + Test Class for RoleAssignmentResourceCreated + """ + + def test_role_assignment_resource_created_serialization(self): + """ + Test serialization/deserialization for RoleAssignmentResourceCreated + """ + + # Construct a json representation of a RoleAssignmentResourceCreated model + role_assignment_resource_created_model_json = {} + role_assignment_resource_created_model_json['id'] = 'testString' + + # Construct a model instance of RoleAssignmentResourceCreated by calling from_dict on the json representation + role_assignment_resource_created_model = RoleAssignmentResourceCreated.from_dict( + role_assignment_resource_created_model_json + ) + assert role_assignment_resource_created_model != False + + # Construct a model instance of RoleAssignmentResourceCreated by calling from_dict on the json representation + role_assignment_resource_created_model_dict = RoleAssignmentResourceCreated.from_dict( + role_assignment_resource_created_model_json + ).__dict__ + role_assignment_resource_created_model2 = RoleAssignmentResourceCreated( + **role_assignment_resource_created_model_dict + ) + + # Verify the model instances are equivalent + assert role_assignment_resource_created_model == role_assignment_resource_created_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_resource_created_model_json2 = role_assignment_resource_created_model.to_dict() + assert role_assignment_resource_created_model_json2 == role_assignment_resource_created_model_json + + +class TestModel_RoleAssignmentResourceRole: + """ + Test Class for RoleAssignmentResourceRole + """ + + def test_role_assignment_resource_role_serialization(self): + """ + Test serialization/deserialization for RoleAssignmentResourceRole + """ + + # Construct dict forms of any model objects needed in order to build this model. + + role_assignment_resource_created_model = {} # RoleAssignmentResourceCreated + role_assignment_resource_created_model['id'] = 'testString' + + conflicts_with_model = {} # ConflictsWith + conflicts_with_model['etag'] = 'testString' + conflicts_with_model['role'] = 'testString' + conflicts_with_model['policy'] = 'testString' + + error_details_model = {} # ErrorDetails + error_details_model['conflicts_with'] = conflicts_with_model + + error_object_model = {} # ErrorObject + error_object_model['code'] = 'insufficent_permissions' + error_object_model['message'] = 'testString' + error_object_model['details'] = error_details_model + error_object_model['more_info'] = 'testString' + + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] + + # Construct a json representation of a RoleAssignmentResourceRole model + role_assignment_resource_role_model_json = {} + role_assignment_resource_role_model_json['resource_created'] = role_assignment_resource_created_model + role_assignment_resource_role_model_json['error_message'] = assignment_resource_error_model + + # Construct a model instance of RoleAssignmentResourceRole by calling from_dict on the json representation + role_assignment_resource_role_model = RoleAssignmentResourceRole.from_dict( + role_assignment_resource_role_model_json + ) + assert role_assignment_resource_role_model != False + + # Construct a model instance of RoleAssignmentResourceRole by calling from_dict on the json representation + role_assignment_resource_role_model_dict = RoleAssignmentResourceRole.from_dict( + role_assignment_resource_role_model_json + ).__dict__ + role_assignment_resource_role_model2 = RoleAssignmentResourceRole(**role_assignment_resource_role_model_dict) + + # Verify the model instances are equivalent + assert role_assignment_resource_role_model == role_assignment_resource_role_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_resource_role_model_json2 = role_assignment_resource_role_model.to_dict() + assert role_assignment_resource_role_model_json2 == role_assignment_resource_role_model_json + + +class TestModel_RoleAssignmentTemplate: + """ + Test Class for RoleAssignmentTemplate + """ + + def test_role_assignment_template_serialization(self): + """ + Test serialization/deserialization for RoleAssignmentTemplate + """ + + # Construct a json representation of a RoleAssignmentTemplate model + role_assignment_template_model_json = {} + role_assignment_template_model_json['id'] = 'testString' + role_assignment_template_model_json['version'] = 'testString' + + # Construct a model instance of RoleAssignmentTemplate by calling from_dict on the json representation + role_assignment_template_model = RoleAssignmentTemplate.from_dict(role_assignment_template_model_json) + assert role_assignment_template_model != False + + # Construct a model instance of RoleAssignmentTemplate by calling from_dict on the json representation + role_assignment_template_model_dict = RoleAssignmentTemplate.from_dict( + role_assignment_template_model_json + ).__dict__ + role_assignment_template_model2 = RoleAssignmentTemplate(**role_assignment_template_model_dict) + + # Verify the model instances are equivalent + assert role_assignment_template_model == role_assignment_template_model2 + + # Convert model instance back to dict and verify no loss of data + role_assignment_template_model_json2 = role_assignment_template_model.to_dict() + assert role_assignment_template_model_json2 == role_assignment_template_model_json + + class TestModel_RoleCollection: """ Test Class for RoleCollection @@ -9984,6 +12304,179 @@ def test_role_collection_serialization(self): assert role_collection_model_json2 == role_collection_model_json +class TestModel_RoleTemplate: + """ + Test Class for RoleTemplate + """ + + def test_role_template_serialization(self): + """ + Test serialization/deserialization for RoleTemplate + """ + + # Construct dict forms of any model objects needed in order to build this model. + + template_role_model = {} # TemplateRole + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + # Construct a json representation of a RoleTemplate model + role_template_model_json = {} + role_template_model_json['name'] = 'testString' + role_template_model_json['description'] = 'testString' + role_template_model_json['account_id'] = 'testString' + role_template_model_json['committed'] = True + role_template_model_json['role'] = template_role_model + role_template_model_json['version'] = 'testString' + role_template_model_json['state'] = 'active' + + # Construct a model instance of RoleTemplate by calling from_dict on the json representation + role_template_model = RoleTemplate.from_dict(role_template_model_json) + assert role_template_model != False + + # Construct a model instance of RoleTemplate by calling from_dict on the json representation + role_template_model_dict = RoleTemplate.from_dict(role_template_model_json).__dict__ + role_template_model2 = RoleTemplate(**role_template_model_dict) + + # Verify the model instances are equivalent + assert role_template_model == role_template_model2 + + # Convert model instance back to dict and verify no loss of data + role_template_model_json2 = role_template_model.to_dict() + assert role_template_model_json2 == role_template_model_json + + +class TestModel_RoleTemplateCollection: + """ + Test Class for RoleTemplateCollection + """ + + def test_role_template_collection_serialization(self): + """ + Test serialization/deserialization for RoleTemplateCollection + """ + + # Construct dict forms of any model objects needed in order to build this model. + + first_model = {} # First + + next_model = {} # Next + next_model['start'] = 'testString' + + previous_model = {} # Previous + previous_model['start'] = 'testString' + + template_role_model = {} # TemplateRole + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + role_template_model = {} # RoleTemplate + role_template_model['name'] = 'testString' + role_template_model['description'] = 'testString' + role_template_model['account_id'] = 'testString' + role_template_model['committed'] = True + role_template_model['role'] = template_role_model + role_template_model['version'] = 'testString' + role_template_model['state'] = 'active' + + # Construct a json representation of a RoleTemplateCollection model + role_template_collection_model_json = {} + role_template_collection_model_json['limit'] = 1 + role_template_collection_model_json['first'] = first_model + role_template_collection_model_json['next'] = next_model + role_template_collection_model_json['previous'] = previous_model + role_template_collection_model_json['role_templates'] = [role_template_model] + + # Construct a model instance of RoleTemplateCollection by calling from_dict on the json representation + role_template_collection_model = RoleTemplateCollection.from_dict(role_template_collection_model_json) + assert role_template_collection_model != False + + # Construct a model instance of RoleTemplateCollection by calling from_dict on the json representation + role_template_collection_model_dict = RoleTemplateCollection.from_dict( + role_template_collection_model_json + ).__dict__ + role_template_collection_model2 = RoleTemplateCollection(**role_template_collection_model_dict) + + # Verify the model instances are equivalent + assert role_template_collection_model == role_template_collection_model2 + + # Convert model instance back to dict and verify no loss of data + role_template_collection_model_json2 = role_template_collection_model.to_dict() + assert role_template_collection_model_json2 == role_template_collection_model_json + + +class TestModel_RoleTemplateVersionsCollection: + """ + Test Class for RoleTemplateVersionsCollection + """ + + def test_role_template_versions_collection_serialization(self): + """ + Test serialization/deserialization for RoleTemplateVersionsCollection + """ + + # Construct dict forms of any model objects needed in order to build this model. + + first_model = {} # First + + next_model = {} # Next + next_model['start'] = 'testString' + + previous_model = {} # Previous + previous_model['start'] = 'testString' + + template_role_model = {} # TemplateRole + template_role_model['name'] = 'testString' + template_role_model['display_name'] = 'testString' + template_role_model['service_name'] = 'testString' + template_role_model['description'] = 'testString' + template_role_model['actions'] = ['testString'] + + role_template_model = {} # RoleTemplate + role_template_model['name'] = 'testString' + role_template_model['description'] = 'testString' + role_template_model['account_id'] = 'testString' + role_template_model['committed'] = True + role_template_model['role'] = template_role_model + role_template_model['version'] = 'testString' + role_template_model['state'] = 'active' + + # Construct a json representation of a RoleTemplateVersionsCollection model + role_template_versions_collection_model_json = {} + role_template_versions_collection_model_json['limit'] = 1 + role_template_versions_collection_model_json['first'] = first_model + role_template_versions_collection_model_json['next'] = next_model + role_template_versions_collection_model_json['previous'] = previous_model + role_template_versions_collection_model_json['versions'] = [role_template_model] + + # Construct a model instance of RoleTemplateVersionsCollection by calling from_dict on the json representation + role_template_versions_collection_model = RoleTemplateVersionsCollection.from_dict( + role_template_versions_collection_model_json + ) + assert role_template_versions_collection_model != False + + # Construct a model instance of RoleTemplateVersionsCollection by calling from_dict on the json representation + role_template_versions_collection_model_dict = RoleTemplateVersionsCollection.from_dict( + role_template_versions_collection_model_json + ).__dict__ + role_template_versions_collection_model2 = RoleTemplateVersionsCollection( + **role_template_versions_collection_model_dict + ) + + # Verify the model instances are equivalent + assert role_template_versions_collection_model == role_template_versions_collection_model2 + + # Convert model instance back to dict and verify no loss of data + role_template_versions_collection_model_json2 = role_template_versions_collection_model.to_dict() + assert role_template_versions_collection_model_json2 == role_template_versions_collection_model_json + + class TestModel_Roles: """ Test Class for Roles @@ -10254,6 +12747,40 @@ def test_template_policy_serialization(self): assert template_policy_model_json2 == template_policy_model_json +class TestModel_TemplateRole: + """ + Test Class for TemplateRole + """ + + def test_template_role_serialization(self): + """ + Test serialization/deserialization for TemplateRole + """ + + # Construct a json representation of a TemplateRole model + template_role_model_json = {} + template_role_model_json['name'] = 'testString' + template_role_model_json['display_name'] = 'testString' + template_role_model_json['service_name'] = 'testString' + template_role_model_json['description'] = 'testString' + template_role_model_json['actions'] = ['testString'] + + # Construct a model instance of TemplateRole by calling from_dict on the json representation + template_role_model = TemplateRole.from_dict(template_role_model_json) + assert template_role_model != False + + # Construct a model instance of TemplateRole by calling from_dict on the json representation + template_role_model_dict = TemplateRole.from_dict(template_role_model_json).__dict__ + template_role_model2 = TemplateRole(**template_role_model_dict) + + # Verify the model instances are equivalent + assert template_role_model == template_role_model2 + + # Convert model instance back to dict and verify no loss of data + template_role_model_json2 = template_role_model.to_dict() + assert template_role_model_json2 == template_role_model_json + + class TestModel_V2Policy: """ Test Class for V2Policy @@ -10906,15 +13433,17 @@ def test_policy_template_assignment_items_policy_assignment_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model policy_assignment_resources_model = {} # PolicyAssignmentResources policy_assignment_resources_model['target'] = 'testString' @@ -10997,15 +13526,17 @@ def test_policy_template_assignment_items_policy_assignment_v1_serialization(sel error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - error_response_model = {} # ErrorResponse - error_response_model['trace'] = 'testString' - error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 0 + assignment_resource_error_model = {} # AssignmentResourceError + assignment_resource_error_model['name'] = 'testString' + assignment_resource_error_model['errorCode'] = 'testString' + assignment_resource_error_model['message'] = 'testString' + assignment_resource_error_model['code'] = 'testString' + assignment_resource_error_model['errors'] = [error_object_model] policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model + policy_assignment_resource_policy_model['error_message'] = assignment_resource_error_model policy_assignment_v1_resources_model = {} # PolicyAssignmentV1Resources policy_assignment_v1_resources_model['target'] = assignment_target_details_model