From 951a9dec73f71bbd49ceadbe614c6c31d158547c Mon Sep 17 00:00:00 2001 From: Kelum Senanayake Date: Thu, 20 Mar 2025 16:16:47 -0400 Subject: [PATCH] feat(IAM Policy Management): add access management account settings API Signed-off-by: Kelum Senanayake --- .../test_iam_policy_management_v1_examples.py | 61 + .../iam_policy_management_v1.py | 6222 ++++++++++------- .../test_iam_policy_management_v1.py | 85 +- test/unit/test_iam_policy_management_v1.py | 1535 +++- 4 files changed, 5077 insertions(+), 2826 deletions(-) diff --git a/examples/test_iam_policy_management_v1_examples.py b/examples/test_iam_policy_management_v1_examples.py index e0d18f4b..2a9c2021 100644 --- a/examples/test_iam_policy_management_v1_examples.py +++ b/examples/test_iam_policy_management_v1_examples.py @@ -60,6 +60,7 @@ example_updated_policy_etag = None example_target_account_id = None example_assignment_etag = None +example_account_settings_etag = None ############################################################################## # Start of Examples for Service: IamPolicyManagementV1 @@ -1003,6 +1004,66 @@ def test_delete_policy_template_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials + def test_get_access_management_account_settings_example(self): + """ + get_access_management_account_settings request example + """ + try: + # begin-get_access_management_account_settings + + response = iam_policy_management_service.get_settings( + account_id=example_account_id, + accept_language='default', + ) + + # end-get_access_management_account_settings + print('\nget_settings() response status code: ', response.get_status_code()) + result = response.get_result() + assert result is not None + global example_account_settings_etag + example_account_settings_etag = response.get_headers().get("Etag") + print(json.dumps(result, indent=2)) + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_update_access_management_account_settings_example(self): + """ + update_access_management_account_settings request example + """ + try: + # Construct a dict representation of a IdentityTypesBase model + identity_types_base_model = {'state': 'monitor', 'external_allowed_accounts': []} + + # Construct a dict representation of a IdentityTypesPatch model + identity_types_patch_model = { + 'user': identity_types_base_model, + 'service_id': identity_types_base_model, + 'service': identity_types_base_model, + } + + # Construct a dict representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model = {'identity_types': identity_types_patch_model} + # begin-update_access_management_account_settings + + response = iam_policy_management_service.update_settings( + account_id=example_account_id, + accept_language='default', + if_match=example_account_settings_etag, + external_account_identity_interaction=external_account_identity_interaction_patch_model, + ) + + # end-update_access_management_account_settings + print('\nupdate_settings() response status code: ', response.get_status_code()) + result = response.get_result() + assert result is not None + print(json.dumps(result, indent=2)) + + 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 41c1f76b..26e9cfb4 100644 --- a/ibm_platform_services/iam_policy_management_v1.py +++ b/ibm_platform_services/iam_policy_management_v1.py @@ -1,6 +1,6 @@ # coding: utf-8 -# (C) Copyright IBM Corp. 2024. +# (C) Copyright IBM Corp. 2025. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -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.90.1-64fd3296-20240515-180710 +# IBM OpenAPI SDK Code Generator Version: 3.102.0-615ec964-20250307-203034 """ IAM Policy Management API @@ -90,6 +90,8 @@ def list_policies( sort: Optional[str] = None, format: Optional[str] = None, state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -135,6 +137,10 @@ 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 + collection. + :param str start: (optional) Page token that refers to the page of + 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 `PolicyCollection` object @@ -163,6 +169,8 @@ def list_policies( 'sort': sort, 'format': format, 'state': state, + 'limit': limit, + 'start': start, } if 'headers' in kwargs: @@ -963,6 +971,8 @@ def list_v2_policies( sort: Optional[str] = None, format: Optional[str] = None, state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -1019,6 +1029,10 @@ 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 + collection. + :param str start: (optional) Page token that refers to the page of + 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 `V2PolicyCollection` object @@ -1047,6 +1061,8 @@ def list_v2_policies( 'sort': sort, 'format': format, 'state': state, + 'limit': limit, + 'start': start, } if 'headers' in kwargs: @@ -1624,6 +1640,8 @@ def list_policy_templates( policy_service_name: Optional[str] = None, policy_service_group_id: Optional[str] = None, policy_type: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -1659,6 +1677,10 @@ 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 + collection. + :param str start: (optional) Page token that refers to the page of + 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 `PolicyTemplateCollection` object @@ -1684,6 +1706,8 @@ def list_policy_templates( 'policy_service_name': policy_service_name, 'policy_service_group_id': policy_service_group_id, 'policy_type': policy_type, + 'limit': limit, + 'start': start, } if 'headers' in kwargs: @@ -1970,6 +1994,8 @@ def list_policy_template_versions( policy_template_id: str, *, state: Optional[str] = None, + limit: Optional[int] = None, + start: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -1979,6 +2005,10 @@ 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 + collection. + :param str start: (optional) Page token that refers to the page of + 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 `PolicyTemplateVersionsCollection` object @@ -1996,6 +2026,8 @@ def list_policy_template_versions( params = { 'state': state, + 'limit': limit, + 'start': start, } if 'headers' in kwargs: @@ -2263,6 +2295,8 @@ def list_policy_assignments( 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: """ @@ -2292,6 +2326,10 @@ 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 + collection. + :param str start: (optional) Page token that refers to the page of + 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 `PolicyTemplateAssignmentCollection` object @@ -2316,6 +2354,8 @@ def list_policy_assignments( 'account_id': account_id, 'template_id': template_id, 'template_version': template_version, + 'limit': limit, + 'start': start, } if 'headers' in kwargs: @@ -2432,7 +2472,7 @@ def get_policy_assignment( :param str version: specify version of response body format. :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 `GetPolicyAssignmentResponse` object + :rtype: DetailedResponse with `dict` result representing a `PolicyTemplateAssignmentItems` object """ if not assignment_id: @@ -2588,6 +2628,181 @@ def delete_policy_assignment( response = self.send(request, **kwargs) return response + ######################### + # Access Management Settings + ######################### + + def get_settings( + self, + account_id: str, + *, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Retrieve Access Management account settings by account ID. + + Retrieve Access Management settings for an account by providing the account ID. + + :param str account_id: The account GUID that the settings 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 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 `AccountSettingsAccessManagement` 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='get_settings', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['account_id'] + path_param_values = self.encode_path_vars(account_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/accounts/{account_id}/settings/access_management'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def update_settings( + self, + account_id: str, + if_match: str, + *, + external_account_identity_interaction: Optional['ExternalAccountIdentityInteractionPatch'] = None, + accept_language: Optional[str] = None, + **kwargs, + ) -> DetailedResponse: + """ + Update Access Management account settings by account ID. + + Update access management settings for an account. + ### External Account Identity Interaction + 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 + 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)), + `service_id` (defined as [IAM + ServiceIds](https://test.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 + Identity’s setting, the `state` and `external_allowed_accounts` fields are + required. + Different identity states are: + * "enabled": An identity type is allowed to access resources in the account + provided it has access policies on those resources. + * "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”. + **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" + should be left empty. + + :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 + 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. + :param ExternalAccountIdentityInteractionPatch + external_account_identity_interaction: (optional) Update to how external + accounts can interact in relation to the requested account. + :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 `AccountSettingsAccessManagement` object + """ + + if not account_id: + raise ValueError('account_id must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if external_account_identity_interaction is not None: + external_account_identity_interaction = convert_model(external_account_identity_interaction) + headers = { + 'If-Match': if_match, + 'Accept-Language': accept_language, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='update_settings', + ) + headers.update(sdk_headers) + + data = { + 'external_account_identity_interaction': external_account_identity_interaction, + } + 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 = ['account_id'] + path_param_values = self.encode_path_vars(account_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/accounts/{account_id}/settings/access_management'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + class ListPoliciesEnums: """ @@ -2773,6 +2988,79 @@ class State(str, Enum): ############################################################################## +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 AssignmentResourceCreated: """ On success, includes the policy assigned. @@ -3566,6 +3854,7 @@ class CodeEnum(str, Enum): POLICY_TEMPLATE_NOT_FOUND = 'policy_template_not_found' POLICY_ASSIGNMENT_NOT_FOUND = 'policy_assignment_not_found' POLICY_ASSIGNMENT_CONFLICT_ERROR = 'policy_assignment_conflict_error' + RESOURCE_NOT_FOUND = 'resource_not_found' class ErrorResponse: @@ -3650,68 +3939,49 @@ def __ne__(self, other: 'ErrorResponse') -> bool: return not self == other -class GetPolicyAssignmentResponse: - """ - GetPolicyAssignmentResponse. - - """ - - def __init__( - self, - ) -> None: - """ - Initialize a GetPolicyAssignmentResponse object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['GetPolicyAssignmentResponsePolicyAssignmentV1', 'GetPolicyAssignmentResponsePolicyAssignment']) - ) - raise Exception(msg) - - -class GetPolicyAssignmentResponsePolicyAssignmentV1Subject: +class ExternalAccountIdentityInteraction: """ - subject details of access type assignment. + How external accounts can interact in relation to the requested account. - :param str id: (optional) - :param str type: (optional) + :param IdentityTypes identity_types: The settings for each identity type. """ def __init__( self, - *, - id: Optional[str] = None, - type: Optional[str] = None, + identity_types: 'IdentityTypes', ) -> None: """ - Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1Subject object. + Initialize a ExternalAccountIdentityInteraction object. + :param IdentityTypes identity_types: The settings for each identity type. """ - self.id = id - self.type = type + self.identity_types = identity_types @classmethod - def from_dict(cls, _dict: Dict) -> 'GetPolicyAssignmentResponsePolicyAssignmentV1Subject': - """Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1Subject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteraction': + """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type + if (identity_types := _dict.get('identity_types')) is not None: + args['identity_types'] = IdentityTypes.from_dict(identity_types) + else: + raise ValueError( + 'Required property \'identity_types\' not present in ExternalAccountIdentityInteraction JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1Subject object from a json dictionary.""" + """Initialize a ExternalAccountIdentityInteraction object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and getattr(self, 'type') is not None: - _dict['type'] = getattr(self, 'type') + if hasattr(self, 'identity_types') and self.identity_types is not None: + if isinstance(self.identity_types, dict): + _dict['identity_types'] = self.identity_types + else: + _dict['identity_types'] = self.identity_types.to_dict() return _dict def _to_dict(self): @@ -3719,74 +3989,62 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GetPolicyAssignmentResponsePolicyAssignmentV1Subject object.""" + """Return a `str` version of this ExternalAccountIdentityInteraction object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GetPolicyAssignmentResponsePolicyAssignmentV1Subject') -> bool: + def __eq__(self, other: 'ExternalAccountIdentityInteraction') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'GetPolicyAssignmentResponsePolicyAssignmentV1Subject') -> bool: + def __ne__(self, other: 'ExternalAccountIdentityInteraction') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): - """ - type. - """ - - IAM_ID = 'iam_id' - ACCESS_GROUP_ID = 'access_group_id' - -class Grant: +class ExternalAccountIdentityInteractionPatch: """ - Permission granted by the policy. + Update to how external accounts can interact in relation to the requested account. - :param List[Roles] roles: A set of role cloud resource names (CRNs) granted by - the policy. + :param IdentityTypesPatch identity_types: (optional) The settings to apply for + each identity type for a request. """ def __init__( self, - roles: List['Roles'], + *, + identity_types: Optional['IdentityTypesPatch'] = None, ) -> None: """ - Initialize a Grant object. + Initialize a ExternalAccountIdentityInteractionPatch object. - :param List[Roles] roles: A set of role cloud resource names (CRNs) granted - by the policy. + :param IdentityTypesPatch identity_types: (optional) The settings to apply + for each identity type for a request. """ - self.roles = roles + self.identity_types = identity_types @classmethod - def from_dict(cls, _dict: Dict) -> 'Grant': - """Initialize a Grant object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ExternalAccountIdentityInteractionPatch': + """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" args = {} - if (roles := _dict.get('roles')) is not None: - args['roles'] = [Roles.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in Grant JSON') + if (identity_types := _dict.get('identity_types')) is not None: + args['identity_types'] = IdentityTypesPatch.from_dict(identity_types) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Grant object from a json dictionary.""" + """Initialize a ExternalAccountIdentityInteractionPatch object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list + if hasattr(self, 'identity_types') and self.identity_types is not None: + if isinstance(self.identity_types, dict): + _dict['identity_types'] = self.identity_types + else: + _dict['identity_types'] = self.identity_types.to_dict() return _dict def _to_dict(self): @@ -3794,65 +4052,57 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Grant object.""" + """Return a `str` version of this ExternalAccountIdentityInteractionPatch object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Grant') -> bool: + def __eq__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Grant') -> bool: + def __ne__(self, other: 'ExternalAccountIdentityInteractionPatch') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GrantWithEnrichedRoles: +class First: """ - Permission granted by the policy with translated roles and additional role - information. + Details with href linking to first page of requested collection. - :param List[EnrichedRoles] roles: A set of roles granted by the policy. + :param str href: (optional) The href linking to the page of requested + collection. """ def __init__( self, - roles: List['EnrichedRoles'], + *, + href: Optional[str] = None, ) -> None: """ - Initialize a GrantWithEnrichedRoles object. + Initialize a First object. - :param List[EnrichedRoles] roles: A set of roles granted by the policy. """ - self.roles = roles + self.href = href @classmethod - def from_dict(cls, _dict: Dict) -> 'GrantWithEnrichedRoles': - """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'First': + """Initialize a First object from a json dictionary.""" args = {} - if (roles := _dict.get('roles')) is not None: - args['roles'] = [EnrichedRoles.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in GrantWithEnrichedRoles JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" + """Initialize a First object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') return _dict def _to_dict(self): @@ -3860,63 +4110,66 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GrantWithEnrichedRoles object.""" + """Return a `str` version of this First object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GrantWithEnrichedRoles') -> bool: + def __eq__(self, other: 'First') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'GrantWithEnrichedRoles') -> bool: + def __ne__(self, other: 'First') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class LimitData: +class Grant: """ - policy template current and limit details with in an account. + Permission granted by the policy. - :param int current: (optional) policy template current count. - :param int limit: (optional) policy template limit count. + :param List[Roles] roles: A set of role cloud resource names (CRNs) granted by + the policy. """ def __init__( self, - *, - current: Optional[int] = None, - limit: Optional[int] = None, + roles: List['Roles'], ) -> None: """ - Initialize a LimitData object. + Initialize a Grant object. + :param List[Roles] roles: A set of role cloud resource names (CRNs) granted + by the policy. """ - self.current = current - self.limit = limit + self.roles = roles @classmethod - def from_dict(cls, _dict: Dict) -> 'LimitData': - """Initialize a LimitData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Grant': + """Initialize a Grant object from a json dictionary.""" args = {} - if (current := _dict.get('current')) is not None: - args['current'] = current - if (limit := _dict.get('limit')) is not None: - args['limit'] = limit + if (roles := _dict.get('roles')) is not None: + args['roles'] = [Roles.from_dict(v) for v in roles] + else: + raise ValueError('Required property \'roles\' not present in Grant JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a LimitData object from a json dictionary.""" + """Initialize a Grant object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'current') and getattr(self, 'current') is not None: - _dict['current'] = getattr(self, 'current') - if hasattr(self, 'limit') and getattr(self, 'limit') is not None: - _dict['limit'] = getattr(self, 'limit') + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list return _dict def _to_dict(self): @@ -3924,163 +4177,57 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this LimitData object.""" + """Return a `str` version of this Grant object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'LimitData') -> bool: + def __eq__(self, other: 'Grant') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'LimitData') -> bool: + def __ne__(self, other: 'Grant') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class NestedCondition: - """ - Condition that specifies additional conditions or RuleAttribute to grant access. - - """ - - def __init__( - self, - ) -> None: - """ - Initialize a NestedCondition object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['NestedConditionRuleAttribute', 'NestedConditionRuleWithConditions']) - ) - raise Exception(msg) - - -class Policy: +class GrantWithEnrichedRoles: """ - The core set of properties associated with a policy. + Permission granted by the policy with translated roles and additional role + information. - :param str id: (optional) The policy ID. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Customer-defined description. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) granted - by the policy. - :param List[PolicyResource] resources: The resources associated with a policy. - :param str href: (optional) The href link back to the policy. - :param datetime created_at: (optional) The UTC timestamp when the policy was - created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy. - :param str state: (optional) The policy state. + :param List[EnrichedRoles] roles: A set of roles granted by the policy. """ def __init__( self, - type: str, - subjects: List['PolicySubject'], - roles: List['PolicyRole'], - resources: List['PolicyResource'], - *, - id: Optional[str] = None, - description: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - state: Optional[str] = None, + roles: List['EnrichedRoles'], ) -> None: """ - Initialize a Policy object. + Initialize a GrantWithEnrichedRoles object. - :param str type: The policy type; either 'access' or 'authorization'. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) - granted by the policy. - :param List[PolicyResource] resources: The resources associated with a - policy. - :param str description: (optional) Customer-defined description. - :param str state: (optional) The policy state. + :param List[EnrichedRoles] roles: A set of roles granted by the policy. """ - self.id = id - self.type = type - self.description = description - self.subjects = subjects self.roles = roles - self.resources = resources - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'Policy': - """Initialize a Policy object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'GrantWithEnrichedRoles': + """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type - else: - raise ValueError('Required property \'type\' not present in Policy JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (subjects := _dict.get('subjects')) is not None: - args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] - else: - raise ValueError('Required property \'subjects\' not present in Policy JSON') if (roles := _dict.get('roles')) is not None: - args['roles'] = [PolicyRole.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in Policy JSON') - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyResource.from_dict(v) for v in resources] + args['roles'] = [EnrichedRoles.from_dict(v) for v in roles] else: - raise ValueError('Required property \'resources\' not present in Policy JSON') - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (state := _dict.get('state')) is not None: - args['state'] = state + raise ValueError('Required property \'roles\' not present in GrantWithEnrichedRoles JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Policy object from a json dictionary.""" + """Initialize a GrantWithEnrichedRoles object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'subjects') and self.subjects is not None: - subjects_list = [] - for v in self.subjects: - if isinstance(v, dict): - subjects_list.append(v) - else: - subjects_list.append(v.to_dict()) - _dict['subjects'] = subjects_list if hasattr(self, 'roles') and self.roles is not None: roles_list = [] for v in self.roles: @@ -4089,26 +4236,6 @@ def to_dict(self) -> Dict: else: roles_list.append(v.to_dict()) _dict['roles'] = roles_list - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state return _dict def _to_dict(self): @@ -4116,89 +4243,93 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Policy object.""" + """Return a `str` version of this GrantWithEnrichedRoles object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Policy') -> bool: + def __eq__(self, other: 'GrantWithEnrichedRoles') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Policy') -> bool: + def __ne__(self, other: 'GrantWithEnrichedRoles') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - The policy state. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class PolicyAssignmentResourcePolicy: +class IdentityTypes: """ - Set of properties for the assigned resource. + The settings for each identity type. - :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy assigned. - :param str status: (optional) policy status. - :param ErrorResponse error_message: (optional) The error response from API. + :param IdentityTypesBase user: The core set of properties associated with an + identity type. + :param IdentityTypesBase service_id: The core set of properties associated with + an identity type. + :param IdentityTypesBase service: The core set of properties associated with an + identity type. """ def __init__( self, - *, - resource_created: Optional['AssignmentResourceCreated'] = None, - status: Optional[str] = None, - error_message: Optional['ErrorResponse'] = None, + user: 'IdentityTypesBase', + service_id: 'IdentityTypesBase', + service: 'IdentityTypesBase', ) -> None: """ - Initialize a PolicyAssignmentResourcePolicy object. + Initialize a IdentityTypes object. - :param AssignmentResourceCreated resource_created: (optional) On success, - includes the policy assigned. - :param str status: (optional) policy status. - :param ErrorResponse error_message: (optional) The error response from API. + :param IdentityTypesBase user: The core set of properties associated with + an identity type. + :param IdentityTypesBase service_id: The core set of properties associated + with an identity type. + :param IdentityTypesBase service: The core set of properties associated + with an identity type. """ - self.resource_created = resource_created - self.status = status - self.error_message = error_message + self.user = user + self.service_id = service_id + self.service = service @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResourcePolicy': - """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypes': + """Initialize a IdentityTypes object from a json dictionary.""" args = {} - if (resource_created := _dict.get('resource_created')) is not None: - args['resource_created'] = AssignmentResourceCreated.from_dict(resource_created) - if (status := _dict.get('status')) is not None: - args['status'] = status - if (error_message := _dict.get('error_message')) is not None: - args['error_message'] = ErrorResponse.from_dict(error_message) + if (user := _dict.get('user')) is not None: + args['user'] = IdentityTypesBase.from_dict(user) + else: + raise ValueError('Required property \'user\' not present in IdentityTypes JSON') + if (service_id := _dict.get('service_id')) is not None: + args['service_id'] = IdentityTypesBase.from_dict(service_id) + else: + raise ValueError('Required property \'service_id\' not present in IdentityTypes JSON') + if (service := _dict.get('service')) is not None: + args['service'] = IdentityTypesBase.from_dict(service) + else: + raise ValueError('Required property \'service\' not present in IdentityTypes JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" + """Initialize a IdentityTypes object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'resource_created') and self.resource_created is not None: - if isinstance(self.resource_created, dict): - _dict['resource_created'] = self.resource_created + if hasattr(self, 'user') and self.user is not None: + if isinstance(self.user, dict): + _dict['user'] = self.user else: - _dict['resource_created'] = self.resource_created.to_dict() - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status - if hasattr(self, 'error_message') and self.error_message is not None: - if isinstance(self.error_message, dict): - _dict['error_message'] = self.error_message + _dict['user'] = self.user.to_dict() + if hasattr(self, 'service_id') and self.service_id is not None: + if isinstance(self.service_id, dict): + _dict['service_id'] = self.service_id else: - _dict['error_message'] = self.error_message.to_dict() + _dict['service_id'] = self.service_id.to_dict() + if hasattr(self, 'service') and self.service is not None: + if isinstance(self.service, dict): + _dict['service'] = self.service + else: + _dict['service'] = self.service.to_dict() return _dict def _to_dict(self): @@ -4206,70 +4337,70 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentResourcePolicy object.""" + """Return a `str` version of this IdentityTypes object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: + def __eq__(self, other: 'IdentityTypes') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: + def __ne__(self, other: 'IdentityTypes') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentResources: +class IdentityTypesBase: """ - The policy assignment resources. + The core set of properties associated with an identity type. - :param str target: (optional) Account ID where resources are assigned. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for - the assigned resource. + :param str state: The state of the identity type. + :param List[str] external_allowed_accounts: List of accounts that the state + applies to for a given identity. """ def __init__( self, - *, - target: Optional[str] = None, - policy: Optional['PolicyAssignmentResourcePolicy'] = None, + state: str, + external_allowed_accounts: List[str], ) -> None: """ - Initialize a PolicyAssignmentResources object. + Initialize a IdentityTypesBase object. - :param str target: (optional) Account ID where resources are assigned. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties - for the assigned resource. + :param str state: The state of the identity type. + :param List[str] external_allowed_accounts: List of accounts that the state + applies to for a given identity. """ - self.target = target - self.policy = policy + self.state = state + self.external_allowed_accounts = external_allowed_accounts @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResources': - """Initialize a PolicyAssignmentResources object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypesBase': + """Initialize a IdentityTypesBase object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = target - if (policy := _dict.get('policy')) is not None: - args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) + if (state := _dict.get('state')) is not None: + args['state'] = state + else: + raise ValueError('Required property \'state\' not present in IdentityTypesBase JSON') + if (external_allowed_accounts := _dict.get('external_allowed_accounts')) is not None: + args['external_allowed_accounts'] = external_allowed_accounts + else: + raise ValueError('Required property \'external_allowed_accounts\' not present in IdentityTypesBase JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentResources object from a json dictionary.""" + """Initialize a IdentityTypesBase object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - _dict['target'] = self.target - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy - else: - _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'external_allowed_accounts') and self.external_allowed_accounts is not None: + _dict['external_allowed_accounts'] = self.external_allowed_accounts return _dict def _to_dict(self): @@ -4277,171 +4408,97 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentResources object.""" + """Return a `str` version of this IdentityTypesBase object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentResources') -> bool: + def __eq__(self, other: 'IdentityTypesBase') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentResources') -> bool: + def __ne__(self, other: 'IdentityTypesBase') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + The state of the identity type. + """ -class PolicyAssignmentV1: + ENABLED = 'enabled' + MONITOR = 'monitor' + LIMITED = 'limited' + + +class IdentityTypesPatch: """ - The set of properties associated with the policy template assignment. + The settings to apply for each identity type for a request. - :param AssignmentTargetDetails target: assignment target account and type. - :param str id: (optional) Policy assignment ID. - :param str account_id: (optional) The account GUID that the policies assignments - belong to.. - :param str href: (optional) The href URL that links to the policies assignments - API by policy assignment ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - assignment was created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy assignment. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - assignment was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy assignment. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param PolicyAssignmentV1Subject subject: (optional) subject details of access - type assignment. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. + :param IdentityTypesBase user: (optional) The core set of properties associated + with an identity type. + :param IdentityTypesBase service_id: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service: (optional) The core set of properties + associated with an identity type. """ def __init__( self, - target: 'AssignmentTargetDetails', - resources: List['PolicyAssignmentV1Resources'], - template: 'AssignmentTemplateDetails', - status: str, *, - id: Optional[str] = None, - account_id: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - subject: Optional['PolicyAssignmentV1Subject'] = None, + user: Optional['IdentityTypesBase'] = None, + service_id: Optional['IdentityTypesBase'] = None, + service: Optional['IdentityTypesBase'] = None, ) -> None: """ - Initialize a PolicyAssignmentV1 object. + Initialize a IdentityTypesPatch object. - :param AssignmentTargetDetails target: assignment target account and type. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. - :param PolicyAssignmentV1Subject subject: (optional) subject details of - access type assignment. + :param IdentityTypesBase user: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service_id: (optional) The core set of properties + associated with an identity type. + :param IdentityTypesBase service: (optional) The core set of properties + associated with an identity type. """ - self.target = target - self.id = id - self.account_id = account_id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.resources = resources - self.subject = subject - self.template = template - self.status = status + self.user = user + self.service_id = service_id + self.service = service @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1': - """Initialize a PolicyAssignmentV1 object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'IdentityTypesPatch': + """Initialize a IdentityTypesPatch object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) - else: - raise ValueError('Required property \'target\' not present in PolicyAssignmentV1 JSON') - if (id := _dict.get('id')) is not None: - args['id'] = id - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyAssignmentV1Resources.from_dict(v) for v in resources] - else: - raise ValueError('Required property \'resources\' not present in PolicyAssignmentV1 JSON') - if (subject := _dict.get('subject')) is not None: - args['subject'] = PolicyAssignmentV1Subject.from_dict(subject) - if (template := _dict.get('template')) is not None: - args['template'] = AssignmentTemplateDetails.from_dict(template) - else: - raise ValueError('Required property \'template\' not present in PolicyAssignmentV1 JSON') - if (status := _dict.get('status')) is not None: - args['status'] = status - else: - raise ValueError('Required property \'status\' not present in PolicyAssignmentV1 JSON') + if (user := _dict.get('user')) is not None: + args['user'] = IdentityTypesBase.from_dict(user) + if (service_id := _dict.get('service_id')) is not None: + args['service_id'] = IdentityTypesBase.from_dict(service_id) + if (service := _dict.get('service')) is not None: + args['service'] = IdentityTypesBase.from_dict(service) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1 object from a json dictionary.""" + """Initialize a IdentityTypesPatch object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target + if hasattr(self, 'user') and self.user is not None: + if isinstance(self.user, dict): + _dict['user'] = self.user else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'subject') and self.subject is not None: - if isinstance(self.subject, dict): - _dict['subject'] = self.subject + _dict['user'] = self.user.to_dict() + if hasattr(self, 'service_id') and self.service_id is not None: + if isinstance(self.service_id, dict): + _dict['service_id'] = self.service_id else: - _dict['subject'] = self.subject.to_dict() - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template + _dict['service_id'] = self.service_id.to_dict() + if hasattr(self, 'service') and self.service is not None: + if isinstance(self.service, dict): + _dict['service'] = self.service else: - _dict['template'] = self.template.to_dict() - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status + _dict['service'] = self.service.to_dict() return _dict def _to_dict(self): @@ -4449,75 +4506,63 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1 object.""" + """Return a `str` version of this IdentityTypesPatch object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1') -> bool: + def __eq__(self, other: 'IdentityTypesPatch') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1') -> bool: + def __ne__(self, other: 'IdentityTypesPatch') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StatusEnum(str, Enum): - """ - The policy assignment status. - """ - - IN_PROGRESS = 'in_progress' - SUCCEEDED = 'succeeded' - SUCCEED_WITH_ERRORS = 'succeed_with_errors' - FAILED = 'failed' - -class PolicyAssignmentV1Collection: +class LimitData: """ - Policy assignment response. + policy template current and limit details with in an account. - :param List[PolicyAssignmentV1] assignments: (optional) Response of policy - assignments. + :param int current: (optional) policy template current count. + :param int limit: (optional) policy template limit count. """ def __init__( self, *, - assignments: Optional[List['PolicyAssignmentV1']] = None, + current: Optional[int] = None, + limit: Optional[int] = None, ) -> None: """ - Initialize a PolicyAssignmentV1Collection object. + Initialize a LimitData object. - :param List[PolicyAssignmentV1] assignments: (optional) Response of policy - assignments. """ - self.assignments = assignments + self.current = current + self.limit = limit @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Collection': - """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'LimitData': + """Initialize a LimitData object from a json dictionary.""" args = {} - if (assignments := _dict.get('assignments')) is not None: - args['assignments'] = [PolicyAssignmentV1.from_dict(v) for v in assignments] + if (current := _dict.get('current')) is not None: + args['current'] = current + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" + """Initialize a LimitData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'assignments') and self.assignments is not None: - assignments_list = [] - for v in self.assignments: - if isinstance(v, dict): - assignments_list.append(v) - else: - assignments_list.append(v.to_dict()) - _dict['assignments'] = assignments_list + if hasattr(self, 'current') and getattr(self, 'current') is not None: + _dict['current'] = getattr(self, 'current') + if hasattr(self, 'limit') and getattr(self, 'limit') is not None: + _dict['limit'] = getattr(self, 'limit') return _dict def _to_dict(self): @@ -4525,75 +4570,85 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Collection object.""" + """Return a `str` version of this LimitData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Collection') -> bool: + def __eq__(self, other: 'LimitData') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Collection') -> bool: + def __ne__(self, other: 'LimitData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentV1Resources: +class NestedCondition: """ - The policy assignment resources. + Condition that specifies additional conditions or RuleAttribute to grant access. - :param AssignmentTargetDetails target: (optional) assignment target account and - type. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for - the assigned resource. """ def __init__( self, - *, - target: Optional['AssignmentTargetDetails'] = None, - policy: Optional['PolicyAssignmentResourcePolicy'] = None, ) -> None: """ - Initialize a PolicyAssignmentV1Resources object. + Initialize a NestedCondition object. - :param AssignmentTargetDetails target: (optional) assignment target account - and type. - :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties - for the assigned resource. """ - self.target = target - self.policy = policy + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['NestedConditionRuleAttribute', 'NestedConditionRuleWithConditions']) + ) + raise Exception(msg) + + +class Next: + """ + Details with href linking to 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. + """ + + def __init__( + self, + *, + href: Optional[str] = None, + start: Optional[str] = None, + ) -> None: + """ + Initialize a Next object. + + :param str start: (optional) Page token that refers to the page of + collection. + """ + self.href = href + self.start = start @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Resources': - """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Next': + """Initialize a Next object from a json dictionary.""" args = {} - if (target := _dict.get('target')) is not None: - args['target'] = AssignmentTargetDetails.from_dict(target) - if (policy := _dict.get('policy')) is not None: - args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) + if (href := _dict.get('href')) is not None: + args['href'] = href + if (start := _dict.get('start')) is not None: + args['start'] = start return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" + """Initialize a Next object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target - else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy - else: - _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start return _dict def _to_dict(self): @@ -4601,54 +4656,125 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Resources object.""" + """Return a `str` version of this Next object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Resources') -> bool: + def __eq__(self, other: 'Next') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Resources') -> bool: + def __ne__(self, other: 'Next') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyAssignmentV1Subject: +class Policy: """ - subject details of access type assignment. + The core set of properties associated with a policy. - :param str id: (optional) - :param str type: (optional) + :param str id: (optional) The policy ID. + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Customer-defined description. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) granted + by the policy. + :param List[PolicyResource] resources: The resources associated with a policy. + :param str href: (optional) The href link back to the policy. + :param datetime created_at: (optional) The UTC timestamp when the policy was + created. + :param str created_by_id: (optional) The iam ID of the entity that created the + policy. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + was last modified. + :param str last_modified_by_id: (optional) The iam ID of the entity that last + modified the policy. + :param str state: (optional) The policy state. """ def __init__( self, + type: str, + subjects: List['PolicySubject'], + roles: List['PolicyRole'], + resources: List['PolicyResource'], *, id: Optional[str] = None, - type: Optional[str] = None, + description: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + state: Optional[str] = None, ) -> None: """ - Initialize a PolicyAssignmentV1Subject object. + Initialize a Policy object. + :param str type: The policy type; either 'access' or 'authorization'. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) + granted by the policy. + :param List[PolicyResource] resources: The resources associated with a + policy. + :param str description: (optional) Customer-defined description. + :param str state: (optional) The policy state. """ self.id = id self.type = type + self.description = description + self.subjects = subjects + self.roles = roles + self.resources = resources + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.state = state @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Subject': - """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Policy': + """Initialize a Policy object from a json dictionary.""" args = {} if (id := _dict.get('id')) is not None: args['id'] = id if (type := _dict.get('type')) is not None: args['type'] = type + else: + raise ValueError('Required property \'type\' not present in Policy JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (subjects := _dict.get('subjects')) is not None: + args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] + else: + raise ValueError('Required property \'subjects\' not present in Policy JSON') + if (roles := _dict.get('roles')) is not None: + args['roles'] = [PolicyRole.from_dict(v) for v in roles] + else: + raise ValueError('Required property \'roles\' not present in Policy JSON') + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyResource.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in Policy JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (state := _dict.get('state')) is not None: + args['state'] = state return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" + """Initialize a Policy object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -4656,8 +4782,46 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and getattr(self, 'type') is not None: - _dict['type'] = getattr(self, 'type') + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'subjects') and self.subjects is not None: + subjects_list = [] + for v in self.subjects: + if isinstance(v, dict): + subjects_list.append(v) + else: + subjects_list.append(v.to_dict()) + _dict['subjects'] = subjects_list + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: + if isinstance(v, dict): + roles_list.append(v) + else: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state return _dict def _to_dict(self): @@ -4665,71 +4829,89 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyAssignmentV1Subject object.""" + """Return a `str` version of this Policy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyAssignmentV1Subject') -> bool: + def __eq__(self, other: 'Policy') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyAssignmentV1Subject') -> bool: + def __ne__(self, other: 'Policy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): + class StateEnum(str, Enum): """ - type. + The policy state. """ - IAM_ID = 'iam_id' - ACCESS_GROUP_ID = 'access_group_id' + ACTIVE = 'active' + DELETED = 'deleted' -class PolicyCollection: +class PolicyAssignmentResourcePolicy: """ - A collection of policies. + Set of properties for the assigned resource. - :param List[PolicyTemplateMetaData] policies: (optional) List of policies. + :param AssignmentResourceCreated resource_created: (optional) On success, + includes the policy assigned. + :param str status: (optional) policy status. + :param ErrorResponse error_message: (optional) The error response from API. """ def __init__( self, *, - policies: Optional[List['PolicyTemplateMetaData']] = None, + resource_created: Optional['AssignmentResourceCreated'] = None, + status: Optional[str] = None, + error_message: Optional['ErrorResponse'] = None, ) -> None: """ - Initialize a PolicyCollection object. + Initialize a PolicyAssignmentResourcePolicy object. - :param List[PolicyTemplateMetaData] policies: (optional) List of policies. + :param AssignmentResourceCreated resource_created: (optional) On success, + includes the policy assigned. + :param str status: (optional) policy status. + :param ErrorResponse error_message: (optional) The error response from API. """ - self.policies = policies + self.resource_created = resource_created + self.status = status + self.error_message = error_message @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyCollection': - """Initialize a PolicyCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResourcePolicy': + """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" args = {} - if (policies := _dict.get('policies')) is not None: - args['policies'] = [PolicyTemplateMetaData.from_dict(v) for v in policies] + if (resource_created := _dict.get('resource_created')) is not None: + args['resource_created'] = AssignmentResourceCreated.from_dict(resource_created) + if (status := _dict.get('status')) is not None: + args['status'] = status + if (error_message := _dict.get('error_message')) is not None: + args['error_message'] = ErrorResponse.from_dict(error_message) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyCollection object from a json dictionary.""" + """Initialize a PolicyAssignmentResourcePolicy object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'policies') and self.policies is not None: - policies_list = [] - for v in self.policies: - if isinstance(v, dict): - policies_list.append(v) - else: - policies_list.append(v.to_dict()) - _dict['policies'] = policies_list + if hasattr(self, 'resource_created') and self.resource_created is not None: + if isinstance(self.resource_created, dict): + _dict['resource_created'] = self.resource_created + else: + _dict['resource_created'] = self.resource_created.to_dict() + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'error_message') and self.error_message is not None: + if isinstance(self.error_message, dict): + _dict['error_message'] = self.error_message + else: + _dict['error_message'] = self.error_message.to_dict() return _dict def _to_dict(self): @@ -4737,79 +4919,70 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyCollection object.""" + """Return a `str` version of this PolicyAssignmentResourcePolicy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyCollection') -> bool: + def __eq__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyCollection') -> bool: + def __ne__(self, other: 'PolicyAssignmentResourcePolicy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyResource: +class PolicyAssignmentResources: """ - The attributes of the resource. Note that only one resource is allowed in a policy. + The policy assignment resources. - :param List[ResourceAttribute] attributes: (optional) List of resource - attributes. - :param List[ResourceTag] tags: (optional) List of access management tags. + :param str target: (optional) Account ID where resources are assigned. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for + the assigned resource. """ def __init__( self, *, - attributes: Optional[List['ResourceAttribute']] = None, - tags: Optional[List['ResourceTag']] = None, + target: Optional[str] = None, + policy: Optional['PolicyAssignmentResourcePolicy'] = None, ) -> None: """ - Initialize a PolicyResource object. + Initialize a PolicyAssignmentResources object. - :param List[ResourceAttribute] attributes: (optional) List of resource - attributes. - :param List[ResourceTag] tags: (optional) List of access management tags. + :param str target: (optional) Account ID where resources are assigned. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties + for the assigned resource. """ - self.attributes = attributes - self.tags = tags + self.target = target + self.policy = policy @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyResource': - """Initialize a PolicyResource object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentResources': + """Initialize a PolicyAssignmentResources object from a json dictionary.""" args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [ResourceAttribute.from_dict(v) for v in attributes] - if (tags := _dict.get('tags')) is not None: - args['tags'] = [ResourceTag.from_dict(v) for v in tags] + if (target := _dict.get('target')) is not None: + args['target'] = target + if (policy := _dict.get('policy')) is not None: + args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyResource object from a json dictionary.""" + """Initialize a PolicyAssignmentResources object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: - if isinstance(v, dict): - attributes_list.append(v) - else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list - if hasattr(self, 'tags') and self.tags is not None: - tags_list = [] - for v in self.tags: - if isinstance(v, dict): - tags_list.append(v) - else: - tags_list.append(v.to_dict()) - _dict['tags'] = tags_list + if hasattr(self, 'target') and self.target is not None: + _dict['target'] = self.target + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy + else: + _dict['policy'] = self.policy.to_dict() return _dict def _to_dict(self): @@ -4817,75 +4990,171 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyResource object.""" + """Return a `str` version of this PolicyAssignmentResources object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyResource') -> bool: + def __eq__(self, other: 'PolicyAssignmentResources') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyResource') -> bool: + def __ne__(self, other: 'PolicyAssignmentResources') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyRole: +class PolicyAssignmentV1: """ - A role associated with a policy. + The set of properties associated with the policy template assignment. - :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. - Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. - :param str display_name: (optional) The display name of the role. - :param str description: (optional) The description of the role. + :param AssignmentTargetDetails target: assignment target account and type. + :param str id: (optional) Policy assignment ID. + :param str account_id: (optional) The account GUID that the policies assignments + belong to.. + :param str href: (optional) The href URL that links to the policies assignments + API by policy assignment ID. + :param datetime created_at: (optional) The UTC timestamp when the policy + assignment was created. + :param str created_by_id: (optional) The iam ID of the entity that created the + policy assignment. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + assignment was last modified. + :param str last_modified_by_id: (optional) The iam ID of the entity that last + modified the policy assignment. + :param List[PolicyAssignmentV1Resources] resources: Object for each account + assigned. + :param PolicyAssignmentV1Subject subject: (optional) subject details of access + type assignment. + :param AssignmentTemplateDetails template: policy template details. + :param str status: The policy assignment status. """ def __init__( self, - role_id: str, + target: 'AssignmentTargetDetails', + resources: List['PolicyAssignmentV1Resources'], + template: 'AssignmentTemplateDetails', + status: str, *, - display_name: Optional[str] = None, - description: Optional[str] = None, + id: Optional[str] = None, + account_id: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + subject: Optional['PolicyAssignmentV1Subject'] = None, ) -> None: """ - Initialize a PolicyRole object. + Initialize a PolicyAssignmentV1 object. - :param str role_id: The role Cloud Resource Name (CRN) granted by the - policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param AssignmentTargetDetails target: assignment target account and type. + :param List[PolicyAssignmentV1Resources] resources: Object for each account + assigned. + :param AssignmentTemplateDetails template: policy template details. + :param str status: The policy assignment status. + :param PolicyAssignmentV1Subject subject: (optional) subject details of + access type assignment. """ - self.role_id = role_id - self.display_name = display_name - self.description = description + self.target = target + self.id = id + self.account_id = account_id + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.resources = resources + self.subject = subject + self.template = template + self.status = status @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyRole': - """Initialize a PolicyRole object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1': + """Initialize a PolicyAssignmentV1 object from a json dictionary.""" args = {} - if (role_id := _dict.get('role_id')) is not None: - args['role_id'] = role_id + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) else: - raise ValueError('Required property \'role_id\' not present in PolicyRole JSON') - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - if (description := _dict.get('description')) is not None: - args['description'] = description + raise ValueError('Required property \'target\' not present in PolicyAssignmentV1 JSON') + if (id := _dict.get('id')) is not None: + args['id'] = id + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyAssignmentV1Resources.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in PolicyAssignmentV1 JSON') + if (subject := _dict.get('subject')) is not None: + args['subject'] = PolicyAssignmentV1Subject.from_dict(subject) + if (template := _dict.get('template')) is not None: + args['template'] = AssignmentTemplateDetails.from_dict(template) + else: + raise ValueError('Required property \'template\' not present in PolicyAssignmentV1 JSON') + if (status := _dict.get('status')) is not None: + args['status'] = status + else: + raise ValueError('Required property \'status\' not present in PolicyAssignmentV1 JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyRole object from a json dictionary.""" + """Initialize a PolicyAssignmentV1 object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'role_id') and self.role_id is not None: - _dict['role_id'] = self.role_id - if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: - _dict['display_name'] = getattr(self, 'display_name') - if hasattr(self, 'description') and getattr(self, 'description') is not None: - _dict['description'] = getattr(self, 'description') + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: + _dict['account_id'] = getattr(self, 'account_id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: + if isinstance(v, dict): + resources_list.append(v) + else: + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'subject') and self.subject is not None: + if isinstance(self.subject, dict): + _dict['subject'] = self.subject + else: + _dict['subject'] = self.subject.to_dict() + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status return _dict def _to_dict(self): @@ -4893,65 +5162,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyRole object.""" + """Return a `str` version of this PolicyAssignmentV1 object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyRole') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyRole') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StatusEnum(str, Enum): + """ + The policy assignment status. + """ -class PolicySubject: + IN_PROGRESS = 'in_progress' + SUCCEEDED = 'succeeded' + SUCCEED_WITH_ERRORS = 'succeed_with_errors' + FAILED = 'failed' + + +class PolicyAssignmentV1Collection: """ - The subject attribute values that must match in order for this policy to apply in a - permission decision. + Policy assignment response. - :param List[SubjectAttribute] attributes: (optional) List of subject attributes. + :param List[PolicyAssignmentV1] assignments: (optional) Response of policy + assignments. """ def __init__( self, *, - attributes: Optional[List['SubjectAttribute']] = None, + assignments: Optional[List['PolicyAssignmentV1']] = None, ) -> None: """ - Initialize a PolicySubject object. + Initialize a PolicyAssignmentV1Collection object. - :param List[SubjectAttribute] attributes: (optional) List of subject - attributes. + :param List[PolicyAssignmentV1] assignments: (optional) Response of policy + assignments. """ - self.attributes = attributes + self.assignments = assignments @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicySubject': - """Initialize a PolicySubject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Collection': + """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [SubjectAttribute.from_dict(v) for v in attributes] + if (assignments := _dict.get('assignments')) is not None: + args['assignments'] = [PolicyAssignmentV1.from_dict(v) for v in assignments] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicySubject object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Collection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: if isinstance(v, dict): - attributes_list.append(v) + assignments_list.append(v) else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list return _dict def _to_dict(self): @@ -4959,176 +5238,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicySubject object.""" + """Return a `str` version of this PolicyAssignmentV1Collection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicySubject') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Collection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicySubject') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Collection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyTemplate: +class PolicyAssignmentV1Resources: """ - The core set of properties associated with the policy template. + The policy assignment resources. - :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 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 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. - :param str id: (optional) The policy template ID. - :param str href: (optional) The href URL that links to the policy templates API - by policy template ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - template was created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy template. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - template was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy template. + :param AssignmentTargetDetails target: (optional) assignment target account and + type. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties for + the assigned resource. """ def __init__( self, - name: str, - account_id: str, - version: str, - policy: 'TemplatePolicy', *, - 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, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, + target: Optional['AssignmentTargetDetails'] = None, + policy: Optional['PolicyAssignmentResourcePolicy'] = None, ) -> None: """ - Initialize a PolicyTemplate object. + Initialize a PolicyAssignmentV1Resources 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 - created. - :param str version: Template version. - :param TemplatePolicy policy: The core set of properties associated with - the template's policy objet. - :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 AssignmentTargetDetails target: (optional) assignment target account + and type. + :param PolicyAssignmentResourcePolicy policy: (optional) Set of properties + for the assigned resource. """ - self.name = name - self.description = description - self.account_id = account_id - self.version = version - self.committed = committed + self.target = target self.policy = policy - self.state = state - 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 @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': - """Initialize a PolicyTemplate object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Resources': + """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name - else: - raise ValueError('Required property \'name\' not present in PolicyTemplate JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - else: - raise ValueError('Required property \'account_id\' not present in PolicyTemplate JSON') - if (version := _dict.get('version')) is not None: - args['version'] = version - else: - raise ValueError('Required property \'version\' not present in PolicyTemplate JSON') - if (committed := _dict.get('committed')) is not None: - args['committed'] = committed + if (target := _dict.get('target')) is not None: + args['target'] = AssignmentTargetDetails.from_dict(target) if (policy := _dict.get('policy')) is not None: - args['policy'] = TemplatePolicy.from_dict(policy) - else: - raise ValueError('Required property \'policy\' not present in PolicyTemplate JSON') - if (state := _dict.get('state')) is not None: - args['state'] = state - 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 + args['policy'] = PolicyAssignmentResourcePolicy.from_dict(policy) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplate object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Resources object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version - if hasattr(self, 'committed') and self.committed is not None: - _dict['committed'] = self.committed + if hasattr(self, 'target') and self.target is not None: + if isinstance(self.target, dict): + _dict['target'] = self.target + else: + _dict['target'] = self.target.to_dict() if hasattr(self, 'policy') and self.policy is not None: if isinstance(self.policy, dict): _dict['policy'] = self.policy else: _dict['policy'] = self.policy.to_dict() - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') return _dict def _to_dict(self): @@ -5136,73 +5314,64 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplate object.""" + """Return a `str` version of this PolicyAssignmentV1Resources object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplate') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Resources') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplate') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Resources') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - State of policy template. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class PolicyTemplateAssignmentCollection: +class PolicyAssignmentV1Subject: """ - A collection of policies assignments. + subject details of access type assignment. - :param List[PolicyTemplateAssignmentItems] assignments: (optional) List of - policy assignments. + :param str id: (optional) The unique identifier of the subject of the + assignment. + :param str type: (optional) The identity type of the subject of the assignment. """ def __init__( self, *, - assignments: Optional[List['PolicyTemplateAssignmentItems']] = None, + id: Optional[str] = None, + type: Optional[str] = None, ) -> None: """ - Initialize a PolicyTemplateAssignmentCollection object. + Initialize a PolicyAssignmentV1Subject object. - :param List[PolicyTemplateAssignmentItems] assignments: (optional) List of - policy assignments. """ - self.assignments = assignments + self.id = id + self.type = type @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': - """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyAssignmentV1Subject': + """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" args = {} - if (assignments := _dict.get('assignments')) is not None: - args['assignments'] = assignments + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" + """Initialize a PolicyAssignmentV1Subject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'assignments') and self.assignments is not None: - assignments_list = [] - for v in self.assignments: - if isinstance(v, dict): - assignments_list.append(v) - else: - assignments_list.append(v.to_dict()) - _dict['assignments'] = assignments_list + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'type') and getattr(self, 'type') is not None: + _dict['type'] = getattr(self, 'type') return _dict def _to_dict(self): @@ -5210,86 +5379,120 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateAssignmentCollection object.""" + """Return a `str` version of this PolicyAssignmentV1Subject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: + def __eq__(self, other: 'PolicyAssignmentV1Subject') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: + def __ne__(self, other: 'PolicyAssignmentV1Subject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TypeEnum(str, Enum): + """ + The identity type of the subject of the assignment. + """ -class PolicyTemplateAssignmentItems: + IAM_ID = 'iam_id' + ACCESS_GROUP_ID = 'access_group_id' + + +class PolicyCollection: """ - PolicyTemplateAssignmentItems. + A collection of policies. - """ - - def __init__( - self, - ) -> None: - """ - Initialize a PolicyTemplateAssignmentItems object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join( - ['PolicyTemplateAssignmentItemsPolicyAssignmentV1', 'PolicyTemplateAssignmentItemsPolicyAssignment'] - ) - ) - raise Exception(msg) - - -class PolicyTemplateCollection: - """ - A collection of policy Templates. - - :param List[PolicyTemplate] policy_templates: (optional) 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 + 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 page + of requested collection. + :param List[PolicyTemplateMetaData] policies: (optional) List of policies. """ def __init__( self, *, - policy_templates: Optional[List['PolicyTemplate']] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + policies: Optional[List['PolicyTemplateMetaData']] = None, ) -> None: """ - Initialize a PolicyTemplateCollection object. + Initialize a PolicyCollection object. - :param List[PolicyTemplate] policy_templates: (optional) 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 + 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 + page of requested collection. + :param List[PolicyTemplateMetaData] policies: (optional) List of policies. """ - self.policy_templates = policy_templates + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.policies = policies @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateCollection': - """Initialize a PolicyTemplateCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyCollection': + """Initialize a PolicyCollection object from a json dictionary.""" args = {} - if (policy_templates := _dict.get('policy_templates')) is not None: - args['policy_templates'] = [PolicyTemplate.from_dict(v) for v in policy_templates] + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (policies := _dict.get('policies')) is not None: + args['policies'] = [PolicyTemplateMetaData.from_dict(v) for v in policies] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateCollection object from a json dictionary.""" + """Initialize a PolicyCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'policy_templates') and self.policy_templates is not None: - policy_templates_list = [] - for v in self.policy_templates: + 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, 'policies') and self.policies is not None: + policies_list = [] + for v in self.policies: if isinstance(v, dict): - policy_templates_list.append(v) + policies_list.append(v) else: - policy_templates_list.append(v.to_dict()) - _dict['policy_templates'] = policy_templates_list + policies_list.append(v.to_dict()) + _dict['policies'] = policies_list return _dict def _to_dict(self): @@ -5297,187 +5500,79 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateCollection object.""" + """Return a `str` version of this PolicyCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateCollection') -> bool: + def __eq__(self, other: 'PolicyCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateCollection') -> bool: + def __ne__(self, other: 'PolicyCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyTemplateLimitData: +class PolicyResource: """ - The core set of properties associated with the policy template. + The attributes of the resource. Note that only one resource is allowed in a policy. - :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 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 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. - :param str id: (optional) The policy template ID. - :param str href: (optional) The href URL that links to the policy templates API - by policy template ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - template was created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy template. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - template was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy template. - :param TemplateCountData counts: (optional) policy template count details. + :param List[ResourceAttribute] attributes: (optional) List of resource + attributes. + :param List[ResourceTag] tags: (optional) List of access management tags. """ def __init__( self, - name: str, - account_id: str, - version: str, - policy: 'TemplatePolicy', *, - 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, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - counts: Optional['TemplateCountData'] = None, + attributes: Optional[List['ResourceAttribute']] = None, + tags: Optional[List['ResourceTag']] = None, ) -> None: """ - Initialize a PolicyTemplateLimitData object. + Initialize a PolicyResource 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 - created. - :param str version: Template version. - :param TemplatePolicy policy: The core set of properties associated with - the template's policy objet. - :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. + :param List[ResourceAttribute] attributes: (optional) List of resource + attributes. + :param List[ResourceTag] tags: (optional) List of access management tags. """ - self.name = name - self.description = description - self.account_id = account_id - self.version = version - self.committed = committed - self.policy = policy - self.state = state - self.id = id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.counts = counts + self.attributes = attributes + self.tags = tags @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData': - """Initialize a PolicyTemplateLimitData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyResource': + """Initialize a PolicyResource 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 PolicyTemplateLimitData JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - else: - raise ValueError('Required property \'account_id\' not present in PolicyTemplateLimitData JSON') - if (version := _dict.get('version')) is not None: - args['version'] = version - else: - raise ValueError('Required property \'version\' not present in PolicyTemplateLimitData JSON') - if (committed := _dict.get('committed')) is not None: - args['committed'] = committed - if (policy := _dict.get('policy')) is not None: - args['policy'] = TemplatePolicy.from_dict(policy) - else: - raise ValueError('Required property \'policy\' not present in PolicyTemplateLimitData JSON') - if (state := _dict.get('state')) is not None: - args['state'] = state - if (id := _dict.get('id')) is not None: - args['id'] = id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (counts := _dict.get('counts')) is not None: - args['counts'] = TemplateCountData.from_dict(counts) + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [ResourceAttribute.from_dict(v) for v in attributes] + if (tags := _dict.get('tags')) is not None: + args['tags'] = [ResourceTag.from_dict(v) for v in tags] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateLimitData object from a json dictionary.""" + """Initialize a PolicyResource object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version - if hasattr(self, 'committed') and self.committed is not None: - _dict['committed'] = self.committed - if hasattr(self, 'policy') and self.policy is not None: - if isinstance(self.policy, dict): - _dict['policy'] = self.policy - else: - _dict['policy'] = self.policy.to_dict() - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'counts') and self.counts is not None: - if isinstance(self.counts, dict): - _dict['counts'] = self.counts - else: - _dict['counts'] = self.counts.to_dict() + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: + if isinstance(v, dict): + attributes_list.append(v) + else: + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list + if hasattr(self, 'tags') and self.tags is not None: + tags_list = [] + for v in self.tags: + if isinstance(v, dict): + tags_list.append(v) + else: + tags_list.append(v.to_dict()) + _dict['tags'] = tags_list return _dict def _to_dict(self): @@ -5485,197 +5580,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateLimitData object.""" + """Return a `str` version of this PolicyResource object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateLimitData') -> bool: + def __eq__(self, other: 'PolicyResource') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateLimitData') -> bool: + def __ne__(self, other: 'PolicyResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - State of policy template. - """ - ACTIVE = 'active' - DELETED = 'deleted' - - -class PolicyTemplateMetaData: +class PolicyRole: """ - The core set of properties associated with a policy. + A role associated with a policy. - :param str id: (optional) The policy ID. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Customer-defined description. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) granted - by the policy. - :param List[PolicyResource] resources: The resources associated with a policy. - :param str href: (optional) The href link back to the policy. - :param datetime created_at: (optional) The UTC timestamp when the policy was - created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy. - :param str state: (optional) The policy state. - :param TemplateMetadata template: (optional) The details of the IAM template - that was used to create an enterprise-managed policy in your account. When - returned, this indicates that the policy is created from and managed by a - template in the root enterprise account. + :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. + Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param str display_name: (optional) The display name of the role. + :param str description: (optional) The description of the role. """ def __init__( self, - type: str, - subjects: List['PolicySubject'], - roles: List['PolicyRole'], - resources: List['PolicyResource'], + role_id: str, *, - id: Optional[str] = None, + display_name: Optional[str] = None, description: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - state: Optional[str] = None, - template: Optional['TemplateMetadata'] = None, ) -> None: """ - Initialize a PolicyTemplateMetaData object. + Initialize a PolicyRole object. - :param str type: The policy type; either 'access' or 'authorization'. - :param List[PolicySubject] subjects: The subjects associated with a policy. - :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) - granted by the policy. - :param List[PolicyResource] resources: The resources associated with a - policy. - :param str description: (optional) Customer-defined description. - :param str state: (optional) The policy state. - :param TemplateMetadata template: (optional) The details of the IAM - template that was used to create an enterprise-managed policy in your - account. When returned, this indicates that the policy is created from and - managed by a template in the root enterprise account. + :param str role_id: The role Cloud Resource Name (CRN) granted by the + policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. """ - self.id = id - self.type = type + self.role_id = role_id + self.display_name = display_name self.description = description - self.subjects = subjects - self.roles = roles - self.resources = resources - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.state = state - self.template = template @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateMetaData': - """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyRole': + """Initialize a PolicyRole object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (type := _dict.get('type')) is not None: - args['type'] = type + if (role_id := _dict.get('role_id')) is not None: + args['role_id'] = role_id else: - raise ValueError('Required property \'type\' not present in PolicyTemplateMetaData JSON') + raise ValueError('Required property \'role_id\' not present in PolicyRole JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name if (description := _dict.get('description')) is not None: args['description'] = description - if (subjects := _dict.get('subjects')) is not None: - args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] - else: - raise ValueError('Required property \'subjects\' not present in PolicyTemplateMetaData JSON') - if (roles := _dict.get('roles')) is not None: - args['roles'] = [PolicyRole.from_dict(v) for v in roles] - else: - raise ValueError('Required property \'roles\' not present in PolicyTemplateMetaData JSON') - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyResource.from_dict(v) for v in resources] - else: - raise ValueError('Required property \'resources\' not present in PolicyTemplateMetaData JSON') - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (state := _dict.get('state')) is not None: - args['state'] = state - if (template := _dict.get('template')) is not None: - args['template'] = TemplateMetadata.from_dict(template) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateMetaData object from a json dictionary.""" + """Initialize a PolicyRole object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'subjects') and self.subjects is not None: - subjects_list = [] - for v in self.subjects: - if isinstance(v, dict): - subjects_list.append(v) - else: - subjects_list.append(v.to_dict()) - _dict['subjects'] = subjects_list - if hasattr(self, 'roles') and self.roles is not None: - roles_list = [] - for v in self.roles: - if isinstance(v, dict): - roles_list.append(v) - else: - roles_list.append(v.to_dict()) - _dict['roles'] = roles_list - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template - else: - _dict['template'] = self.template.to_dict() + if hasattr(self, 'role_id') and self.role_id is not None: + _dict['role_id'] = self.role_id + if hasattr(self, 'display_name') and getattr(self, 'display_name') is not None: + _dict['display_name'] = getattr(self, 'display_name') + if hasattr(self, 'description') and getattr(self, 'description') is not None: + _dict['description'] = getattr(self, 'description') return _dict def _to_dict(self): @@ -5683,73 +5656,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateMetaData object.""" + """Return a `str` version of this PolicyRole object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateMetaData') -> bool: + def __eq__(self, other: 'PolicyRole') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateMetaData') -> bool: + def __ne__(self, other: 'PolicyRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StateEnum(str, Enum): - """ - The policy state. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class PolicyTemplateVersionsCollection: +class PolicySubject: """ - A collection of versions for a specific policy template. + The subject attribute values that must match in order for this policy to apply in a + permission decision. - :param List[PolicyTemplate] versions: (optional) List of policy templates - versions. + :param List[SubjectAttribute] attributes: (optional) List of subject attributes. """ def __init__( self, *, - versions: Optional[List['PolicyTemplate']] = None, + attributes: Optional[List['SubjectAttribute']] = None, ) -> None: """ - Initialize a PolicyTemplateVersionsCollection object. + Initialize a PolicySubject object. - :param List[PolicyTemplate] versions: (optional) List of policy templates - versions. + :param List[SubjectAttribute] attributes: (optional) List of subject + attributes. """ - self.versions = versions + self.attributes = attributes @classmethod - def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': - """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicySubject': + """Initialize a PolicySubject object from a json dictionary.""" args = {} - if (versions := _dict.get('versions')) is not None: - args['versions'] = [PolicyTemplate.from_dict(v) for v in versions] + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [SubjectAttribute.from_dict(v) for v in attributes] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" + """Initialize a PolicySubject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'versions') and self.versions is not None: - versions_list = [] - for v in self.versions: + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: if isinstance(v, dict): - versions_list.append(v) + attributes_list.append(v) else: - versions_list.append(v.to_dict()) - _dict['versions'] = versions_list + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list return _dict def _to_dict(self): @@ -5757,66 +5722,142 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this PolicyTemplateVersionsCollection object.""" + """Return a `str` version of this PolicySubject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + def __eq__(self, other: 'PolicySubject') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'PolicyTemplateVersionsCollection') -> bool: + def __ne__(self, other: 'PolicySubject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAttribute: - """ - An attribute associated with a resource. - - :param str name: The name of an attribute. - :param str value: The value of an attribute. - :param str operator: (optional) The operator of an attribute. +class PolicyTemplate: """ + The core set of properties associated with the policy template. - def __init__( - self, - name: str, - value: str, - *, - operator: Optional[str] = None, - ) -> None: - """ - Initialize a ResourceAttribute object. - - :param str name: The name of an attribute. - :param str value: The value of an attribute. - :param str operator: (optional) The operator of an attribute. - """ - self.name = name - self.value = value - self.operator = operator + :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 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 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. + :param str id: (optional) The policy template ID. + :param str href: (optional) The href URL that links to the policy templates API + by policy template ID. + :param datetime created_at: (optional) The UTC timestamp when the policy + template was created. + :param str created_by_id: (optional) The iam ID of the entity that created the + policy template. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + template was last modified. + :param str last_modified_by_id: (optional) The iam ID of the entity that last + modified the policy template. + """ + + def __init__( + self, + name: str, + account_id: str, + version: str, + policy: 'TemplatePolicy', + *, + 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, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + ) -> None: + """ + 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 + created. + :param str version: Template version. + :param TemplatePolicy policy: The core set of properties associated with + the template's policy objet. + :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 + self.account_id = account_id + self.version = version + self.committed = committed + self.policy = policy + self.state = state + 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 @classmethod - def from_dict(cls, _dict: Dict) -> 'ResourceAttribute': - """Initialize a ResourceAttribute object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplate': + """Initialize a PolicyTemplate object from a json dictionary.""" args = {} if (name := _dict.get('name')) is not None: args['name'] = name else: - raise ValueError('Required property \'name\' not present in ResourceAttribute JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value + raise ValueError('Required property \'name\' not present in PolicyTemplate JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id else: - raise ValueError('Required property \'value\' not present in ResourceAttribute JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator + raise ValueError('Required property \'account_id\' not present in PolicyTemplate JSON') + if (version := _dict.get('version')) is not None: + args['version'] = version + else: + raise ValueError('Required property \'version\' not present in PolicyTemplate JSON') + if (committed := _dict.get('committed')) is not None: + args['committed'] = committed + if (policy := _dict.get('policy')) is not None: + args['policy'] = TemplatePolicy.from_dict(policy) + else: + raise ValueError('Required property \'policy\' not present in PolicyTemplate JSON') + if (state := _dict.get('state')) is not None: + args['state'] = state + 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 return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ResourceAttribute object from a json dictionary.""" + """Initialize a PolicyTemplate object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -5824,10 +5865,33 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'committed') and self.committed is not None: + _dict['committed'] = self.committed + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy + else: + _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') return _dict def _to_dict(self): @@ -5835,77 +5899,122 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ResourceAttribute object.""" + """Return a `str` version of this PolicyTemplate object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ResourceAttribute') -> bool: + def __eq__(self, other: 'PolicyTemplate') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ResourceAttribute') -> bool: + def __ne__(self, other: 'PolicyTemplate') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + State of policy template. + """ -class ResourceTag: + ACTIVE = 'active' + DELETED = 'deleted' + + +class PolicyTemplateAssignmentCollection: """ - A tag associated with a resource. + A collection of policies assignments. - :param str name: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: (optional) The operator of an access management tag. + :param 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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous page + of requested collection. + :param List[PolicyTemplateAssignmentItems] assignments: (optional) List of + policy assignments. """ def __init__( self, - name: str, - value: str, *, - operator: Optional[str] = None, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + assignments: Optional[List['PolicyTemplateAssignmentItems']] = None, ) -> None: """ - Initialize a ResourceTag object. + Initialize a PolicyTemplateAssignmentCollection object. - :param str name: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: (optional) The operator of an access management tag. + :param 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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous + page of requested collection. + :param List[PolicyTemplateAssignmentItems] assignments: (optional) List of + policy assignments. """ - self.name = name - self.value = value - self.operator = operator + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.assignments = assignments @classmethod - def from_dict(cls, _dict: Dict) -> 'ResourceTag': - """Initialize a ResourceTag object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateAssignmentCollection': + """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" args = {} - if (name := _dict.get('name')) is not None: - args['name'] = name - else: - raise ValueError('Required property \'name\' not present in ResourceTag JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value - else: - raise ValueError('Required property \'value\' not present in ResourceTag JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator + 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'] = assignments return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ResourceTag object from a json dictionary.""" + """Initialize a PolicyTemplateAssignmentCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator + if hasattr(self, '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): @@ -5913,91 +6022,135 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ResourceTag object.""" + """Return a `str` version of this PolicyTemplateAssignmentCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ResourceTag') -> bool: + def __eq__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'ResourceTag') -> bool: + def __ne__(self, other: 'PolicyTemplateAssignmentCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Role: +class PolicyTemplateAssignmentItems: """ - A role resource. + PolicyTemplateAssignmentItems. - :param str display_name: The display name of the role that is shown in the - console. - :param str description: (optional) The description of the role. - :param List[str] actions: The actions of the role. For more information, see - [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: - 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. """ def __init__( self, - display_name: str, - actions: List[str], - *, - description: Optional[str] = None, - crn: Optional[str] = None, ) -> None: """ - Initialize a Role object. + Initialize a PolicyTemplateAssignmentItems object. - :param str display_name: The display name of the role that is shown in the - console. - :param List[str] actions: The actions of the role. For more information, - see [IAM roles and - actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). - :param str description: (optional) The description of the role. """ - self.display_name = display_name - self.description = description - self.actions = actions - self.crn = crn + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join( + ['PolicyTemplateAssignmentItemsPolicyAssignmentV1', 'PolicyTemplateAssignmentItemsPolicyAssignment'] + ) + ) + raise Exception(msg) + + +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 + 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 page + of requested collection. + :param List[PolicyTemplate] policy_templates: (optional) List of policy + templates. + """ + + def __init__( + self, + *, + 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 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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous + page of requested collection. + :param List[PolicyTemplate] policy_templates: (optional) List of policy + templates. + """ + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.policy_templates = policy_templates @classmethod - def from_dict(cls, _dict: Dict) -> 'Role': - """Initialize a Role object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateCollection': + """Initialize a PolicyTemplateCollection object from a json dictionary.""" args = {} - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name - else: - raise ValueError('Required property \'display_name\' not present in Role JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (actions := _dict.get('actions')) is not None: - args['actions'] = actions - else: - raise ValueError('Required property \'actions\' not present in Role JSON') - if (crn := _dict.get('crn')) is not None: - args['crn'] = crn + if (limit := _dict.get('limit')) is not None: + args['limit'] = limit + if (first := _dict.get('first')) is not None: + args['first'] = First.from_dict(first) + if (next := _dict.get('next')) is not None: + args['next'] = Next.from_dict(next) + if (previous := _dict.get('previous')) is not None: + args['previous'] = Previous.from_dict(previous) + if (policy_templates := _dict.get('policy_templates')) is not None: + args['policy_templates'] = [PolicyTemplate.from_dict(v) for v in policy_templates] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Role object from a json dictionary.""" + """Initialize a PolicyTemplateCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'display_name') and self.display_name is not None: - _dict['display_name'] = self.display_name - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'actions') and self.actions is not None: - _dict['actions'] = self.actions - if hasattr(self, 'crn') and getattr(self, 'crn') is not None: - _dict['crn'] = getattr(self, 'crn') + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'policy_templates') and self.policy_templates is not None: + policy_templates_list = [] + for v in self.policy_templates: + if isinstance(v, dict): + policy_templates_list.append(v) + else: + policy_templates_list.append(v.to_dict()) + _dict['policy_templates'] = policy_templates_list return _dict def _to_dict(self): @@ -6005,80 +6158,187 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Role object.""" + """Return a `str` version of this PolicyTemplateCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Role') -> bool: + def __eq__(self, other: 'PolicyTemplateCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Role') -> bool: + def __ne__(self, other: 'PolicyTemplateCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RoleAction: +class PolicyTemplateLimitData: """ - An action that can be performed by the policy subject when assigned role. + The core set of properties associated with the policy template. - :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. - :param str description: Service defined description for action. + :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 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 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. + :param str id: (optional) The policy template ID. + :param str href: (optional) The href URL that links to the policy templates API + by policy template ID. + :param datetime created_at: (optional) The UTC timestamp when the policy + template was created. + :param str created_by_id: (optional) The iam ID of the entity that created the + policy template. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + template was last modified. + :param str last_modified_by_id: (optional) The iam ID of the entity that last + modified the policy template. + :param TemplateCountData counts: (optional) policy template count details. """ def __init__( self, - id: str, - display_name: str, - description: str, + name: str, + account_id: str, + version: str, + policy: 'TemplatePolicy', + *, + 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, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + counts: Optional['TemplateCountData'] = None, ) -> None: """ - Initialize a RoleAction object. + Initialize a PolicyTemplateLimitData 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. - :param str description: Service defined description for action. + :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 + created. + :param str version: Template version. + :param TemplatePolicy policy: The core set of properties associated with + the template's policy objet. + :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.id = id - self.display_name = display_name + self.name = name self.description = description + self.account_id = account_id + self.version = version + self.committed = committed + self.policy = policy + self.state = state + self.id = id + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.counts = counts @classmethod - def from_dict(cls, _dict: Dict) -> 'RoleAction': - """Initialize a RoleAction object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData': + """Initialize a PolicyTemplateLimitData object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - else: - raise ValueError('Required property \'id\' not present in RoleAction JSON') - if (display_name := _dict.get('display_name')) is not None: - args['display_name'] = display_name + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'display_name\' not present in RoleAction JSON') + raise ValueError('Required property \'name\' not present in PolicyTemplateLimitData JSON') if (description := _dict.get('description')) is not None: args['description'] = description + if (account_id := _dict.get('account_id')) is not None: + args['account_id'] = account_id else: - raise ValueError('Required property \'description\' not present in RoleAction JSON') + raise ValueError('Required property \'account_id\' not present in PolicyTemplateLimitData JSON') + if (version := _dict.get('version')) is not None: + args['version'] = version + else: + raise ValueError('Required property \'version\' not present in PolicyTemplateLimitData JSON') + if (committed := _dict.get('committed')) is not None: + args['committed'] = committed + if (policy := _dict.get('policy')) is not None: + args['policy'] = TemplatePolicy.from_dict(policy) + else: + raise ValueError('Required property \'policy\' not present in PolicyTemplateLimitData JSON') + if (state := _dict.get('state')) is not None: + args['state'] = state + if (id := _dict.get('id')) is not None: + args['id'] = id + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (counts := _dict.get('counts')) is not None: + args['counts'] = TemplateCountData.from_dict(counts) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RoleAction object from a json dictionary.""" + """Initialize a PolicyTemplateLimitData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id - if hasattr(self, 'display_name') and self.display_name is not None: - _dict['display_name'] = self.display_name + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'description') and self.description is not None: _dict['description'] = self.description + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'committed') and self.committed is not None: + _dict['committed'] = self.committed + if hasattr(self, 'policy') and self.policy is not None: + if isinstance(self.policy, dict): + _dict['policy'] = self.policy + else: + _dict['policy'] = self.policy.to_dict() + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'counts') and self.counts is not None: + if isinstance(self.counts, dict): + _dict['counts'] = self.counts + else: + _dict['counts'] = self.counts.to_dict() return _dict def _to_dict(self): @@ -6086,91 +6346,197 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RoleAction object.""" + """Return a `str` version of this PolicyTemplateLimitData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RoleAction') -> bool: + def __eq__(self, other: 'PolicyTemplateLimitData') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'RoleAction') -> bool: + def __ne__(self, other: 'PolicyTemplateLimitData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + State of policy template. + """ -class RoleCollection: + ACTIVE = 'active' + DELETED = 'deleted' + + +class PolicyTemplateMetaData: """ - A collection of roles returned by the 'list roles' operation. + The core set of properties associated with a policy. - :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 str id: (optional) The policy ID. + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Customer-defined description. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) granted + by the policy. + :param List[PolicyResource] resources: The resources associated with a policy. + :param str href: (optional) The href link back to the policy. + :param datetime created_at: (optional) The UTC timestamp when the policy was + created. + :param str created_by_id: (optional) The iam ID of the entity that created the + policy. + :param datetime last_modified_at: (optional) The UTC timestamp when the policy + was last modified. + :param str last_modified_by_id: (optional) The iam ID of the entity that last + modified the policy. + :param str state: (optional) The policy state. + :param TemplateMetadata template: (optional) The details of the IAM template + that was used to create an enterprise-managed policy in your account. When + returned, this indicates that the policy is created from and managed by a + template in the root enterprise account. """ def __init__( self, + type: str, + subjects: List['PolicySubject'], + roles: List['PolicyRole'], + resources: List['PolicyResource'], *, - custom_roles: Optional[List['CustomRole']] = None, - service_roles: Optional[List['Role']] = None, - system_roles: Optional[List['Role']] = None, + id: Optional[str] = None, + description: Optional[str] = None, + href: Optional[str] = None, + created_at: Optional[datetime] = None, + created_by_id: Optional[str] = None, + last_modified_at: Optional[datetime] = None, + last_modified_by_id: Optional[str] = None, + state: Optional[str] = None, + template: Optional['TemplateMetadata'] = None, ) -> None: """ - Initialize a RoleCollection object. + Initialize a PolicyTemplateMetaData 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 str type: The policy type; either 'access' or 'authorization'. + :param List[PolicySubject] subjects: The subjects associated with a policy. + :param List[PolicyRole] roles: A set of role cloud resource names (CRNs) + granted by the policy. + :param List[PolicyResource] resources: The resources associated with a + policy. + :param str description: (optional) Customer-defined description. + :param str state: (optional) The policy state. + :param TemplateMetadata template: (optional) The details of the IAM + template that was used to create an enterprise-managed policy in your + account. When returned, this indicates that the policy is created from and + managed by a template in the root enterprise account. """ - self.custom_roles = custom_roles - self.service_roles = service_roles - self.system_roles = system_roles + self.id = id + self.type = type + self.description = description + self.subjects = subjects + self.roles = roles + self.resources = resources + self.href = href + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.state = state + self.template = template @classmethod - def from_dict(cls, _dict: Dict) -> 'RoleCollection': - """Initialize a RoleCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateMetaData': + """Initialize a PolicyTemplateMetaData object from a json dictionary.""" args = {} - if (custom_roles := _dict.get('custom_roles')) is not None: - args['custom_roles'] = [CustomRole.from_dict(v) for v in custom_roles] - if (service_roles := _dict.get('service_roles')) is not None: - args['service_roles'] = [Role.from_dict(v) for v in service_roles] - if (system_roles := _dict.get('system_roles')) is not None: - args['system_roles'] = [Role.from_dict(v) for v in system_roles] + if (id := _dict.get('id')) is not None: + args['id'] = id + if (type := _dict.get('type')) is not None: + args['type'] = type + else: + raise ValueError('Required property \'type\' not present in PolicyTemplateMetaData JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (subjects := _dict.get('subjects')) is not None: + args['subjects'] = [PolicySubject.from_dict(v) for v in subjects] + else: + raise ValueError('Required property \'subjects\' not present in PolicyTemplateMetaData JSON') + if (roles := _dict.get('roles')) is not None: + args['roles'] = [PolicyRole.from_dict(v) for v in roles] + else: + raise ValueError('Required property \'roles\' not present in PolicyTemplateMetaData JSON') + if (resources := _dict.get('resources')) is not None: + args['resources'] = [PolicyResource.from_dict(v) for v in resources] + else: + raise ValueError('Required property \'resources\' not present in PolicyTemplateMetaData JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (created_at := _dict.get('created_at')) is not None: + args['created_at'] = string_to_datetime(created_at) + if (created_by_id := _dict.get('created_by_id')) is not None: + args['created_by_id'] = created_by_id + if (last_modified_at := _dict.get('last_modified_at')) is not None: + args['last_modified_at'] = string_to_datetime(last_modified_at) + if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: + args['last_modified_by_id'] = last_modified_by_id + if (state := _dict.get('state')) is not None: + args['state'] = state + if (template := _dict.get('template')) is not None: + args['template'] = TemplateMetadata.from_dict(template) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RoleCollection object from a json dictionary.""" + """Initialize a PolicyTemplateMetaData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'custom_roles') and self.custom_roles is not None: - custom_roles_list = [] - for v in self.custom_roles: + if hasattr(self, 'id') and getattr(self, 'id') is not None: + _dict['id'] = getattr(self, 'id') + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'subjects') and self.subjects is not None: + subjects_list = [] + for v in self.subjects: if isinstance(v, dict): - custom_roles_list.append(v) + subjects_list.append(v) else: - custom_roles_list.append(v.to_dict()) - _dict['custom_roles'] = custom_roles_list - if hasattr(self, 'service_roles') and self.service_roles is not None: - service_roles_list = [] - for v in self.service_roles: + subjects_list.append(v.to_dict()) + _dict['subjects'] = subjects_list + if hasattr(self, 'roles') and self.roles is not None: + roles_list = [] + for v in self.roles: if isinstance(v, dict): - service_roles_list.append(v) + roles_list.append(v) else: - service_roles_list.append(v.to_dict()) - _dict['service_roles'] = service_roles_list - if hasattr(self, 'system_roles') and self.system_roles is not None: - system_roles_list = [] - for v in self.system_roles: + roles_list.append(v.to_dict()) + _dict['roles'] = roles_list + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: if isinstance(v, dict): - system_roles_list.append(v) + resources_list.append(v) else: - system_roles_list.append(v.to_dict()) - _dict['system_roles'] = system_roles_list + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() return _dict def _to_dict(self): @@ -6178,60 +6544,122 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RoleCollection object.""" + """Return a `str` version of this PolicyTemplateMetaData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RoleCollection') -> bool: + def __eq__(self, other: 'PolicyTemplateMetaData') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'RoleCollection') -> bool: + def __ne__(self, other: 'PolicyTemplateMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class StateEnum(str, Enum): + """ + The policy state. + """ + + ACTIVE = 'active' + DELETED = 'deleted' + -class Roles: +class PolicyTemplateVersionsCollection: """ - A role associated with a policy. + A collection of versions for a specific policy template. - :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. - Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous page + of requested collection. + :param List[PolicyTemplate] versions: (optional) List of policy templates + versions. """ def __init__( self, - role_id: str, + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + versions: Optional[List['PolicyTemplate']] = None, ) -> None: """ - Initialize a Roles object. + Initialize a PolicyTemplateVersionsCollection object. - :param str role_id: The role Cloud Resource Name (CRN) granted by the - policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. + :param 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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous + page of requested collection. + :param List[PolicyTemplate] versions: (optional) List of policy templates + versions. """ - self.role_id = role_id + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.versions = versions @classmethod - def from_dict(cls, _dict: Dict) -> 'Roles': - """Initialize a Roles object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplateVersionsCollection': + """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" args = {} - if (role_id := _dict.get('role_id')) is not None: - args['role_id'] = role_id - else: - raise ValueError('Required property \'role_id\' not present in Roles JSON') + 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'] = [PolicyTemplate.from_dict(v) for v in versions] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Roles object from a json dictionary.""" + """Initialize a PolicyTemplateVersionsCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'role_id') and self.role_id is not None: - _dict['role_id'] = self.role_id + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'first') and self.first is not None: + if isinstance(self.first, dict): + _dict['first'] = self.first + else: + _dict['first'] = self.first.to_dict() + if hasattr(self, 'next') and self.next is not None: + if isinstance(self.next, dict): + _dict['next'] = self.next + else: + _dict['next'] = self.next.to_dict() + if hasattr(self, 'previous') and self.previous is not None: + if isinstance(self.previous, dict): + _dict['previous'] = self.previous + else: + _dict['previous'] = self.previous.to_dict() + if hasattr(self, 'versions') and self.versions is not None: + versions_list = [] + for v in self.versions: + if isinstance(v, dict): + versions_list.append(v) + else: + versions_list.append(v.to_dict()) + _dict['versions'] = versions_list return _dict def _to_dict(self): @@ -6239,83 +6667,66 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Roles object.""" + """Return a `str` version of this PolicyTemplateVersionsCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Roles') -> bool: + def __eq__(self, other: 'PolicyTemplateVersionsCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'Roles') -> bool: + def __ne__(self, other: 'PolicyTemplateVersionsCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RuleAttribute: +class Previous: """ - Rule that specifies additional access granted (e.g., time-based condition). + Details with href linking to previous page of requested collection. - :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. + :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. """ def __init__( self, - key: str, - operator: str, - value: object, + *, + href: Optional[str] = None, + start: Optional[str] = None, ) -> None: """ - Initialize a RuleAttribute object. + Initialize a Previous object. - :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. + :param str start: (optional) Page token that refers to the page of + collection. """ - self.key = key - self.operator = operator - self.value = value + self.href = href + self.start = start @classmethod - def from_dict(cls, _dict: Dict) -> 'RuleAttribute': - """Initialize a RuleAttribute object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Previous': + """Initialize a Previous object from a json dictionary.""" args = {} - if (key := _dict.get('key')) is not None: - args['key'] = key - else: - raise ValueError('Required property \'key\' not present in RuleAttribute JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator - else: - raise ValueError('Required property \'operator\' not present in RuleAttribute JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value - else: - raise ValueError('Required property \'value\' not present in RuleAttribute JSON') + if (href := _dict.get('href')) is not None: + args['href'] = href + if (start := _dict.get('start')) is not None: + args['start'] = start return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RuleAttribute object from a json dictionary.""" + """Initialize a Previous object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'key') and self.key is not None: - _dict['key'] = self.key - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value + if hasattr(self, 'href') and getattr(self, 'href') is not None: + _dict['href'] = getattr(self, 'href') + if hasattr(self, 'start') and self.start is not None: + _dict['start'] = self.start return _dict def _to_dict(self): @@ -6323,84 +6734,66 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RuleAttribute object.""" + """Return a `str` version of this Previous object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RuleAttribute') -> bool: + def __eq__(self, other: 'Previous') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'RuleAttribute') -> bool: + def __ne__(self, other: 'Previous') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class OperatorEnum(str, Enum): - """ - The operator of an attribute. - """ - - STRINGEQUALS = 'stringEquals' - STRINGEXISTS = 'stringExists' - STRINGEQUALSANYOF = 'stringEqualsAnyOf' - STRINGMATCHANYOF = 'stringMatchAnyOf' - STRINGMATCH = 'stringMatch' - TIMELESSTHAN = 'timeLessThan' - TIMELESSTHANOREQUALS = 'timeLessThanOrEquals' - TIMEGREATERTHAN = 'timeGreaterThan' - TIMEGREATERTHANOREQUALS = 'timeGreaterThanOrEquals' - DATELESSTHAN = 'dateLessThan' - DATELESSTHANOREQUALS = 'dateLessThanOrEquals' - DATEGREATERTHAN = 'dateGreaterThan' - DATEGREATERTHANOREQUALS = 'dateGreaterThanOrEquals' - DATETIMELESSTHAN = 'dateTimeLessThan' - DATETIMELESSTHANOREQUALS = 'dateTimeLessThanOrEquals' - DATETIMEGREATERTHAN = 'dateTimeGreaterThan' - DATETIMEGREATERTHANOREQUALS = 'dateTimeGreaterThanOrEquals' - DAYOFWEEKEQUALS = 'dayOfWeekEquals' - DAYOFWEEKANYOF = 'dayOfWeekAnyOf' - -class SubjectAttribute: +class ResourceAttribute: """ - An attribute associated with a subject. + An attribute associated with a resource. :param str name: The name of an attribute. :param str value: The value of an attribute. + :param str operator: (optional) The operator of an attribute. """ def __init__( self, name: str, value: str, + *, + operator: Optional[str] = None, ) -> None: """ - Initialize a SubjectAttribute object. + Initialize a ResourceAttribute object. :param str name: The name of an attribute. :param str value: The value of an attribute. + :param str operator: (optional) The operator of an attribute. """ self.name = name self.value = value + self.operator = operator @classmethod - def from_dict(cls, _dict: Dict) -> 'SubjectAttribute': - """Initialize a SubjectAttribute object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ResourceAttribute': + """Initialize a ResourceAttribute object from a json dictionary.""" args = {} if (name := _dict.get('name')) is not None: args['name'] = name else: - raise ValueError('Required property \'name\' not present in SubjectAttribute JSON') + raise ValueError('Required property \'name\' not present in ResourceAttribute JSON') if (value := _dict.get('value')) is not None: args['value'] = value else: - raise ValueError('Required property \'value\' not present in SubjectAttribute JSON') + raise ValueError('Required property \'value\' not present in ResourceAttribute JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a SubjectAttribute object from a json dictionary.""" + """Initialize a ResourceAttribute object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -6410,6 +6803,8 @@ def to_dict(self) -> Dict: _dict['name'] = self.name if hasattr(self, 'value') and self.value is not None: _dict['value'] = self.value + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator return _dict def _to_dict(self): @@ -6417,75 +6812,77 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this SubjectAttribute object.""" + """Return a `str` version of this ResourceAttribute object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'SubjectAttribute') -> bool: + def __eq__(self, other: 'ResourceAttribute') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'SubjectAttribute') -> bool: + def __ne__(self, other: 'ResourceAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TemplateCountData: +class ResourceTag: """ - policy template count details. + A tag associated with a resource. - :param LimitData template: (optional) policy template current and limit details - with in an account. - :param LimitData version: (optional) policy template current and limit details - with in an account. + :param str name: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: (optional) The operator of an access management tag. """ def __init__( self, + name: str, + value: str, *, - template: Optional['LimitData'] = None, - version: Optional['LimitData'] = None, + operator: Optional[str] = None, ) -> None: """ - Initialize a TemplateCountData object. + Initialize a ResourceTag object. - :param LimitData template: (optional) policy template current and limit - details with in an account. - :param LimitData version: (optional) policy template current and limit - details with in an account. + :param str name: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: (optional) The operator of an access management tag. """ - self.template = template - self.version = version + self.name = name + self.value = value + self.operator = operator @classmethod - def from_dict(cls, _dict: Dict) -> 'TemplateCountData': - """Initialize a TemplateCountData object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ResourceTag': + """Initialize a ResourceTag object from a json dictionary.""" args = {} - if (template := _dict.get('template')) is not None: - args['template'] = LimitData.from_dict(template) - if (version := _dict.get('version')) is not None: - args['version'] = LimitData.from_dict(version) + if (name := _dict.get('name')) is not None: + args['name'] = name + else: + raise ValueError('Required property \'name\' not present in ResourceTag JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in ResourceTag JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a TemplateCountData object from a json dictionary.""" + """Initialize a ResourceTag object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, '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, 'version') and self.version is not None: - if isinstance(self.version, dict): - _dict['version'] = self.version - else: - _dict['version'] = self.version.to_dict() + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator return _dict def _to_dict(self): @@ -6493,91 +6890,91 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TemplateCountData object.""" + """Return a `str` version of this ResourceTag object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TemplateCountData') -> bool: + def __eq__(self, other: 'ResourceTag') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'TemplateCountData') -> bool: + def __ne__(self, other: 'ResourceTag') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TemplateMetadata: +class Role: """ - The details of the IAM template that was used to create an enterprise-managed policy - in your account. When returned, this indicates that the policy is created from and - managed by a template in the root enterprise account. + A role resource. - :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 display_name: The display name of the role that is shown in the + console. + :param str description: (optional) The description of the role. + :param List[str] actions: The actions of the role. For more information, see + [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str crn: (optional) The role Cloud Resource Name (CRN). Example CRN: + 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. """ def __init__( self, + display_name: str, + actions: List[str], *, - id: Optional[str] = None, - version: Optional[str] = None, - assignment_id: Optional[str] = None, - root_id: Optional[str] = None, - root_version: Optional[str] = None, + description: Optional[str] = None, + crn: Optional[str] = None, ) -> None: """ - Initialize a TemplateMetadata object. + Initialize a Role object. - :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 display_name: The display name of the role that is shown in the + console. + :param List[str] actions: The actions of the role. For more information, + see [IAM roles and + actions](https://cloud.ibm.com/docs/account?topic=account-iam-service-roles-actions). + :param str description: (optional) The description of the role. """ - self.id = id - self.version = version - self.assignment_id = assignment_id - self.root_id = root_id - self.root_version = root_version + self.display_name = display_name + self.description = description + self.actions = actions + self.crn = crn @classmethod - def from_dict(cls, _dict: Dict) -> 'TemplateMetadata': - """Initialize a TemplateMetadata object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Role': + """Initialize a Role object from a json dictionary.""" args = {} - if (id := _dict.get('id')) is not None: - args['id'] = id - if (version := _dict.get('version')) is not None: - args['version'] = version - if (assignment_id := _dict.get('assignment_id')) is not None: - args['assignment_id'] = assignment_id - if (root_id := _dict.get('root_id')) is not None: - args['root_id'] = root_id - if (root_version := _dict.get('root_version')) is not None: - args['root_version'] = root_version - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a TemplateMetadata object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'id') and self.id is not None: - _dict['id'] = self.id - if hasattr(self, 'version') and self.version is not None: - _dict['version'] = self.version - if hasattr(self, 'assignment_id') and self.assignment_id is not None: - _dict['assignment_id'] = self.assignment_id - if hasattr(self, 'root_id') and self.root_id is not None: - _dict['root_id'] = self.root_id - if hasattr(self, 'root_version') and self.root_version is not None: - _dict['root_version'] = self.root_version + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + else: + raise ValueError('Required property \'display_name\' not present in Role JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (actions := _dict.get('actions')) is not None: + args['actions'] = actions + else: + raise ValueError('Required property \'actions\' not present in Role JSON') + if (crn := _dict.get('crn')) is not None: + args['crn'] = crn + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Role object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'actions') and self.actions is not None: + _dict['actions'] = self.actions + if hasattr(self, 'crn') and getattr(self, 'crn') is not None: + _dict['crn'] = getattr(self, 'crn') return _dict def _to_dict(self): @@ -6585,135 +6982,80 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TemplateMetadata object.""" + """Return a `str` version of this Role object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TemplateMetadata') -> bool: + def __eq__(self, other: 'Role') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'TemplateMetadata') -> bool: + def __ne__(self, other: 'Role') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TemplatePolicy: +class RoleAction: """ - The core set of properties associated with the template's policy objet. + An action that can be performed by the policy subject when assigned role. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Description of the policy. This is shown in - child accounts when an access group or trusted profile template uses the policy - template to assign access. - :param V2PolicyResource resource: (optional) The resource attributes to which - the policy grants access. - :param V2PolicySubject subject: (optional) The subject attributes for whom the - policy grants access. - :param str pattern: (optional) Indicates pattern of rule, either - 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or - '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 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. + :param str description: Service defined description for action. """ def __init__( self, - type: str, - *, - description: Optional[str] = None, - resource: Optional['V2PolicyResource'] = None, - subject: Optional['V2PolicySubject'] = None, - pattern: Optional[str] = None, - rule: Optional['V2PolicyRule'] = None, - control: Optional['Control'] = None, + id: str, + display_name: str, + description: str, ) -> None: """ - Initialize a TemplatePolicy object. + Initialize a RoleAction object. - :param str type: The policy type; either 'access' or 'authorization'. - :param str description: (optional) Description of the policy. This is shown - in child accounts when an access group or trusted profile template uses the - policy template to assign access. - :param V2PolicyResource resource: (optional) The resource attributes to - which the policy grants access. - :param V2PolicySubject subject: (optional) The subject attributes for whom - the policy grants access. - :param str pattern: (optional) Indicates pattern of rule, either - 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or - '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 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. + :param str description: Service defined description for action. """ - self.type = type + self.id = id + self.display_name = display_name self.description = description - self.resource = resource - self.subject = subject - self.pattern = pattern - self.rule = rule - self.control = control @classmethod - def from_dict(cls, _dict: Dict) -> 'TemplatePolicy': - """Initialize a TemplatePolicy object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleAction': + """Initialize a RoleAction object from a json dictionary.""" args = {} - if (type := _dict.get('type')) is not None: - args['type'] = type + if (id := _dict.get('id')) is not None: + args['id'] = id else: - raise ValueError('Required property \'type\' not present in TemplatePolicy JSON') + raise ValueError('Required property \'id\' not present in RoleAction JSON') + if (display_name := _dict.get('display_name')) is not None: + args['display_name'] = display_name + else: + raise ValueError('Required property \'display_name\' not present in RoleAction JSON') if (description := _dict.get('description')) is not None: args['description'] = description - if (resource := _dict.get('resource')) is not None: - args['resource'] = V2PolicyResource.from_dict(resource) - if (subject := _dict.get('subject')) is not None: - args['subject'] = V2PolicySubject.from_dict(subject) - if (pattern := _dict.get('pattern')) is not None: - args['pattern'] = pattern - if (rule := _dict.get('rule')) is not None: - args['rule'] = rule - if (control := _dict.get('control')) is not None: - args['control'] = Control.from_dict(control) + else: + raise ValueError('Required property \'description\' not present in RoleAction JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a TemplatePolicy object from a json dictionary.""" + """Initialize a RoleAction object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'display_name') and self.display_name is not None: + _dict['display_name'] = self.display_name if hasattr(self, 'description') and self.description is not None: _dict['description'] = self.description - if hasattr(self, 'resource') and self.resource is not None: - if isinstance(self.resource, dict): - _dict['resource'] = self.resource - else: - _dict['resource'] = self.resource.to_dict() - if hasattr(self, 'subject') and self.subject is not None: - if isinstance(self.subject, dict): - _dict['subject'] = self.subject - else: - _dict['subject'] = self.subject.to_dict() - if hasattr(self, 'pattern') and self.pattern is not None: - _dict['pattern'] = self.pattern - if hasattr(self, 'rule') and self.rule is not None: - if isinstance(self.rule, dict): - _dict['rule'] = self.rule - else: - _dict['rule'] = self.rule.to_dict() - if hasattr(self, 'control') and self.control is not None: - if isinstance(self.control, dict): - _dict['control'] = self.control - else: - _dict['control'] = self.control.to_dict() return _dict def _to_dict(self): @@ -6721,218 +7063,91 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this TemplatePolicy object.""" + """Return a `str` version of this RoleAction object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'TemplatePolicy') -> bool: + def __eq__(self, other: 'RoleAction') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'TemplatePolicy') -> bool: + def __ne__(self, other: 'RoleAction') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): - """ - The policy type; either 'access' or 'authorization'. - """ - - ACCESS = 'access' - AUTHORIZATION = 'authorization' - -class V2Policy: +class RoleCollection: """ - The core set of properties associated with the policy. + A collection of roles returned by the 'list roles' operation. - :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 the - policy grants access. - :param V2PolicyResource resource: (optional) The resource attributes to which - the policy grants access. - :param str pattern: (optional) Indicates pattern of rule, either - 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or - 'time-based-conditions:weekly:custom-hours'. - :param V2PolicyRule rule: (optional) Additional access conditions associated - with the policy. - :param str id: (optional) The policy ID. - :param str href: (optional) The href URL that links to the policies API by - policy ID. - :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 - policy. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy. - :param str state: The policy state, either 'deleted' or 'active'. - :param str last_permit_at: (optional) The optional last permit time of policy, - when passing query parameter format=include_last_permit. - :param int last_permit_frequency: (optional) The optional count of times that - policy has provided a permit, when passing query parameter - format=include_last_permit. + :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. """ def __init__( self, - type: str, - control: 'ControlResponse', - state: str, *, - description: Optional[str] = None, - subject: Optional['V2PolicySubject'] = None, - resource: Optional['V2PolicyResource'] = None, - pattern: Optional[str] = None, - rule: Optional['V2PolicyRule'] = 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, - last_permit_at: Optional[str] = None, - last_permit_frequency: Optional[int] = None, + custom_roles: Optional[List['CustomRole']] = None, + service_roles: Optional[List['Role']] = None, + system_roles: Optional[List['Role']] = None, ) -> None: """ - Initialize a V2Policy object. + Initialize a RoleCollection object. - :param str type: The policy type; either 'access' or 'authorization'. - :param ControlResponse control: - :param str state: The policy state, either 'deleted' or 'active'. - :param str description: (optional) Description of the policy. - :param V2PolicySubject subject: (optional) The subject attributes for whom - the policy grants access. - :param V2PolicyResource resource: (optional) The resource attributes to - which the policy grants access. - :param str pattern: (optional) Indicates pattern of rule, either - 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or - 'time-based-conditions:weekly:custom-hours'. - :param V2PolicyRule rule: (optional) Additional access conditions - associated with the policy. - :param str last_permit_at: (optional) The optional last permit time of - policy, when passing query parameter format=include_last_permit. - :param int last_permit_frequency: (optional) The optional count of times - that policy has provided a permit, when passing query parameter - format=include_last_permit. - """ - self.type = type - self.description = description - self.subject = subject - self.resource = resource - self.pattern = pattern - self.rule = rule - self.id = id - self.href = href - self.control = control - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.state = state - self.last_permit_at = last_permit_at - self.last_permit_frequency = last_permit_frequency + :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. + """ + self.custom_roles = custom_roles + self.service_roles = service_roles + self.system_roles = system_roles @classmethod - def from_dict(cls, _dict: Dict) -> 'V2Policy': - """Initialize a V2Policy object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RoleCollection': + """Initialize a RoleCollection object from a json dictionary.""" args = {} - if (type := _dict.get('type')) is not None: - args['type'] = type - else: - raise ValueError('Required property \'type\' not present in V2Policy JSON') - if (description := _dict.get('description')) is not None: - args['description'] = description - if (subject := _dict.get('subject')) is not None: - args['subject'] = V2PolicySubject.from_dict(subject) - if (resource := _dict.get('resource')) is not None: - args['resource'] = V2PolicyResource.from_dict(resource) - if (pattern := _dict.get('pattern')) is not None: - args['pattern'] = pattern - if (rule := _dict.get('rule')) is not None: - args['rule'] = rule - if (id := _dict.get('id')) is not None: - args['id'] = id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (control := _dict.get('control')) is not None: - args['control'] = control - else: - raise ValueError('Required property \'control\' not present in V2Policy JSON') - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (state := _dict.get('state')) is not None: - args['state'] = state - else: - raise ValueError('Required property \'state\' not present in V2Policy JSON') - if (last_permit_at := _dict.get('last_permit_at')) is not None: - args['last_permit_at'] = last_permit_at - if (last_permit_frequency := _dict.get('last_permit_frequency')) is not None: - args['last_permit_frequency'] = last_permit_frequency + if (custom_roles := _dict.get('custom_roles')) is not None: + args['custom_roles'] = [CustomRole.from_dict(v) for v in custom_roles] + if (service_roles := _dict.get('service_roles')) is not None: + args['service_roles'] = [Role.from_dict(v) for v in service_roles] + if (system_roles := _dict.get('system_roles')) is not None: + args['system_roles'] = [Role.from_dict(v) for v in system_roles] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2Policy object from a json dictionary.""" + """Initialize a RoleCollection object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description - if hasattr(self, 'subject') and self.subject is not None: - if isinstance(self.subject, dict): - _dict['subject'] = self.subject - else: - _dict['subject'] = self.subject.to_dict() - if hasattr(self, 'resource') and self.resource is not None: - if isinstance(self.resource, dict): - _dict['resource'] = self.resource - else: - _dict['resource'] = self.resource.to_dict() - if hasattr(self, 'pattern') and self.pattern is not None: - _dict['pattern'] = self.pattern - if hasattr(self, 'rule') and self.rule is not None: - if isinstance(self.rule, dict): - _dict['rule'] = self.rule - else: - _dict['rule'] = self.rule.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, 'control') and self.control is not None: - if isinstance(self.control, dict): - _dict['control'] = self.control - else: - _dict['control'] = self.control.to_dict() - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'state') and self.state is not None: - _dict['state'] = self.state - if hasattr(self, 'last_permit_at') and self.last_permit_at is not None: - _dict['last_permit_at'] = self.last_permit_at - if hasattr(self, 'last_permit_frequency') and self.last_permit_frequency is not None: - _dict['last_permit_frequency'] = self.last_permit_frequency + if hasattr(self, 'custom_roles') and self.custom_roles is not None: + custom_roles_list = [] + for v in self.custom_roles: + if isinstance(v, dict): + custom_roles_list.append(v) + else: + custom_roles_list.append(v.to_dict()) + _dict['custom_roles'] = custom_roles_list + if hasattr(self, 'service_roles') and self.service_roles is not None: + service_roles_list = [] + for v in self.service_roles: + if isinstance(v, dict): + service_roles_list.append(v) + else: + service_roles_list.append(v.to_dict()) + _dict['service_roles'] = service_roles_list + if hasattr(self, 'system_roles') and self.system_roles is not None: + system_roles_list = [] + for v in self.system_roles: + if isinstance(v, dict): + system_roles_list.append(v) + else: + system_roles_list.append(v.to_dict()) + _dict['system_roles'] = system_roles_list return _dict def _to_dict(self): @@ -6940,80 +7155,60 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2Policy object.""" + """Return a `str` version of this RoleCollection object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2Policy') -> bool: + def __eq__(self, other: 'RoleCollection') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'V2Policy') -> bool: + def __ne__(self, other: 'RoleCollection') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TypeEnum(str, Enum): - """ - The policy type; either 'access' or 'authorization'. - """ - - ACCESS = 'access' - AUTHORIZATION = 'authorization' - - class StateEnum(str, Enum): - """ - The policy state, either 'deleted' or 'active'. - """ - - ACTIVE = 'active' - DELETED = 'deleted' - -class V2PolicyCollection: +class Roles: """ - A collection of policies. + A role associated with a policy. - :param List[V2PolicyTemplateMetaData] policies: (optional) List of policies. + :param str role_id: The role Cloud Resource Name (CRN) granted by the policy. + Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. """ def __init__( self, - *, - policies: Optional[List['V2PolicyTemplateMetaData']] = None, + role_id: str, ) -> None: """ - Initialize a V2PolicyCollection object. + Initialize a Roles object. - :param List[V2PolicyTemplateMetaData] policies: (optional) List of - policies. + :param str role_id: The role Cloud Resource Name (CRN) granted by the + policy. Example CRN: 'crn:v1:bluemix:public:iam::::role:Editor'. """ - self.policies = policies + self.role_id = role_id @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicyCollection': - """Initialize a V2PolicyCollection object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Roles': + """Initialize a Roles object from a json dictionary.""" args = {} - if (policies := _dict.get('policies')) is not None: - args['policies'] = [V2PolicyTemplateMetaData.from_dict(v) for v in policies] + if (role_id := _dict.get('role_id')) is not None: + args['role_id'] = role_id + else: + raise ValueError('Required property \'role_id\' not present in Roles JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicyCollection object from a json dictionary.""" + """Initialize a Roles 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, 'policies') and self.policies is not None: - policies_list = [] - for v in self.policies: - if isinstance(v, dict): - policies_list.append(v) - else: - policies_list.append(v.to_dict()) - _dict['policies'] = policies_list + if hasattr(self, 'role_id') and self.role_id is not None: + _dict['role_id'] = self.role_id return _dict def _to_dict(self): @@ -7021,156 +7216,72 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicyCollection object.""" + """Return a `str` version of this Roles object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicyCollection') -> bool: + def __eq__(self, other: 'Roles') -> 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: 'V2PolicyCollection') -> bool: + def __ne__(self, other: 'Roles') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class V2PolicyResource: +class RuleAttribute: """ - The resource attributes to which the policy grants access. + Rule that specifies additional access granted (e.g., time-based condition). - :param List[V2PolicyResourceAttribute] attributes: List of resource attributes - to which the policy grants access. - :param List[V2PolicyResourceTag] tags: (optional) Optional list of resource tags - to which the policy grants access. + :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. """ def __init__( self, - attributes: List['V2PolicyResourceAttribute'], - *, - tags: Optional[List['V2PolicyResourceTag']] = None, + key: str, + operator: str, + value: object, ) -> None: """ - Initialize a V2PolicyResource object. + Initialize a RuleAttribute object. - :param List[V2PolicyResourceAttribute] attributes: List of resource - attributes to which the policy grants access. - :param List[V2PolicyResourceTag] tags: (optional) Optional list of resource - tags to which the policy grants access. + :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. """ - self.attributes = attributes - self.tags = tags + self.key = key + self.operator = operator + self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicyResource': - """Initialize a V2PolicyResource object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RuleAttribute': + """Initialize a RuleAttribute object from a json dictionary.""" args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [V2PolicyResourceAttribute.from_dict(v) for v in attributes] + if (key := _dict.get('key')) is not None: + args['key'] = key else: - raise ValueError('Required property \'attributes\' not present in V2PolicyResource JSON') - if (tags := _dict.get('tags')) is not None: - args['tags'] = [V2PolicyResourceTag.from_dict(v) for v in tags] - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a V2PolicyResource object from a json dictionary.""" - return cls.from_dict(_dict) - - def to_dict(self) -> Dict: - """Return a json dictionary representing this model.""" - _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: - if isinstance(v, dict): - attributes_list.append(v) - else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list - if hasattr(self, 'tags') and self.tags is not None: - tags_list = [] - for v in self.tags: - if isinstance(v, dict): - tags_list.append(v) - else: - tags_list.append(v.to_dict()) - _dict['tags'] = tags_list - return _dict - - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() - - def __str__(self) -> str: - """Return a `str` version of this V2PolicyResource object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'V2PolicyResource') -> 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: 'V2PolicyResource') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - - -class V2PolicyResourceAttribute: - """ - Resource attribute to which the policy grants access. - - :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. - """ - - def __init__( - self, - key: str, - operator: str, - value: object, - ) -> None: - """ - Initialize a V2PolicyResourceAttribute object. - - :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. - """ - self.key = key - self.operator = operator - self.value = value - - @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicyResourceAttribute': - """Initialize a V2PolicyResourceAttribute object from a json dictionary.""" - args = {} - if (key := _dict.get('key')) is not None: - args['key'] = key - else: - raise ValueError('Required property \'key\' not present in V2PolicyResourceAttribute JSON') + raise ValueError('Required property \'key\' not present in RuleAttribute JSON') if (operator := _dict.get('operator')) is not None: args['operator'] = operator else: - raise ValueError('Required property \'operator\' not present in V2PolicyResourceAttribute JSON') + raise ValueError('Required property \'operator\' not present in RuleAttribute JSON') if (value := _dict.get('value')) is not None: args['value'] = value else: - raise ValueError('Required property \'value\' not present in V2PolicyResourceAttribute JSON') + raise ValueError('Required property \'value\' not present in RuleAttribute JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicyResourceAttribute object from a json dictionary.""" + """Initialize a RuleAttribute object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -7189,16 +7300,16 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicyResourceAttribute object.""" + """Return a `str` version of this RuleAttribute object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicyResourceAttribute') -> bool: + def __eq__(self, other: 'RuleAttribute') -> 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: 'V2PolicyResourceAttribute') -> bool: + def __ne__(self, other: 'RuleAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -7209,69 +7320,73 @@ class OperatorEnum(str, Enum): STRINGEQUALS = 'stringEquals' STRINGEXISTS = 'stringExists' - STRINGMATCH = 'stringMatch' STRINGEQUALSANYOF = 'stringEqualsAnyOf' STRINGMATCHANYOF = 'stringMatchAnyOf' + STRINGMATCH = 'stringMatch' + TIMELESSTHAN = 'timeLessThan' + TIMELESSTHANOREQUALS = 'timeLessThanOrEquals' + TIMEGREATERTHAN = 'timeGreaterThan' + TIMEGREATERTHANOREQUALS = 'timeGreaterThanOrEquals' + DATELESSTHAN = 'dateLessThan' + DATELESSTHANOREQUALS = 'dateLessThanOrEquals' + DATEGREATERTHAN = 'dateGreaterThan' + DATEGREATERTHANOREQUALS = 'dateGreaterThanOrEquals' + DATETIMELESSTHAN = 'dateTimeLessThan' + DATETIMELESSTHANOREQUALS = 'dateTimeLessThanOrEquals' + DATETIMEGREATERTHAN = 'dateTimeGreaterThan' + DATETIMEGREATERTHANOREQUALS = 'dateTimeGreaterThanOrEquals' + DAYOFWEEKEQUALS = 'dayOfWeekEquals' + DAYOFWEEKANYOF = 'dayOfWeekAnyOf' -class V2PolicyResourceTag: +class SubjectAttribute: """ - A tag associated with a resource. + An attribute associated with a subject. - :param str key: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: The operator of an access management tag. + :param str name: The name of an attribute. + :param str value: The value of an attribute. """ def __init__( self, - key: str, + name: str, value: str, - operator: str, ) -> None: """ - Initialize a V2PolicyResourceTag object. + Initialize a SubjectAttribute object. - :param str key: The name of an access management tag. - :param str value: The value of an access management tag. - :param str operator: The operator of an access management tag. + :param str name: The name of an attribute. + :param str value: The value of an attribute. """ - self.key = key + self.name = name self.value = value - self.operator = operator @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicyResourceTag': - """Initialize a V2PolicyResourceTag object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'SubjectAttribute': + """Initialize a SubjectAttribute object from a json dictionary.""" args = {} - if (key := _dict.get('key')) is not None: - args['key'] = key + if (name := _dict.get('name')) is not None: + args['name'] = name else: - raise ValueError('Required property \'key\' not present in V2PolicyResourceTag JSON') + raise ValueError('Required property \'name\' not present in SubjectAttribute JSON') if (value := _dict.get('value')) is not None: args['value'] = value else: - raise ValueError('Required property \'value\' not present in V2PolicyResourceTag JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator - else: - raise ValueError('Required property \'operator\' not present in V2PolicyResourceTag JSON') + raise ValueError('Required property \'value\' not present in SubjectAttribute JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicyResourceTag object from a json dictionary.""" + """Initialize a SubjectAttribute 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, 'key') and self.key is not None: - _dict['key'] = self.key + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name if hasattr(self, 'value') and self.value is not None: _dict['value'] = self.value - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator return _dict def _to_dict(self): @@ -7279,93 +7394,75 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicyResourceTag object.""" + """Return a `str` version of this SubjectAttribute object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicyResourceTag') -> bool: + def __eq__(self, other: 'SubjectAttribute') -> 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: 'V2PolicyResourceTag') -> bool: + def __ne__(self, other: 'SubjectAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class OperatorEnum(str, Enum): - """ - The operator of an access management tag. - """ - - STRINGEQUALS = 'stringEquals' - STRINGMATCH = 'stringMatch' - - -class V2PolicyRule: - """ - Additional access conditions associated with the policy. - - """ - - def __init__( - self, - ) -> None: - """ - Initialize a V2PolicyRule object. - - """ - msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['V2PolicyRuleRuleAttribute', 'V2PolicyRuleRuleWithNestedConditions']) - ) - raise Exception(msg) - -class V2PolicySubject: +class TemplateCountData: """ - The subject attributes for whom the policy grants access. + policy template count details. - :param List[V2PolicySubjectAttribute] attributes: List of subject attributes - associated with policy/. + :param LimitData template: (optional) policy template current and limit details + with in an account. + :param LimitData version: (optional) policy template current and limit details + with in an account. """ def __init__( self, - attributes: List['V2PolicySubjectAttribute'], + *, + template: Optional['LimitData'] = None, + version: Optional['LimitData'] = None, ) -> None: """ - Initialize a V2PolicySubject object. + Initialize a TemplateCountData object. - :param List[V2PolicySubjectAttribute] attributes: List of subject - attributes associated with policy/. + :param LimitData template: (optional) policy template current and limit + details with in an account. + :param LimitData version: (optional) policy template current and limit + details with in an account. """ - self.attributes = attributes + self.template = template + self.version = version @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicySubject': - """Initialize a V2PolicySubject object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateCountData': + """Initialize a TemplateCountData object from a json dictionary.""" args = {} - if (attributes := _dict.get('attributes')) is not None: - args['attributes'] = [V2PolicySubjectAttribute.from_dict(v) for v in attributes] - else: - raise ValueError('Required property \'attributes\' not present in V2PolicySubject JSON') + if (template := _dict.get('template')) is not None: + args['template'] = LimitData.from_dict(template) + if (version := _dict.get('version')) is not None: + args['version'] = LimitData.from_dict(version) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicySubject object from a json dictionary.""" + """Initialize a TemplateCountData object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'attributes') and self.attributes is not None: - attributes_list = [] - for v in self.attributes: - if isinstance(v, dict): - attributes_list.append(v) - else: - attributes_list.append(v.to_dict()) - _dict['attributes'] = attributes_list + if hasattr(self, '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, 'version') and self.version is not None: + if isinstance(self.version, dict): + _dict['version'] = self.version + else: + _dict['version'] = self.version.to_dict() return _dict def _to_dict(self): @@ -7373,84 +7470,227 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicySubject object.""" + """Return a `str` version of this TemplateCountData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicySubject') -> bool: + def __eq__(self, other: 'TemplateCountData') -> 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: 'V2PolicySubject') -> bool: + def __ne__(self, other: 'TemplateCountData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class V2PolicySubjectAttribute: +class TemplateMetadata: """ - Subject attribute for whom the policy grants access. + The details of the IAM template that was used to create an enterprise-managed policy + in your account. When returned, this indicates that the policy is created from and + managed by a template in the root enterprise account. - :param str key: The name of a subject attribute, e.g., 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. + :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. """ def __init__( self, - key: str, - operator: str, - value: object, + *, + id: Optional[str] = None, + version: Optional[str] = None, + assignment_id: Optional[str] = None, + root_id: Optional[str] = None, + root_version: Optional[str] = None, ) -> None: """ - Initialize a V2PolicySubjectAttribute object. + Initialize a TemplateMetadata object. - :param str key: The name of a subject attribute, e.g., 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. + :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. """ - self.key = key - self.operator = operator - self.value = value + self.id = id + self.version = version + self.assignment_id = assignment_id + self.root_id = root_id + self.root_version = root_version @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicySubjectAttribute': - """Initialize a V2PolicySubjectAttribute object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateMetadata': + """Initialize a TemplateMetadata object from a json dictionary.""" args = {} - if (key := _dict.get('key')) is not None: - args['key'] = key - else: - raise ValueError('Required property \'key\' not present in V2PolicySubjectAttribute JSON') - if (operator := _dict.get('operator')) is not None: - args['operator'] = operator - else: - raise ValueError('Required property \'operator\' not present in V2PolicySubjectAttribute JSON') - if (value := _dict.get('value')) is not None: - args['value'] = value + if (id := _dict.get('id')) is not None: + args['id'] = id + if (version := _dict.get('version')) is not None: + args['version'] = version + if (assignment_id := _dict.get('assignment_id')) is not None: + args['assignment_id'] = assignment_id + if (root_id := _dict.get('root_id')) is not None: + args['root_id'] = root_id + if (root_version := _dict.get('root_version')) is not None: + args['root_version'] = root_version + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a TemplateMetadata object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'assignment_id') and self.assignment_id is not None: + _dict['assignment_id'] = self.assignment_id + if hasattr(self, 'root_id') and self.root_id is not None: + _dict['root_id'] = self.root_id + if hasattr(self, 'root_version') and self.root_version is not None: + _dict['root_version'] = self.root_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 TemplateMetadata object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'TemplateMetadata') -> 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: 'TemplateMetadata') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class TemplatePolicy: + """ + The core set of properties associated with the template's policy objet. + + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Description of the policy. This is shown in + child accounts when an access group or trusted profile template uses the policy + template to assign access. + :param V2PolicyResource resource: (optional) The resource attributes to which + the policy grants access. + :param V2PolicySubject subject: (optional) The subject attributes for whom the + policy grants access. + :param str pattern: (optional) Indicates pattern of rule, either + 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + '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. + """ + + def __init__( + self, + type: str, + *, + description: Optional[str] = None, + resource: Optional['V2PolicyResource'] = None, + subject: Optional['V2PolicySubject'] = None, + pattern: Optional[str] = None, + rule: Optional['V2PolicyRule'] = None, + control: Optional['Control'] = None, + ) -> None: + """ + Initialize a TemplatePolicy object. + + :param str type: The policy type; either 'access' or 'authorization'. + :param str description: (optional) Description of the policy. This is shown + in child accounts when an access group or trusted profile template uses the + policy template to assign access. + :param V2PolicyResource resource: (optional) The resource attributes to + which the policy grants access. + :param V2PolicySubject subject: (optional) The subject attributes for whom + the policy grants access. + :param str pattern: (optional) Indicates pattern of rule, either + 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + '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. + """ + self.type = type + self.description = description + self.resource = resource + self.subject = subject + self.pattern = pattern + self.rule = rule + self.control = control + + @classmethod + def from_dict(cls, _dict: Dict) -> 'TemplatePolicy': + """Initialize a TemplatePolicy object from a json dictionary.""" + args = {} + if (type := _dict.get('type')) is not None: + args['type'] = type else: - raise ValueError('Required property \'value\' not present in V2PolicySubjectAttribute JSON') + raise ValueError('Required property \'type\' not present in TemplatePolicy JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (resource := _dict.get('resource')) is not None: + args['resource'] = V2PolicyResource.from_dict(resource) + if (subject := _dict.get('subject')) is not None: + args['subject'] = V2PolicySubject.from_dict(subject) + if (pattern := _dict.get('pattern')) is not None: + args['pattern'] = pattern + if (rule := _dict.get('rule')) is not None: + args['rule'] = rule + if (control := _dict.get('control')) is not None: + args['control'] = Control.from_dict(control) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicySubjectAttribute object from a json dictionary.""" + """Initialize a TemplatePolicy 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, 'key') and self.key is not None: - _dict['key'] = self.key - if hasattr(self, 'operator') and self.operator is not None: - _dict['operator'] = self.operator - if hasattr(self, 'value') and self.value is not None: - _dict['value'] = self.value + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'resource') and self.resource is not None: + if isinstance(self.resource, dict): + _dict['resource'] = self.resource + else: + _dict['resource'] = self.resource.to_dict() + if hasattr(self, 'subject') and self.subject is not None: + if isinstance(self.subject, dict): + _dict['subject'] = self.subject + else: + _dict['subject'] = self.subject.to_dict() + if hasattr(self, 'pattern') and self.pattern is not None: + _dict['pattern'] = self.pattern + if hasattr(self, 'rule') and self.rule is not None: + if isinstance(self.rule, dict): + _dict['rule'] = self.rule + else: + _dict['rule'] = self.rule.to_dict() + if hasattr(self, 'control') and self.control is not None: + if isinstance(self.control, dict): + _dict['control'] = self.control + else: + _dict['control'] = self.control.to_dict() return _dict def _to_dict(self): @@ -7458,29 +7698,29 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicySubjectAttribute object.""" + """Return a `str` version of this TemplatePolicy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicySubjectAttribute') -> bool: + def __eq__(self, other: 'TemplatePolicy') -> bool: """Return `true` when self and other are equal, false otherwise.""" if not isinstance(other, self.__class__): return False return self.__dict__ == other.__dict__ - def __ne__(self, other: 'V2PolicySubjectAttribute') -> bool: + def __ne__(self, other: 'TemplatePolicy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class OperatorEnum(str, Enum): + class TypeEnum(str, Enum): """ - The operator of an attribute. + The policy type; either 'access' or 'authorization'. """ - STRINGEQUALS = 'stringEquals' - STRINGEXISTS = 'stringExists' + ACCESS = 'access' + AUTHORIZATION = 'authorization' -class V2PolicyTemplateMetaData: +class V2Policy: """ The core set of properties associated with the policy. @@ -7513,10 +7753,6 @@ class V2PolicyTemplateMetaData: :param int last_permit_frequency: (optional) The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit. - :param TemplateMetadata template: (optional) The details of the IAM template - that was used to create an enterprise-managed policy in your account. When - returned, this indicates that the policy is created from and managed by a - template in the root enterprise account. """ def __init__( @@ -7538,10 +7774,9 @@ def __init__( last_modified_by_id: Optional[str] = None, last_permit_at: Optional[str] = None, last_permit_frequency: Optional[int] = None, - template: Optional['TemplateMetadata'] = None, ) -> None: """ - Initialize a V2PolicyTemplateMetaData object. + Initialize a V2Policy object. :param str type: The policy type; either 'access' or 'authorization'. :param ControlResponse control: @@ -7561,10 +7796,6 @@ def __init__( :param int last_permit_frequency: (optional) The optional count of times that policy has provided a permit, when passing query parameter format=include_last_permit. - :param TemplateMetadata template: (optional) The details of the IAM - template that was used to create an enterprise-managed policy in your - account. When returned, this indicates that the policy is created from and - managed by a template in the root enterprise account. """ self.type = type self.description = description @@ -7582,16 +7813,15 @@ def __init__( self.state = state self.last_permit_at = last_permit_at self.last_permit_frequency = last_permit_frequency - self.template = template @classmethod - def from_dict(cls, _dict: Dict) -> 'V2PolicyTemplateMetaData': - """Initialize a V2PolicyTemplateMetaData object from a json dictionary.""" - args = {} + def from_dict(cls, _dict: Dict) -> 'V2Policy': + """Initialize a V2Policy object from a json dictionary.""" + args = {} if (type := _dict.get('type')) is not None: args['type'] = type else: - raise ValueError('Required property \'type\' not present in V2PolicyTemplateMetaData JSON') + raise ValueError('Required property \'type\' not present in V2Policy JSON') if (description := _dict.get('description')) is not None: args['description'] = description if (subject := _dict.get('subject')) is not None: @@ -7609,7 +7839,7 @@ def from_dict(cls, _dict: Dict) -> 'V2PolicyTemplateMetaData': if (control := _dict.get('control')) is not None: args['control'] = control else: - raise ValueError('Required property \'control\' not present in V2PolicyTemplateMetaData JSON') + raise ValueError('Required property \'control\' not present in V2Policy JSON') if (created_at := _dict.get('created_at')) is not None: args['created_at'] = string_to_datetime(created_at) if (created_by_id := _dict.get('created_by_id')) is not None: @@ -7621,18 +7851,16 @@ def from_dict(cls, _dict: Dict) -> 'V2PolicyTemplateMetaData': if (state := _dict.get('state')) is not None: args['state'] = state else: - raise ValueError('Required property \'state\' not present in V2PolicyTemplateMetaData JSON') + raise ValueError('Required property \'state\' not present in V2Policy JSON') if (last_permit_at := _dict.get('last_permit_at')) is not None: args['last_permit_at'] = last_permit_at if (last_permit_frequency := _dict.get('last_permit_frequency')) is not None: args['last_permit_frequency'] = last_permit_frequency - if (template := _dict.get('template')) is not None: - args['template'] = TemplateMetadata.from_dict(template) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a V2PolicyTemplateMetaData object from a json dictionary.""" + """Initialize a V2Policy object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -7682,11 +7910,6 @@ def to_dict(self) -> Dict: _dict['last_permit_at'] = self.last_permit_at if hasattr(self, 'last_permit_frequency') and self.last_permit_frequency is not None: _dict['last_permit_frequency'] = self.last_permit_frequency - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template - else: - _dict['template'] = self.template.to_dict() return _dict def _to_dict(self): @@ -7694,16 +7917,16 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this V2PolicyTemplateMetaData object.""" + """Return a `str` version of this V2Policy object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'V2PolicyTemplateMetaData') -> bool: + def __eq__(self, other: 'V2Policy') -> 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: 'V2PolicyTemplateMetaData') -> bool: + def __ne__(self, other: 'V2Policy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -7724,48 +7947,451 @@ class StateEnum(str, Enum): DELETED = 'deleted' -class ControlResponseControl(ControlResponse): +class V2PolicyCollection: """ - Specifies the type of access granted by the policy. + A collection of policies. - :param Grant grant: Permission granted by the policy. + :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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous page + of requested collection. + :param List[V2PolicyTemplateMetaData] policies: (optional) List of policies. """ def __init__( self, - grant: 'Grant', + *, + limit: Optional[int] = None, + first: Optional['First'] = None, + next: Optional['Next'] = None, + previous: Optional['Previous'] = None, + policies: Optional[List['V2PolicyTemplateMetaData']] = None, ) -> None: """ - Initialize a ControlResponseControl object. + Initialize a V2PolicyCollection object. + + :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 + requested collection. + :param Previous previous: (optional) Details with href linking to previous + page of requested collection. + :param List[V2PolicyTemplateMetaData] policies: (optional) List of + policies. + """ + self.limit = limit + self.first = first + self.next = next + self.previous = previous + self.policies = policies + + @classmethod + def from_dict(cls, _dict: Dict) -> 'V2PolicyCollection': + """Initialize a V2PolicyCollection 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 (policies := _dict.get('policies')) is not None: + args['policies'] = [V2PolicyTemplateMetaData.from_dict(v) for v in policies] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a V2PolicyCollection 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, 'policies') and self.policies is not None: + policies_list = [] + for v in self.policies: + if isinstance(v, dict): + policies_list.append(v) + else: + policies_list.append(v.to_dict()) + _dict['policies'] = policies_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this V2PolicyCollection object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'V2PolicyCollection') -> 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: 'V2PolicyCollection') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class V2PolicyResource: + """ + The resource attributes to which the policy grants access. + + :param List[V2PolicyResourceAttribute] attributes: List of resource attributes + to which the policy grants access. + :param List[V2PolicyResourceTag] tags: (optional) Optional list of resource tags + to which the policy grants access. + """ + + def __init__( + self, + attributes: List['V2PolicyResourceAttribute'], + *, + tags: Optional[List['V2PolicyResourceTag']] = None, + ) -> None: + """ + Initialize a V2PolicyResource object. + + :param List[V2PolicyResourceAttribute] attributes: List of resource + attributes to which the policy grants access. + :param List[V2PolicyResourceTag] tags: (optional) Optional list of resource + tags to which the policy grants access. + """ + self.attributes = attributes + self.tags = tags + + @classmethod + def from_dict(cls, _dict: Dict) -> 'V2PolicyResource': + """Initialize a V2PolicyResource object from a json dictionary.""" + args = {} + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [V2PolicyResourceAttribute.from_dict(v) for v in attributes] + else: + raise ValueError('Required property \'attributes\' not present in V2PolicyResource JSON') + if (tags := _dict.get('tags')) is not None: + args['tags'] = [V2PolicyResourceTag.from_dict(v) for v in tags] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a V2PolicyResource object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: + if isinstance(v, dict): + attributes_list.append(v) + else: + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list + if hasattr(self, 'tags') and self.tags is not None: + tags_list = [] + for v in self.tags: + if isinstance(v, dict): + tags_list.append(v) + else: + tags_list.append(v.to_dict()) + _dict['tags'] = tags_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this V2PolicyResource object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'V2PolicyResource') -> 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: 'V2PolicyResource') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class V2PolicyResourceAttribute: + """ + Resource attribute to which the policy grants access. + + :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. + """ + + def __init__( + self, + key: str, + operator: str, + value: object, + ) -> None: + """ + Initialize a V2PolicyResourceAttribute object. + + :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. + """ + self.key = key + self.operator = operator + self.value = value + + @classmethod + def from_dict(cls, _dict: Dict) -> 'V2PolicyResourceAttribute': + """Initialize a V2PolicyResourceAttribute object from a json dictionary.""" + args = {} + if (key := _dict.get('key')) is not None: + args['key'] = key + else: + raise ValueError('Required property \'key\' not present in V2PolicyResourceAttribute JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator + else: + raise ValueError('Required property \'operator\' not present in V2PolicyResourceAttribute JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in V2PolicyResourceAttribute JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a V2PolicyResourceAttribute 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, 'key') and self.key is not None: + _dict['key'] = self.key + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + 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 V2PolicyResourceAttribute object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'V2PolicyResourceAttribute') -> 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: 'V2PolicyResourceAttribute') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class OperatorEnum(str, Enum): + """ + The operator of an attribute. + """ + + STRINGEQUALS = 'stringEquals' + STRINGEXISTS = 'stringExists' + STRINGMATCH = 'stringMatch' + STRINGEQUALSANYOF = 'stringEqualsAnyOf' + STRINGMATCHANYOF = 'stringMatchAnyOf' + + +class V2PolicyResourceTag: + """ + A tag associated with a resource. + + :param str key: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: The operator of an access management tag. + """ + + def __init__( + self, + key: str, + value: str, + operator: str, + ) -> None: + """ + Initialize a V2PolicyResourceTag object. + + :param str key: The name of an access management tag. + :param str value: The value of an access management tag. + :param str operator: The operator of an access management tag. + """ + self.key = key + self.value = value + self.operator = operator + + @classmethod + def from_dict(cls, _dict: Dict) -> 'V2PolicyResourceTag': + """Initialize a V2PolicyResourceTag object from a json dictionary.""" + args = {} + if (key := _dict.get('key')) is not None: + args['key'] = key + else: + raise ValueError('Required property \'key\' not present in V2PolicyResourceTag JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in V2PolicyResourceTag JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator + else: + raise ValueError('Required property \'operator\' not present in V2PolicyResourceTag JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a V2PolicyResourceTag 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, 'key') and self.key is not None: + _dict['key'] = self.key + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this V2PolicyResourceTag object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'V2PolicyResourceTag') -> 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: 'V2PolicyResourceTag') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + class OperatorEnum(str, Enum): + """ + The operator of an access management tag. + """ + + STRINGEQUALS = 'stringEquals' + STRINGMATCH = 'stringMatch' + + +class V2PolicyRule: + """ + Additional access conditions associated with the policy. + + """ + + def __init__( + self, + ) -> None: + """ + Initialize a V2PolicyRule object. + + """ + msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( + ", ".join(['V2PolicyRuleRuleAttribute', 'V2PolicyRuleRuleWithNestedConditions']) + ) + raise Exception(msg) + + +class V2PolicySubject: + """ + The subject attributes for whom the policy grants access. + + :param List[V2PolicySubjectAttribute] attributes: List of subject attributes + associated with policy/. + """ + + def __init__( + self, + attributes: List['V2PolicySubjectAttribute'], + ) -> None: + """ + Initialize a V2PolicySubject object. - :param Grant grant: Permission granted by the policy. + :param List[V2PolicySubjectAttribute] attributes: List of subject + attributes associated with policy/. """ - # pylint: disable=super-init-not-called - self.grant = grant + self.attributes = attributes @classmethod - def from_dict(cls, _dict: Dict) -> 'ControlResponseControl': - """Initialize a ControlResponseControl object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'V2PolicySubject': + """Initialize a V2PolicySubject object from a json dictionary.""" args = {} - if (grant := _dict.get('grant')) is not None: - args['grant'] = Grant.from_dict(grant) + if (attributes := _dict.get('attributes')) is not None: + args['attributes'] = [V2PolicySubjectAttribute.from_dict(v) for v in attributes] else: - raise ValueError('Required property \'grant\' not present in ControlResponseControl JSON') + raise ValueError('Required property \'attributes\' not present in V2PolicySubject JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ControlResponseControl object from a json dictionary.""" + """Initialize a V2PolicySubject object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'grant') and self.grant is not None: - if isinstance(self.grant, dict): - _dict['grant'] = self.grant - else: - _dict['grant'] = self.grant.to_dict() + if hasattr(self, 'attributes') and self.attributes is not None: + attributes_list = [] + for v in self.attributes: + if isinstance(v, dict): + attributes_list.append(v) + else: + attributes_list.append(v.to_dict()) + _dict['attributes'] = attributes_list return _dict def _to_dict(self): @@ -7773,64 +8399,84 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ControlResponseControl object.""" + """Return a `str` version of this V2PolicySubject object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ControlResponseControl') -> bool: + def __eq__(self, other: 'V2PolicySubject') -> 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: 'ControlResponseControl') -> bool: + def __ne__(self, other: 'V2PolicySubject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ControlResponseControlWithEnrichedRoles(ControlResponse): +class V2PolicySubjectAttribute: """ - Specifies the type of access granted by the policy with additional role information. + Subject attribute for whom the policy grants access. - :param GrantWithEnrichedRoles grant: Permission granted by the policy with - translated roles and additional role information. + :param str key: The name of a subject attribute, e.g., 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. """ def __init__( self, - grant: 'GrantWithEnrichedRoles', + key: str, + operator: str, + value: object, ) -> None: """ - Initialize a ControlResponseControlWithEnrichedRoles object. + Initialize a V2PolicySubjectAttribute object. - :param GrantWithEnrichedRoles grant: Permission granted by the policy with - translated roles and additional role information. + :param str key: The name of a subject attribute, e.g., 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. """ - # pylint: disable=super-init-not-called - self.grant = grant + self.key = key + self.operator = operator + self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'ControlResponseControlWithEnrichedRoles': - """Initialize a ControlResponseControlWithEnrichedRoles object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'V2PolicySubjectAttribute': + """Initialize a V2PolicySubjectAttribute object from a json dictionary.""" args = {} - if (grant := _dict.get('grant')) is not None: - args['grant'] = GrantWithEnrichedRoles.from_dict(grant) + if (key := _dict.get('key')) is not None: + args['key'] = key else: - raise ValueError('Required property \'grant\' not present in ControlResponseControlWithEnrichedRoles JSON') + raise ValueError('Required property \'key\' not present in V2PolicySubjectAttribute JSON') + if (operator := _dict.get('operator')) is not None: + args['operator'] = operator + else: + raise ValueError('Required property \'operator\' not present in V2PolicySubjectAttribute JSON') + if (value := _dict.get('value')) is not None: + args['value'] = value + else: + raise ValueError('Required property \'value\' not present in V2PolicySubjectAttribute JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ControlResponseControlWithEnrichedRoles object from a json dictionary.""" + """Initialize a V2PolicySubjectAttribute object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'grant') and self.grant is not None: - if isinstance(self.grant, dict): - _dict['grant'] = self.grant - else: - _dict['grant'] = self.grant.to_dict() + if hasattr(self, 'key') and self.key is not None: + _dict['key'] = self.key + if hasattr(self, 'operator') and self.operator is not None: + _dict['operator'] = self.operator + if hasattr(self, 'value') and self.value is not None: + _dict['value'] = self.value return _dict def _to_dict(self): @@ -7838,115 +8484,158 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ControlResponseControlWithEnrichedRoles object.""" + """Return a `str` version of this V2PolicySubjectAttribute object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ControlResponseControlWithEnrichedRoles') -> bool: + def __eq__(self, other: 'V2PolicySubjectAttribute') -> 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: 'ControlResponseControlWithEnrichedRoles') -> bool: + def __ne__(self, other: 'V2PolicySubjectAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class OperatorEnum(str, Enum): + """ + The operator of an attribute. + """ + + STRINGEQUALS = 'stringEquals' + STRINGEXISTS = 'stringExists' + -class GetPolicyAssignmentResponsePolicyAssignment(GetPolicyAssignmentResponse): +class V2PolicyTemplateMetaData: """ - The set of properties associated with the policy template assignment. + The core set of properties associated with the policy. - :param str template_id: (optional) policy template id. - :param str template_version: (optional) 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 id: (optional) Policy assignment ID. - :param str account_id: (optional) The account GUID that the policies assignments - belong to.. - :param str href: (optional) The href URL that links to the policies assignments - API by policy assignment ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - assignment was created. + :param str 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 the + policy grants access. + :param V2PolicyResource resource: (optional) The resource attributes to which + the policy grants access. + :param str pattern: (optional) Indicates pattern of rule, either + 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + 'time-based-conditions:weekly:custom-hours'. + :param V2PolicyRule rule: (optional) Additional access conditions associated + with the policy. + :param str id: (optional) The policy ID. + :param str href: (optional) The href URL that links to the policies API by + policy ID. + :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 - policy assignment. + policy. :param datetime last_modified_at: (optional) The UTC timestamp when the policy - assignment was last modified. + was last modified. :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. + 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, + when passing query parameter format=include_last_permit. + :param int last_permit_frequency: (optional) The optional count of times that + policy has provided a permit, when passing query parameter + format=include_last_permit. + :param TemplateMetadata template: (optional) The details of the IAM template + that was used to create an enterprise-managed policy in your account. When + returned, this indicates that the policy is created from and managed by a + template in the root enterprise account. """ def __init__( self, + type: str, + control: 'ControlResponse', + state: 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, + description: Optional[str] = None, + subject: Optional['V2PolicySubject'] = None, + resource: Optional['V2PolicyResource'] = None, + pattern: Optional[str] = None, + rule: Optional['V2PolicyRule'] = None, id: Optional[str] = None, - account_id: Optional[str] = None, href: Optional[str] = None, created_at: Optional[datetime] = None, created_by_id: Optional[str] = None, last_modified_at: Optional[datetime] = None, last_modified_by_id: Optional[str] = None, - resources: Optional[List['PolicyAssignmentResources']] = None, - status: Optional[str] = None, + last_permit_at: Optional[str] = None, + last_permit_frequency: Optional[int] = None, + template: Optional['TemplateMetadata'] = None, ) -> None: """ - Initialize a GetPolicyAssignmentResponsePolicyAssignment object. + Initialize a V2PolicyTemplateMetaData object. - :param str template_id: (optional) policy template id. - :param str template_version: (optional) 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 List[PolicyAssignmentResources] resources: (optional) Object for - each account assigned. - :param str status: (optional) The policy assignment status. + :param str type: The policy type; either 'access' or 'authorization'. + :param ControlResponse control: + :param str state: The policy state, either 'deleted' or 'active'. + :param str description: (optional) Description of the policy. + :param V2PolicySubject subject: (optional) The subject attributes for whom + the policy grants access. + :param V2PolicyResource resource: (optional) The resource attributes to + which the policy grants access. + :param str pattern: (optional) Indicates pattern of rule, either + 'time-based-conditions:once', 'time-based-conditions:weekly:all-day', or + 'time-based-conditions:weekly:custom-hours'. + :param V2PolicyRule rule: (optional) Additional access conditions + associated with the policy. + :param str last_permit_at: (optional) The optional last permit time of + policy, when passing query parameter format=include_last_permit. + :param int last_permit_frequency: (optional) The optional count of times + that policy has provided a permit, when passing query parameter + format=include_last_permit. + :param TemplateMetadata template: (optional) The details of the IAM + template that was used to create an enterprise-managed policy in your + account. When returned, this indicates that the policy is created from and + managed by a template in the root enterprise account. """ - # pylint: disable=super-init-not-called - self.template_id = template_id - self.template_version = template_version - self.assignment_id = assignment_id - self.target_type = target_type - self.target = target + self.type = type + self.description = description + self.subject = subject + self.resource = resource + self.pattern = pattern + self.rule = rule self.id = id - self.account_id = account_id self.href = href + self.control = control self.created_at = created_at self.created_by_id = created_by_id self.last_modified_at = last_modified_at self.last_modified_by_id = last_modified_by_id - self.resources = resources - self.status = status + self.state = state + self.last_permit_at = last_permit_at + self.last_permit_frequency = last_permit_frequency + self.template = template @classmethod - def from_dict(cls, _dict: Dict) -> 'GetPolicyAssignmentResponsePolicyAssignment': - """Initialize a GetPolicyAssignmentResponsePolicyAssignment object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'V2PolicyTemplateMetaData': + """Initialize a V2PolicyTemplateMetaData object from a json dictionary.""" args = {} - if (template_id := _dict.get('template_id')) is not None: - args['template_id'] = template_id - if (template_version := _dict.get('template_version')) is not None: - args['template_version'] = template_version - 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 - if (target := _dict.get('target')) is not None: - args['target'] = target + if (type := _dict.get('type')) is not None: + args['type'] = type + else: + raise ValueError('Required property \'type\' not present in V2PolicyTemplateMetaData JSON') + if (description := _dict.get('description')) is not None: + args['description'] = description + if (subject := _dict.get('subject')) is not None: + args['subject'] = V2PolicySubject.from_dict(subject) + if (resource := _dict.get('resource')) is not None: + args['resource'] = V2PolicyResource.from_dict(resource) + if (pattern := _dict.get('pattern')) is not None: + args['pattern'] = pattern + if (rule := _dict.get('rule')) is not None: + args['rule'] = rule 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 (control := _dict.get('control')) is not None: + args['control'] = control + else: + raise ValueError('Required property \'control\' not present in V2PolicyTemplateMetaData JSON') if (created_at := _dict.get('created_at')) is not None: args['created_at'] = string_to_datetime(created_at) if (created_by_id := _dict.get('created_by_id')) is not None: @@ -7955,36 +8644,56 @@ def from_dict(cls, _dict: Dict) -> 'GetPolicyAssignmentResponsePolicyAssignment' args['last_modified_at'] = string_to_datetime(last_modified_at) if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: args['last_modified_by_id'] = last_modified_by_id - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyAssignmentResources.from_dict(v) for v in resources] - if (status := _dict.get('status')) is not None: - args['status'] = status + if (state := _dict.get('state')) is not None: + args['state'] = state + else: + raise ValueError('Required property \'state\' not present in V2PolicyTemplateMetaData JSON') + if (last_permit_at := _dict.get('last_permit_at')) is not None: + args['last_permit_at'] = last_permit_at + if (last_permit_frequency := _dict.get('last_permit_frequency')) is not None: + args['last_permit_frequency'] = last_permit_frequency + if (template := _dict.get('template')) is not None: + args['template'] = TemplateMetadata.from_dict(template) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GetPolicyAssignmentResponsePolicyAssignment object from a json dictionary.""" + """Initialize a V2PolicyTemplateMetaData 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, 'template_id') and self.template_id is not None: - _dict['template_id'] = self.template_id - if hasattr(self, 'template_version') and self.template_version is not None: - _dict['template_version'] = self.template_version - if hasattr(self, 'assignment_id') and self.assignment_id is not None: - _dict['assignment_id'] = self.assignment_id - if hasattr(self, 'target_type') and self.target_type is not None: - _dict['target_type'] = self.target_type - if hasattr(self, 'target') and self.target is not None: - _dict['target'] = self.target + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'subject') and self.subject is not None: + if isinstance(self.subject, dict): + _dict['subject'] = self.subject + else: + _dict['subject'] = self.subject.to_dict() + if hasattr(self, 'resource') and self.resource is not None: + if isinstance(self.resource, dict): + _dict['resource'] = self.resource + else: + _dict['resource'] = self.resource.to_dict() + if hasattr(self, 'pattern') and self.pattern is not None: + _dict['pattern'] = self.pattern + if hasattr(self, 'rule') and self.rule is not None: + if isinstance(self.rule, dict): + _dict['rule'] = self.rule + else: + _dict['rule'] = self.rule.to_dict() if hasattr(self, 'id') and getattr(self, 'id') is not None: _dict['id'] = getattr(self, 'id') - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') if hasattr(self, 'href') and getattr(self, 'href') is not None: _dict['href'] = getattr(self, 'href') + if hasattr(self, 'control') and self.control is not None: + if isinstance(self.control, dict): + _dict['control'] = self.control + else: + _dict['control'] = self.control.to_dict() 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: @@ -7993,16 +8702,17 @@ def to_dict(self) -> Dict: _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status + if hasattr(self, 'state') and self.state is not None: + _dict['state'] = self.state + if hasattr(self, 'last_permit_at') and self.last_permit_at is not None: + _dict['last_permit_at'] = self.last_permit_at + if hasattr(self, 'last_permit_frequency') and self.last_permit_frequency is not None: + _dict['last_permit_frequency'] = self.last_permit_frequency + if hasattr(self, 'template') and self.template is not None: + if isinstance(self.template, dict): + _dict['template'] = self.template + else: + _dict['template'] = self.template.to_dict() return _dict def _to_dict(self): @@ -8010,199 +8720,143 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GetPolicyAssignmentResponsePolicyAssignment object.""" + """Return a `str` version of this V2PolicyTemplateMetaData object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GetPolicyAssignmentResponsePolicyAssignment') -> bool: + def __eq__(self, other: 'V2PolicyTemplateMetaData') -> 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: 'GetPolicyAssignmentResponsePolicyAssignment') -> bool: + def __ne__(self, other: 'V2PolicyTemplateMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class TargetTypeEnum(str, Enum): + class TypeEnum(str, Enum): """ - Assignment target type. + The policy type; either 'access' or 'authorization'. """ - ACCOUNT = 'Account' - ACCOUNTGROUP = 'AccountGroup' - ENTERPRISE = 'Enterprise' + ACCESS = 'access' + AUTHORIZATION = 'authorization' - class StatusEnum(str, Enum): + class StateEnum(str, Enum): """ - The policy assignment status. + The policy state, either 'deleted' or 'active'. """ - IN_PROGRESS = 'in_progress' - SUCCEEDED = 'succeeded' - SUCCEED_WITH_ERRORS = 'succeed_with_errors' - FAILED = 'failed' + ACTIVE = 'active' + DELETED = 'deleted' -class GetPolicyAssignmentResponsePolicyAssignmentV1(GetPolicyAssignmentResponse): +class ControlResponseControl(ControlResponse): """ - The set of properties associated with the policy template assignment. + Specifies the type of access granted by the policy. - :param AssignmentTargetDetails target: assignment target account and type. - :param str id: (optional) Policy assignment ID. - :param str account_id: (optional) The account GUID that the policies assignments - belong to.. - :param str href: (optional) The href URL that links to the policies assignments - API by policy assignment ID. - :param datetime created_at: (optional) The UTC timestamp when the policy - assignment was created. - :param str created_by_id: (optional) The iam ID of the entity that created the - policy assignment. - :param datetime last_modified_at: (optional) The UTC timestamp when the policy - assignment was last modified. - :param str last_modified_by_id: (optional) The iam ID of the entity that last - modified the policy assignment. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param GetPolicyAssignmentResponsePolicyAssignmentV1Subject subject: (optional) - subject details of access type assignment. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. + :param Grant grant: Permission granted by the policy. """ def __init__( self, - target: 'AssignmentTargetDetails', - resources: List['PolicyAssignmentV1Resources'], - template: 'AssignmentTemplateDetails', - status: str, - *, - id: Optional[str] = None, - account_id: Optional[str] = None, - href: Optional[str] = None, - created_at: Optional[datetime] = None, - created_by_id: Optional[str] = None, - last_modified_at: Optional[datetime] = None, - last_modified_by_id: Optional[str] = None, - subject: Optional['GetPolicyAssignmentResponsePolicyAssignmentV1Subject'] = None, + grant: 'Grant', ) -> None: """ - Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1 object. + Initialize a ControlResponseControl object. - :param AssignmentTargetDetails target: assignment target account and type. - :param List[PolicyAssignmentV1Resources] resources: Object for each account - assigned. - :param AssignmentTemplateDetails template: policy template details. - :param str status: The policy assignment status. - :param GetPolicyAssignmentResponsePolicyAssignmentV1Subject subject: - (optional) subject details of access type assignment. + :param Grant grant: Permission granted by the policy. """ # pylint: disable=super-init-not-called - self.target = target - self.id = id - self.account_id = account_id - self.href = href - self.created_at = created_at - self.created_by_id = created_by_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.resources = resources - self.subject = subject - self.template = template - self.status = status + self.grant = grant @classmethod - def from_dict(cls, _dict: Dict) -> 'GetPolicyAssignmentResponsePolicyAssignmentV1': - """Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1 object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ControlResponseControl': + """Initialize a ControlResponseControl 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 GetPolicyAssignmentResponsePolicyAssignmentV1 JSON' - ) - if (id := _dict.get('id')) is not None: - args['id'] = id - if (account_id := _dict.get('account_id')) is not None: - args['account_id'] = account_id - if (href := _dict.get('href')) is not None: - args['href'] = href - if (created_at := _dict.get('created_at')) is not None: - args['created_at'] = string_to_datetime(created_at) - if (created_by_id := _dict.get('created_by_id')) is not None: - args['created_by_id'] = created_by_id - if (last_modified_at := _dict.get('last_modified_at')) is not None: - args['last_modified_at'] = string_to_datetime(last_modified_at) - if (last_modified_by_id := _dict.get('last_modified_by_id')) is not None: - args['last_modified_by_id'] = last_modified_by_id - if (resources := _dict.get('resources')) is not None: - args['resources'] = [PolicyAssignmentV1Resources.from_dict(v) for v in resources] - else: - raise ValueError( - 'Required property \'resources\' not present in GetPolicyAssignmentResponsePolicyAssignmentV1 JSON' - ) - if (subject := _dict.get('subject')) is not None: - args['subject'] = GetPolicyAssignmentResponsePolicyAssignmentV1Subject.from_dict(subject) - if (template := _dict.get('template')) is not None: - args['template'] = AssignmentTemplateDetails.from_dict(template) + if (grant := _dict.get('grant')) is not None: + args['grant'] = Grant.from_dict(grant) else: - raise ValueError( - 'Required property \'template\' not present in GetPolicyAssignmentResponsePolicyAssignmentV1 JSON' - ) - if (status := _dict.get('status')) is not None: - args['status'] = status + raise ValueError('Required property \'grant\' not present in ControlResponseControl JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ControlResponseControl object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'grant') and self.grant is not None: + if isinstance(self.grant, dict): + _dict['grant'] = self.grant + else: + _dict['grant'] = self.grant.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 ControlResponseControl object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ControlResponseControl') -> 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: 'ControlResponseControl') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ControlResponseControlWithEnrichedRoles(ControlResponse): + """ + Specifies the type of access granted by the policy with additional role information. + + :param GrantWithEnrichedRoles grant: Permission granted by the policy with + translated roles and additional role information. + """ + + def __init__( + self, + grant: 'GrantWithEnrichedRoles', + ) -> None: + """ + Initialize a ControlResponseControlWithEnrichedRoles object. + + :param GrantWithEnrichedRoles grant: Permission granted by the policy with + translated roles and additional role information. + """ + # pylint: disable=super-init-not-called + self.grant = grant + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ControlResponseControlWithEnrichedRoles': + """Initialize a ControlResponseControlWithEnrichedRoles object from a json dictionary.""" + args = {} + if (grant := _dict.get('grant')) is not None: + args['grant'] = GrantWithEnrichedRoles.from_dict(grant) else: - raise ValueError( - 'Required property \'status\' not present in GetPolicyAssignmentResponsePolicyAssignmentV1 JSON' - ) + raise ValueError('Required property \'grant\' not present in ControlResponseControlWithEnrichedRoles JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GetPolicyAssignmentResponsePolicyAssignmentV1 object from a json dictionary.""" + """Initialize a ControlResponseControlWithEnrichedRoles object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'target') and self.target is not None: - if isinstance(self.target, dict): - _dict['target'] = self.target - else: - _dict['target'] = self.target.to_dict() - if hasattr(self, 'id') and getattr(self, 'id') is not None: - _dict['id'] = getattr(self, 'id') - if hasattr(self, 'account_id') and getattr(self, 'account_id') is not None: - _dict['account_id'] = getattr(self, 'account_id') - if hasattr(self, 'href') and getattr(self, 'href') is not None: - _dict['href'] = getattr(self, 'href') - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'resources') and self.resources is not None: - resources_list = [] - for v in self.resources: - if isinstance(v, dict): - resources_list.append(v) - else: - resources_list.append(v.to_dict()) - _dict['resources'] = resources_list - if hasattr(self, 'subject') and self.subject is not None: - if isinstance(self.subject, dict): - _dict['subject'] = self.subject - else: - _dict['subject'] = self.subject.to_dict() - if hasattr(self, 'template') and self.template is not None: - if isinstance(self.template, dict): - _dict['template'] = self.template + if hasattr(self, 'grant') and self.grant is not None: + if isinstance(self.grant, dict): + _dict['grant'] = self.grant else: - _dict['template'] = self.template.to_dict() - if hasattr(self, 'status') and self.status is not None: - _dict['status'] = self.status + _dict['grant'] = self.grant.to_dict() return _dict def _to_dict(self): @@ -8210,29 +8864,19 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GetPolicyAssignmentResponsePolicyAssignmentV1 object.""" + """Return a `str` version of this ControlResponseControlWithEnrichedRoles object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GetPolicyAssignmentResponsePolicyAssignmentV1') -> bool: + def __eq__(self, other: 'ControlResponseControlWithEnrichedRoles') -> 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: 'GetPolicyAssignmentResponsePolicyAssignmentV1') -> bool: + def __ne__(self, other: 'ControlResponseControlWithEnrichedRoles') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class StatusEnum(str, Enum): - """ - The policy assignment status. - """ - - IN_PROGRESS = 'in_progress' - SUCCEEDED = 'succeeded' - SUCCEED_WITH_ERRORS = 'succeed_with_errors' - FAILED = 'failed' - class NestedConditionRuleAttribute(NestedCondition): """ @@ -8610,8 +9254,6 @@ class TargetTypeEnum(str, Enum): """ ACCOUNT = 'Account' - ACCOUNTGROUP = 'AccountGroup' - ENTERPRISE = 'Enterprise' class StatusEnum(str, Enum): """ @@ -9014,3 +9656,557 @@ class OperatorEnum(str, Enum): AND = 'and' OR = 'or' + + +############################################################################## +# Pagers +############################################################################## + + +class PoliciesPager: + """ + PoliciesPager can be used to simplify the use of the "list_policies" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + iam_id: str = None, + access_group_id: str = None, + type: str = None, + service_type: str = None, + tag_name: str = None, + tag_value: str = None, + sort: str = None, + format: str = None, + state: str = None, + limit: int = None, + ) -> None: + """ + Initialize a PoliciesPager object. + :param str account_id: The account GUID that the policies belong to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str iam_id: (optional) Optional IAM ID used to identify the subject. + :param str access_group_id: (optional) Optional access group id. + :param str type: (optional) Optional type of policy. + :param str service_type: (optional) Optional type of service. + :param str tag_name: (optional) Optional name of the access tag in the + policy. + :param str tag_value: (optional) Optional value of the access tag in the + policy. + :param str sort: (optional) Optional top level policy field to sort + results. Ascending sort is default. Descending sort available by prepending + '-' to field. Example '-last_modified_at'. + :param str format: (optional) 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. + :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 + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._accept_language = accept_language + self._iam_id = iam_id + self._access_group_id = access_group_id + self._type = type + self._service_type = service_type + self._tag_name = tag_name + self._tag_value = tag_value + self._sort = sort + self._format = format + 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 PolicyTemplateMetaData. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_policies( + account_id=self._account_id, + accept_language=self._accept_language, + iam_id=self._iam_id, + access_group_id=self._access_group_id, + type=self._type, + service_type=self._service_type, + tag_name=self._tag_name, + tag_value=self._tag_value, + sort=self._sort, + format=self._format, + 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('policies') + + 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 PolicyTemplateMetaData. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class V2PoliciesPager: + """ + V2PoliciesPager can be used to simplify the use of the "list_v2_policies" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + iam_id: str = None, + access_group_id: str = None, + type: str = None, + service_type: str = None, + service_name: str = None, + service_group_id: str = None, + sort: str = None, + format: str = None, + state: str = None, + limit: int = None, + ) -> None: + """ + Initialize a V2PoliciesPager object. + :param str account_id: The account GUID in which the policies belong to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str iam_id: (optional) Optional IAM ID used to identify the subject. + :param str access_group_id: (optional) Optional access group id. + :param str type: (optional) Optional type of policy. + :param str service_type: (optional) Optional type of service. + :param str service_name: (optional) Optional name of service. + :param str service_group_id: (optional) Optional ID of service group. + :param str sort: (optional) Optional top level policy field to sort + results. Ascending sort is default. Descending sort available by prepending + '-' to field, for example, '-last_modified_at'. Note that last permit + information is only included when 'format=include_last_permit', for + example, "format=include_last_permit&sort=last_permit_at" Example fields + that can be sorted on: + - 'id' + - 'type' + - 'href' + - 'created_at' + - 'created_by_id' + - 'last_modified_at' + - 'last_modified_by_id' + - 'state' + - 'last_permit_at' + - 'last_permit_frequency'. + :param str format: (optional) 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. + :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 + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._accept_language = accept_language + self._iam_id = iam_id + self._access_group_id = access_group_id + self._type = type + self._service_type = service_type + self._service_name = service_name + self._service_group_id = service_group_id + self._sort = sort + self._format = format + 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 V2PolicyTemplateMetaData. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_v2_policies( + account_id=self._account_id, + accept_language=self._accept_language, + iam_id=self._iam_id, + access_group_id=self._access_group_id, + type=self._type, + service_type=self._service_type, + service_name=self._service_name, + service_group_id=self._service_group_id, + sort=self._sort, + format=self._format, + 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('policies') + + 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 V2PolicyTemplateMetaData. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class PolicyTemplatesPager: + """ + PolicyTemplatesPager can be used to simplify the use of the "list_policy_templates" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + account_id: str, + accept_language: str = None, + state: str = None, + name: str = None, + policy_service_type: str = None, + policy_service_name: str = None, + policy_service_group_id: str = None, + policy_type: str = None, + limit: int = None, + ) -> None: + """ + Initialize a PolicyTemplatesPager object. + :param str account_id: The account GUID that the policy templates belong + to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str state: (optional) The policy template state. + :param str name: (optional) The policy template name. + :param str policy_service_type: (optional) Service type, Optional. + :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 + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._accept_language = accept_language + self._state = state + self._name = name + self._policy_service_type = policy_service_type + self._policy_service_name = policy_service_name + self._policy_service_group_id = policy_service_group_id + self._policy_type = policy_type + 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 PolicyTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_policy_templates( + account_id=self._account_id, + accept_language=self._accept_language, + state=self._state, + name=self._name, + policy_service_type=self._policy_service_type, + policy_service_name=self._policy_service_name, + policy_service_group_id=self._policy_service_group_id, + policy_type=self._policy_type, + 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('policy_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 PolicyTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class PolicyTemplateVersionsPager: + """ + PolicyTemplateVersionsPager can be used to simplify the use of the "list_policy_template_versions" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + policy_template_id: str, + state: str = None, + limit: int = None, + ) -> None: + """ + 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 + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._policy_template_id = policy_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 PolicyTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_policy_template_versions( + policy_template_id=self._policy_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 PolicyTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class PolicyAssignmentsPager: + """ + PolicyAssignmentsPager can be used to simplify the use of the "list_policy_assignments" method. + """ + + def __init__( + self, + *, + client: IamPolicyManagementV1, + version: str, + account_id: str, + accept_language: str = None, + template_id: str = None, + template_version: str = None, + limit: int = None, + ) -> None: + """ + Initialize a PolicyAssignmentsPager object. + :param str version: specify version of response body format. + :param str account_id: The account GUID in which the policies belong to. + :param str accept_language: (optional) Language code for translations + * `default` - English + * `de` - German (Standard) + * `en` - English + * `es` - Spanish (Spain) + * `fr` - French (Standard) + * `it` - Italian (Standard) + * `ja` - Japanese + * `ko` - Korean + * `pt-br` - Portuguese (Brazil) + * `zh-cn` - Chinese (Simplified, PRC) + * `zh-tw` - (Chinese, Taiwan). + :param str 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 + collection. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._version = version + 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 PolicyTemplateAssignmentItems. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_policy_assignments( + version=self._version, + 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 PolicyTemplateAssignmentItems. + :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 9101aab8..b0e78440 100644 --- a/test/integration/test_iam_policy_management_v1.py +++ b/test/integration/test_iam_policy_management_v1.py @@ -68,6 +68,7 @@ def setUpClass(cls): cls.testPolicySubject = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=cls.testUserId)]) cls.testPolicyRole = PolicyRole(role_id=cls.testViewerRoleCrn) cls.testPolicyAssignmentETag = "" + cls.testAccountSettingsETag = "" resource_tag = ResourceTag(name='project', value='prototype', operator='stringEquals') cls.testPolicyResources = PolicyResource( attributes=[ @@ -826,24 +827,6 @@ def test_25_create_policy_s2s_template_version(self): assert result.state == "active" def test_26_create_policy_assignment(self): - try: - response = self.service.create_policy_template_assignment( - version="1.0", - target=AssignmentTargetDetails( - type="Enterprise", - id=self.testTargetEnterpriseAccountId, - ), - templates=[ - AssignmentTemplateDetails(id=self.testS2STemplateId, version=self.testS2SBaseTemplateVersion) - ], - ) - except ApiException as e: - assert ( - e.message - == "Invalid body format. Check the input parameters. instance.target.type is not one of enum values: Account" - ) - - def test_27_create_policy_assignment(self): response = self.service.create_policy_template_assignment( version="1.0", target=AssignmentTargetDetails( @@ -863,7 +846,7 @@ def test_27_create_policy_assignment(self): self.__class__.testAssignmentPolicyId = result.assignments[0].resources[0].policy.resource_created.id self.__class__.testPolicyAssignmentETag = response.get_headers().get(self.etagHeader) - def test_28_list_policy_assignments(self): + def test_27_list_policy_assignments(self): response = self.service.list_policy_assignments( account_id=self.testAccountId, accept_language='default', @@ -876,7 +859,7 @@ def test_28_list_policy_assignments(self): result = PolicyTemplateAssignmentCollection.from_dict(result_dict) assert result is not None - def test_29_get_policy_assignment(self): + def test_28_get_policy_assignment(self): assert self.testAssignmentId print("Assignment ID: ", self.testAssignmentId) response = self.service.get_policy_assignment( @@ -892,7 +875,7 @@ def test_29_get_policy_assignment(self): assert result is not None assert result.id == self.testAssignmentId - def test_30_update_policy_assignment(self): + def test_29_update_policy_assignment(self): assert self.testAssignmentId assert self.testPolicyAssignmentETag print("Assignment ID: ", self.testAssignmentId) @@ -911,7 +894,7 @@ def test_30_update_policy_assignment(self): assert result is not None print("Policy Assignment Update: ", result) - def test_31_get_v2_assignment_policy(self): + def test_30_get_v2_assignment_policy(self): assert self.testAssignmentPolicyId print("Assignment Policy ID: ", self.testAssignmentPolicyId) @@ -926,14 +909,68 @@ def test_31_get_v2_assignment_policy(self): assert result is not None assert result.template is not None - def test_32_delete_policy_assignment(self): + def test_31_delete_policy_assignment(self): response = self.service.delete_policy_assignment( assignment_id=self.testAssignmentId, ) assert response.get_status_code() == 204 - def test_33_delete_policy_template(self): + def test_32_delete_policy_template(self): response = self.service.delete_policy_template( policy_template_id=self.testS2STemplateId, ) assert response.get_status_code() == 204 + + def test_33_get_access_management_account_settings(self): + response = self.service.get_settings( + account_id=self.testAccountId, + accept_language='default', + ) + assert response is not None + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + result = AccountSettingsAccessManagement.from_dict(result_dict) + assert result is not None + assert result.external_account_identity_interaction is not None + assert result.external_account_identity_interaction.identity_types is not None + assert result.external_account_identity_interaction.identity_types.user is not None + assert result.external_account_identity_interaction.identity_types.service is not None + assert result.external_account_identity_interaction.identity_types.service_id is not None + self.__class__.testAccountSettingsETag = response.get_headers().get(self.etagHeader) + + def test_34_update_access_management_account_settings(self): + assert self.testAccountSettingsETag + # Construct a dict representation of a IdentityTypesBase model + identity_types_base_model = {'state': 'monitor', 'external_allowed_accounts': []} + + # Construct a dict representation of a IdentityTypesPatch model + identity_types_patch_model = { + 'user': identity_types_base_model, + 'service_id': identity_types_base_model, + 'service': identity_types_base_model, + } + + # Construct a dict representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model = {'identity_types': identity_types_patch_model} + + response = self.service.update_settings( + account_id=self.testAccountId, + accept_language='default', + if_match=self.testAccountSettingsETag, + external_account_identity_interaction=external_account_identity_interaction_patch_model, + ) + + assert response.get_status_code() == 200 + result_dict = response.get_result() + assert result_dict is not None + result = AccountSettingsAccessManagement.from_dict(result_dict) + assert result is not None + assert result.external_account_identity_interaction is not None + assert result.external_account_identity_interaction.identity_types is not None + assert result.external_account_identity_interaction.identity_types.user is not None + assert result.external_account_identity_interaction.identity_types.user.state == "monitor" + assert result.external_account_identity_interaction.identity_types.service is not None + 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" diff --git a/test/unit/test_iam_policy_management_v1.py b/test/unit/test_iam_policy_management_v1.py index 0aa0d0ae..8f523003 100644 --- a/test/unit/test_iam_policy_management_v1.py +++ b/test/unit/test_iam_policy_management_v1.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# (C) Copyright IBM Corp. 2024. +# (C) Copyright IBM Corp. 2025. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,15 +44,8 @@ def preprocess_url(operation_path: str): The returned request URL is used to register the mock response so it needs to match the request URL that is formed by the requests library. """ - # First, unquote the path since it might have some quoted/escaped characters in it - # due to how the generator inserts the operation paths into the unit test code. - operation_path = urllib.parse.unquote(operation_path) - # Next, quote the path using urllib so that we approximate what will - # happen during request processing. - operation_path = urllib.parse.quote(operation_path, safe='/') - - # Finally, form the request URL from the base URL and operation path. + # Form the request URL from the base URL and operation path. request_url = _base_url + operation_path # If the request url does NOT end with a /, then just return it as-is. @@ -108,7 +101,7 @@ def test_list_policies_all_params(self): """ # Set up mock url = preprocess_url('/v1/policies') - mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -129,6 +122,8 @@ def test_list_policies_all_params(self): sort = 'id' format = 'include_last_permit' state = 'active' + limit = 50 + start = 'testString' # Invoke method response = _service.list_policies( @@ -143,6 +138,8 @@ def test_list_policies_all_params(self): sort=sort, format=format, state=state, + limit=limit, + start=start, headers={}, ) @@ -162,6 +159,8 @@ def test_list_policies_all_params(self): assert 'sort={}'.format(sort) in query_string assert 'format={}'.format(format) in query_string assert 'state={}'.format(state) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string def test_list_policies_all_params_with_retries(self): # Enable retries and run test_list_policies_all_params. @@ -179,7 +178,7 @@ def test_list_policies_required_params(self): """ # Set up mock url = preprocess_url('/v1/policies') - mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -221,7 +220,7 @@ def test_list_policies_value_error(self): """ # Set up mock url = preprocess_url('/v1/policies') - mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "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", "state": "active", "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -251,6 +250,97 @@ def test_list_policies_value_error_with_retries(self): _service.disable_retries() self.test_list_policies_value_error() + @responses.activate + def test_list_policies_with_pager_get_next(self): + """ + test_list_policies_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policies') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"policies":[{"id":"id","type":"type","description":"description","subjects":[{"attributes":[{"name":"name","value":"value"}]}],"roles":[{"role_id":"role_id","display_name":"display_name","description":"description"}],"resources":[{"attributes":[{"name":"name","value":"value","operator":"operator"}],"tags":[{"name":"name","value":"value","operator":"operator"}]}],"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","state":"active","template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"policies":[{"id":"id","type":"type","description":"description","subjects":[{"attributes":[{"name":"name","value":"value"}]}],"roles":[{"role_id":"role_id","display_name":"display_name","description":"description"}],"resources":[{"attributes":[{"name":"name","value":"value","operator":"operator"}],"tags":[{"name":"name","value":"value","operator":"operator"}]}],"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","state":"active","template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + 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 = PoliciesPager( + client=_service, + account_id='testString', + accept_language='default', + iam_id='testString', + access_group_id='testString', + type='access', + service_type='service', + tag_name='testString', + tag_value='testString', + sort='id', + format='include_last_permit', + 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_policies_with_pager_get_all(self): + """ + test_list_policies_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policies') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"policies":[{"id":"id","type":"type","description":"description","subjects":[{"attributes":[{"name":"name","value":"value"}]}],"roles":[{"role_id":"role_id","display_name":"display_name","description":"description"}],"resources":[{"attributes":[{"name":"name","value":"value","operator":"operator"}],"tags":[{"name":"name","value":"value","operator":"operator"}]}],"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","state":"active","template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"policies":[{"id":"id","type":"type","description":"description","subjects":[{"attributes":[{"name":"name","value":"value"}]}],"roles":[{"role_id":"role_id","display_name":"display_name","description":"description"}],"resources":[{"attributes":[{"name":"name","value":"value","operator":"operator"}],"tags":[{"name":"name","value":"value","operator":"operator"}]}],"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","state":"active","template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + 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 = PoliciesPager( + client=_service, + account_id='testString', + accept_language='default', + iam_id='testString', + access_group_id='testString', + type='access', + service_type='service', + tag_name='testString', + tag_value='testString', + sort='id', + format='include_last_permit', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + class TestCreatePolicy: """ @@ -1525,7 +1615,7 @@ def test_list_v2_policies_all_params(self): """ # Set up mock url = preprocess_url('/v2/policies') - mock_response = '{"policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -1546,6 +1636,8 @@ def test_list_v2_policies_all_params(self): sort = 'testString' format = 'include_last_permit' state = 'active' + limit = 50 + start = 'testString' # Invoke method response = _service.list_v2_policies( @@ -1560,6 +1652,8 @@ def test_list_v2_policies_all_params(self): sort=sort, format=format, state=state, + limit=limit, + start=start, headers={}, ) @@ -1579,6 +1673,8 @@ def test_list_v2_policies_all_params(self): assert 'sort={}'.format(sort) in query_string assert 'format={}'.format(format) in query_string assert 'state={}'.format(state) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string def test_list_v2_policies_all_params_with_retries(self): # Enable retries and run test_list_v2_policies_all_params. @@ -1596,7 +1692,7 @@ def test_list_v2_policies_required_params(self): """ # Set up mock url = preprocess_url('/v2/policies') - mock_response = '{"policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -1638,7 +1734,7 @@ def test_list_v2_policies_value_error(self): """ # Set up mock url = preprocess_url('/v2/policies') - mock_response = '{"policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policies": [{"type": "access", "description": "description", "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "id": "id", "href": "href", "control": {"grant": {"roles": [{"role_id": "role_id"}]}}, "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", "state": "active", "last_permit_at": "last_permit_at", "last_permit_frequency": 21, "template": {"id": "id", "version": "version", "assignment_id": "assignment_id", "root_id": "root_id", "root_version": "root_version"}}]}' responses.add( responses.GET, url, @@ -1668,6 +1764,97 @@ def test_list_v2_policies_value_error_with_retries(self): _service.disable_retries() self.test_list_v2_policies_value_error() + @responses.activate + def test_list_v2_policies_with_pager_get_next(self): + """ + test_list_v2_policies_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v2/policies') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"policies":[{"type":"access","description":"description","subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"id":"id","href":"href","control":{"grant":{"roles":[{"role_id":"role_id"}]}},"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","state":"active","last_permit_at":"last_permit_at","last_permit_frequency":21,"template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"policies":[{"type":"access","description":"description","subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"id":"id","href":"href","control":{"grant":{"roles":[{"role_id":"role_id"}]}},"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","state":"active","last_permit_at":"last_permit_at","last_permit_frequency":21,"template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + 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 = V2PoliciesPager( + client=_service, + account_id='testString', + accept_language='default', + iam_id='testString', + access_group_id='testString', + type='access', + service_type='service', + service_name='testString', + service_group_id='testString', + sort='testString', + format='include_last_permit', + 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_v2_policies_with_pager_get_all(self): + """ + test_list_v2_policies_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v2/policies') + mock_response1 = '{"next":{"start":"1"},"total_count":2,"limit":1,"policies":[{"type":"access","description":"description","subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"id":"id","href":"href","control":{"grant":{"roles":[{"role_id":"role_id"}]}},"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","state":"active","last_permit_at":"last_permit_at","last_permit_frequency":21,"template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + mock_response2 = '{"total_count":2,"limit":1,"policies":[{"type":"access","description":"description","subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"id":"id","href":"href","control":{"grant":{"roles":[{"role_id":"role_id"}]}},"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","state":"active","last_permit_at":"last_permit_at","last_permit_frequency":21,"template":{"id":"id","version":"version","assignment_id":"assignment_id","root_id":"root_id","root_version":"root_version"}}]}' + 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 = V2PoliciesPager( + client=_service, + account_id='testString', + accept_language='default', + iam_id='testString', + access_group_id='testString', + type='access', + service_type='service', + service_name='testString', + service_group_id='testString', + sort='testString', + format='include_last_permit', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + class TestCreateV2Policy: """ @@ -2432,7 +2619,7 @@ def test_list_policy_templates_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_templates') - mock_response = '{"policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -2450,6 +2637,8 @@ def test_list_policy_templates_all_params(self): policy_service_name = 'testString' policy_service_group_id = 'testString' policy_type = 'access' + limit = 50 + start = 'testString' # Invoke method response = _service.list_policy_templates( @@ -2461,6 +2650,8 @@ def test_list_policy_templates_all_params(self): policy_service_name=policy_service_name, policy_service_group_id=policy_service_group_id, policy_type=policy_type, + limit=limit, + start=start, headers={}, ) @@ -2477,6 +2668,8 @@ def test_list_policy_templates_all_params(self): assert 'policy_service_name={}'.format(policy_service_name) in query_string assert 'policy_service_group_id={}'.format(policy_service_group_id) in query_string assert 'policy_type={}'.format(policy_type) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'start={}'.format(start) in query_string def test_list_policy_templates_all_params_with_retries(self): # Enable retries and run test_list_policy_templates_all_params. @@ -2494,7 +2687,7 @@ def test_list_policy_templates_required_params(self): """ # Set up mock url = preprocess_url('/v1/policy_templates') - mock_response = '{"policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -2536,7 +2729,7 @@ def test_list_policy_templates_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_templates') - mock_response = '{"policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + mock_response = '{"limit": 1, "first": {"href": "href"}, "next": {"href": "href", "start": "start"}, "previous": {"href": "href", "start": "start"}, "policy_templates": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -2566,6 +2759,91 @@ def test_list_policy_templates_value_error_with_retries(self): _service.disable_retries() self.test_list_policy_templates_value_error() + @responses.activate + def test_list_policy_templates_with_pager_get_next(self): + """ + test_list_policy_templates_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policy_templates') + mock_response1 = '{"next":{"start":"1"},"policy_templates":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"total_count":2,"limit":1}' + mock_response2 = '{"policy_templates":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"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 = PolicyTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + state='active', + name='testString', + policy_service_type='service', + policy_service_name='testString', + policy_service_group_id='testString', + policy_type='access', + 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_policy_templates_with_pager_get_all(self): + """ + test_list_policy_templates_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policy_templates') + mock_response1 = '{"next":{"start":"1"},"policy_templates":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"total_count":2,"limit":1}' + mock_response2 = '{"policy_templates":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"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 = PolicyTemplatesPager( + client=_service, + account_id='testString', + accept_language='default', + state='active', + name='testString', + policy_service_type='service', + policy_service_name='testString', + policy_service_group_id='testString', + policy_type='access', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + class TestCreatePolicyTemplate: """ @@ -3311,7 +3589,7 @@ def test_list_policy_template_versions_all_params(self): """ # Set up mock url = preprocess_url('/v1/policy_templates/testString/versions') - mock_response = '{"versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + 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", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -3323,11 +3601,15 @@ def test_list_policy_template_versions_all_params(self): # Set up parameter values policy_template_id = 'testString' state = 'active' + limit = 50 + start = 'testString' # Invoke method response = _service.list_policy_template_versions( policy_template_id, state=state, + limit=limit, + start=start, headers={}, ) @@ -3338,6 +3620,8 @@ def test_list_policy_template_versions_all_params(self): 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_policy_template_versions_all_params_with_retries(self): # Enable retries and run test_list_policy_template_versions_all_params. @@ -3355,7 +3639,7 @@ def test_list_policy_template_versions_required_params(self): """ # Set up mock url = preprocess_url('/v1/policy_templates/testString/versions') - mock_response = '{"versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + 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", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -3393,7 +3677,7 @@ def test_list_policy_template_versions_value_error(self): """ # Set up mock url = preprocess_url('/v1/policy_templates/testString/versions') - mock_response = '{"versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' + 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", "version": "version", "committed": false, "policy": {"type": "access", "description": "description", "resource": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}], "tags": [{"key": "key", "value": "value", "operator": "stringEquals"}]}, "subject": {"attributes": [{"key": "key", "operator": "stringEquals", "value": "anyValue"}]}, "pattern": "pattern", "rule": {"key": "key", "operator": "stringEquals", "value": "anyValue"}, "control": {"grant": {"roles": [{"role_id": "role_id"}]}}}, "state": "active", "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"}]}' responses.add( responses.GET, url, @@ -3423,6 +3707,79 @@ def test_list_policy_template_versions_value_error_with_retries(self): _service.disable_retries() self.test_list_policy_template_versions_value_error() + @responses.activate + def test_list_policy_template_versions_with_pager_get_next(self): + """ + test_list_policy_template_versions_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policy_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"total_count":2,"limit":1}' + mock_response2 = '{"versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"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 = PolicyTemplateVersionsPager( + client=_service, + policy_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_policy_template_versions_with_pager_get_all(self): + """ + test_list_policy_template_versions_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/policy_templates/testString/versions') + mock_response1 = '{"next":{"start":"1"},"versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"total_count":2,"limit":1}' + mock_response2 = '{"versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"policy":{"type":"access","description":"description","resource":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}],"tags":[{"key":"key","value":"value","operator":"stringEquals"}]},"subject":{"attributes":[{"key":"key","operator":"stringEquals","value":"anyValue"}]},"pattern":"pattern","rule":{"key":"key","operator":"stringEquals","value":"anyValue"},"control":{"grant":{"roles":[{"role_id":"role_id"}]}}},"state":"active","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"}],"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 = PolicyTemplateVersionsPager( + client=_service, + policy_template_id='testString', + state='active', + limit=10, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + class TestReplacePolicyTemplate: """ @@ -3936,7 +4293,7 @@ def test_list_policy_assignments_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": 11}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -3951,6 +4308,8 @@ def test_list_policy_assignments_all_params(self): accept_language = 'default' template_id = 'testString' template_version = 'testString' + limit = 50 + start = 'testString' # Invoke method response = _service.list_policy_assignments( @@ -3959,6 +4318,8 @@ def test_list_policy_assignments_all_params(self): accept_language=accept_language, template_id=template_id, template_version=template_version, + limit=limit, + start=start, headers={}, ) @@ -3972,6 +4333,8 @@ def test_list_policy_assignments_all_params(self): 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_policy_assignments_all_params_with_retries(self): # Enable retries and run test_list_policy_assignments_all_params. @@ -3989,7 +4352,7 @@ def test_list_policy_assignments_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": 11}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -4034,7 +4397,7 @@ def test_list_policy_assignments_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": 11}}}], "subject": {"id": "id", "type": "iam_id"}, "template": {"id": "id", "version": "version"}, "status": "in_progress"}]}' responses.add( responses.GET, url, @@ -4066,6 +4429,85 @@ def test_list_policy_assignments_value_error_with_retries(self): _service.disable_retries() self.test_list_policy_assignments_value_error() + @responses.activate + def test_list_policy_assignments_with_pager_get_next(self): + """ + test_list_policy_assignments_with_pager_get_next() + """ + # 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}' + 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 = PolicyAssignmentsPager( + client=_service, + version='1.0', + 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_policy_assignments_with_pager_get_all(self): + """ + test_list_policy_assignments_with_pager_get_all() + """ + # 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}' + 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 = PolicyAssignmentsPager( + client=_service, + version='1.0', + 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 TestCreatePolicyTemplateAssignment: """ @@ -4515,63 +4957,458 @@ def test_delete_policy_assignment_value_error_with_retries(self): # End of Service: PolicyAssignments ############################################################################## - ############################################################################## -# Start of Model Tests +# Start of Service: AccessManagementSettings ############################################################################## # region -class TestModel_AssignmentResourceCreated: +class TestNewInstance: """ - Test Class for AssignmentResourceCreated + Test Class for new_instance """ - def test_assignment_resource_created_serialization(self): + def test_new_instance(self): """ - Test serialization/deserialization for AssignmentResourceCreated + new_instance() """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' - # Construct a json representation of a AssignmentResourceCreated model - assignment_resource_created_model_json = {} - assignment_resource_created_model_json['id'] = 'testString' - - # Construct a model instance of AssignmentResourceCreated by calling from_dict on the json representation - assignment_resource_created_model = AssignmentResourceCreated.from_dict(assignment_resource_created_model_json) - assert assignment_resource_created_model != False - - # Construct a model instance of AssignmentResourceCreated by calling from_dict on the json representation - assignment_resource_created_model_dict = AssignmentResourceCreated.from_dict( - assignment_resource_created_model_json - ).__dict__ - assignment_resource_created_model2 = AssignmentResourceCreated(**assignment_resource_created_model_dict) + service = IamPolicyManagementV1.new_instance( + service_name='TEST_SERVICE', + ) - # Verify the model instances are equivalent - assert assignment_resource_created_model == assignment_resource_created_model2 + assert service is not None + assert isinstance(service, IamPolicyManagementV1) - # Convert model instance back to dict and verify no loss of data - assignment_resource_created_model_json2 = assignment_resource_created_model.to_dict() - assert assignment_resource_created_model_json2 == assignment_resource_created_model_json + 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 TestModel_AssignmentTargetDetails: +class TestGetSettings: """ - Test Class for AssignmentTargetDetails + Test Class for get_settings """ - def test_assignment_target_details_serialization(self): + @responses.activate + def test_get_settings_all_params(self): """ - Test serialization/deserialization for AssignmentTargetDetails + get_settings() """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) - # Construct a json representation of a AssignmentTargetDetails model - assignment_target_details_model_json = {} - assignment_target_details_model_json['type'] = 'Account' - assignment_target_details_model_json['id'] = 'testString' + # Set up parameter values + account_id = 'testString' + accept_language = 'default' - # Construct a model instance of AssignmentTargetDetails by calling from_dict on the json representation - assignment_target_details_model = AssignmentTargetDetails.from_dict(assignment_target_details_model_json) - assert assignment_target_details_model != False + # Invoke method + response = _service.get_settings( + account_id, + accept_language=accept_language, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_settings_all_params_with_retries(self): + # Enable retries and run test_get_settings_all_params. + _service.enable_retries() + self.test_get_settings_all_params() + + # Disable retries and run test_get_settings_all_params. + _service.disable_retries() + self.test_get_settings_all_params() + + @responses.activate + def test_get_settings_required_params(self): + """ + test_get_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + 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.get_settings( + account_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_settings_required_params_with_retries(self): + # Enable retries and run test_get_settings_required_params. + _service.enable_retries() + self.test_get_settings_required_params() + + # Disable retries and run test_get_settings_required_params. + _service.disable_retries() + self.test_get_settings_required_params() + + @responses.activate + def test_get_settings_value_error(self): + """ + test_get_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + 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.get_settings(**req_copy) + + def test_get_settings_value_error_with_retries(self): + # Enable retries and run test_get_settings_value_error. + _service.enable_retries() + self.test_get_settings_value_error() + + # Disable retries and run test_get_settings_value_error. + _service.disable_retries() + self.test_get_settings_value_error() + + +class TestUpdateSettings: + """ + Test Class for update_settings + """ + + @responses.activate + def test_update_settings_all_params(self): + """ + update_settings() + """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a IdentityTypesBase model + identity_types_base_model = {} + identity_types_base_model['state'] = 'enabled' + identity_types_base_model['external_allowed_accounts'] = ['testString'] + + # Construct a dict representation of a IdentityTypesPatch model + identity_types_patch_model = {} + identity_types_patch_model['user'] = identity_types_base_model + identity_types_patch_model['service_id'] = identity_types_base_model + identity_types_patch_model['service'] = identity_types_base_model + + # Construct a dict representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model = {} + external_account_identity_interaction_patch_model['identity_types'] = identity_types_patch_model + + # Set up parameter values + account_id = 'testString' + if_match = 'testString' + external_account_identity_interaction = external_account_identity_interaction_patch_model + accept_language = 'default' + + # Invoke method + response = _service.update_settings( + account_id, + if_match, + external_account_identity_interaction=external_account_identity_interaction, + accept_language=accept_language, + 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['external_account_identity_interaction'] == external_account_identity_interaction_patch_model + + def test_update_settings_all_params_with_retries(self): + # Enable retries and run test_update_settings_all_params. + _service.enable_retries() + self.test_update_settings_all_params() + + # Disable retries and run test_update_settings_all_params. + _service.disable_retries() + self.test_update_settings_all_params() + + @responses.activate + def test_update_settings_required_params(self): + """ + test_update_settings_required_params() + """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a IdentityTypesBase model + identity_types_base_model = {} + identity_types_base_model['state'] = 'enabled' + identity_types_base_model['external_allowed_accounts'] = ['testString'] + + # Construct a dict representation of a IdentityTypesPatch model + identity_types_patch_model = {} + identity_types_patch_model['user'] = identity_types_base_model + identity_types_patch_model['service_id'] = identity_types_base_model + identity_types_patch_model['service'] = identity_types_base_model + + # Construct a dict representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model = {} + external_account_identity_interaction_patch_model['identity_types'] = identity_types_patch_model + + # Set up parameter values + account_id = 'testString' + if_match = 'testString' + external_account_identity_interaction = external_account_identity_interaction_patch_model + + # Invoke method + response = _service.update_settings( + account_id, + if_match, + external_account_identity_interaction=external_account_identity_interaction, + 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['external_account_identity_interaction'] == external_account_identity_interaction_patch_model + + def test_update_settings_required_params_with_retries(self): + # Enable retries and run test_update_settings_required_params. + _service.enable_retries() + self.test_update_settings_required_params() + + # Disable retries and run test_update_settings_required_params. + _service.disable_retries() + self.test_update_settings_required_params() + + @responses.activate + def test_update_settings_value_error(self): + """ + test_update_settings_value_error() + """ + # Set up mock + url = preprocess_url('/v1/accounts/testString/settings/access_management') + mock_response = '{"external_account_identity_interaction": {"identity_types": {"user": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service_id": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}, "service": {"state": "enabled", "external_allowed_accounts": ["external_allowed_accounts"]}}}}' + responses.add( + responses.PATCH, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Construct a dict representation of a IdentityTypesBase model + identity_types_base_model = {} + identity_types_base_model['state'] = 'enabled' + identity_types_base_model['external_allowed_accounts'] = ['testString'] + + # Construct a dict representation of a IdentityTypesPatch model + identity_types_patch_model = {} + identity_types_patch_model['user'] = identity_types_base_model + identity_types_patch_model['service_id'] = identity_types_base_model + identity_types_patch_model['service'] = identity_types_base_model + + # Construct a dict representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model = {} + external_account_identity_interaction_patch_model['identity_types'] = identity_types_patch_model + + # Set up parameter values + account_id = 'testString' + if_match = 'testString' + external_account_identity_interaction = external_account_identity_interaction_patch_model + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "account_id": account_id, + "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.update_settings(**req_copy) + + def test_update_settings_value_error_with_retries(self): + # Enable retries and run test_update_settings_value_error. + _service.enable_retries() + self.test_update_settings_value_error() + + # Disable retries and run test_update_settings_value_error. + _service.disable_retries() + self.test_update_settings_value_error() + + +# endregion +############################################################################## +# End of Service: AccessManagementSettings +############################################################################## + + +############################################################################## +# 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_AssignmentResourceCreated: + """ + Test Class for AssignmentResourceCreated + """ + + def test_assignment_resource_created_serialization(self): + """ + Test serialization/deserialization for AssignmentResourceCreated + """ + + # Construct a json representation of a AssignmentResourceCreated model + assignment_resource_created_model_json = {} + assignment_resource_created_model_json['id'] = 'testString' + + # Construct a model instance of AssignmentResourceCreated by calling from_dict on the json representation + assignment_resource_created_model = AssignmentResourceCreated.from_dict(assignment_resource_created_model_json) + assert assignment_resource_created_model != False + + # Construct a model instance of AssignmentResourceCreated by calling from_dict on the json representation + assignment_resource_created_model_dict = AssignmentResourceCreated.from_dict( + assignment_resource_created_model_json + ).__dict__ + assignment_resource_created_model2 = AssignmentResourceCreated(**assignment_resource_created_model_dict) + + # Verify the model instances are equivalent + assert assignment_resource_created_model == assignment_resource_created_model2 + + # Convert model instance back to dict and verify no loss of data + assignment_resource_created_model_json2 = assignment_resource_created_model.to_dict() + assert assignment_resource_created_model_json2 == assignment_resource_created_model_json + + +class TestModel_AssignmentTargetDetails: + """ + Test Class for AssignmentTargetDetails + """ + + def test_assignment_target_details_serialization(self): + """ + Test serialization/deserialization for AssignmentTargetDetails + """ + + # Construct a json representation of a AssignmentTargetDetails model + assignment_target_details_model_json = {} + assignment_target_details_model_json['type'] = 'Account' + assignment_target_details_model_json['id'] = 'testString' + + # Construct a model instance of AssignmentTargetDetails by calling from_dict on the json representation + assignment_target_details_model = AssignmentTargetDetails.from_dict(assignment_target_details_model_json) + assert assignment_target_details_model != False # Construct a model instance of AssignmentTargetDetails by calling from_dict on the json representation assignment_target_details_model_dict = AssignmentTargetDetails.from_dict( @@ -4869,77 +5706,156 @@ def test_error_response_serialization(self): error_object_model['details'] = error_details_model error_object_model['more_info'] = 'testString' - # Construct a json representation of a ErrorResponse model - error_response_model_json = {} - error_response_model_json['trace'] = 'testString' - error_response_model_json['errors'] = [error_object_model] - error_response_model_json['status_code'] = 38 + # Construct a json representation of a ErrorResponse model + error_response_model_json = {} + error_response_model_json['trace'] = 'testString' + error_response_model_json['errors'] = [error_object_model] + error_response_model_json['status_code'] = 38 + + # Construct a model instance of ErrorResponse by calling from_dict on the json representation + error_response_model = ErrorResponse.from_dict(error_response_model_json) + assert error_response_model != False + + # Construct a model instance of ErrorResponse by calling from_dict on the json representation + error_response_model_dict = ErrorResponse.from_dict(error_response_model_json).__dict__ + error_response_model2 = ErrorResponse(**error_response_model_dict) + + # Verify the model instances are equivalent + assert error_response_model == error_response_model2 + + # Convert model instance back to dict and verify no loss of data + error_response_model_json2 = error_response_model.to_dict() + assert error_response_model_json2 == error_response_model_json + + +class TestModel_ExternalAccountIdentityInteraction: + """ + Test Class for ExternalAccountIdentityInteraction + """ + + def test_external_account_identity_interaction_serialization(self): + """ + Test serialization/deserialization for ExternalAccountIdentityInteraction + """ + + # 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 - # Construct a model instance of ErrorResponse by calling from_dict on the json representation - error_response_model = ErrorResponse.from_dict(error_response_model_json) - assert error_response_model != False + # Construct a json representation of a ExternalAccountIdentityInteraction model + external_account_identity_interaction_model_json = {} + external_account_identity_interaction_model_json['identity_types'] = identity_types_model - # Construct a model instance of ErrorResponse by calling from_dict on the json representation - error_response_model_dict = ErrorResponse.from_dict(error_response_model_json).__dict__ - error_response_model2 = ErrorResponse(**error_response_model_dict) + # Construct a model instance of ExternalAccountIdentityInteraction by calling from_dict on the json representation + external_account_identity_interaction_model = ExternalAccountIdentityInteraction.from_dict( + external_account_identity_interaction_model_json + ) + assert external_account_identity_interaction_model != False + + # Construct a model instance of ExternalAccountIdentityInteraction by calling from_dict on the json representation + external_account_identity_interaction_model_dict = ExternalAccountIdentityInteraction.from_dict( + external_account_identity_interaction_model_json + ).__dict__ + external_account_identity_interaction_model2 = ExternalAccountIdentityInteraction( + **external_account_identity_interaction_model_dict + ) # Verify the model instances are equivalent - assert error_response_model == error_response_model2 + assert external_account_identity_interaction_model == external_account_identity_interaction_model2 # Convert model instance back to dict and verify no loss of data - error_response_model_json2 = error_response_model.to_dict() - assert error_response_model_json2 == error_response_model_json + external_account_identity_interaction_model_json2 = external_account_identity_interaction_model.to_dict() + assert external_account_identity_interaction_model_json2 == external_account_identity_interaction_model_json -class TestModel_GetPolicyAssignmentResponsePolicyAssignmentV1Subject: +class TestModel_ExternalAccountIdentityInteractionPatch: """ - Test Class for GetPolicyAssignmentResponsePolicyAssignmentV1Subject + Test Class for ExternalAccountIdentityInteractionPatch """ - def test_get_policy_assignment_response_policy_assignment_v1_subject_serialization(self): + def test_external_account_identity_interaction_patch_serialization(self): """ - Test serialization/deserialization for GetPolicyAssignmentResponsePolicyAssignmentV1Subject + Test serialization/deserialization for ExternalAccountIdentityInteractionPatch """ - # Construct a json representation of a GetPolicyAssignmentResponsePolicyAssignmentV1Subject model - get_policy_assignment_response_policy_assignment_v1_subject_model_json = {} + # Construct dict forms of any model objects needed in order to build this model. - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignmentV1Subject by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_v1_subject_model = ( - GetPolicyAssignmentResponsePolicyAssignmentV1Subject.from_dict( - get_policy_assignment_response_policy_assignment_v1_subject_model_json - ) - ) - assert get_policy_assignment_response_policy_assignment_v1_subject_model != False + identity_types_base_model = {} # IdentityTypesBase + identity_types_base_model['state'] = 'enabled' + identity_types_base_model['external_allowed_accounts'] = ['testString'] - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignmentV1Subject by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_v1_subject_model_dict = ( - GetPolicyAssignmentResponsePolicyAssignmentV1Subject.from_dict( - get_policy_assignment_response_policy_assignment_v1_subject_model_json - ).__dict__ + identity_types_patch_model = {} # IdentityTypesPatch + identity_types_patch_model['user'] = identity_types_base_model + identity_types_patch_model['service_id'] = identity_types_base_model + identity_types_patch_model['service'] = identity_types_base_model + + # Construct a json representation of a ExternalAccountIdentityInteractionPatch model + external_account_identity_interaction_patch_model_json = {} + external_account_identity_interaction_patch_model_json['identity_types'] = identity_types_patch_model + + # Construct a model instance of ExternalAccountIdentityInteractionPatch by calling from_dict on the json representation + external_account_identity_interaction_patch_model = ExternalAccountIdentityInteractionPatch.from_dict( + external_account_identity_interaction_patch_model_json ) - get_policy_assignment_response_policy_assignment_v1_subject_model2 = ( - GetPolicyAssignmentResponsePolicyAssignmentV1Subject( - **get_policy_assignment_response_policy_assignment_v1_subject_model_dict - ) + assert external_account_identity_interaction_patch_model != False + + # Construct a model instance of ExternalAccountIdentityInteractionPatch by calling from_dict on the json representation + external_account_identity_interaction_patch_model_dict = ExternalAccountIdentityInteractionPatch.from_dict( + external_account_identity_interaction_patch_model_json + ).__dict__ + external_account_identity_interaction_patch_model2 = ExternalAccountIdentityInteractionPatch( + **external_account_identity_interaction_patch_model_dict ) # Verify the model instances are equivalent - assert ( - get_policy_assignment_response_policy_assignment_v1_subject_model - == get_policy_assignment_response_policy_assignment_v1_subject_model2 - ) + assert external_account_identity_interaction_patch_model == external_account_identity_interaction_patch_model2 # Convert model instance back to dict and verify no loss of data - get_policy_assignment_response_policy_assignment_v1_subject_model_json2 = ( - get_policy_assignment_response_policy_assignment_v1_subject_model.to_dict() + external_account_identity_interaction_patch_model_json2 = ( + external_account_identity_interaction_patch_model.to_dict() ) assert ( - get_policy_assignment_response_policy_assignment_v1_subject_model_json2 - == get_policy_assignment_response_policy_assignment_v1_subject_model_json + external_account_identity_interaction_patch_model_json2 + == external_account_identity_interaction_patch_model_json ) +class TestModel_First: + """ + Test Class for First + """ + + def test_first_serialization(self): + """ + Test serialization/deserialization for First + """ + + # Construct a json representation of a First model + first_model_json = {} + + # Construct a model instance of First by calling from_dict on the json representation + first_model = First.from_dict(first_model_json) + assert first_model != False + + # Construct a model instance of First by calling from_dict on the json representation + first_model_dict = First.from_dict(first_model_json).__dict__ + first_model2 = First(**first_model_dict) + + # Verify the model instances are equivalent + assert first_model == first_model2 + + # Convert model instance back to dict and verify no loss of data + first_model_json2 = first_model.to_dict() + assert first_model_json2 == first_model_json + + class TestModel_Grant: """ Test Class for Grant @@ -5018,6 +5934,113 @@ def test_grant_with_enriched_roles_serialization(self): assert grant_with_enriched_roles_model_json2 == grant_with_enriched_roles_model_json +class TestModel_IdentityTypes: + """ + Test Class for IdentityTypes + """ + + def test_identity_types_serialization(self): + """ + Test serialization/deserialization for IdentityTypes + """ + + # 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'] + + # Construct a json representation of a IdentityTypes model + identity_types_model_json = {} + identity_types_model_json['user'] = identity_types_base_model + identity_types_model_json['service_id'] = identity_types_base_model + identity_types_model_json['service'] = identity_types_base_model + + # Construct a model instance of IdentityTypes by calling from_dict on the json representation + identity_types_model = IdentityTypes.from_dict(identity_types_model_json) + assert identity_types_model != False + + # Construct a model instance of IdentityTypes by calling from_dict on the json representation + identity_types_model_dict = IdentityTypes.from_dict(identity_types_model_json).__dict__ + identity_types_model2 = IdentityTypes(**identity_types_model_dict) + + # Verify the model instances are equivalent + assert identity_types_model == identity_types_model2 + + # Convert model instance back to dict and verify no loss of data + identity_types_model_json2 = identity_types_model.to_dict() + assert identity_types_model_json2 == identity_types_model_json + + +class TestModel_IdentityTypesBase: + """ + Test Class for IdentityTypesBase + """ + + def test_identity_types_base_serialization(self): + """ + Test serialization/deserialization for IdentityTypesBase + """ + + # Construct a json representation of a IdentityTypesBase model + identity_types_base_model_json = {} + identity_types_base_model_json['state'] = 'enabled' + identity_types_base_model_json['external_allowed_accounts'] = ['testString'] + + # Construct a model instance of IdentityTypesBase by calling from_dict on the json representation + identity_types_base_model = IdentityTypesBase.from_dict(identity_types_base_model_json) + assert identity_types_base_model != False + + # Construct a model instance of IdentityTypesBase by calling from_dict on the json representation + identity_types_base_model_dict = IdentityTypesBase.from_dict(identity_types_base_model_json).__dict__ + identity_types_base_model2 = IdentityTypesBase(**identity_types_base_model_dict) + + # Verify the model instances are equivalent + assert identity_types_base_model == identity_types_base_model2 + + # Convert model instance back to dict and verify no loss of data + identity_types_base_model_json2 = identity_types_base_model.to_dict() + assert identity_types_base_model_json2 == identity_types_base_model_json + + +class TestModel_IdentityTypesPatch: + """ + Test Class for IdentityTypesPatch + """ + + def test_identity_types_patch_serialization(self): + """ + Test serialization/deserialization for IdentityTypesPatch + """ + + # 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'] + + # Construct a json representation of a IdentityTypesPatch model + identity_types_patch_model_json = {} + identity_types_patch_model_json['user'] = identity_types_base_model + identity_types_patch_model_json['service_id'] = identity_types_base_model + identity_types_patch_model_json['service'] = identity_types_base_model + + # Construct a model instance of IdentityTypesPatch by calling from_dict on the json representation + identity_types_patch_model = IdentityTypesPatch.from_dict(identity_types_patch_model_json) + assert identity_types_patch_model != False + + # Construct a model instance of IdentityTypesPatch by calling from_dict on the json representation + identity_types_patch_model_dict = IdentityTypesPatch.from_dict(identity_types_patch_model_json).__dict__ + identity_types_patch_model2 = IdentityTypesPatch(**identity_types_patch_model_dict) + + # Verify the model instances are equivalent + assert identity_types_patch_model == identity_types_patch_model2 + + # Convert model instance back to dict and verify no loss of data + identity_types_patch_model_json2 = identity_types_patch_model.to_dict() + assert identity_types_patch_model_json2 == identity_types_patch_model_json + + class TestModel_LimitData: """ Test Class for LimitData @@ -5047,6 +6070,36 @@ def test_limit_data_serialization(self): assert limit_data_model_json2 == limit_data_model_json +class TestModel_Next: + """ + Test Class for Next + """ + + def test_next_serialization(self): + """ + Test serialization/deserialization for Next + """ + + # Construct a json representation of a Next model + next_model_json = {} + next_model_json['start'] = 'testString' + + # Construct a model instance of Next by calling from_dict on the json representation + next_model = Next.from_dict(next_model_json) + assert next_model != False + + # Construct a model instance of Next by calling from_dict on the json representation + next_model_dict = Next.from_dict(next_model_json).__dict__ + next_model2 = Next(**next_model_dict) + + # Verify the model instances are equivalent + assert next_model == next_model2 + + # Convert model instance back to dict and verify no loss of data + next_model_json2 = next_model.to_dict() + assert next_model_json2 == next_model_json + + class TestModel_Policy: """ Test Class for Policy @@ -5508,6 +6561,14 @@ def test_policy_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' + subject_attribute_model = {} # SubjectAttribute subject_attribute_model['name'] = 'testString' subject_attribute_model['value'] = 'testString' @@ -5550,6 +6611,10 @@ def test_policy_collection_serialization(self): # Construct a json representation of a PolicyCollection model policy_collection_model_json = {} + policy_collection_model_json['limit'] = 1 + policy_collection_model_json['first'] = first_model + policy_collection_model_json['next'] = next_model + policy_collection_model_json['previous'] = previous_model policy_collection_model_json['policies'] = [policy_template_meta_data_model] # Construct a model instance of PolicyCollection by calling from_dict on the json representation @@ -5772,6 +6837,14 @@ def test_policy_template_assignment_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' @@ -5822,6 +6895,10 @@ def test_policy_template_assignment_collection_serialization(self): # Construct a json representation of a PolicyTemplateAssignmentCollection model policy_template_assignment_collection_model_json = {} + policy_template_assignment_collection_model_json['limit'] = 1 + policy_template_assignment_collection_model_json['first'] = first_model + policy_template_assignment_collection_model_json['next'] = next_model + policy_template_assignment_collection_model_json['previous'] = previous_model policy_template_assignment_collection_model_json['assignments'] = [policy_template_assignment_items_model] # Construct a model instance of PolicyTemplateAssignmentCollection by calling from_dict on the json representation @@ -5858,6 +6935,14 @@ def test_policy_template_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' + v2_policy_resource_attribute_model = {} # V2PolicyResourceAttribute v2_policy_resource_attribute_model['key'] = 'testString' v2_policy_resource_attribute_model['operator'] = 'stringEquals' @@ -5914,6 +6999,10 @@ def test_policy_template_collection_serialization(self): # Construct a json representation of a PolicyTemplateCollection model policy_template_collection_model_json = {} + policy_template_collection_model_json['limit'] = 1 + policy_template_collection_model_json['first'] = first_model + policy_template_collection_model_json['next'] = next_model + policy_template_collection_model_json['previous'] = previous_model policy_template_collection_model_json['policy_templates'] = [policy_template_model] # Construct a model instance of PolicyTemplateCollection by calling from_dict on the json representation @@ -6109,6 +7198,14 @@ def test_policy_template_versions_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' + v2_policy_resource_attribute_model = {} # V2PolicyResourceAttribute v2_policy_resource_attribute_model['key'] = 'testString' v2_policy_resource_attribute_model['operator'] = 'stringEquals' @@ -6165,6 +7262,10 @@ def test_policy_template_versions_collection_serialization(self): # Construct a json representation of a PolicyTemplateVersionsCollection model policy_template_versions_collection_model_json = {} + policy_template_versions_collection_model_json['limit'] = 1 + policy_template_versions_collection_model_json['first'] = first_model + policy_template_versions_collection_model_json['next'] = next_model + policy_template_versions_collection_model_json['previous'] = previous_model policy_template_versions_collection_model_json['versions'] = [policy_template_model] # Construct a model instance of PolicyTemplateVersionsCollection by calling from_dict on the json representation @@ -6189,6 +7290,36 @@ def test_policy_template_versions_collection_serialization(self): assert policy_template_versions_collection_model_json2 == policy_template_versions_collection_model_json +class TestModel_Previous: + """ + Test Class for Previous + """ + + def test_previous_serialization(self): + """ + Test serialization/deserialization for Previous + """ + + # Construct a json representation of a Previous model + previous_model_json = {} + previous_model_json['start'] = 'testString' + + # Construct a model instance of Previous by calling from_dict on the json representation + previous_model = Previous.from_dict(previous_model_json) + assert previous_model != False + + # Construct a model instance of Previous by calling from_dict on the json representation + previous_model_dict = Previous.from_dict(previous_model_json).__dict__ + previous_model2 = Previous(**previous_model_dict) + + # Verify the model instances are equivalent + assert previous_model == previous_model2 + + # Convert model instance back to dict and verify no loss of data + previous_model_json2 = previous_model.to_dict() + assert previous_model_json2 == previous_model_json + + class TestModel_ResourceAttribute: """ Test Class for ResourceAttribute @@ -6689,6 +7820,14 @@ def test_v2_policy_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' + v2_policy_subject_attribute_model = {} # V2PolicySubjectAttribute v2_policy_subject_attribute_model['key'] = 'testString' v2_policy_subject_attribute_model['operator'] = 'stringEquals' @@ -6747,6 +7886,10 @@ def test_v2_policy_collection_serialization(self): # Construct a json representation of a V2PolicyCollection model v2_policy_collection_model_json = {} + v2_policy_collection_model_json['limit'] = 1 + v2_policy_collection_model_json['first'] = first_model + v2_policy_collection_model_json['next'] = next_model + v2_policy_collection_model_json['previous'] = previous_model v2_policy_collection_model_json['policies'] = [v2_policy_template_meta_data_model] # Construct a model instance of V2PolicyCollection by calling from_dict on the json representation @@ -7129,192 +8272,6 @@ def test_control_response_control_with_enriched_roles_serialization(self): ) -class TestModel_GetPolicyAssignmentResponsePolicyAssignment: - """ - Test Class for GetPolicyAssignmentResponsePolicyAssignment - """ - - def test_get_policy_assignment_response_policy_assignment_serialization(self): - """ - Test serialization/deserialization for GetPolicyAssignmentResponsePolicyAssignment - """ - - # Construct dict forms of any model objects needed in order to build this model. - - assignment_resource_created_model = {} # AssignmentResourceCreated - 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'] = 38 - - policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy - policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model - policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model - - policy_assignment_resources_model = {} # PolicyAssignmentResources - policy_assignment_resources_model['target'] = 'testString' - policy_assignment_resources_model['policy'] = policy_assignment_resource_policy_model - - # Construct a json representation of a GetPolicyAssignmentResponsePolicyAssignment model - get_policy_assignment_response_policy_assignment_model_json = {} - get_policy_assignment_response_policy_assignment_model_json['template_id'] = 'testString' - get_policy_assignment_response_policy_assignment_model_json['template_version'] = 'testString' - get_policy_assignment_response_policy_assignment_model_json['assignment_id'] = 'testString' - get_policy_assignment_response_policy_assignment_model_json['target_type'] = 'Account' - get_policy_assignment_response_policy_assignment_model_json['target'] = 'testString' - get_policy_assignment_response_policy_assignment_model_json['resources'] = [policy_assignment_resources_model] - get_policy_assignment_response_policy_assignment_model_json['status'] = 'in_progress' - - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignment by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_model = GetPolicyAssignmentResponsePolicyAssignment.from_dict( - get_policy_assignment_response_policy_assignment_model_json - ) - assert get_policy_assignment_response_policy_assignment_model != False - - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignment by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_model_dict = ( - GetPolicyAssignmentResponsePolicyAssignment.from_dict( - get_policy_assignment_response_policy_assignment_model_json - ).__dict__ - ) - get_policy_assignment_response_policy_assignment_model2 = GetPolicyAssignmentResponsePolicyAssignment( - **get_policy_assignment_response_policy_assignment_model_dict - ) - - # Verify the model instances are equivalent - assert ( - get_policy_assignment_response_policy_assignment_model - == get_policy_assignment_response_policy_assignment_model2 - ) - - # Convert model instance back to dict and verify no loss of data - get_policy_assignment_response_policy_assignment_model_json2 = ( - get_policy_assignment_response_policy_assignment_model.to_dict() - ) - assert ( - get_policy_assignment_response_policy_assignment_model_json2 - == get_policy_assignment_response_policy_assignment_model_json - ) - - -class TestModel_GetPolicyAssignmentResponsePolicyAssignmentV1: - """ - Test Class for GetPolicyAssignmentResponsePolicyAssignmentV1 - """ - - def test_get_policy_assignment_response_policy_assignment_v1_serialization(self): - """ - Test serialization/deserialization for GetPolicyAssignmentResponsePolicyAssignmentV1 - """ - - # Construct dict forms of any model objects needed in order to build this model. - - assignment_target_details_model = {} # AssignmentTargetDetails - assignment_target_details_model['type'] = 'Account' - assignment_target_details_model['id'] = 'testString' - - assignment_resource_created_model = {} # AssignmentResourceCreated - 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'] = 38 - - policy_assignment_resource_policy_model = {} # PolicyAssignmentResourcePolicy - policy_assignment_resource_policy_model['resource_created'] = assignment_resource_created_model - policy_assignment_resource_policy_model['status'] = 'testString' - policy_assignment_resource_policy_model['error_message'] = error_response_model - - policy_assignment_v1_resources_model = {} # PolicyAssignmentV1Resources - policy_assignment_v1_resources_model['target'] = assignment_target_details_model - policy_assignment_v1_resources_model['policy'] = policy_assignment_resource_policy_model - - get_policy_assignment_response_policy_assignment_v1_subject_model = ( - {} - ) # GetPolicyAssignmentResponsePolicyAssignmentV1Subject - - assignment_template_details_model = {} # AssignmentTemplateDetails - assignment_template_details_model['id'] = 'testString' - assignment_template_details_model['version'] = 'testString' - - # Construct a json representation of a GetPolicyAssignmentResponsePolicyAssignmentV1 model - get_policy_assignment_response_policy_assignment_v1_model_json = {} - get_policy_assignment_response_policy_assignment_v1_model_json['target'] = assignment_target_details_model - get_policy_assignment_response_policy_assignment_v1_model_json['resources'] = [ - policy_assignment_v1_resources_model - ] - get_policy_assignment_response_policy_assignment_v1_model_json['subject'] = ( - get_policy_assignment_response_policy_assignment_v1_subject_model - ) - get_policy_assignment_response_policy_assignment_v1_model_json['template'] = assignment_template_details_model - get_policy_assignment_response_policy_assignment_v1_model_json['status'] = 'in_progress' - - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignmentV1 by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_v1_model = ( - GetPolicyAssignmentResponsePolicyAssignmentV1.from_dict( - get_policy_assignment_response_policy_assignment_v1_model_json - ) - ) - assert get_policy_assignment_response_policy_assignment_v1_model != False - - # Construct a model instance of GetPolicyAssignmentResponsePolicyAssignmentV1 by calling from_dict on the json representation - get_policy_assignment_response_policy_assignment_v1_model_dict = ( - GetPolicyAssignmentResponsePolicyAssignmentV1.from_dict( - get_policy_assignment_response_policy_assignment_v1_model_json - ).__dict__ - ) - get_policy_assignment_response_policy_assignment_v1_model2 = GetPolicyAssignmentResponsePolicyAssignmentV1( - **get_policy_assignment_response_policy_assignment_v1_model_dict - ) - - # Verify the model instances are equivalent - assert ( - get_policy_assignment_response_policy_assignment_v1_model - == get_policy_assignment_response_policy_assignment_v1_model2 - ) - - # Convert model instance back to dict and verify no loss of data - get_policy_assignment_response_policy_assignment_v1_model_json2 = ( - get_policy_assignment_response_policy_assignment_v1_model.to_dict() - ) - assert ( - get_policy_assignment_response_policy_assignment_v1_model_json2 - == get_policy_assignment_response_policy_assignment_v1_model_json - ) - - class TestModel_NestedConditionRuleAttribute: """ Test Class for NestedConditionRuleAttribute