From 1dbb7675995ad934d160e6f1af5bcce2eff31384 Mon Sep 17 00:00:00 2001 From: Rajesh Pirati Date: Mon, 5 May 2025 13:29:12 +0530 Subject: [PATCH 1/2] feat(IAM Policy Management): add support for action control templates from IAM Signed-off-by: Rajesh Pirati --- .../test_iam_policy_management_v1_examples.py | 346 ++ .../iam_policy_management_v1.py | 3449 ++++++++++++++--- .../test_iam_policy_management_v1.py | 332 +- test/unit/test_iam_policy_management_v1.py | 2635 ++++++++++++- 4 files changed, 6203 insertions(+), 559 deletions(-) diff --git a/examples/test_iam_policy_management_v1_examples.py b/examples/test_iam_policy_management_v1_examples.py index 2a9c202..7c634ae 100644 --- a/examples/test_iam_policy_management_v1_examples.py +++ b/examples/test_iam_policy_management_v1_examples.py @@ -61,6 +61,13 @@ example_target_account_id = None example_assignment_etag = None example_account_settings_etag = None +example_action_control_template_id = None +example_action_control_template_etag = None +example_action_control_template_version = None +example_basic_action_control_template_version = None +example_action_control_assignment_id = None +example_action_control_assignment_etag = None + ############################################################################## # Start of Examples for Service: IamPolicyManagementV1 @@ -1064,6 +1071,345 @@ def test_update_access_management_account_settings_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_create_action_control_template_example(self): + """ + create_action_control_template request example + """ + try: + print('\ncreate_action_control_template() result:') + # begin-create_action_control_template + + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.delete'], + } + + response = iam_policy_management_service.create_action_control_template( + name='SDKExamplesTest', + account_id=example_account_id, + description='SDK Test ActionControl Template', + action_control=template_action_control_model, + ) + action_control_template = response.get_result() + + global example_action_control_template_id + example_action_control_template_id = action_control_template['id'] + global example_basic_action_control_template_version + example_basic_action_control_template_version = action_control_template['version'] + + print(json.dumps(action_control_template, indent=2)) + + # end-create_action_control_template + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_action_control_template_example(self): + """ + get_action_control_template request example + """ + try: + print('\nget_action_control_template() result:') + # begin-get_action_control_template + + print('example_action_control_template_id: ', example_action_control_template_id) + response = iam_policy_management_service.get_action_control_template( + action_control_template_id=example_action_control_template_id, + ) + action_control_template = response.get_result() + + global example_action_control_template_etag + example_action_control_template_etag = response.get_headers().get("Etag") + + print(json.dumps(action_control_template, indent=2)) + + # end-get_action_control_template + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_replace_action_control_template_example(self): + """ + replace_action_control_template request example + """ + try: + print('\nreplace_action_control_template() result:') + # begin-replace_action_control_template + + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.delete'], + } + + response = iam_policy_management_service.replace_action_control_template( + action_control_template_id=example_action_control_template_id, + version=example_basic_action_control_template_version, + if_match=example_action_control_template_etag, + action_control=template_action_control_model, + ) + action_control_template = response.get_result() + + print(json.dumps(action_control_template, indent=2)) + + # end-replace_action_control_template + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_action_control_templates_example(self): + """ + list_action_control_templates request example + """ + try: + print('\nlist_action_control_templates() result:') + # begin-list_action_control_templates + + response = iam_policy_management_service.list_action_control_templates( + account_id=example_account_id, + ) + action_control_template_collection = response.get_result() + + print(json.dumps(action_control_template_collection, indent=2)) + + # end-list_action_control_templates + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_action_control_template_version_example(self): + """ + create_action_control_template_version request example + """ + try: + print('\ncreate_action_control_template_version() result:') + # begin-create_action_control_template_version + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.create'], + } + + response = iam_policy_management_service.create_action_control_template_version( + action_control_template_id=example_action_control_template_id, + committed=True, + action_control=template_action_control_model, + ) + action_control_template = response.get_result() + global example_action_control_template_version + example_action_control_template_version = action_control_template['version'] + print(json.dumps(action_control_template, indent=2)) + + # end-create_action_control_template_version + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_action_control_template_versions_example(self): + """ + list_action_control_template_versions request example + """ + try: + print('\nlist_action_control_template_versions() result:') + # begin-list_action_control_template_versions + + response = iam_policy_management_service.list_action_control_template_versions( + action_control_template_id=example_action_control_template_id, + ) + action_control_template_versions_collection = response.get_result() + + print(json.dumps(action_control_template_versions_collection, indent=2)) + + # end-list_action_control_template_versions + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_get_action_control_template_version_example(self): + """ + get_action_control_template_version request example + """ + try: + print('\nget_action_control_template_version() result:') + # begin-get_action_control_template_version + + response = iam_policy_management_service.get_action_control_template_version( + action_control_template_id=example_action_control_template_id, + version=example_action_control_template_version, + ) + action_control_template = response.get_result() + + global example_template_etag + example_template_etag = response.get_headers().get("Etag") + + print(json.dumps(action_control_template, indent=2)) + + # end-get_action_control_template_version + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_commit_action_control_template_example(self): + """ + commit_action_control_template request example + """ + try: + # begin-commit_action_control_template + + response = iam_policy_management_service.commit_action_control_template( + action_control_template_id=example_action_control_template_id, + version=example_basic_action_control_template_version, + ) + + # end-commit_action_control_template + print('\ncommit_action_control_template() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_create_action_control_assignment_example(self): + """ + create_action_control_template_assignment request example + """ + try: + print('\ncreate_action_control_template_assignment() result:') + # begin-create_action_control_template_assignment + response = iam_policy_management_service.create_action_control_template_assignment( + target=AssignmentTargetDetails( + type="Account", + id=example_target_account_id, + ), + templates=[ + AssignmentTemplateDetails( + id=example_action_control_template_id, version=example_basic_action_control_template_version + ) + ], + ) + result = response.get_result() + assert result is not None + + global example_action_control_assignment_id + example_action_control_assignment_id = result['assignments'][0]['id'] + global example_action_control_assignment_etag + example_action_control_assignment_etag = response.get_headers().get("Etag") + print(json.dumps(result, indent=2)) + + # end-create_action_control_template_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_update_action_control_assignment_example(self): + """ + update_action_control_assignment request example + """ + try: + print('\nupdate_action_control_assignment() result:') + # begin-update_action_control_assignment + + response = iam_policy_management_service.update_action_control_assignment( + assignment_id=example_action_control_assignment_id, + if_match=example_action_control_assignment_etag, + template_version=example_action_control_template_version, + ) + assignment = response.get_result() + + print(json.dumps(assignment, indent=2)) + + # end-update_action_control_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_list_action_control_assignments_example(self): + """ + list_action_control_assignments request example + """ + try: + print('\nlist_action_control_assignments() result:') + # begin-list_action_control_assignments + + response = iam_policy_management_service.list_action_control_assignments( + account_id=example_account_id, + ) + action_control_template_assignment_collection = response.get_result() + + print(json.dumps(action_control_template_assignment_collection, indent=2)) + + # end-list_action_control_assignments + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_get_action_control_assignment_example(self): + """ + get_action_control_assignment request example + """ + try: + print('\nget_action_control_assignment() result:') + # begin-get_action_control_assignment + + response = iam_policy_management_service.get_action_control_assignment( + assignment_id=example_action_control_assignment_id, + ) + action_control_assignment_record = response.get_result() + + print(json.dumps(action_control_assignment_record, indent=2)) + + # end-get_action_control_assignment + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_delete_action_control_assignment_example(self): + """ + delete_action_control_assignment request example + """ + try: + # begin-delete_action_control_assignment + + response = iam_policy_management_service.delete_action_control_assignment( + assignment_id=example_action_control_assignment_id, + ) + + # end-delete_action_control_assignment + print('\ndelete_action_control_assignment() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + + # @needscredentials + def test_delete_action_control_template_example(self): + """ + delete_action_control_template request example + """ + try: + # begin-action_control_policy_template + + response = iam_policy_management_service.delete_action_control_template( + action_control_template_id=example_action_control_template_id, + ) + + # end-delete_action_control_template + print('\ndelete_action_control_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 26e9cfb..2782aac 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.102.0-615ec964-20250307-203034 +# IBM OpenAPI SDK Code Generator Version: 3.103.0-e8b84313-20250402-201816 """ IAM Policy Management API @@ -137,9 +137,9 @@ def list_policies( :param str state: (optional) The state of the policy. * `active` - returns active policies * `deleted` - returns non-active policies. - :param int limit: (optional) The number of documents to include in + :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 + :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. @@ -254,7 +254,7 @@ def create_policy( :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) + :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. @@ -388,7 +388,7 @@ def replace_policy( header. :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) + :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. @@ -713,13 +713,13 @@ def create_role( the new role, but there must be at least one service-defined action to successfully create the new role. - :param str display_name: The display name of the role that is shown in the - console. + :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. Can only be - alphanumeric and has to be capitalized. + :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. @@ -809,8 +809,8 @@ def replace_role( :param str if_match: The revision number for updating a role and must match the ETag value of the existing role. The Etag can be retrieved using the GET /v2/roles/{role_id} API and looking at the ETag response header. - :param str display_name: The display name of the role that is shown in the - console. + :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). @@ -1029,9 +1029,9 @@ def list_v2_policies( :param str state: (optional) The state of the policy. * `active` - returns active policies * `deleted` - returns non-active policies. - :param int limit: (optional) The number of documents to include in + :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 + :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. @@ -1148,8 +1148,9 @@ def create_v2_policy( 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan', 'dateTimeGreaterThanOrEquals', 'dayOfWeekEquals', 'dayOfWeekAnyOf' - ``` The pattern field that matches the rule is required when rule is provided. For - the business hour rule example above, the **`pattern`** is + ``` + The pattern field that matches the rule is required when rule is provided. For the + business hour rule example above, the **`pattern`** is **`"time-based-conditions:weekly"`**. For more information, see [Time-based conditions operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties) @@ -1225,7 +1226,8 @@ def create_v2_policy( locationvalues are supported by the service, they are validated against Global Catalog locations. - :param Control control: Specifies the type of access granted by the policy. + :param Control control: Specifies the type of access that is granted by the + policy. :param str type: The policy type; either 'access' or 'authorization'. :param str description: (optional) Description of the policy. :param V2PolicySubject subject: (optional) The subject attributes for whom @@ -1450,7 +1452,8 @@ def replace_v2_policy( match the ETag value of the existing policy. The Etag can be retrieved using the GET /v2/policies/{id} API and looking at the ETag response header. - :param Control control: Specifies the type of access granted by the policy. + :param Control control: Specifies the type of access that is granted by the + policy. :param str type: The policy type; either 'access' or 'authorization'. :param str description: (optional) Description of the policy. :param V2PolicySubject subject: (optional) The subject attributes for whom @@ -1677,9 +1680,9 @@ def list_policy_templates( :param str policy_service_name: (optional) Service name, Optional. :param str policy_service_group_id: (optional) Service group id, Optional. :param str policy_type: (optional) Policy type, Optional. - :param int limit: (optional) The number of documents to include in + :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 + :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. @@ -1743,13 +1746,13 @@ def create_policy_template( Create a policy template. Policy templates define a policy without requiring a subject, and you can use them to grant access to multiple subjects. - :param str name: 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 account_id: Enterprise account ID where this template will be + :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 TemplatePolicy policy: The core set of properties associated with - the template's policy objet. + the template's policy object. :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 @@ -1933,10 +1936,10 @@ def create_policy_template_version( :param str policy_template_id: The policy template ID. :param TemplatePolicy policy: The core set of properties associated with - the template's policy objet. + the template's policy object. :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. + 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 @@ -2005,9 +2008,9 @@ def list_policy_template_versions( :param str policy_template_id: The policy template ID. :param str state: (optional) The policy template state. - :param int limit: (optional) The number of documents to include in + :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 + :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. @@ -2075,10 +2078,10 @@ def replace_policy_template( /v1/policy_templates/{policy_template_id}/versions/{version} API and looking at the ETag response header. :param TemplatePolicy policy: The core set of properties associated with - the template's policy objet. + the template's policy object. :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. + 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 @@ -2326,9 +2329,9 @@ def list_policy_assignments( * `zh-tw` - (Chinese, Taiwan). :param str template_id: (optional) Optional template id. :param str template_version: (optional) Optional policy template version. - :param int limit: (optional) The number of documents to include in + :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 + :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. @@ -2526,9 +2529,9 @@ def update_policy_assignment( :param str assignment_id: The policy template assignment ID. :param str version: specify version of response body format. :param str if_match: The revision number for updating a policy assignment - and must match the ETag value of the existing policy assignment. The Etag + and must match the Etag value of the existing policy assignment. The Etag can be retrieved using the GET /v1/policy_assignments/{assignment_id} API - and looking at the ETag response header. + and looking at the Etag response header. :param str template_version: The policy template version to update to. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. @@ -2709,15 +2712,15 @@ def update_settings( Update the way identities within an external account are allowed to interact with the requested account by providing: * the `account_id` as a parameter - * the external account ID(s) and state for the specific identity in the request - body + * one or more external account ID(s) and state for the specific identity in the + request body External account identity interaction includes the following `identity_types`: - `user` (user identities defined as - [IBMid's](https://test.cloud.ibm.com/docs/account?topic=account-identity-overview#users-bestpract)), + `user` (user identities that are defined as + [IBMid's](https://cloud.ibm.com/docs/account?topic=account-identity-overview#users-bestpract)), `service_id` (defined as [IAM - ServiceIds](https://test.cloud.ibm.com/docs/account?topic=account-identity-overview#serviceid-bestpract)), + ServiceIds](https://cloud.ibm.com/docs/account?topic=account-identity-overview#serviceid-bestpract)), `service` (defined by a service’s - [CRN](https://test.cloud.ibm.com/docs/account?topic=account-crn)). To update an + [CRN](https://cloud.ibm.com/docs/account?topic=account-crn)). To update an Identity’s setting, the `state` and `external_allowed_accounts` fields are required. Different identity states are: @@ -2726,9 +2729,9 @@ def update_settings( * "limited": An identity type is allowed to access resources in the account provided it has access policies on those resources AND it is associated with either the account the resources are in or one of the allowed accounts. This - setting leverages the "external_allowed_accounts" list. - * "monitor": Has no direct impact on an Identity’s access. Instead, it creates AT - events for access decisions as if the account were in a limited “state”. + setting uses the "external_allowed_accounts" list. + * "monitor": It has no direct impact on an Identity’s access. Instead, it creates + AT events for access decisions as if the account were in a limited “state”. **Note**: The state "enabled" is a special case. In this case, access is given to all accounts and there is no need to specify a particular list. Therefore, when updating "state" to "enabled" for an identity type "external_allowed_accounts" @@ -2736,10 +2739,10 @@ def update_settings( :param str account_id: The account GUID that the settings belong to. :param str if_match: The revision number for updating Access Management - Account Settings and must match the ETag value of the existing Access + Account Settings and must match the Etag value of the existing Access Management Account Settings. The Etag can be retrieved using the GET /v1/accounts/{account_id}/settings/access_management API and looking at the - ETag response header. + Etag response header. :param ExternalAccountIdentityInteractionPatch external_account_identity_interaction: (optional) Update to how external accounts can interact in relation to the requested account. @@ -2803,243 +2806,2247 @@ def update_settings( response = self.send(request, **kwargs) return response + ######################### + # Action Control Templates + ######################### -class ListPoliciesEnums: - """ - Enums for list_policies parameters. - """ - - class Type(str, Enum): - """ - Optional type of policy. + def list_action_control_templates( + self, + account_id: str, + *, + accept_language: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ + List action control templates by attributes. - ACCESS = 'access' - AUTHORIZATION = 'authorization' + List action control templates and filter by attributes by using query parameters. + The following attributes are supported: + `account_id` + `account_id` is a required query parameter. Only action control 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 action control templates an empty + array is returned. - class ServiceType(str, Enum): - """ - Optional type of service. + :param str account_id: The account GUID that the action control 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 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 `ActionControlTemplateCollection` object """ - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' + 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_action_control_templates', + ) + headers.update(sdk_headers) - 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'. - """ + params = { + 'account_id': account_id, + 'limit': limit, + 'start': start, + } - 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' + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' - 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. - """ + url = '/v1/action_control_templates' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' + response = self.send(request, **kwargs) + return response - class State(str, Enum): - """ - The state of the policy. - * `active` - returns active policies - * `deleted` - returns non-active policies. + def create_action_control_template( + self, + name: str, + account_id: str, + *, + description: Optional[str] = None, + committed: Optional[bool] = None, + action_control: Optional['TemplateActionControl'] = None, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ + Create an action control template. - ACTIVE = 'active' - DELETED = 'deleted' + Create an action control template. Action control templates define a service + action control. + :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 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 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 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 `ActionControlTemplate` object + """ -class ListV2PoliciesEnums: - """ - Enums for list_v2_policies parameters. - """ + if name is None: + raise ValueError('name must be provided') + if account_id is None: + raise ValueError('account_id must be provided') + if action_control is not None: + action_control = convert_model(action_control) + headers = { + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_action_control_template', + ) + headers.update(sdk_headers) - class Type(str, Enum): - """ - Optional type of policy. - """ + data = { + 'name': name, + 'account_id': account_id, + 'description': description, + 'committed': committed, + 'action_control': action_control, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' - ACCESS = 'access' - AUTHORIZATION = 'authorization' + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' - class ServiceType(str, Enum): - """ - Optional type of service. - """ + url = '/v1/action_control_templates' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' + response = self.send(request, **kwargs) + return response - 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 get_action_control_template( + self, + action_control_template_id: str, + *, + state: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: """ + Retrieve the latest version of an action control template. - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' + Retrieve the latest version of an action control template by providing an action + control template ID. - class State(str, Enum): - """ - The state of the policy. - * `active` - returns active policies - * `deleted` - returns non-active policies. + :param str action_control_template_id: Action control template ID. + :param str state: (optional) The action control 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 `ActionControlTemplate` object """ - ACTIVE = 'active' - DELETED = 'deleted' + if not action_control_template_id: + raise ValueError('action_control_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='get_action_control_template', + ) + headers.update(sdk_headers) + params = { + 'state': state, + } -class GetV2PolicyEnums: - """ - Enums for get_v2_policy parameters. - """ + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' - 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. - """ + path_param_keys = ['action_control_template_id'] + path_param_values = self.encode_path_vars(action_control_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_template_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) - INCLUDE_LAST_PERMIT = 'include_last_permit' - DISPLAY = 'display' + response = self.send(request, **kwargs) + return response + def delete_action_control_template( + self, + action_control_template_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete an action control template. -class ListPolicyTemplatesEnums: - """ - Enums for list_policy_templates parameters. - """ + Delete an action control template by providing the action control template ID. + This deletes all versions of this template. An action control template can't be + deleted if any version of the template is assigned to one or more child accounts. + You must remove the action control assignments first. - class State(str, Enum): - """ - The policy template state. + :param str action_control_template_id: Action control template ID. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse """ - ACTIVE = 'active' + if not action_control_template_id: + raise ValueError('action_control_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='delete_action_control_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['action_control_template_id'] + path_param_values = self.encode_path_vars(action_control_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template_version( + self, + action_control_template_id: str, + *, + name: Optional[str] = None, + description: Optional[str] = None, + action_control: Optional['TemplateActionControl'] = None, + committed: Optional[bool] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create a new action control template version. + + Create a new version of an action control template. Use this if you need to make + updates to an action control template that is committed. + + :param str action_control_template_id: The action control template ID. + :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 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 TemplateActionControl action_control: (optional) The action control + properties that are created in an action resource when the template is + assigned. + :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 `ActionControlTemplate` object + """ + + if not action_control_template_id: + raise ValueError('action_control_template_id must be provided') + if action_control is not None: + action_control = convert_model(action_control) + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='create_action_control_template_version', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'description': description, + 'action_control': action_control, + '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 = ['action_control_template_id'] + path_param_values = self.encode_path_vars(action_control_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template_versions( + self, + action_control_template_id: str, + *, + state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve action control template versions. + + Retrieve the versions of an action control template by providing an action control + template ID. + + :param str action_control_template_id: The action control template ID. + :param str state: (optional) Action control 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 `ActionControlTemplateVersionsCollection` object + """ + + if not action_control_template_id: + raise ValueError('action_control_template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_action_control_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 = ['action_control_template_id'] + path_param_values = self.encode_path_vars(action_control_template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template( + self, + action_control_template_id: str, + version: str, + if_match: str, + *, + name: Optional[str] = None, + description: Optional[str] = None, + action_control: Optional['TemplateActionControl'] = None, + committed: Optional[bool] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update an action control template version. + + Update a specific version of an action control template. You can use this only if + the version isn't committed. + + :param str action_control_template_id: Action control template ID. + :param str version: Action control template version. + :param str if_match: The revision number for updating an action control + template version must match the Etag value of the existing action control + template version. The Etag can be retrieved using the GET + /v1/action_control_templates/{template_id}/versions/{version} API and + looking at the Etag response header. + :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 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 TemplateActionControl action_control: (optional) The action control + properties that are created in an action resource when the template is + assigned. + :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 `ActionControlTemplate` object + """ + + if not action_control_template_id: + raise ValueError('action_control_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 action_control is not None: + action_control = convert_model(action_control) + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='replace_action_control_template', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'description': description, + 'action_control': action_control, + '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 = ['action_control_template_id', 'version'] + path_param_values = self.encode_path_vars(action_control_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template_version( + self, + action_control_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Delete an action control template version. + + Delete a specific version of an action control template by providing an action + control template ID and version number. You can't delete an action control + template version that is assigned to one or more child accounts. You must remove + the action control assignments first. + + :param str action_control_template_id: Action control template ID. + :param str version: Action control 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 action_control_template_id: + raise ValueError('action_control_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_action_control_template_version', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['action_control_template_id', 'version'] + path_param_values = self.encode_path_vars(action_control_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template_version( + self, + action_control_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve an action control template version. + + Retrieve an action control template by providing an action control template ID and + version number. + + :param str action_control_template_id: Action control template ID. + :param str version: Action control 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 `ActionControlTemplate` object + """ + + if not action_control_template_id: + raise ValueError('action_control_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_action_control_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 = ['action_control_template_id', 'version'] + path_param_values = self.encode_path_vars(action_control_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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_action_control_template( + self, + action_control_template_id: str, + version: str, + **kwargs, + ) -> DetailedResponse: + """ + Commit an action control template version. + + Commit an action control template version. You cannot make any further changes to + the action control template once it's committed. If you have to make updates after + committing a version, create a new version. + + :param str action_control_template_id: Action control template ID. + :param str version: The action control 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 action_control_template_id: + raise ValueError('action_control_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_action_control_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['action_control_template_id', 'version'] + path_param_values = self.encode_path_vars(action_control_template_id, version) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/action_control_templates/{action_control_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 + + ######################### + # Action Control Assignments + ######################### + + def list_action_control_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 action control template assignments. + + Get action control template assignments by attributes. The following attributes + are supported: + `account_id`, `template_id`, `template_version`, `sort`. + `account_id` is a required query parameter. Only action control template + assignments with the specified attributes and accessible by the caller are + returned. If the caller does not have read access to any action control template + assignments, an empty array is returned. + + :param str account_id: The account GUID in which the action control + 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 action control 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 `ActionControlAssignmentCollection` 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_action_control_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/action_control_assignments' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def create_action_control_template_assignment( + self, + target: 'AssignmentTargetDetails', + templates: List['ActionControlAssignmentTemplate'], + *, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Create an action control template assignment. + + Assign an action control template to child accounts and account groups. This + creates the action control in the accounts and account groups that you specify. + + :param AssignmentTargetDetails target: assignment target account and type. + :param List[ActionControlAssignmentTemplate] templates: List of action + control template details for action control 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 `ActionControlAssignmentCollection` 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_action_control_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/action_control_assignments' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def get_action_control_assignment( + self, + assignment_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve an action control assignment. + + Retrieve an action control template assignment by providing an action control + assignment ID. + + :param str assignment_id: Action control 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 `ActionControlAssignment` 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_action_control_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/action_control_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_action_control_assignment( + self, + assignment_id: str, + if_match: str, + template_version: str, + **kwargs, + ) -> DetailedResponse: + """ + Update an action control assignment. + + Update an action control assignment by providing an action control assignment ID. + + :param str assignment_id: Action control template assignment ID. + :param str if_match: The revision number for updating an action control + assignment and must match the Etag value of the existing action control + assignment. The Etag can be retrieved using the GET + /v1/action_control_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 `ActionControlAssignment` 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_action_control_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/action_control_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_action_control_assignment( + self, + assignment_id: str, + **kwargs, + ) -> DetailedResponse: + """ + Remove an action control assignment. + + Remove an action control template assignment by providing an action control + assignment ID. You can't delete an action control assignment if the status is + "in_progress". + + :param str assignment_id: Action control 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_action_control_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/action_control_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 PolicyType(str, Enum): + """ + Policy type, Optional. + """ + + ACCESS = 'access' + AUTHORIZATION = 'authorization' + + +class GetPolicyTemplateEnums: + """ + 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 PolicyServiceType(str, Enum): - """ - Service type, Optional. - """ - SERVICE = 'service' - PLATFORM_SERVICE = 'platform_service' +############################################################################## +# 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. + """ + + 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) + + 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 + + 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 ActionControlAssignment object.""" + return json.dumps(self.to_dict(), indent=2) + + 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__ + + def __ne__(self, other: 'ActionControlAssignment') -> 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): + """ + The action control assignment status. + """ + + ACCEPTED = 'accepted' + FAILURE = 'failure' + IN_PROGRESS = 'in_progress' + SUPERSEDED = 'superseded' + + +class ActionControlAssignmentCollection: + """ + 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. + """ + + def __init__( + self, + assignments: List['ActionControlAssignment'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + ) -> None: + """ + 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 + + @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) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentCollection 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 + 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 ActionControlAssignmentCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + 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__ + + def __ne__(self, other: 'ActionControlAssignmentCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ActionControlAssignmentResource: + """ + 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. + """ + + def __init__( + self, + target: 'AssignmentTargetDetails', + *, + action_control: Optional['ActionControlAssignmentResourceActionControl'] = None, + ) -> None: + """ + Initialize a ActionControlAssignmentResource 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. + """ + self.target = target + self.action_control = action_control + + @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) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlAssignmentResource 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, '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 + + 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 ActionControlAssignmentResource object.""" + return json.dumps(self.to_dict(), indent=2) + + 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__ + + def __ne__(self, other: 'ActionControlAssignmentResource') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ActionControlAssignmentResourceActionControl: + """ + 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 ErrorResponse error_message: (optional) The error response from API. + """ + + def __init__( + self, + *, + resource_created: Optional['ActionControlAssignmentResourceCreated'] = None, + error_message: Optional['ErrorResponse'] = None, + ) -> None: + """ + Initialize a ActionControlAssignmentResourceActionControl object. + + :param ActionControlAssignmentResourceCreated resource_created: (optional) + On success, it includes the action control assigned. + :param ErrorResponse error_message: (optional) The error response from API. + """ + self.resource_created = resource_created + self.error_message = error_message + + @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'] = ErrorResponse.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) + + 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 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 ActionControlAssignmentResourceCreated: + """ + On success, it includes the action control assigned. + + :param str id: (optional) action control id. + """ + + def __init__( + self, + *, + id: Optional[str] = None, + ) -> None: + """ + Initialize a ActionControlAssignmentResourceCreated object. + + :param str id: (optional) action control id. + """ + self.id = id + + @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) + + 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 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__ + + def __ne__(self, other: 'ActionControlAssignmentResourceCreated') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + - class PolicyType(str, Enum): +class ActionControlAssignmentTemplate: + """ + The action control 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: """ - Policy type, Optional. + Initialize a ActionControlAssignmentTemplate object. + + :param str id: Action control template ID. + :param str version: Action control template version. """ + self.id = id + self.version = version - ACCESS = 'access' - AUTHORIZATION = 'authorization' + @classmethod + def from_dict(cls, _dict: Dict) -> 'ActionControlAssignmentTemplate': + """Initialize a ActionControlAssignmentTemplate 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 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 ActionControlAssignmentTemplate object from a json dictionary.""" + return cls.from_dict(_dict) -class GetPolicyTemplateEnums: + 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 + 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 ActionControlAssignmentTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + 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: 'ActionControlAssignmentTemplate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ActionControlTemplate: """ - Enums for get_policy_template parameters. + The set of properties associated with the action control template. + + :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. """ - class State(str, Enum): + 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, + ) -> None: """ - The policy template state. + Initialize a ActionControlTemplate 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. + """ + 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.""" + 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.""" + 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, '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): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ActionControlTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + 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: 'ActionControlTemplate') -> 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 ListPolicyTemplateVersionsEnums: +class ActionControlTemplateCollection: """ - Enums for list_policy_template_versions parameters. + A collection 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 List[ActionControlTemplate] action_control_templates: List of action + control templates. """ - class State(str, Enum): - """ - The policy template state. - """ + def __init__( + self, + action_control_templates: List['ActionControlTemplate'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + ) -> None: + """ + Initialize a ActionControlTemplateCollection 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. + """ + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.action_control_templates = action_control_templates + + @classmethod + 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 + 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' + ) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ActionControlTemplateCollection 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 + return _dict + + 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 ActionControlTemplateCollection object.""" + return json.dumps(self.to_dict(), indent=2) + 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__ -############################################################################## -# Models -############################################################################## + def __ne__(self, other: 'ActionControlTemplateCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other -class AccountSettingsAccessManagement: +class ActionControlTemplateVersionsCollection: """ - The Access Management Account Settings that are currently set for the requested - account. + A collection of versions for a specific action control template. - :param ExternalAccountIdentityInteraction external_account_identity_interaction: - How external accounts can interact in relation to the requested account. + :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, - external_account_identity_interaction: 'ExternalAccountIdentityInteraction', + versions: List['ActionControlTemplate'], + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ - Initialize a AccountSettingsAccessManagement object. + Initialize a ActionControlTemplateVersionsCollection object. - :param ExternalAccountIdentityInteraction - external_account_identity_interaction: How external accounts can interact - in relation to the requested account. + :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.external_account_identity_interaction = external_account_identity_interaction + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.versions = versions @classmethod - def from_dict(cls, _dict: Dict) -> 'AccountSettingsAccessManagement': - """Initialize a AccountSettingsAccessManagement object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ActionControlTemplateVersionsCollection': + """Initialize a ActionControlTemplateVersionsCollection 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 (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 \'external_account_identity_interaction\' not present in AccountSettingsAccessManagement JSON' + 'Required property \'versions\' not present in ActionControlTemplateVersionsCollection JSON' ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AccountSettingsAccessManagement 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, '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 + 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['external_account_identity_interaction'] = self.external_account_identity_interaction.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, '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): @@ -3047,25 +5054,25 @@ 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 ActionControlTemplateVersionsCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AccountSettingsAccessManagement') -> 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: 'AccountSettingsAccessManagement') -> bool: + def __ne__(self, other: 'ActionControlTemplateVersionsCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other class AssignmentResourceCreated: """ - On success, includes the policy assigned. + On success, includes the policy that is assigned. - :param str id: (optional) policy id. + :param str id: (optional) Policy id. """ def __init__( @@ -3076,7 +5083,7 @@ def __init__( """ Initialize a AssignmentResourceCreated object. - :param str id: (optional) policy id. + :param str id: (optional) Policy id. """ self.id = id @@ -3123,21 +5130,20 @@ class AssignmentTargetDetails: """ assignment target account and type. - :param str type: (optional) Assignment target type. - :param str id: (optional) ID of the target account. + :param str type: Assignment target type. + :param str id: ID of the target account. """ def __init__( self, - *, - type: Optional[str] = None, - id: Optional[str] = None, + type: str, + id: str, ) -> None: """ Initialize a AssignmentTargetDetails object. - :param str type: (optional) Assignment target type. - :param str id: (optional) ID of the target account. + :param str type: Assignment target type. + :param str id: ID of the target account. """ self.type = type self.id = id @@ -3148,8 +5154,12 @@ def from_dict(cls, _dict: Dict) -> 'AssignmentTargetDetails': 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 AssignmentTargetDetails JSON') return cls(**args) @classmethod @@ -3196,8 +5206,8 @@ class AssignmentTemplateDetails: """ policy template details. - :param str id: (optional) policy template id. - :param str version: (optional) policy template version. + :param str id: (optional) Policy template ID. + :param str version: (optional) Policy template version. """ def __init__( @@ -3209,8 +5219,8 @@ def __init__( """ Initialize a AssignmentTemplateDetails object. - :param str id: (optional) policy template id. - :param str version: (optional) policy template version. + :param str id: (optional) Policy template ID. + :param str version: (optional) Policy template version. """ self.id = id self.version = version @@ -3263,8 +5273,8 @@ class ConflictsWith: Details of conflicting resource. :param str etag: (optional) The revision number of the resource. - :param str role: (optional) The conflicting role id. - :param str policy: (optional) The conflicting policy id. + :param str role: (optional) The conflicting role of ID. + :param str policy: (optional) The conflicting policy ID. """ def __init__( @@ -3278,8 +5288,8 @@ def __init__( Initialize a ConflictsWith object. :param str etag: (optional) The revision number of the resource. - :param str role: (optional) The conflicting role id. - :param str policy: (optional) The conflicting policy id. + :param str role: (optional) The conflicting role of ID. + :param str policy: (optional) The conflicting policy ID. """ self.etag = etag self.role = role @@ -3334,9 +5344,9 @@ def __ne__(self, other: 'ConflictsWith') -> bool: class Control: """ - Specifies the type of access granted by the policy. + Specifies the type of access that is granted by the policy. - :param Grant grant: Permission granted by the policy. + :param Grant grant: Permission is granted by the policy. """ def __init__( @@ -3346,7 +5356,7 @@ def __init__( """ Initialize a Control object. - :param Grant grant: Permission granted by the policy. + :param Grant grant: Permission is granted by the policy. """ self.grant = grant @@ -3418,7 +5428,7 @@ 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 name of the role that is shown in the + :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 @@ -3426,19 +5436,19 @@ class CustomRole: 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. Can only be - alphanumeric and has to be capitalized. + :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 + :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 + :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy. - :param str href: (optional) The href link back to the role. + :param str href: (optional) The href links back to the role. """ def __init__( @@ -3461,13 +5471,13 @@ def __init__( """ Initialize a CustomRole object. - :param str display_name: The display name of the role that is shown in the - console. + :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. Can only be - alphanumeric and has to be capitalized. + :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. @@ -3590,10 +5600,10 @@ class EnrichedRoles: :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 service defined (or user defined if a - custom role) display name of the role. - :param str description: (optional) The service defined (or user defined if a - custom role) description of the role. + :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). @@ -3855,32 +5865,32 @@ class CodeEnum(str, Enum): 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: """ The error response from API. - :param str trace: (optional) The unique transaction id for the request. - :param List[ErrorObject] errors: (optional) The errors encountered during the - response. - :param int status_code: (optional) The http error code of the response. + :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. """ def __init__( self, - *, - trace: Optional[str] = None, - errors: Optional[List['ErrorObject']] = None, - status_code: Optional[int] = None, + trace: str, + errors: List['ErrorObject'], + status_code: int, ) -> None: """ Initialize a ErrorResponse object. - :param str trace: (optional) The unique transaction id for the request. - :param List[ErrorObject] errors: (optional) The errors encountered during - the response. - :param int status_code: (optional) The http error code of the response. + :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. """ self.trace = trace self.errors = errors @@ -3892,10 +5902,16 @@ def from_dict(cls, _dict: Dict) -> 'ErrorResponse': args = {} if (trace := _dict.get('trace')) is not None: args['trace'] = trace + 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] + 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 + else: + raise ValueError('Required property \'status_code\' not present in ErrorResponse JSON') return cls(**args) @classmethod @@ -4068,7 +6084,7 @@ def __ne__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: class First: """ - Details with href linking to first page of requested collection. + Details with linking href to first page of requested collection. :param str href: (optional) The href linking to the page of requested collection. @@ -4126,9 +6142,9 @@ def __ne__(self, other: 'First') -> bool: class Grant: """ - Permission granted by the policy. + Permission is granted by the policy. - :param List[Roles] roles: A set of role cloud resource names (CRNs) granted by + :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted by the policy. """ @@ -4139,7 +6155,7 @@ def __init__( """ Initialize a Grant object. - :param List[Roles] roles: A set of role cloud resource names (CRNs) granted + :param List[Roles] roles: A set of role Cloud Resource Names (CRNs) granted by the policy. """ self.roles = roles @@ -4605,11 +6621,12 @@ def __init__( class Next: """ - Details with href linking to following page of requested collection. + Details with href linking to the following 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 collection. + :param str start: (optional) Page token that refers to the page of the + collection. """ def __init__( @@ -4621,7 +6638,7 @@ def __init__( """ Initialize a Next object. - :param str start: (optional) Page token that refers to the page of + :param str start: (optional) Page token that refers to the page of the collection. """ self.href = href @@ -4678,17 +6695,17 @@ class Policy: :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 + :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 link back to the 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 + :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 + :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. """ @@ -4714,7 +6731,7 @@ def __init__( :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) + :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. @@ -4856,7 +6873,7 @@ class PolicyAssignmentResourcePolicy: Set of properties for the assigned resource. :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy assigned. + includes the policy that is assigned. :param str status: (optional) policy status. :param ErrorResponse error_message: (optional) The error response from API. """ @@ -4872,7 +6889,7 @@ def __init__( Initialize a PolicyAssignmentResourcePolicy object. :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy assigned. + includes the policy that is assigned. :param str status: (optional) policy status. :param ErrorResponse error_message: (optional) The error response from API. """ @@ -5011,20 +7028,20 @@ class PolicyAssignmentV1: :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.. + 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 + :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 + :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 + :param PolicyAssignmentV1Subject subject: (optional) Subject details of access type assignment. :param AssignmentTemplateDetails template: policy template details. :param str status: The policy assignment status. @@ -5054,7 +7071,7 @@ def __init__( assigned. :param AssignmentTemplateDetails template: policy template details. :param str status: The policy assignment status. - :param PolicyAssignmentV1Subject subject: (optional) subject details of + :param PolicyAssignmentV1Subject subject: (optional) Subject details of access type assignment. """ self.target = target @@ -5190,29 +7207,62 @@ class PolicyAssignmentV1Collection: """ Policy assignment response. - :param List[PolicyAssignmentV1] assignments: (optional) 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 List[PolicyAssignmentV1] assignments: Response of policy assignments. """ def __init__( self, + assignments: List['PolicyAssignmentV1'], *, - assignments: Optional[List['PolicyAssignmentV1']] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, ) -> None: """ Initialize a PolicyAssignmentV1Collection object. - :param List[PolicyAssignmentV1] assignments: (optional) Response of policy + :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.limit = limit + self.first = first + self.next = next + self.previous = previous self.assignments = assignments @classmethod def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Collection': """Initialize a PolicyAssignmentV1Collection 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] + else: + raise ValueError('Required property \'assignments\' not present in PolicyAssignmentV1Collection JSON') return cls(**args) @classmethod @@ -5223,6 +7273,23 @@ def _from_dict(cls, _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: @@ -5330,7 +7397,7 @@ def __ne__(self, other: 'PolicyAssignmentV1Resources') -> bool: class PolicyAssignmentV1Subject: """ - subject details of access type assignment. + Subject details of access type assignment. :param str id: (optional) The unique identifier of the subject of the assignment. @@ -5406,37 +7473,37 @@ class PolicyCollection: A collection of policies. :param int limit: (optional) The number of documents to include per each page of - collection. - :param First first: (optional) Details with href linking to first 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 following page of + :param Next next: (optional) Details with href linking to the following page of requested collection. - :param Previous previous: (optional) Details with href linking to previous page + :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplateMetaData] policies: (optional) List of policies. + :param List[PolicyTemplateMetaData] policies: List of policies. """ def __init__( self, + policies: List['PolicyTemplateMetaData'], *, limit: Optional[int] = None, first: Optional['First'] = None, next: Optional['Next'] = None, previous: Optional['Previous'] = None, - policies: Optional[List['PolicyTemplateMetaData']] = None, ) -> None: """ Initialize a PolicyCollection object. + :param List[PolicyTemplateMetaData] policies: List of policies. :param int limit: (optional) The number of documents to include per each - page of collection. - :param First first: (optional) Details with href linking to first page of - requested collection. - :param Next next: (optional) Details with href linking to following page of + page of the collection. + :param First first: (optional) Details with linking href to first page of requested collection. - :param Previous previous: (optional) Details with href linking to previous + :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: (optional) List of policies. """ self.limit = limit self.first = first @@ -5458,6 +7525,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyCollection': 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 @@ -5518,22 +7587,20 @@ class PolicyResource: """ The attributes of the resource. Note that only one resource is allowed in a policy. - :param List[ResourceAttribute] attributes: (optional) List of resource - attributes. + :param List[ResourceAttribute] attributes: List of resource attributes. :param List[ResourceTag] tags: (optional) List of access management tags. """ def __init__( self, + attributes: List['ResourceAttribute'], *, - attributes: Optional[List['ResourceAttribute']] = None, tags: Optional[List['ResourceTag']] = None, ) -> None: """ Initialize a PolicyResource object. - :param List[ResourceAttribute] attributes: (optional) List of resource - attributes. + :param List[ResourceAttribute] attributes: List of resource attributes. :param List[ResourceTag] tags: (optional) List of access management tags. """ self.attributes = attributes @@ -5545,6 +7612,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyResource': 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) @@ -5675,19 +7744,17 @@ class PolicySubject: The subject attribute values that must match in order for this policy to apply in a permission decision. - :param List[SubjectAttribute] attributes: (optional) List of subject attributes. + :param List[SubjectAttribute] attributes: List of subject attributes. """ def __init__( self, - *, - attributes: Optional[List['SubjectAttribute']] = None, + attributes: List['SubjectAttribute'], ) -> None: """ Initialize a PolicySubject object. - :param List[SubjectAttribute] attributes: (optional) List of subject - attributes. + :param List[SubjectAttribute] attributes: List of subject attributes. """ self.attributes = attributes @@ -5697,6 +7764,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicySubject': args = {} 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 @@ -5740,29 +7809,28 @@ class PolicyTemplate: """ The core set of properties associated with the policy template. - :param str name: 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 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 will be - created. + :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 objet. - :param str state: (optional) State of policy template. + 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 + :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 + :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy template. """ @@ -5772,10 +7840,10 @@ def __init__( account_id: str, version: str, policy: 'TemplatePolicy', + state: str, *, description: Optional[str] = None, committed: Optional[bool] = None, - state: Optional[str] = None, id: Optional[str] = None, href: Optional[str] = None, created_at: Optional[datetime] = None, @@ -5786,20 +7854,20 @@ def __init__( """ 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 will change the name - value for all existing versions of the template. - :param str account_id: Enterprise account ID where this template will be + :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 objet. + 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 str state: (optional) State of policy template. """ self.name = name self.description = description @@ -5841,6 +7909,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': 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 (href := _dict.get('href')) is not None: @@ -5926,39 +7996,39 @@ class PolicyTemplateAssignmentCollection: A collection of policies assignments. :param int limit: (optional) The number of documents to include per each page of - collection. - :param First first: (optional) Details with href linking to first 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 following page of + :param Next next: (optional) Details with href linking to the following page of requested collection. - :param Previous previous: (optional) Details with href linking to previous page + :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplateAssignmentItems] assignments: (optional) List of - policy assignments. + :param List[PolicyTemplateAssignmentItems] assignments: List of policy + assignments. """ def __init__( self, + assignments: List['PolicyTemplateAssignmentItems'], *, limit: Optional[int] = None, first: Optional['First'] = None, next: Optional['Next'] = None, previous: Optional['Previous'] = None, - assignments: Optional[List['PolicyTemplateAssignmentItems']] = None, ) -> None: """ Initialize a PolicyTemplateAssignmentCollection object. + :param List[PolicyTemplateAssignmentItems] assignments: List of policy + assignments. :param int limit: (optional) The number of documents to include per each - page of collection. - :param First first: (optional) Details with href linking to first page of + 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 following page of - requested collection. - :param Previous previous: (optional) Details with href linking to previous + :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[PolicyTemplateAssignmentItems] assignments: (optional) List of - policy assignments. """ self.limit = limit self.first = first @@ -5980,6 +8050,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': args['previous'] = Previous.from_dict(previous) if (assignments := _dict.get('assignments')) is not None: args['assignments'] = assignments + else: + raise ValueError('Required property \'assignments\' not present in PolicyTemplateAssignmentCollection JSON') return cls(**args) @classmethod @@ -6062,39 +8134,37 @@ class PolicyTemplateCollection: A collection of policy Templates. :param int limit: (optional) The number of documents to include per each page of - collection. - :param First first: (optional) Details with href linking to first 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 following page of + :param Next next: (optional) Details with href linking to the following page of requested collection. - :param Previous previous: (optional) Details with href linking to previous page + :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplate] policy_templates: (optional) List of policy - templates. + :param List[PolicyTemplate] policy_templates: List of policy templates. """ def __init__( self, + policy_templates: List['PolicyTemplate'], *, limit: Optional[int] = None, first: Optional['First'] = None, next: Optional['Next'] = None, previous: Optional['Previous'] = None, - policy_templates: Optional[List['PolicyTemplate']] = None, ) -> None: """ Initialize a PolicyTemplateCollection object. + :param List[PolicyTemplate] policy_templates: List of policy templates. :param int limit: (optional) The number of documents to include per each - page of collection. - :param First first: (optional) Details with href linking to first page of + 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 following page of - requested collection. - :param Previous previous: (optional) Details with href linking to previous + :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: (optional) List of policy - templates. """ self.limit = limit self.first = first @@ -6116,6 +8186,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateCollection': 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 \'policy_templates\' not present in PolicyTemplateCollection JSON') return cls(**args) @classmethod @@ -6176,29 +8248,28 @@ class PolicyTemplateLimitData: """ The core set of properties associated with the policy template. - :param str name: 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 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 will be - created. + :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 objet. - :param str state: (optional) State of policy template. + 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 + :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 + :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. """ @@ -6209,10 +8280,10 @@ def __init__( account_id: str, version: str, policy: 'TemplatePolicy', + state: str, *, description: Optional[str] = None, committed: Optional[bool] = None, - state: Optional[str] = None, id: Optional[str] = None, href: Optional[str] = None, created_at: Optional[datetime] = None, @@ -6224,20 +8295,20 @@ def __init__( """ 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 will change the name - value for all existing versions of the template. - :param str account_id: Enterprise account ID where this template will be + :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 objet. + 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 str state: (optional) State of policy template. :param TemplateCountData counts: (optional) policy template count details. """ self.name = name @@ -6281,6 +8352,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData': 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: @@ -6376,17 +8449,17 @@ class PolicyTemplateMetaData: :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 + :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 link back to the 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 + :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 + :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 @@ -6417,7 +8490,7 @@ def __init__( :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) + :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. @@ -6571,39 +8644,37 @@ class PolicyTemplateVersionsCollection: A collection of versions for a specific policy template. :param int limit: (optional) The number of documents to include per each page of - collection. - :param First first: (optional) Details with href linking to first 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 following page of + :param Next next: (optional) Details with href linking to the following page of requested collection. - :param Previous previous: (optional) Details with href linking to previous page + :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[PolicyTemplate] versions: (optional) List of policy templates - versions. + :param List[PolicyTemplate] versions: List of policy templates versions. """ def __init__( self, + versions: List['PolicyTemplate'], *, limit: Optional[int] = None, first: Optional['First'] = None, next: Optional['Next'] = None, previous: Optional['Previous'] = None, - versions: Optional[List['PolicyTemplate']] = None, ) -> None: """ Initialize a PolicyTemplateVersionsCollection object. + :param List[PolicyTemplate] versions: List of policy templates versions. :param int limit: (optional) The number of documents to include per each - page of collection. - :param First first: (optional) Details with href linking to first page of + 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 following page of - requested collection. - :param Previous previous: (optional) Details with href linking to previous + :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] versions: (optional) List of policy templates - versions. """ self.limit = limit self.first = first @@ -6625,6 +8696,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': args['previous'] = Previous.from_dict(previous) if (versions := _dict.get('versions')) is not None: args['versions'] = [PolicyTemplate.from_dict(v) for v in versions] + else: + raise ValueError('Required property \'versions\' not present in PolicyTemplateVersionsCollection JSON') return cls(**args) @classmethod @@ -6683,11 +8756,12 @@ def __ne__(self, other: 'PolicyTemplateVersionsCollection') -> bool: class Previous: """ - Details with href linking to previous page of requested collection. + 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 collection. + :param str start: (optional) Page token that refers to the page of the + collection. """ def __init__( @@ -6699,7 +8773,7 @@ def __init__( """ Initialize a Previous object. - :param str start: (optional) Page token that refers to the page of + :param str start: (optional) Page token that refers to the page of the collection. """ self.href = href @@ -6908,7 +8982,7 @@ class Role: """ A role resource. - :param str display_name: The display name of the role that is shown in the + :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 @@ -6929,8 +9003,8 @@ def __init__( """ Initialize a Role object. - :param str display_name: The display name of the role that is shown in the - console. + :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). @@ -6998,11 +9072,11 @@ def __ne__(self, other: 'Role') -> bool: class RoleAction: """ - An action that can be performed by the policy subject when assigned role. + An action that can be performed by the policy subject when assigned a role. :param str id: Unique identifier for action with structure - service.resource.action e.g., cbr.rule.read. - :param str display_name: Service defined display name for action. + 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. """ @@ -7016,8 +9090,8 @@ def __init__( Initialize a RoleAction object. :param str id: Unique identifier for action with structure - service.resource.action e.g., cbr.rule.read. - :param str display_name: Service defined display name for action. + 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 @@ -7081,24 +9155,23 @@ class RoleCollection: """ A collection of roles returned by the 'list roles' operation. - :param List[CustomRole] custom_roles: (optional) List of custom roles. - :param List[Role] service_roles: (optional) List of service roles. - :param List[Role] system_roles: (optional) List of system roles. + :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, - *, - custom_roles: Optional[List['CustomRole']] = None, - service_roles: Optional[List['Role']] = None, - system_roles: Optional[List['Role']] = None, + custom_roles: List['CustomRole'], + service_roles: List['Role'], + system_roles: List['Role'], ) -> None: """ Initialize a RoleCollection object. - :param List[CustomRole] custom_roles: (optional) List of custom roles. - :param List[Role] service_roles: (optional) List of service roles. - :param List[Role] system_roles: (optional) List of system roles. + :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.custom_roles = custom_roles self.service_roles = service_roles @@ -7110,10 +9183,16 @@ def from_dict(cls, _dict: Dict) -> 'RoleCollection': 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] + else: + raise ValueError('Required property \'system_roles\' not present in RoleCollection JSON') return cls(**args) @classmethod @@ -7232,13 +9311,15 @@ def __ne__(self, other: 'Roles') -> bool: class RuleAttribute: """ - Rule that specifies additional access granted (e.g., time-based condition). + Rule that specifies additional access that is granted (For example, time-based + condition). :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; can be - boolean or string for resource and subject attribute. Can be string or an array - of strings (e.g., array of days to permit access) for rule attribute. + boolean or string for resource and subject attribute. Can be a string or an + array of strings (for example, an array of days to permit access) for rule + attribute. """ def __init__( @@ -7253,9 +9334,9 @@ def __init__( :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; - can be boolean or string for resource and subject attribute. Can be string - or an array of strings (e.g., array of days to permit access) for rule - attribute. + can be boolean or string for resource and subject attribute. Can be a + string or an array of strings (for example, an array of days to permit + access) for rule attribute. """ self.key = key self.operator = operator @@ -7403,7 +9484,86 @@ def __eq__(self, other: 'SubjectAttribute') -> bool: return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'SubjectAttribute') -> bool: + def __ne__(self, other: 'SubjectAttribute') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class TemplateActionControl: + """ + The action control properties that are created in an action resource when the template + is assigned. + + :param str service_name: The service name that the action control refers. + :param str description: (optional) Description of the action control. + :param List[str] actions: List of actions to control access. + """ + + def __init__( + self, + service_name: str, + actions: List[str], + *, + description: Optional[str] = None, + ) -> None: + """ + Initialize a TemplateActionControl object. + + :param str service_name: The service name that the action control refers. + :param List[str] actions: List of actions to control access. + :param str description: (optional) Description of the action control. + """ + self.service_name = service_name + self.description = description + self.actions = actions + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TemplateActionControl': + """Initialize a TemplateActionControl object from a json dictionary.""" + args = {} + 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 TemplateActionControl 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 TemplateActionControl JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TemplateActionControl 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, '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 TemplateActionControl object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TemplateActionControl') -> 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: 'TemplateActionControl') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -7492,9 +9652,9 @@ class TemplateMetadata: :param str id: (optional) The policy template ID. :param str version: (optional) Template version. - :param str assignment_id: (optional) policy assignment id. - :param str root_id: (optional) orchestrator template id. - :param str root_version: (optional) orchestrator template version. + :param str assignment_id: (optional) Policy assignment ID. + :param str root_id: (optional) Orchestrator template ID. + :param str root_version: (optional) Orchestrator template version. """ def __init__( @@ -7511,9 +9671,9 @@ def __init__( :param str id: (optional) The policy template ID. :param str version: (optional) Template version. - :param str assignment_id: (optional) policy assignment id. - :param str root_id: (optional) orchestrator template id. - :param str root_version: (optional) orchestrator template version. + :param str assignment_id: (optional) Policy assignment ID. + :param str root_id: (optional) Orchestrator template ID. + :param str root_version: (optional) Orchestrator template version. """ self.id = id self.version = version @@ -7578,7 +9738,7 @@ def __ne__(self, other: 'TemplateMetadata') -> bool: class TemplatePolicy: """ - The core set of properties associated with the template's policy objet. + The core set of properties associated with the template's policy object. :param str type: The policy type; either 'access' or 'authorization'. :param str description: (optional) Description of the policy. This is shown in @@ -7593,8 +9753,8 @@ class TemplatePolicy: 'time-based-conditions:weekly:custom-hours'. :param V2PolicyRule rule: (optional) Additional access conditions associated with the policy. - :param Control control: (optional) Specifies the type of access granted by the - policy. + :param Control control: (optional) Specifies the type of access that is granted + by the policy. """ def __init__( @@ -7624,8 +9784,8 @@ def __init__( 'time-based-conditions:weekly:custom-hours'. :param V2PolicyRule rule: (optional) Additional access conditions associated with the policy. - :param Control control: (optional) Specifies the type of access granted by - the policy. + :param Control control: (optional) Specifies the type of access that is + granted by the policy. """ self.type = type self.description = description @@ -7741,11 +9901,11 @@ class V2Policy: :param ControlResponse control: :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 + :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 + :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy. :param str state: The policy state, either 'deleted' or 'active'. :param str last_permit_at: (optional) The optional last permit time of policy, @@ -7952,38 +10112,37 @@ class V2PolicyCollection: A collection of policies. :param int limit: (optional) The number of documents to include per each page of - collection. - :param First first: (optional) Details with href linking to first 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 following page of + :param Next next: (optional) Details with href linking to the following page of requested collection. - :param Previous previous: (optional) Details with href linking to previous page + :param Previous previous: (optional) Details with linking href to previous page of requested collection. - :param List[V2PolicyTemplateMetaData] policies: (optional) List of policies. + :param List[V2PolicyTemplateMetaData] policies: List of policies. """ def __init__( self, + policies: List['V2PolicyTemplateMetaData'], *, limit: Optional[int] = None, first: Optional['First'] = None, next: Optional['Next'] = None, previous: Optional['Previous'] = None, - policies: Optional[List['V2PolicyTemplateMetaData']] = None, ) -> None: """ Initialize a V2PolicyCollection object. + :param List[V2PolicyTemplateMetaData] policies: List of policies. :param int limit: (optional) The number of documents to include per each - page of collection. - :param First first: (optional) Details with href linking to first page of - requested collection. - :param Next next: (optional) Details with href linking to following page of + page of the collection. + :param First first: (optional) Details with linking href to first page of requested collection. - :param Previous previous: (optional) Details with href linking to previous + :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[V2PolicyTemplateMetaData] policies: (optional) List of - policies. """ self.limit = limit self.first = first @@ -8005,6 +10164,8 @@ def from_dict(cls, _dict: Dict) -> 'V2PolicyCollection': args['previous'] = Previous.from_dict(previous) if (policies := _dict.get('policies')) is not None: args['policies'] = [V2PolicyTemplateMetaData.from_dict(v) for v in policies] + else: + raise ValueError('Required property \'policies\' not present in V2PolicyCollection JSON') return cls(**args) @classmethod @@ -8152,8 +10313,9 @@ class V2PolicyResourceAttribute: :param str key: The name of a resource attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; can be - boolean or string for resource and subject attribute. Can be string or an array - of strings (e.g., array of days to permit access) for rule attribute. + boolean or string for resource and subject attribute. Can be a string or an + array of strings (for example, an array of days to permit access) for rule + attribute. """ def __init__( @@ -8168,9 +10330,9 @@ def __init__( :param str key: The name of a resource attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; - can be boolean or string for resource and subject attribute. Can be string - or an array of strings (e.g., array of days to permit access) for rule - attribute. + can be boolean or string for resource and subject attribute. Can be a + string or an array of strings (for example, an array of days to permit + access) for rule attribute. """ self.key = key self.operator = operator @@ -8351,7 +10513,7 @@ class V2PolicySubject: The subject attributes for whom the policy grants access. :param List[V2PolicySubjectAttribute] attributes: List of subject attributes - associated with policy/. + associated with policy. """ def __init__( @@ -8362,7 +10524,7 @@ def __init__( Initialize a V2PolicySubject object. :param List[V2PolicySubjectAttribute] attributes: List of subject - attributes associated with policy/. + attributes associated with policy. """ self.attributes = attributes @@ -8417,11 +10579,13 @@ class V2PolicySubjectAttribute: """ Subject attribute for whom the policy grants access. - :param str key: The name of a subject attribute, e.g., iam_id, access_group_id. + :param str key: The name of a subject attribute. For example, iam_id, + access_group_id. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; can be - boolean or string for resource and subject attribute. Can be string or an array - of strings (e.g., array of days to permit access) for rule attribute. + boolean or string for resource and subject attribute. Can be a string or an + array of strings (for example, an array of days to permit access) for rule + attribute. """ def __init__( @@ -8433,13 +10597,13 @@ def __init__( """ Initialize a V2PolicySubjectAttribute object. - :param str key: The name of a subject attribute, e.g., iam_id, + :param str key: The name of a subject attribute. For example, iam_id, access_group_id. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; - can be boolean or string for resource and subject attribute. Can be string - or an array of strings (e.g., array of days to permit access) for rule - attribute. + can be boolean or string for resource and subject attribute. Can be a + string or an array of strings (for example, an array of days to permit + access) for rule attribute. """ self.key = key self.operator = operator @@ -8527,11 +10691,11 @@ class V2PolicyTemplateMetaData: :param ControlResponse control: :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 + :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 + :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy. :param str state: The policy state, either 'deleted' or 'active'. :param str last_permit_at: (optional) The optional last permit time of policy, @@ -8752,9 +10916,9 @@ class StateEnum(str, Enum): class ControlResponseControl(ControlResponse): """ - Specifies the type of access granted by the policy. + Specifies the type of access that is granted by the policy. - :param Grant grant: Permission granted by the policy. + :param Grant grant: Permission is granted by the policy. """ def __init__( @@ -8764,7 +10928,7 @@ def __init__( """ Initialize a ControlResponseControl object. - :param Grant grant: Permission granted by the policy. + :param Grant grant: Permission is granted by the policy. """ # pylint: disable=super-init-not-called self.grant = grant @@ -8815,7 +10979,8 @@ def __ne__(self, other: 'ControlResponseControl') -> bool: class ControlResponseControlWithEnrichedRoles(ControlResponse): """ - Specifies the type of access granted by the policy with additional role information. + Specifies the type of access that is granted by the policy with additional role + information. :param GrantWithEnrichedRoles grant: Permission granted by the policy with translated roles and additional role information. @@ -8880,13 +11045,15 @@ def __ne__(self, other: 'ControlResponseControlWithEnrichedRoles') -> bool: class NestedConditionRuleAttribute(NestedCondition): """ - Rule that specifies additional access granted (e.g., time-based condition). + Rule that specifies additional access that is granted (For example, time-based + condition). :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; can be - boolean or string for resource and subject attribute. Can be string or an array - of strings (e.g., array of days to permit access) for rule attribute. + boolean or string for resource and subject attribute. Can be a string or an + array of strings (for example, an array of days to permit access) for rule + attribute. """ def __init__( @@ -8901,9 +11068,9 @@ def __init__( :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; - can be boolean or string for resource and subject attribute. Can be string - or an array of strings (e.g., array of days to permit access) for rule - attribute. + can be boolean or string for resource and subject attribute. Can be a + string or an array of strings (for example, an array of days to permit + access) for rule attribute. """ # pylint: disable=super-init-not-called self.key = key @@ -8990,12 +11157,12 @@ class OperatorEnum(str, Enum): class NestedConditionRuleWithConditions(NestedCondition): """ - Rule that specifies additional access granted (e.g., time-based condition) accross - multiple conditions. + Rule that specifies additional access that is granted (for example, time-based + condition) accross multiple conditions. :param str operator: Operator to evaluate conditions. :param List[RuleAttribute] conditions: List of conditions associated with a - policy, e.g., time-based conditions that grant access over a certain time + policy. For example, time-based conditions that grant access over a certain time period. """ @@ -9009,8 +11176,8 @@ def __init__( :param str operator: Operator to evaluate conditions. :param List[RuleAttribute] conditions: List of conditions associated with a - policy, e.g., time-based conditions that grant access over a certain time - period. + policy. For example, time-based conditions that grant access over a certain + time period. """ # pylint: disable=super-init-not-called self.operator = operator @@ -9081,38 +11248,40 @@ class PolicyTemplateAssignmentItemsPolicyAssignment(PolicyTemplateAssignmentItem """ The set of properties associated with the policy template assignment. - :param str template_id: (optional) policy template id. - :param str template_version: (optional) policy template version. + :param str template_id: policy template ID. + :param str template_version: policy template version. :param str assignment_id: (optional) Passed in value to correlate with other assignments. - :param str target_type: (optional) Assignment target type. - :param str target: (optional) ID of the target account. + :param str target_type: Assignment target type. + :param str target: ID of the target account. :param str id: (optional) Policy assignment ID. :param str account_id: (optional) The account GUID that the policies assignments - belong to.. + 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 + :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 + :param str last_modified_by_id: (optional) The IAM ID of the entity that last modified the policy assignment. - :param List[PolicyAssignmentResources] resources: (optional) Object for each - account assigned. - :param str status: (optional) The policy assignment status. + :param List[PolicyAssignmentResources] resources: Object for each account + assigned. + :param str status: The policy assignment status. """ def __init__( self, + template_id: str, + template_version: str, + target_type: str, + target: str, + resources: List['PolicyAssignmentResources'], + status: str, *, - template_id: Optional[str] = None, - template_version: Optional[str] = None, assignment_id: Optional[str] = None, - target_type: Optional[str] = None, - target: Optional[str] = None, id: Optional[str] = None, account_id: Optional[str] = None, href: Optional[str] = None, @@ -9120,21 +11289,19 @@ def __init__( created_by_id: Optional[str] = None, last_modified_at: Optional[datetime] = None, last_modified_by_id: Optional[str] = None, - resources: Optional[List['PolicyAssignmentResources']] = None, - status: Optional[str] = None, ) -> None: """ Initialize a PolicyTemplateAssignmentItemsPolicyAssignment object. - :param str template_id: (optional) policy template id. - :param str template_version: (optional) policy template version. + :param str template_id: policy template ID. + :param str template_version: policy template version. + :param str target_type: Assignment target type. + :param str target: ID of the target account. + :param List[PolicyAssignmentResources] resources: Object for each account + assigned. + :param str status: The policy assignment status. :param str assignment_id: (optional) Passed in value to correlate with other assignments. - :param str target_type: (optional) Assignment target type. - :param str target: (optional) ID of the target account. - :param List[PolicyAssignmentResources] resources: (optional) Object for - each account assigned. - :param str status: (optional) The policy assignment status. """ # pylint: disable=super-init-not-called self.template_id = template_id @@ -9158,14 +11325,30 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentItemsPolicyAssignmen args = {} if (template_id := _dict.get('template_id')) is not None: args['template_id'] = template_id + else: + raise ValueError( + 'Required property \'template_id\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) if (template_version := _dict.get('template_version')) is not None: args['template_version'] = template_version + else: + raise ValueError( + 'Required property \'template_version\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) if (assignment_id := _dict.get('assignment_id')) is not None: args['assignment_id'] = assignment_id if (target_type := _dict.get('target_type')) is not None: args['target_type'] = target_type + else: + raise ValueError( + 'Required property \'target_type\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) if (target := _dict.get('target')) is not None: args['target'] = target + else: + raise ValueError( + 'Required property \'target\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) if (id := _dict.get('id')) is not None: args['id'] = id if (account_id := _dict.get('account_id')) is not None: @@ -9182,8 +11365,16 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentItemsPolicyAssignmen args['last_modified_by_id'] = last_modified_by_id if (resources := _dict.get('resources')) is not None: args['resources'] = [PolicyAssignmentResources.from_dict(v) for v in resources] + else: + raise ValueError( + 'Required property \'resources\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) if (status := _dict.get('status')) is not None: args['status'] = status + else: + raise ValueError( + 'Required property \'status\' not present in PolicyTemplateAssignmentItemsPolicyAssignment JSON' + ) return cls(**args) @classmethod @@ -9254,6 +11445,8 @@ class TargetTypeEnum(str, Enum): """ ACCOUNT = 'Account' + ACCOUNTGROUP = 'AccountGroup' + ENTERPRISE = 'Enterprise' class StatusEnum(str, Enum): """ @@ -9273,20 +11466,20 @@ class PolicyTemplateAssignmentItemsPolicyAssignmentV1(PolicyTemplateAssignmentIt :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.. + 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 + :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 + :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 + :param PolicyAssignmentV1Subject subject: (optional) Subject details of access type assignment. :param AssignmentTemplateDetails template: policy template details. :param str status: The policy assignment status. @@ -9316,7 +11509,7 @@ def __init__( assigned. :param AssignmentTemplateDetails template: policy template details. :param str status: The policy assignment status. - :param PolicyAssignmentV1Subject subject: (optional) subject details of + :param PolicyAssignmentV1Subject subject: (optional) Subject details of access type assignment. """ # pylint: disable=super-init-not-called @@ -9459,13 +11652,15 @@ class StatusEnum(str, Enum): class V2PolicyRuleRuleAttribute(V2PolicyRule): """ - Rule that specifies additional access granted (e.g., time-based condition). + Rule that specifies additional access that is granted (For example, time-based + condition). :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; can be - boolean or string for resource and subject attribute. Can be string or an array - of strings (e.g., array of days to permit access) for rule attribute. + boolean or string for resource and subject attribute. Can be a string or an + array of strings (for example, an array of days to permit access) for rule + attribute. """ def __init__( @@ -9480,9 +11675,9 @@ def __init__( :param str key: The name of an attribute. :param str operator: The operator of an attribute. :param object value: The value of a rule, resource, or subject attribute; - can be boolean or string for resource and subject attribute. Can be string - or an array of strings (e.g., array of days to permit access) for rule - attribute. + can be boolean or string for resource and subject attribute. Can be a + string or an array of strings (for example, an array of days to permit + access) for rule attribute. """ # pylint: disable=super-init-not-called self.key = key @@ -9569,12 +11764,12 @@ class OperatorEnum(str, Enum): class V2PolicyRuleRuleWithNestedConditions(V2PolicyRule): """ - Rule that specifies additional access granted (e.g., time-based condition) accross - multiple conditions. + Rule that specifies additional access that is granted (for example, time-based + condition) accross multiple conditions. :param str operator: Operator to evaluate conditions. :param List[NestedCondition] conditions: List of conditions associated with a - policy, e.g., time-based conditions that grant access over a certain time + policy. For example, time-based conditions that grant access over a certain time period. """ @@ -9588,8 +11783,8 @@ def __init__( :param str operator: Operator to evaluate conditions. :param List[NestedCondition] conditions: List of conditions associated with - a policy, e.g., time-based conditions that grant access over a certain time - period. + a policy. For example, time-based conditions that grant access over a + certain time period. """ # pylint: disable=super-init-not-called self.operator = operator @@ -9719,7 +11914,7 @@ def __init__( :param str state: (optional) The state of the policy. * `active` - returns active policies * `deleted` - returns non-active policies. - :param int limit: (optional) The number of documents to include in + :param int limit: (optional) The number of documents to include in the collection. """ self._has_next = True @@ -9860,7 +12055,7 @@ def __init__( :param str state: (optional) The state of the policy. * `active` - returns active policies * `deleted` - returns non-active policies. - :param int limit: (optional) The number of documents to include in + :param int limit: (optional) The number of documents to include in the collection. """ self._has_next = True @@ -9975,7 +12170,7 @@ def __init__( :param str policy_service_name: (optional) Service name, Optional. :param str policy_service_group_id: (optional) Service group id, Optional. :param str policy_type: (optional) Policy type, Optional. - :param int limit: (optional) The number of documents to include in + :param int limit: (optional) The number of documents to include in the collection. """ self._has_next = True @@ -10060,7 +12255,7 @@ def __init__( Initialize a PolicyTemplateVersionsPager object. :param str policy_template_id: The policy template ID. :param str state: (optional) The policy template state. - :param int limit: (optional) The number of documents to include in + :param int limit: (optional) The number of documents to include in the collection. """ self._has_next = True @@ -10150,7 +12345,7 @@ def __init__( * `zh-tw` - (Chinese, Taiwan). :param str template_id: (optional) Optional template id. :param str template_version: (optional) Optional policy template version. - :param int limit: (optional) The number of documents to include in + :param int limit: (optional) The number of documents to include in the collection. """ self._has_next = True @@ -10210,3 +12405,255 @@ def get_all(self) -> List[dict]: next_page = self.get_next() results.extend(next_page) return results + + +class ActionControlTemplatesPager: + """ + ActionControlTemplatesPager can be used to simplify the use of the "list_action_control_templates" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + limit: int = None, + ) -> None: + """ + Initialize a ActionControlTemplatesPager object. + :param str account_id: The account GUID that the action control 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 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._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 ActionControlTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_action_control_templates( + account_id=self._account_id, + accept_language=self._accept_language, + 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('action_control_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 ActionControlTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class ActionControlTemplateVersionsPager: + """ + ActionControlTemplateVersionsPager can be used to simplify the use of the "list_action_control_template_versions" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + action_control_template_id: str, + state: str = None, + limit: int = None, + ) -> None: + """ + Initialize a ActionControlTemplateVersionsPager object. + :param str action_control_template_id: The action control template ID. + :param str state: (optional) Action control 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._action_control_template_id = action_control_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 ActionControlTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_action_control_template_versions( + action_control_template_id=self._action_control_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 ActionControlTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class ActionControlAssignmentsPager: + """ + ActionControlAssignmentsPager can be used to simplify the use of the "list_action_control_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 ActionControlAssignmentsPager object. + :param str account_id: The account GUID in which the action control + 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 action control 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 ActionControlAssignment. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_action_control_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 ActionControlAssignment. + :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 b0e7844..6f4dc51 100644 --- a/test/integration/test_iam_policy_management_v1.py +++ b/test/integration/test_iam_policy_management_v1.py @@ -53,8 +53,6 @@ def setUpClass(cls): assert cls.testAccountId is not None cls.testTargetAccountId = cls.config.get('TEST_TARGET_ACCOUNT_ID') assert cls.testTargetAccountId is not None - cls.testTargetEnterpriseAccountId = cls.config.get('TEST_TARGET_ENTERPRISE_ACCOUNT_ID') - assert cls.testTargetEnterpriseAccountId is not None cls.etagHeader = "ETag" cls.testPolicyETag = "" @@ -144,6 +142,16 @@ def setUpClass(cls): ) cls.testTemplatePrefix = 'SDKPython' cls.testTemplateName = cls.testTemplatePrefix + str(random.randint(0, 99999)) + cls.testActionControlTemplateName = 'TestActionControl' + cls.testTemplatePrefix + str(random.randint(0, 99999)) + cls.testActionControlBaseTemplateId = "" + cls.testActionControlBaseTemplateVersion = "" + cls.testActionControlBaseTemplateETag = "" + cls.testActionControlTemplateId = "" + cls.testActionControlTemplateVersion = "" + cls.testActionControlAssignmentId = "" + cls.testActionControlTemplateUpdateVersion = "" + cls.testActionControlTemplateETag = "" + cls.testActionControlAssignmentEtag = "" print('\nSetup complete.') @@ -974,3 +982,323 @@ def test_34_update_access_management_account_settings(self): assert result.external_account_identity_interaction.identity_types.service.state == "monitor" assert result.external_account_identity_interaction.identity_types.service_id is not None assert result.external_account_identity_interaction.identity_types.service_id.state == "monitor" + + def test_35_create_action_control_basic_template(self): + response = self.service.create_action_control_template( + name=self.testActionControlTemplateName, + account_id=self.testAccountId, + description='SDK Test ActionControl Template', + ) + assert response is not None + + assert response.get_status_code() == 201 + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + + self.__class__.testActionControlBaseTemplateId = result.id + self.__class__.testActionControlBaseTemplateVersion = result.version + assert result.state == "active" + + def test_36_get_action_control_basic_template(self): + assert self.testActionControlBaseTemplateId + print("Action Control Template ID: ", self.testActionControlBaseTemplateId) + + response = self.service.get_action_control_template( + action_control_template_id=self.testActionControlBaseTemplateId, + ) + assert response is not None + assert response.get_status_code() == 200 + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + + self.__class__.testActionControlBaseTemplateETag = response.get_headers().get(self.etagHeader) + assert result.state == "active" + + def test_37_replace_action_control_basic_template(self): + assert self.testActionControlBaseTemplateId + assert self.testActionControlBaseTemplateETag + assert self.testActionControlBaseTemplateVersion + + print("ActionControl Template ID: ", self.testActionControlBaseTemplateId) + + updated_template_description = 'SDK Updated Test Action Control Template' + updated_template_name = 'SDK Test Action Control Without Action Control' + response = self.service.replace_action_control_template( + action_control_template_id=self.testActionControlBaseTemplateId, + version=self.testActionControlBaseTemplateVersion, + if_match=self.testActionControlBaseTemplateETag, + description=updated_template_description, + name=updated_template_name, + ) + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + self.__class__.testActionControlBaseTemplateETag = response.get_headers().get(self.etagHeader) + assert result.description == updated_template_description + assert result.name == updated_template_name + assert result.state == "active" + + def test_38_replace_action_control_template(self): + assert self.testActionControlBaseTemplateId + assert self.testActionControlBaseTemplateETag + assert self.testActionControlBaseTemplateVersion + + print("ActionControl Template ID: ", self.testActionControlBaseTemplateId) + + updated_template_description = 'SDK Updated Test Action Control Template With ActionControl' + + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.delete'], + } + + response = self.service.replace_action_control_template( + action_control_template_id=self.testActionControlBaseTemplateId, + version=self.testActionControlBaseTemplateVersion, + if_match=self.testActionControlBaseTemplateETag, + description=updated_template_description, + action_control=template_action_control_model, + ) + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + assert result.description == updated_template_description + assert result.state == "active" + + def test_39_list_action_control_templates(self): + response = self.service.list_action_control_templates( + account_id=self.testAccountId, + accept_language='default', + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplateCollection.from_dict(result_dict) + + print("Action Control Template list: ", result) + + # Confirm the test action control template is present + foundTestTemplate = False + for template in result.action_control_templates: + if template.id == self.testActionControlBaseTemplateId: + foundTestTemplate = True + break + assert foundTestTemplate + assert result.action_control_templates[0].state == "active" + + def test_40_delete_action_control_base_template_version(self): + response = self.service.delete_action_control_template_version( + action_control_template_id=self.testActionControlBaseTemplateId, + version=self.testActionControlBaseTemplateVersion, + ) + assert response.get_status_code() == 204 + + def test_41_create_action_template(self): + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.delete'], + } + + response = self.service.create_action_control_template( + name=self.testActionControlTemplateName, + account_id=self.testAccountId, + description='SDK Test ActionControl Template', + action_control=template_action_control_model, + ) + assert response is not None + + assert response.get_status_code() == 201 + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + + self.__class__.testActionControlTemplateId = result.id + self.__class__.testActionControlTemplateVersion = result.version + self.__class__.testActionControlTemplateETag = response.get_headers().get(self.etagHeader) + assert result.state == "active" + + def test_41_create_action_template_version(self): + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.create'], + } + + response = self.service.create_action_control_template_version( + action_control=template_action_control_model, + description='SDK Test Policy S2S Template', + committed=True, + action_control_template_id=self.testActionControlTemplateId, + ) + assert response is not None + + assert response.get_status_code() == 201 + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + print("ActionControl Template Version: ", result) + assert result is not None + + self.__class__.testActionControlTemplateUpdateVersion = result.version + assert result.state == "active" + + def test_42_replace_action_control_template(self): + assert self.testActionControlTemplateId + assert self.testActionControlTemplateVersion + assert self.testActionControlTemplateETag + + print("ActionControl Template ID: ", self.testActionControlTemplateId) + + updated_template_description = 'SDK Updated Test Action Control Template' + + template_action_control_model = { + 'service_name': 'am-test-service', + 'description': 'am-test-service service actionControl', + 'actions': ['am-test-service.test.delete'], + } + + response = self.service.replace_action_control_template( + action_control_template_id=self.testActionControlTemplateId, + version=self.testActionControlTemplateVersion, + if_match=self.testActionControlTemplateETag, + description=updated_template_description, + action_control=template_action_control_model, + ) + + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + assert result.description == updated_template_description + assert result.state == "active" + + def test_43_get_action_control_template_version(self): + response = self.service.get_action_control_template_version( + action_control_template_id=self.testActionControlTemplateId, + version=self.testActionControlTemplateVersion, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + self.__class__.testTemplateETag = response.get_headers().get(self.etagHeader) + result = ActionControlTemplate.from_dict(result_dict) + assert result is not None + assert result.state == "active" + + def test_44_commit_action_control_template(self): + response = self.service.commit_action_control_template( + action_control_template_id=self.testActionControlTemplateId, + version=self.testActionControlTemplateVersion, + ) + assert response.get_status_code() == 204 + + def test_45_list_policy_template_versions(self): + response = self.service.list_action_control_template_versions( + action_control_template_id=self.testActionControlTemplateId, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlTemplateVersionsCollection.from_dict(result_dict) + assert result is not None + assert len(result.versions) == 2 + + # Confirm the test policy template with new version is present + foundTestTemplateVersion = False + for version in result.versions: + if version.version == self.testActionControlTemplateVersion: + foundTestTemplateVersion = True + break + assert foundTestTemplateVersion + + def test_46_create_action_control_assignment(self): + response = self.service.create_action_control_template_assignment( + target=AssignmentTargetDetails( + type="Account", + id=self.testTargetAccountId, + ), + templates=[ + AssignmentTemplateDetails( + id=self.testActionControlTemplateId, version=self.testActionControlTemplateVersion + ) + ], + ) + assert response.get_status_code() == 201 + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlAssignmentCollection.from_dict(result_dict) + print("ActionControl Assignment Creation: ", result) + assert result is not None + self.__class__.testActionControlAssignmentId = result.assignments[0].id + self.__class__.testActionControlAssignmentEtag = response.get_headers().get(self.etagHeader) + + def test_47_list_action_control_assignments(self): + response = self.service.list_action_control_assignments( + account_id=self.testAccountId, + accept_language='default', + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + result = ActionControlAssignmentCollection.from_dict(result_dict) + assert result is not None + + def test_48_update_action_control_assignment(self): + assert self.testActionControlAssignmentId + assert self.testActionControlAssignmentEtag + print("Assignment ID: ", self.testActionControlAssignmentId) + response = self.service.update_action_control_assignment( + assignment_id=self.testActionControlAssignmentId, + if_match=self.testActionControlAssignmentEtag, + template_version=self.testActionControlTemplateUpdateVersion, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlAssignment.from_dict(result_dict) + assert result is not None + print("ActionControl Assignment Update: ", result) + + def test_49_delete_action_control_assignment(self): + response = self.service.delete_action_control_assignment( + assignment_id=self.testActionControlAssignmentId, + ) + assert response.get_status_code() == 204 + + def test_50_delete_action_control_template(self): + response = self.service.delete_action_control_template( + action_control_template_id=self.testActionControlTemplateId, + ) + 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 8f52300..3fd2919 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": 11}}}], "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": {"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"}]}' 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": 11}}}], "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": {"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"}]}' 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": 11}}}], "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": {"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"}]}' 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":11}}}],"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":11}}}],"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":{"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}' 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":11}}}],"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":11}}}],"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":{"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}' 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 = '{"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": 11}}}], "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": {"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"}]}' 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 = '{"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": 11}}}], "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": {"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"}]}' 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 = '{"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": 11}}}], "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": {"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"}]}' 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": 11}}}], "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": {"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"}' 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": 11}}}], "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": {"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"}' 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": 11}}}], "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": {"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"}' 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": 11}}}], "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": {"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"}' responses.add( responses.PATCH, url, @@ -5300,63 +5300,2540 @@ def test_update_settings_value_error_with_retries(self): # End of Service: AccessManagementSettings ############################################################################## +############################################################################## +# Start of Service: ActionControlTemplates +############################################################################## +# 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 TestListActionControlTemplates: + """ + Test Class for list_action_control_templates + """ + + @responses.activate + def test_list_action_control_templates_all_params(self): + """ + list_action_control_templates() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "action_control_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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' + limit = 50 + start = 'testString' + + # Invoke method + response = _service.list_action_control_templates( + account_id, + accept_language=accept_language, + 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 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string + + def test_list_action_control_templates_all_params_with_retries(self): + # Enable retries and run test_list_action_control_templates_all_params. + _service.enable_retries() + self.test_list_action_control_templates_all_params() + + # Disable retries and run test_list_action_control_templates_all_params. + _service.disable_retries() + self.test_list_action_control_templates_all_params() + + @responses.activate + def test_list_action_control_templates_required_params(self): + """ + test_list_action_control_templates_required_params() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "action_control_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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_action_control_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_action_control_templates_required_params_with_retries(self): + # Enable retries and run test_list_action_control_templates_required_params. + _service.enable_retries() + self.test_list_action_control_templates_required_params() + + # Disable retries and run test_list_action_control_templates_required_params. + _service.disable_retries() + self.test_list_action_control_templates_required_params() + + @responses.activate + def test_list_action_control_templates_value_error(self): + """ + test_list_action_control_templates_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "action_control_templates": [{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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_action_control_templates(**req_copy) + + def test_list_action_control_templates_value_error_with_retries(self): + # Enable retries and run test_list_action_control_templates_value_error. + _service.enable_retries() + self.test_list_action_control_templates_value_error() + + # Disable retries and run test_list_action_control_templates_value_error. + _service.disable_retries() + self.test_list_action_control_templates_value_error() + + @responses.activate + def test_list_action_control_templates_with_pager_get_next(self): + """ + test_list_action_control_templates_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/action_control_templates') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"action_control_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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,"action_control_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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 = ActionControlTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + 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_action_control_templates_with_pager_get_all(self): + """ + test_list_action_control_templates_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/action_control_templates') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"action_control_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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,"action_control_templates":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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 = ActionControlTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateActionControlTemplate: + """ + Test Class for create_action_control_template + """ + + @responses.activate + def test_create_action_control_template_all_params(self): + """ + create_action_control_template() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + action_control = template_action_control_model + accept_language = 'default' + + # Invoke method + response = _service.create_action_control_template( + name, + account_id, + description=description, + committed=committed, + action_control=action_control, + 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['action_control'] == template_action_control_model + + def test_create_action_control_template_all_params_with_retries(self): + # Enable retries and run test_create_action_control_template_all_params. + _service.enable_retries() + self.test_create_action_control_template_all_params() + + # Disable retries and run test_create_action_control_template_all_params. + _service.disable_retries() + self.test_create_action_control_template_all_params() + + @responses.activate + def test_create_action_control_template_required_params(self): + """ + test_create_action_control_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + action_control = template_action_control_model + + # Invoke method + response = _service.create_action_control_template( + name, + account_id, + description=description, + committed=committed, + action_control=action_control, + 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['action_control'] == template_action_control_model + + def test_create_action_control_template_required_params_with_retries(self): + # Enable retries and run test_create_action_control_template_required_params. + _service.enable_retries() + self.test_create_action_control_template_required_params() + + # Disable retries and run test_create_action_control_template_required_params. + _service.disable_retries() + self.test_create_action_control_template_required_params() + + @responses.activate + def test_create_action_control_template_value_error(self): + """ + test_create_action_control_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + name = 'testString' + account_id = 'testString' + description = 'testString' + committed = True + action_control = template_action_control_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_action_control_template(**req_copy) + + def test_create_action_control_template_value_error_with_retries(self): + # Enable retries and run test_create_action_control_template_value_error. + _service.enable_retries() + self.test_create_action_control_template_value_error() + + # Disable retries and run test_create_action_control_template_value_error. + _service.disable_retries() + self.test_create_action_control_template_value_error() + + +class TestGetActionControlTemplate: + """ + Test Class for get_action_control_template + """ + + @responses.activate + def test_get_action_control_template_all_params(self): + """ + get_action_control_template() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 + action_control_template_id = 'testString' + state = 'active' + + # Invoke method + response = _service.get_action_control_template( + action_control_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_action_control_template_all_params_with_retries(self): + # Enable retries and run test_get_action_control_template_all_params. + _service.enable_retries() + self.test_get_action_control_template_all_params() + + # Disable retries and run test_get_action_control_template_all_params. + _service.disable_retries() + self.test_get_action_control_template_all_params() + + @responses.activate + def test_get_action_control_template_required_params(self): + """ + test_get_action_control_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 + action_control_template_id = 'testString' + + # Invoke method + response = _service.get_action_control_template( + action_control_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_action_control_template_required_params_with_retries(self): + # Enable retries and run test_get_action_control_template_required_params. + _service.enable_retries() + self.test_get_action_control_template_required_params() + + # Disable retries and run test_get_action_control_template_required_params. + _service.disable_retries() + self.test_get_action_control_template_required_params() + + @responses.activate + def test_get_action_control_template_value_error(self): + """ + test_get_action_control_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 + action_control_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template(**req_copy) + + def test_get_action_control_template_value_error_with_retries(self): + # Enable retries and run test_get_action_control_template_value_error. + _service.enable_retries() + self.test_get_action_control_template_value_error() + + # Disable retries and run test_get_action_control_template_value_error. + _service.disable_retries() + self.test_get_action_control_template_value_error() + + +class TestDeleteActionControlTemplate: + """ + Test Class for delete_action_control_template + """ + + @responses.activate + def test_delete_action_control_template_all_params(self): + """ + delete_action_control_template() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + + # Invoke method + response = _service.delete_action_control_template( + action_control_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_action_control_template_all_params_with_retries(self): + # Enable retries and run test_delete_action_control_template_all_params. + _service.enable_retries() + self.test_delete_action_control_template_all_params() + + # Disable retries and run test_delete_action_control_template_all_params. + _service.disable_retries() + self.test_delete_action_control_template_all_params() + + @responses.activate + def test_delete_action_control_template_value_error(self): + """ + test_delete_action_control_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template(**req_copy) + + def test_delete_action_control_template_value_error_with_retries(self): + # Enable retries and run test_delete_action_control_template_value_error. + _service.enable_retries() + self.test_delete_action_control_template_value_error() + + # Disable retries and run test_delete_action_control_template_value_error. + _service.disable_retries() + self.test_delete_action_control_template_value_error() + + +class TestCreateActionControlTemplateVersion: + """ + Test Class for create_action_control_template_version + """ + + @responses.activate + def test_create_action_control_template_version_all_params(self): + """ + create_action_control_template_version() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + action_control_template_id = 'testString' + name = 'testString' + description = 'testString' + action_control = template_action_control_model + committed = True + + # Invoke method + response = _service.create_action_control_template_version( + action_control_template_id, + name=name, + description=description, + action_control=action_control, + 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['name'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['action_control'] == template_action_control_model + assert req_body['committed'] == True + + def test_create_action_control_template_version_all_params_with_retries(self): + # Enable retries and run test_create_action_control_template_version_all_params. + _service.enable_retries() + self.test_create_action_control_template_version_all_params() + + # Disable retries and run test_create_action_control_template_version_all_params. + _service.disable_retries() + self.test_create_action_control_template_version_all_params() + + @responses.activate + def test_create_action_control_template_version_value_error(self): + """ + test_create_action_control_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + action_control_template_id = 'testString' + name = 'testString' + description = 'testString' + action_control = template_action_control_model + committed = True + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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.create_action_control_template_version(**req_copy) + + def test_create_action_control_template_version_value_error_with_retries(self): + # Enable retries and run test_create_action_control_template_version_value_error. + _service.enable_retries() + self.test_create_action_control_template_version_value_error() + + # Disable retries and run test_create_action_control_template_version_value_error. + _service.disable_retries() + self.test_create_action_control_template_version_value_error() + + +class TestListActionControlTemplateVersions: + """ + Test Class for list_action_control_template_versions + """ + + @responses.activate + def test_list_action_control_template_versions_all_params(self): + """ + list_action_control_template_versions() + """ + # Set up mock + url = preprocess_url('/v1/action_control_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, "action_control": {"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 + action_control_template_id = 'testString' + state = 'active' + limit = 50 + start = 'testString' + + # Invoke method + response = _service.list_action_control_template_versions( + action_control_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_action_control_template_versions_all_params_with_retries(self): + # Enable retries and run test_list_action_control_template_versions_all_params. + _service.enable_retries() + self.test_list_action_control_template_versions_all_params() + + # Disable retries and run test_list_action_control_template_versions_all_params. + _service.disable_retries() + self.test_list_action_control_template_versions_all_params() + + @responses.activate + def test_list_action_control_template_versions_required_params(self): + """ + test_list_action_control_template_versions_required_params() + """ + # Set up mock + url = preprocess_url('/v1/action_control_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, "action_control": {"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 + action_control_template_id = 'testString' + + # Invoke method + response = _service.list_action_control_template_versions( + action_control_template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_action_control_template_versions_required_params_with_retries(self): + # Enable retries and run test_list_action_control_template_versions_required_params. + _service.enable_retries() + self.test_list_action_control_template_versions_required_params() + + # Disable retries and run test_list_action_control_template_versions_required_params. + _service.disable_retries() + self.test_list_action_control_template_versions_required_params() + + @responses.activate + def test_list_action_control_template_versions_value_error(self): + """ + test_list_action_control_template_versions_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_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, "action_control": {"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 + action_control_template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template_versions(**req_copy) + + def test_list_action_control_template_versions_value_error_with_retries(self): + # Enable retries and run test_list_action_control_template_versions_value_error. + _service.enable_retries() + self.test_list_action_control_template_versions_value_error() + + # Disable retries and run test_list_action_control_template_versions_value_error. + _service.disable_retries() + self.test_list_action_control_template_versions_value_error() + + @responses.activate + def test_list_action_control_template_versions_with_pager_get_next(self): + """ + test_list_action_control_template_versions_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/action_control_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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,"action_control":{"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 = ActionControlTemplateVersionsPager( + client=_service, + action_control_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_action_control_template_versions_with_pager_get_all(self): + """ + test_list_action_control_template_versions_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/action_control_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","committed":false,"action_control":{"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,"action_control":{"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 = ActionControlTemplateVersionsPager( + client=_service, + action_control_template_id='testString', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestReplaceActionControlTemplate: + """ + Test Class for replace_action_control_template + """ + + @responses.activate + def test_replace_action_control_template_all_params(self): + """ + replace_action_control_template() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + if_match = 'testString' + name = 'testString' + description = 'testString' + action_control = template_action_control_model + committed = True + + # Invoke method + response = _service.replace_action_control_template( + action_control_template_id, + version, + if_match, + name=name, + description=description, + action_control=action_control, + 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['name'] == 'testString' + assert req_body['description'] == 'testString' + assert req_body['action_control'] == template_action_control_model + assert req_body['committed'] == True + + def test_replace_action_control_template_all_params_with_retries(self): + # Enable retries and run test_replace_action_control_template_all_params. + _service.enable_retries() + self.test_replace_action_control_template_all_params() + + # Disable retries and run test_replace_action_control_template_all_params. + _service.disable_retries() + self.test_replace_action_control_template_all_params() + + @responses.activate + def test_replace_action_control_template_value_error(self): + """ + test_replace_action_control_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 TemplateActionControl model + template_action_control_model = {} + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + if_match = 'testString' + name = 'testString' + description = 'testString' + action_control = template_action_control_model + committed = True + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_template_id, + "version": version, + "if_match": if_match, + } + 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_action_control_template(**req_copy) + + def test_replace_action_control_template_value_error_with_retries(self): + # Enable retries and run test_replace_action_control_template_value_error. + _service.enable_retries() + self.test_replace_action_control_template_value_error() + + # Disable retries and run test_replace_action_control_template_value_error. + _service.disable_retries() + self.test_replace_action_control_template_value_error() + + +class TestDeleteActionControlTemplateVersion: + """ + Test Class for delete_action_control_template_version + """ + + @responses.activate + def test_delete_action_control_template_version_all_params(self): + """ + delete_action_control_template_version() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.delete_action_control_template_version( + action_control_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_action_control_template_version_all_params_with_retries(self): + # Enable retries and run test_delete_action_control_template_version_all_params. + _service.enable_retries() + self.test_delete_action_control_template_version_all_params() + + # Disable retries and run test_delete_action_control_template_version_all_params. + _service.disable_retries() + self.test_delete_action_control_template_version_all_params() + + @responses.activate + def test_delete_action_control_template_version_value_error(self): + """ + test_delete_action_control_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template_version(**req_copy) + + def test_delete_action_control_template_version_value_error_with_retries(self): + # Enable retries and run test_delete_action_control_template_version_value_error. + _service.enable_retries() + self.test_delete_action_control_template_version_value_error() + + # Disable retries and run test_delete_action_control_template_version_value_error. + _service.disable_retries() + self.test_delete_action_control_template_version_value_error() + + +class TestGetActionControlTemplateVersion: + """ + Test Class for get_action_control_template_version + """ + + @responses.activate + def test_get_action_control_template_version_all_params(self): + """ + get_action_control_template_version() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 + action_control_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.get_action_control_template_version( + action_control_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_action_control_template_version_all_params_with_retries(self): + # Enable retries and run test_get_action_control_template_version_all_params. + _service.enable_retries() + self.test_get_action_control_template_version_all_params() + + # Disable retries and run test_get_action_control_template_version_all_params. + _service.disable_retries() + self.test_get_action_control_template_version_all_params() + + @responses.activate + def test_get_action_control_template_version_value_error(self): + """ + test_get_action_control_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString') + mock_response = '{"name": "name", "description": "description", "account_id": "account_id", "committed": false, "action_control": {"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 + action_control_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template_version(**req_copy) + + def test_get_action_control_template_version_value_error_with_retries(self): + # Enable retries and run test_get_action_control_template_version_value_error. + _service.enable_retries() + self.test_get_action_control_template_version_value_error() + + # Disable retries and run test_get_action_control_template_version_value_error. + _service.disable_retries() + self.test_get_action_control_template_version_value_error() + + +class TestCommitActionControlTemplate: + """ + Test Class for commit_action_control_template + """ + + @responses.activate + def test_commit_action_control_template_all_params(self): + """ + commit_action_control_template() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + + # Invoke method + response = _service.commit_action_control_template( + action_control_template_id, + version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_commit_action_control_template_all_params_with_retries(self): + # Enable retries and run test_commit_action_control_template_all_params. + _service.enable_retries() + self.test_commit_action_control_template_all_params() + + # Disable retries and run test_commit_action_control_template_all_params. + _service.disable_retries() + self.test_commit_action_control_template_all_params() + + @responses.activate + def test_commit_action_control_template_value_error(self): + """ + test_commit_action_control_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + action_control_template_id = 'testString' + version = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "action_control_template_id": action_control_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_action_control_template(**req_copy) + + def test_commit_action_control_template_value_error_with_retries(self): + # Enable retries and run test_commit_action_control_template_value_error. + _service.enable_retries() + self.test_commit_action_control_template_value_error() + + # Disable retries and run test_commit_action_control_template_value_error. + _service.disable_retries() + self.test_commit_action_control_template_value_error() + + +# endregion +############################################################################## +# End of Service: ActionControlTemplates +############################################################################## + +############################################################################## +# Start of Service: ActionControlAssignments +############################################################################## +# 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 TestListActionControlAssignments: + """ + Test Class for list_action_control_assignments + """ + + @responses.activate + def test_list_action_control_assignments_all_params(self): + """ + list_action_control_assignments() + """ + # 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"}]}' + 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_action_control_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_action_control_assignments_all_params_with_retries(self): + # Enable retries and run test_list_action_control_assignments_all_params. + _service.enable_retries() + self.test_list_action_control_assignments_all_params() + + # Disable retries and run test_list_action_control_assignments_all_params. + _service.disable_retries() + self.test_list_action_control_assignments_all_params() + + @responses.activate + def test_list_action_control_assignments_required_params(self): + """ + test_list_action_control_assignments_required_params() + """ + # 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"}]}' + 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_action_control_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_action_control_assignments_required_params_with_retries(self): + # Enable retries and run test_list_action_control_assignments_required_params. + _service.enable_retries() + self.test_list_action_control_assignments_required_params() + + # Disable retries and run test_list_action_control_assignments_required_params. + _service.disable_retries() + self.test_list_action_control_assignments_required_params() + + @responses.activate + def test_list_action_control_assignments_value_error(self): + """ + test_list_action_control_assignments_value_error() + """ + # 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"}]}' + 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_action_control_assignments(**req_copy) + + def test_list_action_control_assignments_value_error_with_retries(self): + # Enable retries and run test_list_action_control_assignments_value_error. + _service.enable_retries() + self.test_list_action_control_assignments_value_error() + + # Disable retries and run test_list_action_control_assignments_value_error. + _service.disable_retries() + self.test_list_action_control_assignments_value_error() + + @responses.activate + def test_list_action_control_assignments_with_pager_get_next(self): + """ + test_list_action_control_assignments_with_pager_get_next() + """ + # 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}' + 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 = ActionControlAssignmentsPager( + 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_action_control_assignments_with_pager_get_all(self): + """ + test_list_action_control_assignments_with_pager_get_all() + """ + # 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}' + 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 = ActionControlAssignmentsPager( + 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 TestCreateActionControlTemplateAssignment: + """ + Test Class for create_action_control_template_assignment + """ + + @responses.activate + def test_create_action_control_template_assignment_all_params(self): + """ + create_action_control_template_assignment() + """ + # 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"}]}' + 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 ActionControlAssignmentTemplate model + action_control_assignment_template_model = {} + action_control_assignment_template_model['id'] = 'testString' + action_control_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [action_control_assignment_template_model] + accept_language = 'default' + + # Invoke method + response = _service.create_action_control_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'] == [action_control_assignment_template_model] + + def test_create_action_control_template_assignment_all_params_with_retries(self): + # Enable retries and run test_create_action_control_template_assignment_all_params. + _service.enable_retries() + self.test_create_action_control_template_assignment_all_params() + + # Disable retries and run test_create_action_control_template_assignment_all_params. + _service.disable_retries() + self.test_create_action_control_template_assignment_all_params() + + @responses.activate + def test_create_action_control_template_assignment_required_params(self): + """ + test_create_action_control_template_assignment_required_params() + """ + # 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"}]}' + 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 ActionControlAssignmentTemplate model + action_control_assignment_template_model = {} + action_control_assignment_template_model['id'] = 'testString' + action_control_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [action_control_assignment_template_model] + + # Invoke method + response = _service.create_action_control_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'] == [action_control_assignment_template_model] + + def test_create_action_control_template_assignment_required_params_with_retries(self): + # Enable retries and run test_create_action_control_template_assignment_required_params. + _service.enable_retries() + self.test_create_action_control_template_assignment_required_params() + + # Disable retries and run test_create_action_control_template_assignment_required_params. + _service.disable_retries() + self.test_create_action_control_template_assignment_required_params() + + @responses.activate + def test_create_action_control_template_assignment_value_error(self): + """ + test_create_action_control_template_assignment_value_error() + """ + # 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"}]}' + 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 ActionControlAssignmentTemplate model + action_control_assignment_template_model = {} + action_control_assignment_template_model['id'] = 'testString' + action_control_assignment_template_model['version'] = 'testString' + + # Set up parameter values + target = assignment_target_details_model + templates = [action_control_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_action_control_template_assignment(**req_copy) + + def test_create_action_control_template_assignment_value_error_with_retries(self): + # Enable retries and run test_create_action_control_template_assignment_value_error. + _service.enable_retries() + self.test_create_action_control_template_assignment_value_error() + + # Disable retries and run test_create_action_control_template_assignment_value_error. + _service.disable_retries() + self.test_create_action_control_template_assignment_value_error() + + +class TestGetActionControlAssignment: + """ + Test Class for get_action_control_assignment + """ + + @responses.activate + def test_get_action_control_assignment_all_params(self): + """ + get_action_control_assignment() + """ + # 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"}' + 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_action_control_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_action_control_assignment_all_params_with_retries(self): + # Enable retries and run test_get_action_control_assignment_all_params. + _service.enable_retries() + self.test_get_action_control_assignment_all_params() + + # Disable retries and run test_get_action_control_assignment_all_params. + _service.disable_retries() + self.test_get_action_control_assignment_all_params() + + @responses.activate + def test_get_action_control_assignment_value_error(self): + """ + test_get_action_control_assignment_value_error() + """ + # 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"}' + 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_action_control_assignment(**req_copy) + + def test_get_action_control_assignment_value_error_with_retries(self): + # Enable retries and run test_get_action_control_assignment_value_error. + _service.enable_retries() + self.test_get_action_control_assignment_value_error() + + # Disable retries and run test_get_action_control_assignment_value_error. + _service.disable_retries() + self.test_get_action_control_assignment_value_error() + + +class TestUpdateActionControlAssignment: + """ + Test Class for update_action_control_assignment + """ + + @responses.activate + def test_update_action_control_assignment_all_params(self): + """ + update_action_control_assignment() + """ + # 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"}' + 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_action_control_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_action_control_assignment_all_params_with_retries(self): + # Enable retries and run test_update_action_control_assignment_all_params. + _service.enable_retries() + self.test_update_action_control_assignment_all_params() + + # Disable retries and run test_update_action_control_assignment_all_params. + _service.disable_retries() + self.test_update_action_control_assignment_all_params() + + @responses.activate + def test_update_action_control_assignment_value_error(self): + """ + test_update_action_control_assignment_value_error() + """ + # 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"}' + 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_action_control_assignment(**req_copy) + + def test_update_action_control_assignment_value_error_with_retries(self): + # Enable retries and run test_update_action_control_assignment_value_error. + _service.enable_retries() + self.test_update_action_control_assignment_value_error() + + # Disable retries and run test_update_action_control_assignment_value_error. + _service.disable_retries() + self.test_update_action_control_assignment_value_error() + + +class TestDeleteActionControlAssignment: + """ + Test Class for delete_action_control_assignment + """ + + @responses.activate + def test_delete_action_control_assignment_all_params(self): + """ + delete_action_control_assignment() + """ + # Set up mock + url = preprocess_url('/v1/action_control_assignments/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Invoke method + response = _service.delete_action_control_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_action_control_assignment_all_params_with_retries(self): + # Enable retries and run test_delete_action_control_assignment_all_params. + _service.enable_retries() + self.test_delete_action_control_assignment_all_params() + + # Disable retries and run test_delete_action_control_assignment_all_params. + _service.disable_retries() + self.test_delete_action_control_assignment_all_params() + + @responses.activate + def test_delete_action_control_assignment_value_error(self): + """ + test_delete_action_control_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/action_control_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_action_control_assignment(**req_copy) + + def test_delete_action_control_assignment_value_error_with_retries(self): + # Enable retries and run test_delete_action_control_assignment_value_error. + _service.enable_retries() + self.test_delete_action_control_assignment_value_error() + + # Disable retries and run test_delete_action_control_assignment_value_error. + _service.disable_retries() + self.test_delete_action_control_assignment_value_error() + + +# endregion +############################################################################## +# End of Service: ActionControlAssignments +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region + + +class TestModel_AccountSettingsAccessManagement: + """ + Test Class for AccountSettingsAccessManagement + """ + + def test_account_settings_access_management_serialization(self): + """ + Test serialization/deserialization for AccountSettingsAccessManagement + """ + + # Construct dict forms of any model objects needed in order to build this model. + + identity_types_base_model = {} # IdentityTypesBase + identity_types_base_model['state'] = 'enabled' + identity_types_base_model['external_allowed_accounts'] = ['testString'] + + identity_types_model = {} # IdentityTypes + identity_types_model['user'] = identity_types_base_model + identity_types_model['service_id'] = identity_types_base_model + identity_types_model['service'] = identity_types_base_model + + external_account_identity_interaction_model = {} # ExternalAccountIdentityInteraction + external_account_identity_interaction_model['identity_types'] = identity_types_model + + # Construct a json representation of a AccountSettingsAccessManagement model + account_settings_access_management_model_json = {} + account_settings_access_management_model_json['external_account_identity_interaction'] = ( + external_account_identity_interaction_model + ) + + # Construct a model instance of AccountSettingsAccessManagement by calling from_dict on the json representation + account_settings_access_management_model = AccountSettingsAccessManagement.from_dict( + account_settings_access_management_model_json + ) + assert account_settings_access_management_model != False + + # Construct a model instance of AccountSettingsAccessManagement by calling from_dict on the json representation + account_settings_access_management_model_dict = AccountSettingsAccessManagement.from_dict( + account_settings_access_management_model_json + ).__dict__ + account_settings_access_management_model2 = AccountSettingsAccessManagement( + **account_settings_access_management_model_dict + ) + + # Verify the model instances are equivalent + assert account_settings_access_management_model == account_settings_access_management_model2 + + # Convert model instance back to dict and verify no loss of data + account_settings_access_management_model_json2 = account_settings_access_management_model.to_dict() + assert account_settings_access_management_model_json2 == account_settings_access_management_model_json + + +class TestModel_ActionControlAssignment: + """ + Test Class for ActionControlAssignment + """ + + def test_action_control_assignment_serialization(self): + """ + Test serialization/deserialization for ActionControlAssignment + """ + + # Construct dict forms of any model objects needed in order to build this model. + + action_control_assignment_template_model = {} # ActionControlAssignmentTemplate + action_control_assignment_template_model['id'] = 'testString' + action_control_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 ActionControlAssignment model + action_control_assignment_model_json = {} + action_control_assignment_model_json['template'] = action_control_assignment_template_model + action_control_assignment_model_json['target'] = assignment_target_details_model + + # Construct a model instance of ActionControlAssignment by calling from_dict on the json representation + action_control_assignment_model = ActionControlAssignment.from_dict(action_control_assignment_model_json) + assert action_control_assignment_model != False + + # Construct a model instance of ActionControlAssignment by calling from_dict on the json representation + action_control_assignment_model_dict = ActionControlAssignment.from_dict( + action_control_assignment_model_json + ).__dict__ + action_control_assignment_model2 = ActionControlAssignment(**action_control_assignment_model_dict) + + # Verify the model instances are equivalent + assert action_control_assignment_model == action_control_assignment_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_assignment_model_json2 = action_control_assignment_model.to_dict() + assert action_control_assignment_model_json2 == action_control_assignment_model_json + + +class TestModel_ActionControlAssignmentCollection: + """ + Test Class for ActionControlAssignmentCollection + """ -############################################################################## -# Start of Model Tests -############################################################################## -# region + def test_action_control_assignment_collection_serialization(self): + """ + Test serialization/deserialization for ActionControlAssignmentCollection + """ + + # Construct dict forms of any model objects needed in order to build this model. + first_model = {} # First -class TestModel_AccountSettingsAccessManagement: + next_model = {} # Next + next_model['start'] = 'testString' + + previous_model = {} # Previous + previous_model['start'] = 'testString' + + action_control_assignment_template_model = {} # ActionControlAssignmentTemplate + action_control_assignment_template_model['id'] = 'testString' + action_control_assignment_template_model['version'] = 'testString' + + assignment_target_details_model = {} # AssignmentTargetDetails + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' + + action_control_assignment_model = {} # ActionControlAssignment + action_control_assignment_model['template'] = action_control_assignment_template_model + action_control_assignment_model['target'] = assignment_target_details_model + + # Construct a json representation of a ActionControlAssignmentCollection model + action_control_assignment_collection_model_json = {} + action_control_assignment_collection_model_json['limit'] = 1 + action_control_assignment_collection_model_json['first'] = first_model + action_control_assignment_collection_model_json['next'] = next_model + action_control_assignment_collection_model_json['previous'] = previous_model + action_control_assignment_collection_model_json['assignments'] = [action_control_assignment_model] + + # Construct a model instance of ActionControlAssignmentCollection by calling from_dict on the json representation + action_control_assignment_collection_model = ActionControlAssignmentCollection.from_dict( + action_control_assignment_collection_model_json + ) + assert action_control_assignment_collection_model != False + + # Construct a model instance of ActionControlAssignmentCollection by calling from_dict on the json representation + action_control_assignment_collection_model_dict = ActionControlAssignmentCollection.from_dict( + action_control_assignment_collection_model_json + ).__dict__ + action_control_assignment_collection_model2 = ActionControlAssignmentCollection( + **action_control_assignment_collection_model_dict + ) + + # Verify the model instances are equivalent + assert action_control_assignment_collection_model == action_control_assignment_collection_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_assignment_collection_model_json2 = action_control_assignment_collection_model.to_dict() + assert action_control_assignment_collection_model_json2 == action_control_assignment_collection_model_json + + +class TestModel_ActionControlAssignmentResource: """ - Test Class for AccountSettingsAccessManagement + Test Class for ActionControlAssignmentResource """ - def test_account_settings_access_management_serialization(self): + def test_action_control_assignment_resource_serialization(self): """ - Test serialization/deserialization for AccountSettingsAccessManagement + Test serialization/deserialization for ActionControlAssignmentResource """ # Construct dict forms of any model objects needed in order to build this model. - identity_types_base_model = {} # IdentityTypesBase - identity_types_base_model['state'] = 'enabled' - identity_types_base_model['external_allowed_accounts'] = ['testString'] + assignment_target_details_model = {} # AssignmentTargetDetails + assignment_target_details_model['type'] = 'Account' + assignment_target_details_model['id'] = 'testString' - identity_types_model = {} # IdentityTypes - identity_types_model['user'] = identity_types_base_model - identity_types_model['service_id'] = identity_types_base_model - identity_types_model['service'] = identity_types_base_model + action_control_assignment_resource_created_model = {} # ActionControlAssignmentResourceCreated + action_control_assignment_resource_created_model['id'] = 'testString' - external_account_identity_interaction_model = {} # ExternalAccountIdentityInteraction - external_account_identity_interaction_model['identity_types'] = identity_types_model + conflicts_with_model = {} # ConflictsWith + conflicts_with_model['etag'] = 'testString' + conflicts_with_model['role'] = 'testString' + conflicts_with_model['policy'] = 'testString' - # Construct a json representation of a AccountSettingsAccessManagement model - account_settings_access_management_model_json = {} - account_settings_access_management_model_json['external_account_identity_interaction'] = ( - external_account_identity_interaction_model + 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' + + error_response_model = {} # ErrorResponse + error_response_model['trace'] = 'testString' + error_response_model['errors'] = [error_object_model] + error_response_model['status_code'] = 0 + + 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 - # Construct a model instance of AccountSettingsAccessManagement by calling from_dict on the json representation - account_settings_access_management_model = AccountSettingsAccessManagement.from_dict( - account_settings_access_management_model_json + # Construct a json representation of a ActionControlAssignmentResource model + action_control_assignment_resource_model_json = {} + action_control_assignment_resource_model_json['target'] = assignment_target_details_model + action_control_assignment_resource_model_json['action_control'] = ( + action_control_assignment_resource_action_control_model ) - assert account_settings_access_management_model != False - # Construct a model instance of AccountSettingsAccessManagement by calling from_dict on the json representation - account_settings_access_management_model_dict = AccountSettingsAccessManagement.from_dict( - account_settings_access_management_model_json + # Construct a model instance of ActionControlAssignmentResource by calling from_dict on the json representation + action_control_assignment_resource_model = ActionControlAssignmentResource.from_dict( + action_control_assignment_resource_model_json + ) + assert action_control_assignment_resource_model != False + + # Construct a model instance of ActionControlAssignmentResource by calling from_dict on the json representation + action_control_assignment_resource_model_dict = ActionControlAssignmentResource.from_dict( + action_control_assignment_resource_model_json ).__dict__ - account_settings_access_management_model2 = AccountSettingsAccessManagement( - **account_settings_access_management_model_dict + action_control_assignment_resource_model2 = ActionControlAssignmentResource( + **action_control_assignment_resource_model_dict ) # Verify the model instances are equivalent - assert account_settings_access_management_model == account_settings_access_management_model2 + assert action_control_assignment_resource_model == action_control_assignment_resource_model2 # Convert model instance back to dict and verify no loss of data - account_settings_access_management_model_json2 = account_settings_access_management_model.to_dict() - assert account_settings_access_management_model_json2 == account_settings_access_management_model_json + action_control_assignment_resource_model_json2 = action_control_assignment_resource_model.to_dict() + assert action_control_assignment_resource_model_json2 == action_control_assignment_resource_model_json + + +class TestModel_ActionControlAssignmentResourceActionControl: + """ + Test Class for ActionControlAssignmentResourceActionControl + """ + + def test_action_control_assignment_resource_action_control_serialization(self): + """ + Test serialization/deserialization for ActionControlAssignmentResourceActionControl + """ + + # Construct dict forms of any model objects needed in order to build this model. + + action_control_assignment_resource_created_model = {} # ActionControlAssignmentResourceCreated + action_control_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' + + error_response_model = {} # ErrorResponse + error_response_model['trace'] = 'testString' + error_response_model['errors'] = [error_object_model] + error_response_model['status_code'] = 0 + + # 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 + + # Construct a model instance of ActionControlAssignmentResourceActionControl by calling from_dict on the json representation + action_control_assignment_resource_action_control_model = ( + ActionControlAssignmentResourceActionControl.from_dict( + action_control_assignment_resource_action_control_model_json + ) + ) + assert action_control_assignment_resource_action_control_model != False + + # Construct a model instance of ActionControlAssignmentResourceActionControl by calling from_dict on the json representation + action_control_assignment_resource_action_control_model_dict = ( + ActionControlAssignmentResourceActionControl.from_dict( + action_control_assignment_resource_action_control_model_json + ).__dict__ + ) + action_control_assignment_resource_action_control_model2 = ActionControlAssignmentResourceActionControl( + **action_control_assignment_resource_action_control_model_dict + ) + + # Verify the model instances are equivalent + assert ( + action_control_assignment_resource_action_control_model + == action_control_assignment_resource_action_control_model2 + ) + + # Convert model instance back to dict and verify no loss of data + action_control_assignment_resource_action_control_model_json2 = ( + action_control_assignment_resource_action_control_model.to_dict() + ) + assert ( + action_control_assignment_resource_action_control_model_json2 + == action_control_assignment_resource_action_control_model_json + ) + + +class TestModel_ActionControlAssignmentResourceCreated: + """ + Test Class for ActionControlAssignmentResourceCreated + """ + + def test_action_control_assignment_resource_created_serialization(self): + """ + Test serialization/deserialization for ActionControlAssignmentResourceCreated + """ + + # Construct a json representation of a ActionControlAssignmentResourceCreated model + action_control_assignment_resource_created_model_json = {} + action_control_assignment_resource_created_model_json['id'] = 'testString' + + # Construct a model instance of ActionControlAssignmentResourceCreated by calling from_dict on the json representation + action_control_assignment_resource_created_model = ActionControlAssignmentResourceCreated.from_dict( + action_control_assignment_resource_created_model_json + ) + assert action_control_assignment_resource_created_model != False + + # Construct a model instance of ActionControlAssignmentResourceCreated by calling from_dict on the json representation + action_control_assignment_resource_created_model_dict = ActionControlAssignmentResourceCreated.from_dict( + action_control_assignment_resource_created_model_json + ).__dict__ + action_control_assignment_resource_created_model2 = ActionControlAssignmentResourceCreated( + **action_control_assignment_resource_created_model_dict + ) + + # Verify the model instances are equivalent + assert action_control_assignment_resource_created_model == action_control_assignment_resource_created_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_assignment_resource_created_model_json2 = ( + action_control_assignment_resource_created_model.to_dict() + ) + assert ( + action_control_assignment_resource_created_model_json2 + == action_control_assignment_resource_created_model_json + ) + + +class TestModel_ActionControlAssignmentTemplate: + """ + Test Class for ActionControlAssignmentTemplate + """ + + def test_action_control_assignment_template_serialization(self): + """ + Test serialization/deserialization for ActionControlAssignmentTemplate + """ + + # Construct a json representation of a ActionControlAssignmentTemplate model + action_control_assignment_template_model_json = {} + action_control_assignment_template_model_json['id'] = 'testString' + action_control_assignment_template_model_json['version'] = 'testString' + + # Construct a model instance of ActionControlAssignmentTemplate by calling from_dict on the json representation + action_control_assignment_template_model = ActionControlAssignmentTemplate.from_dict( + action_control_assignment_template_model_json + ) + assert action_control_assignment_template_model != False + + # Construct a model instance of ActionControlAssignmentTemplate by calling from_dict on the json representation + action_control_assignment_template_model_dict = ActionControlAssignmentTemplate.from_dict( + action_control_assignment_template_model_json + ).__dict__ + action_control_assignment_template_model2 = ActionControlAssignmentTemplate( + **action_control_assignment_template_model_dict + ) + + # Verify the model instances are equivalent + assert action_control_assignment_template_model == action_control_assignment_template_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_assignment_template_model_json2 = action_control_assignment_template_model.to_dict() + assert action_control_assignment_template_model_json2 == action_control_assignment_template_model_json + + +class TestModel_ActionControlTemplate: + """ + Test Class for ActionControlTemplate + """ + + def test_action_control_template_serialization(self): + """ + Test serialization/deserialization for ActionControlTemplate + """ + + # Construct dict forms of any model objects needed in order to build this model. + + template_action_control_model = {} # TemplateActionControl + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + # Construct a json representation of a ActionControlTemplate model + action_control_template_model_json = {} + action_control_template_model_json['name'] = 'testString' + action_control_template_model_json['description'] = 'testString' + action_control_template_model_json['account_id'] = 'testString' + action_control_template_model_json['committed'] = True + action_control_template_model_json['action_control'] = template_action_control_model + action_control_template_model_json['version'] = 'testString' + action_control_template_model_json['state'] = 'active' + + # Construct a model instance of ActionControlTemplate by calling from_dict on the json representation + action_control_template_model = ActionControlTemplate.from_dict(action_control_template_model_json) + assert action_control_template_model != False + + # Construct a model instance of ActionControlTemplate by calling from_dict on the json representation + action_control_template_model_dict = ActionControlTemplate.from_dict( + action_control_template_model_json + ).__dict__ + action_control_template_model2 = ActionControlTemplate(**action_control_template_model_dict) + + # Verify the model instances are equivalent + assert action_control_template_model == action_control_template_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_template_model_json2 = action_control_template_model.to_dict() + assert action_control_template_model_json2 == action_control_template_model_json + + +class TestModel_ActionControlTemplateCollection: + """ + Test Class for ActionControlTemplateCollection + """ + + def test_action_control_template_collection_serialization(self): + """ + Test serialization/deserialization for ActionControlTemplateCollection + """ + + # 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_action_control_model = {} # TemplateActionControl + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + action_control_template_model = {} # ActionControlTemplate + action_control_template_model['name'] = 'testString' + action_control_template_model['description'] = 'testString' + action_control_template_model['account_id'] = 'testString' + action_control_template_model['committed'] = True + action_control_template_model['action_control'] = template_action_control_model + action_control_template_model['version'] = 'testString' + action_control_template_model['state'] = 'active' + + # Construct a json representation of a ActionControlTemplateCollection model + action_control_template_collection_model_json = {} + action_control_template_collection_model_json['limit'] = 1 + action_control_template_collection_model_json['first'] = first_model + action_control_template_collection_model_json['next'] = next_model + action_control_template_collection_model_json['previous'] = previous_model + action_control_template_collection_model_json['action_control_templates'] = [action_control_template_model] + + # Construct a model instance of ActionControlTemplateCollection by calling from_dict on the json representation + action_control_template_collection_model = ActionControlTemplateCollection.from_dict( + action_control_template_collection_model_json + ) + assert action_control_template_collection_model != False + + # Construct a model instance of ActionControlTemplateCollection by calling from_dict on the json representation + action_control_template_collection_model_dict = ActionControlTemplateCollection.from_dict( + action_control_template_collection_model_json + ).__dict__ + action_control_template_collection_model2 = ActionControlTemplateCollection( + **action_control_template_collection_model_dict + ) + + # Verify the model instances are equivalent + assert action_control_template_collection_model == action_control_template_collection_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_template_collection_model_json2 = action_control_template_collection_model.to_dict() + assert action_control_template_collection_model_json2 == action_control_template_collection_model_json + + +class TestModel_ActionControlTemplateVersionsCollection: + """ + Test Class for ActionControlTemplateVersionsCollection + """ + + def test_action_control_template_versions_collection_serialization(self): + """ + Test serialization/deserialization for ActionControlTemplateVersionsCollection + """ + + # 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_action_control_model = {} # TemplateActionControl + template_action_control_model['service_name'] = 'testString' + template_action_control_model['description'] = 'testString' + template_action_control_model['actions'] = ['testString'] + + action_control_template_model = {} # ActionControlTemplate + action_control_template_model['name'] = 'testString' + action_control_template_model['description'] = 'testString' + action_control_template_model['account_id'] = 'testString' + action_control_template_model['committed'] = True + action_control_template_model['action_control'] = template_action_control_model + action_control_template_model['version'] = 'testString' + action_control_template_model['state'] = 'active' + + # Construct a json representation of a ActionControlTemplateVersionsCollection model + action_control_template_versions_collection_model_json = {} + action_control_template_versions_collection_model_json['limit'] = 1 + action_control_template_versions_collection_model_json['first'] = first_model + action_control_template_versions_collection_model_json['next'] = next_model + action_control_template_versions_collection_model_json['previous'] = previous_model + action_control_template_versions_collection_model_json['versions'] = [action_control_template_model] + + # Construct a model instance of ActionControlTemplateVersionsCollection by calling from_dict on the json representation + action_control_template_versions_collection_model = ActionControlTemplateVersionsCollection.from_dict( + action_control_template_versions_collection_model_json + ) + assert action_control_template_versions_collection_model != False + + # Construct a model instance of ActionControlTemplateVersionsCollection by calling from_dict on the json representation + action_control_template_versions_collection_model_dict = ActionControlTemplateVersionsCollection.from_dict( + action_control_template_versions_collection_model_json + ).__dict__ + action_control_template_versions_collection_model2 = ActionControlTemplateVersionsCollection( + **action_control_template_versions_collection_model_dict + ) + + # Verify the model instances are equivalent + assert action_control_template_versions_collection_model == action_control_template_versions_collection_model2 + + # Convert model instance back to dict and verify no loss of data + action_control_template_versions_collection_model_json2 = ( + action_control_template_versions_collection_model.to_dict() + ) + assert ( + action_control_template_versions_collection_model_json2 + == action_control_template_versions_collection_model_json + ) class TestModel_AssignmentResourceCreated: @@ -5710,7 +8187,7 @@ def test_error_response_serialization(self): error_response_model_json = {} error_response_model_json['trace'] = 'testString' error_response_model_json['errors'] = [error_object_model] - error_response_model_json['status_code'] = 38 + 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) @@ -6193,7 +8670,7 @@ def test_policy_assignment_resource_policy_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 # Construct a json representation of a PolicyAssignmentResourcePolicy model policy_assignment_resource_policy_model_json = {} @@ -6255,7 +8732,7 @@ def test_policy_assignment_resources_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -6321,7 +8798,7 @@ def test_policy_assignment_v1_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -6374,6 +8851,14 @@ def test_policy_assignment_v1_collection_serialization(self): # 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' + assignment_target_details_model = {} # AssignmentTargetDetails assignment_target_details_model['type'] = 'Account' assignment_target_details_model['id'] = 'testString' @@ -6398,7 +8883,7 @@ def test_policy_assignment_v1_collection_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -6424,6 +8909,10 @@ def test_policy_assignment_v1_collection_serialization(self): # Construct a json representation of a PolicyAssignmentV1Collection model policy_assignment_v1_collection_model_json = {} + policy_assignment_v1_collection_model_json['limit'] = 1 + policy_assignment_v1_collection_model_json['first'] = first_model + policy_assignment_v1_collection_model_json['next'] = next_model + policy_assignment_v1_collection_model_json['previous'] = previous_model policy_assignment_v1_collection_model_json['assignments'] = [policy_assignment_v1_model] # Construct a model instance of PolicyAssignmentV1Collection by calling from_dict on the json representation @@ -6484,7 +8973,7 @@ def test_policy_assignment_v1_resources_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -6869,7 +9358,7 @@ def test_policy_template_assignment_collection_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -7588,6 +10077,40 @@ def test_subject_attribute_serialization(self): assert subject_attribute_model_json2 == subject_attribute_model_json +class TestModel_TemplateActionControl: + """ + Test Class for TemplateActionControl + """ + + def test_template_action_control_serialization(self): + """ + Test serialization/deserialization for TemplateActionControl + """ + + # Construct a json representation of a TemplateActionControl model + template_action_control_model_json = {} + template_action_control_model_json['service_name'] = 'testString' + template_action_control_model_json['description'] = 'testString' + template_action_control_model_json['actions'] = ['testString'] + + # Construct a model instance of TemplateActionControl by calling from_dict on the json representation + template_action_control_model = TemplateActionControl.from_dict(template_action_control_model_json) + assert template_action_control_model != False + + # Construct a model instance of TemplateActionControl by calling from_dict on the json representation + template_action_control_model_dict = TemplateActionControl.from_dict( + template_action_control_model_json + ).__dict__ + template_action_control_model2 = TemplateActionControl(**template_action_control_model_dict) + + # Verify the model instances are equivalent + assert template_action_control_model == template_action_control_model2 + + # Convert model instance back to dict and verify no loss of data + template_action_control_model_json2 = template_action_control_model.to_dict() + assert template_action_control_model_json2 == template_action_control_model_json + + class TestModel_TemplateCountData: """ Test Class for TemplateCountData @@ -8386,7 +10909,7 @@ def test_policy_template_assignment_items_policy_assignment_serialization(self): error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model @@ -8477,7 +11000,7 @@ def test_policy_template_assignment_items_policy_assignment_v1_serialization(sel error_response_model = {} # ErrorResponse error_response_model['trace'] = 'testString' error_response_model['errors'] = [error_object_model] - error_response_model['status_code'] = 38 + error_response_model['status_code'] = 0 policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model From de152dfb7a950ffdcdf9de32e906acd4aa42f12d Mon Sep 17 00:00:00 2001 From: Rajesh Pirati Date: Tue, 6 May 2025 23:54:59 +0530 Subject: [PATCH 2/2] feat(IAM Policy Management): Added integration tests and usage examples based on review feedback Signed-off-by: Rajesh Pirati --- .../test_iam_policy_management_v1_examples.py | 21 ++++++++++++++++++- .../test_iam_policy_management_v1.py | 21 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/examples/test_iam_policy_management_v1_examples.py b/examples/test_iam_policy_management_v1_examples.py index 7c634ae..5e32e3d 100644 --- a/examples/test_iam_policy_management_v1_examples.py +++ b/examples/test_iam_policy_management_v1_examples.py @@ -1392,13 +1392,32 @@ def test_delete_action_control_assignment_example(self): except ApiException as e: pytest.fail(str(e)) + # @needscredentials + def test_delete_action_control_template_version_example(self): + """ + delete_action_control_template_version request example + """ + try: + # begin-delete_action_control_template_version + + response = iam_policy_management_service.delete_action_control_template_version( + action_control_template_id=example_action_control_template_id, + version=example_basic_action_control_template_version, + ) + + # end-delete_action_control_template_version + print('\ndelete_action_control_template_version() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + # @needscredentials def test_delete_action_control_template_example(self): """ delete_action_control_template request example """ try: - # begin-action_control_policy_template + # begin-delete_action_control_template response = iam_policy_management_service.delete_action_control_template( action_control_template_id=example_action_control_template_id, diff --git a/test/integration/test_iam_policy_management_v1.py b/test/integration/test_iam_policy_management_v1.py index 6f4dc51..bea8257 100644 --- a/test/integration/test_iam_policy_management_v1.py +++ b/test/integration/test_iam_policy_management_v1.py @@ -1218,7 +1218,7 @@ def test_44_commit_action_control_template(self): ) assert response.get_status_code() == 204 - def test_45_list_policy_template_versions(self): + def test_45_list_action_control_template_versions(self): response = self.service.list_action_control_template_versions( action_control_template_id=self.testActionControlTemplateId, ) @@ -1291,13 +1291,28 @@ def test_48_update_action_control_assignment(self): assert result is not None print("ActionControl Assignment Update: ", result) - def test_49_delete_action_control_assignment(self): + def test_49_get_action_control_assignment(self): + assert self.testActionControlAssignmentId + print("Assignment ID: ", self.testActionControlAssignmentId) + response = self.service.get_action_control_assignment( + assignment_id=self.testActionControlAssignmentId, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + + result = ActionControlAssignment.from_dict(result_dict) + assert result is not None + assert result.id == self.testActionControlAssignmentId + + def test_50_delete_action_control_assignment(self): response = self.service.delete_action_control_assignment( assignment_id=self.testActionControlAssignmentId, ) assert response.get_status_code() == 204 - def test_50_delete_action_control_template(self): + def test_51_delete_action_control_template(self): response = self.service.delete_action_control_template( action_control_template_id=self.testActionControlTemplateId, )