From ad501b679c8618eb70976042457f4d3d0ee53da4 Mon Sep 17 00:00:00 2001 From: HARI K ARLA Date: Wed, 19 Jul 2023 21:16:38 +0530 Subject: [PATCH] feat (IAM Access Groups): Add support for access group templates Signed-off-by: HARI K ARLA --- .../test_iam_access_groups_v2_examples.py | 546 +- ibm_platform_services/iam_access_groups_v2.py | 6330 ++++++++++++++--- test/integration/test_iam_access_groups_v2.py | 459 +- test/unit/test_iam_access_groups_v2.py | 4276 ++++++++++- 4 files changed, 10339 insertions(+), 1272 deletions(-) diff --git a/examples/test_iam_access_groups_v2_examples.py b/examples/test_iam_access_groups_v2_examples.py index c7bce008..a5ef13eb 100644 --- a/examples/test_iam_access_groups_v2_examples.py +++ b/examples/test_iam_access_groups_v2_examples.py @@ -18,7 +18,9 @@ """ from ibm_cloud_sdk_core import ApiException, read_external_sources +from ibm_cloud_sdk_core.utils import datetime_to_string, string_to_datetime import os +import time import pytest from ibm_platform_services.iam_access_groups_v2 import * @@ -49,6 +51,13 @@ test_group_id = None test_claim_rule_id = None test_claim_rule_etag = None +test_policy_template_id = None +test_template_id = None +test_template_etag = None +test_template_latest_etag = None +test_account_group_id = None +test_assignment_id = None +test_assignment_etag = None ############################################################################## # Start of Examples for Service: IamAccessGroupsV2 @@ -73,10 +82,12 @@ def setup_class(cls): assert iam_access_groups_service is not None # Load the configuration - global config, test_account_id, test_profile_id + global config, test_account_id, test_profile_id, test_policy_template_id, test_account_group_id config = read_external_sources(IamAccessGroupsV2.DEFAULT_SERVICE_NAME) test_account_id = config['TEST_ACCOUNT_ID'] test_profile_id = config['TEST_PROFILE_ID'] + test_policy_template_id = config['TEST_POLICY_TEMPLATE_ID'] + test_account_group_id = config['TEST_ACCOUNT_GROUP_ID'] print('Setup complete.') @@ -511,6 +522,539 @@ def test_update_account_settings_example(self): except ApiException as e: pytest.fail(str(e)) + def test_create_template_example(self): + """ + create_template request example + """ + try: + print('\ncreate_template() result:') + # begin-create_template + + members_action_controls_model = { + 'add': True, + 'remove': False, + } + + members_input_model = { + 'users': ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + + rules_action_controls_model = { + 'remove': False, + 'update': False, + } + + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + 'action_controls': rules_action_controls_model, + } + + assertions_action_controls_model = { + 'add': False, + 'remove': True, + 'update': True, + } + + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + + access_action_controls_model = { + 'add': False, + } + + group_action_controls_model = { + 'access': access_action_controls_model, + } + + access_group_input_model = { + 'name': 'IAM Admin Group', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + + policy_templates_input_model = { + 'id': test_policy_template_id, + 'version': '1', + } + + response = iam_access_groups_service.create_template( + name='IAM Admin Group template', + account_id=test_account_id, + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + ) + create_template_response = response.get_result() + + print(json.dumps(create_template_response, indent=2)) + # end-create_template + + global test_template_id + test_template_id = create_template_response['id'] + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_list_templates_example(self): + """ + list_templates request example + """ + try: + print('\nlist_templates() result:') + # begin-list_templates + + all_results = [] + pager = TemplatesPager( + client=iam_access_groups_service, + account_id=test_account_id, + transaction_id='testString', + limit=50, + verbose=True, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_templates + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_template_version_example(self): + """ + create_template_version request example + """ + try: + print('\ncreate_template_version() result:') + # begin-create_template_version + + members_action_controls_model = { + 'add': True, + 'remove': False, + } + + members_input_model = { + 'users': ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + } + + assertions_action_controls_model = { + 'add': False, + } + + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + + access_action_controls_model = { + 'add': False, + } + + group_action_controls_model = { + 'access': access_action_controls_model, + } + + access_group_input_model = { + 'name': 'IAM Admin Group 8', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + + policy_templates_input_model = { + 'id': test_policy_template_id, + 'version': '1', + } + + response = iam_access_groups_service.create_template_version( + template_id=test_template_id, + name='IAM Admin Group template 2', + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + ) + create_template_version_response = response.get_result() + + print(json.dumps(create_template_version_response, indent=2)) + + # end-create_template_version + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_list_template_versions_example(self): + """ + list_template_versions request example + """ + try: + print('\nlist_template_versions() result:') + # begin-list_template_versions + + all_results = [] + pager = TemplateVersionsPager( + client=iam_access_groups_service, + template_id=test_template_id, + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + print(json.dumps(all_results, indent=2)) + + # end-list_template_versions + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_template_version_example(self): + """ + get_template_version request example + """ + try: + print('\nget_template_version() result:') + # begin-get_template_version + + response = iam_access_groups_service.get_template_version( + template_id=test_template_id, + version_num='1', + ) + get_template_version_response = response.get_result() + + print(json.dumps(get_template_version_response, indent=2)) + + # end-get_template_version + + global test_template_etag + test_template_etag = response.get_headers().get('ETag') + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_update_template_version_example(self): + """ + update_template_version request example + """ + try: + print('\nupdate_template_version() result:') + # begin-update_template_version + + members_action_controls_model = { + 'add': True, + 'remove': False, + } + + members_input_model = { + 'users': ['IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + + rules_action_controls_model = { + 'remove': False, + 'update': False, + } + + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + 'action_controls': rules_action_controls_model, + } + + assertions_action_controls_model = { + 'add': False, + } + + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + + access_action_controls_model = { + 'add': False, + } + + group_action_controls_model = { + 'access': access_action_controls_model, + } + + access_group_input_model = { + 'name': 'IAM Admin Group 8', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + + policy_templates_input_model = { + 'id': test_policy_template_id, + 'version': '1', + } + + response = iam_access_groups_service.update_template_version( + template_id=test_template_id, + version_num='1', + if_match=test_template_etag, + name='IAM Admin Group template 2', + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + transaction_id='83adf5bd-de790caa3', + ) + update_template_version_response = response.get_result() + + print(json.dumps(update_template_version_response, indent=2)) + + # end-update_template_version + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_latest_template_version_example(self): + """ + get_latest_template_version request example + """ + try: + print('\nget_latest_template_version() result:') + # begin-get_latest_template_version + + response = iam_access_groups_service.get_latest_template_version( + template_id=test_template_id, + ) + get_latest_template_response = response.get_result() + + print(json.dumps(get_latest_template_response, indent=2)) + + # end-get_latest_template_version + + global test_template_latest_etag + test_template_latest_etag = response.get_headers().get('ETag') + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_commit_template_example(self): + """ + commit_template request example + """ + try: + print('\ncommit_template() result:') + # begin-commit_template + + response = iam_access_groups_service.commit_template( + template_id=test_template_id, + version_num='2', + if_match=test_template_latest_etag, + ) + commit_template_response = response.get_result() + + print(json.dumps(commit_template_response, indent=2)) + + # end-commit_template + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_create_assignment_example(self): + """ + create_assignment request example + """ + try: + print('\ncreate_assignment() result:') + # begin-create_assignment + + response = iam_access_groups_service.create_assignment( + template_id=test_template_id, + template_version='2', + target_type='AccountGroup', + target=test_account_group_id, + ) + create_assignment_response = response.get_result() + + print(json.dumps(create_assignment_response, indent=2)) + + # end-create_assignment + global test_assignment_id + test_assignment_id = create_assignment_response['id'] + time.sleep(30) + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_list_assignments_example(self): + """ + list_assignments request example + """ + try: + print('\nlist_assignments() result:') + # begin-list_assignments + + response = iam_access_groups_service.list_assignments( + account_id=test_account_id, + ) + list_assignment_response = response.get_result() + + print(json.dumps(list_assignment_response, indent=2)) + + # end-list_assignments + time.sleep(30) + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_get_assignment_example(self): + """ + get_assignment request example + """ + try: + print('\nget_assignment() result:') + # begin-get_assignment + + response = iam_access_groups_service.get_assignment( + assignment_id=test_assignment_id, + ) + get_assignment_response = response.get_result() + + print(json.dumps(get_assignment_response, indent=2)) + + # end-get_assignment + + global test_assignment_etag + test_assignment_etag = response.get_headers().get('ETag') + + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_update_assignment_example(self): + """ + update_assignment request example + """ + try: + print('\nupdate_assignment() result:') + # begin-update_assignment + + response = iam_access_groups_service.update_assignment( + assignment_id=test_assignment_id, + template_version="2", + if_match=test_assignment_etag, + ) + update_assignment_response = response.get_result() + + print(json.dumps(update_assignment_response, indent=2)) + + # end-update_assignment + time.sleep(60) + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_delete_assignment_example(self): + """ + delete_assignment request example + """ + try: + print('\ndelete_assignment() result:') + # begin-delete_assignment + + response = iam_access_groups_service.delete_assignment( + assignment_id=test_assignment_id, + ) + delete_assignment_response = response.get_result() + + print(json.dumps(delete_assignment_response, indent=2)) + + # end-delete_assignment + time.sleep(90) + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_delete_template_version_example(self): + """ + delete_template_version request example + """ + try: + # begin-delete_template_version + + response = iam_access_groups_service.delete_template_version( + template_id=test_template_id, + version_num='2', + transaction_id='testString', + ) + + # end-delete_template_version + print('\ndelete_template_version() response status code: ', response.get_status_code()) + time.sleep(30) + except ApiException as e: + pytest.fail(str(e)) + + @needscredentials + def test_delete_template_example(self): + """ + delete_access_group request example + """ + try: + # begin-delete_template + + response = iam_access_groups_service.delete_template( + template_id=test_template_id, + transaction_id='testString', + ) + + # end-delete_template + print('\ndelete_template() response status code: ', response.get_status_code()) + + except ApiException as e: + pytest.fail(str(e)) + @needscredentials def test_delete_access_group_example(self): """ diff --git a/ibm_platform_services/iam_access_groups_v2.py b/ibm_platform_services/iam_access_groups_v2.py index 81fea45a..1719d15a 100644 --- a/ibm_platform_services/iam_access_groups_v2.py +++ b/ibm_platform_services/iam_access_groups_v2.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.70.0-7df966bf-20230419-195904 +# IBM OpenAPI SDK Code Generator Version: 3.74.0-89f1dbab-20230630-160213 """ The IAM Access Groups API allows for the management of access groups (Create, Read, @@ -100,9 +100,9 @@ def create_access_group( IAM ID is specified in iam_id then account_id must match the account of the IAM ID. If a user IAM ID is specified in iam_id then then account_id must match the account of the Authorization token. - :param str name: Assign the specified name to the access group. This field - is case-insensitive and has a limit of 100 characters. The group name has - to be unique within an account. + :param str name: Give the access group a unique name that doesn't conflict + with an existing access group in the account. This field is + case-insensitive and has a limit of 100 characters. :param str description: (optional) Assign an optional description for the access group. This field has a limit of 250 characters. :param str transaction_id: (optional) An optional transaction ID can be @@ -348,9 +348,9 @@ def update_access_group( :param str if_match: The current revision number of the group being updated. This can be found in the Create/Get access group response ETag header. - :param str name: (optional) Assign the specified name to the access group. - This field is case-insensitive and has a limit of 100 characters. The group - name has to be unique within an account. + :param str name: (optional) Give the access group a unique name that + doesn't conflict with an existing access group in the account. This field + is case-insensitive and has a limit of 100 characters. :param str description: (optional) Assign an optional description for the access group. This field has a limit of 250 characters. :param str transaction_id: (optional) An optional transaction ID can be @@ -632,9 +632,9 @@ def list_access_group_members( Transaction-Id and the value is anything that you choose. If no transaction ID is passed in, then a random ID is generated. :param str membership_type: (optional) Filters members by membership type. - Membership type can be either `static`, `dynamic` or `all`. `static` lists - those members explicitly added to the access group, `dynamic` lists those - members part of access group via dynamic rules at the moment. `all` lists + Filter by `static`, `dynamic` or `all`. `static` lists the members + explicitly added to the access group, and `dynamic` lists the members that + are part of the access group at that time via dynamic rules. `all` lists both static and dynamic members. :param int limit: (optional) Return up to this limit of results where limit is between 0 and 100. @@ -995,11 +995,13 @@ def add_access_group_rule( dynamic rules.](/docs/account?topic=account-rules). :param str access_group_id: The access group identifier. - :param int expiration: The number of hours that the rule lives for. - :param str realm_name: The url of the identity provider. - :param List[RuleConditions] conditions: A list of conditions the rule must - satisfy. - :param str name: (optional) The name of the rule. + :param int expiration: Session duration in hours. Access group membership + is revoked after this time period expires. Users must log back in to + refresh their access group membership. + :param str realm_name: The URL of the identity provider (IdP). + :param List[RuleConditions] conditions: A list of conditions that + identities must satisfy to gain access group membership. + :param str name: (optional) The name of the dynaimic rule. :param str transaction_id: (optional) An optional transaction ID can be passed to your request, which can be useful for tracking calls through multiple services by using one identifier. The header key must be set to @@ -1194,11 +1196,13 @@ def replace_access_group_rule( :param str rule_id: The rule to get. :param str if_match: The current revision number of the rule being updated. This can be found in the Get Rule response ETag header. - :param int expiration: The number of hours that the rule lives for. - :param str realm_name: The url of the identity provider. - :param List[RuleConditions] conditions: A list of conditions the rule must - satisfy. - :param str name: (optional) The name of the rule. + :param int expiration: Session duration in hours. Access group membership + is revoked after this time period expires. Users must log back in to + refresh their access group membership. + :param str realm_name: The URL of the identity provider (IdP). + :param List[RuleConditions] conditions: A list of conditions that + identities must satisfy to gain access group membership. + :param str name: (optional) The name of the dynaimic rule. :param str transaction_id: (optional) An optional transaction ID can be passed to your request, which can be useful for tracking calls through multiple services by using one identifier. The header key must be set to @@ -1457,222 +1461,3511 @@ def update_account_settings( response = self.send(request, **kwargs) return response + ######################### + # Template operations + ######################### -############################################################################## -# Models -############################################################################## - - -class AccountSettings: - """ - The access groups settings for a specific account. - - :attr str account_id: (optional) The account id of the settings being shown. - :attr datetime last_modified_at: (optional) The timestamp the settings were last - edited at. - :attr str last_modified_by_id: (optional) The `iam_id` of the entity that last - modified the settings. - :attr bool public_access_enabled: (optional) This flag controls the public - access feature within the account. It is set to true by default. Note: When this - flag is set to false, all policies within the account attached to the Public - Access group will be deleted. - """ - - def __init__( + def create_template( self, + name: str, + account_id: str, *, - account_id: str = None, - last_modified_at: datetime = None, - last_modified_by_id: str = None, - public_access_enabled: bool = None, - ) -> None: - """ - Initialize a AccountSettings object. - - :param str account_id: (optional) The account id of the settings being - shown. - :param datetime last_modified_at: (optional) The timestamp the settings - were last edited at. - :param str last_modified_by_id: (optional) The `iam_id` of the entity that - last modified the settings. - :param bool public_access_enabled: (optional) This flag controls the public - access feature within the account. It is set to true by default. Note: When - this flag is set to false, all policies within the account attached to the - Public Access group will be deleted. + description: str = None, + group: 'AccessGroupRequest' = None, + policy_template_references: List['PolicyTemplates'] = None, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: """ - self.account_id = account_id - self.last_modified_at = last_modified_at - self.last_modified_by_id = last_modified_by_id - self.public_access_enabled = public_access_enabled - - @classmethod - def from_dict(cls, _dict: Dict) -> 'AccountSettings': - """Initialize a AccountSettings object from a json dictionary.""" - args = {} - if 'account_id' in _dict: - args['account_id'] = _dict.get('account_id') - if 'last_modified_at' in _dict: - args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) - if 'last_modified_by_id' in _dict: - args['last_modified_by_id'] = _dict.get('last_modified_by_id') - if 'public_access_enabled' in _dict: - args['public_access_enabled'] = _dict.get('public_access_enabled') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a AccountSettings 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, 'account_id') and self.account_id is not None: - _dict['account_id'] = self.account_id - if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: - _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) - if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: - _dict['last_modified_by_id'] = self.last_modified_by_id - if hasattr(self, 'public_access_enabled') and self.public_access_enabled is not None: - _dict['public_access_enabled'] = self.public_access_enabled - return _dict + Create template. - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() + Create an access group template. Make sure that the template is generic enough to + apply to multiple different child accounts. Before you can assign an access group + template to child accounts, you must commit it so that no further changes can be + made to the version. - def __str__(self) -> str: - """Return a `str` version of this AccountSettings object.""" - return json.dumps(self.to_dict(), indent=2) + :param str name: Give the access group template a unique name that doesn't + conflict with an existing access group templates in the account. + :param str account_id: Enterprise account id in which the template will be + created. + :param str description: (optional) Assign an optional description for the + access group template. + :param AccessGroupRequest group: (optional) Access Group Component. + :param List[PolicyTemplates] policy_template_references: (optional) + Existing policy templates that you can reference to assign access in the + Access group input component. + :param str transaction_id: (optional) An optional transaction id for the + request. + :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 `TemplateResponse` object + """ - def __eq__(self, other: 'AccountSettings') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ + if name is None: + raise ValueError('name must be provided') + if account_id is None: + raise ValueError('account_id must be provided') + if group is not None: + group = convert_model(group) + if policy_template_references is not None: + policy_template_references = [convert_model(x) for x in policy_template_references] + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_template', + ) + headers.update(sdk_headers) - def __ne__(self, other: 'AccountSettings') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other + data = { + 'name': name, + 'account_id': account_id, + 'description': description, + 'group': group, + 'policy_template_references': policy_template_references, + } + 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' -class AddGroupMembersRequestMembersItem: - """ - AddGroupMembersRequestMembersItem. + url = '/v1/group_templates' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) - :attr str iam_id: The IBMid, service ID or trusted profile ID of the member. - :attr str type: The type of the member, must be either "user", "service" or - "profile". - """ + response = self.send(request, **kwargs) + return response - def __init__( + def list_templates( self, - iam_id: str, - type: str, - ) -> None: - """ - Initialize a AddGroupMembersRequestMembersItem object. - - :param str iam_id: The IBMid, service ID or trusted profile ID of the - member. - :param str type: The type of the member, must be either "user", "service" - or "profile". + account_id: str, + *, + transaction_id: str = None, + limit: int = None, + offset: int = None, + verbose: bool = None, + **kwargs, + ) -> DetailedResponse: """ - self.iam_id = iam_id - self.type = type - - @classmethod - def from_dict(cls, _dict: Dict) -> 'AddGroupMembersRequestMembersItem': - """Initialize a AddGroupMembersRequestMembersItem object from a json dictionary.""" - args = {} - if 'iam_id' in _dict: - args['iam_id'] = _dict.get('iam_id') - else: - raise ValueError('Required property \'iam_id\' not present in AddGroupMembersRequestMembersItem JSON') - if 'type' in _dict: - args['type'] = _dict.get('type') - else: - raise ValueError('Required property \'type\' not present in AddGroupMembersRequestMembersItem JSON') - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a AddGroupMembersRequestMembersItem 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - return _dict + List templates. - def _to_dict(self): - """Return a json dictionary representing this model.""" - return self.to_dict() + List the access group templates in an enterprise account. - def __str__(self) -> str: - """Return a `str` version of this AddGroupMembersRequestMembersItem object.""" - return json.dumps(self.to_dict(), indent=2) + :param str account_id: Enterprise account ID. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param int limit: (optional) Return up to this limit of results where limit + is between 0 and 100. + :param int offset: (optional) The offset of the first result item to be + returned. + :param bool verbose: (optional) If `verbose=true`, IAM resource details are + returned. If performance is a concern, leave the `verbose` parameter off so + that details are not retrieved. + :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 `ListTemplatesResponse` object + """ - def __eq__(self, other: 'AddGroupMembersRequestMembersItem') -> bool: - """Return `true` when self and other are equal, false otherwise.""" - if not isinstance(other, self.__class__): - return False - return self.__dict__ == other.__dict__ + if not account_id: + raise ValueError('account_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_templates', + ) + headers.update(sdk_headers) - def __ne__(self, other: 'AddGroupMembersRequestMembersItem') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other + params = { + 'account_id': account_id, + 'limit': limit, + 'offset': offset, + 'verbose': verbose, + } + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' -class AddGroupMembersResponse: - """ - The members added to an access group. + url = '/v1/group_templates' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) - :attr List[AddGroupMembersResponseMembersItem] members: (optional) The members - added to an access group. - """ + response = self.send(request, **kwargs) + return response - def __init__( + def create_template_version( self, + template_id: str, *, - members: List['AddGroupMembersResponseMembersItem'] = None, - ) -> None: + name: str = None, + description: str = None, + group: 'AccessGroupRequest' = None, + policy_template_references: List['PolicyTemplates'] = None, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: """ - Initialize a AddGroupMembersResponse object. + Create template version. - :param List[AddGroupMembersResponseMembersItem] members: (optional) The + Create a new version of an access group template. + + :param str template_id: ID of the template that you want to create a new + version of. + :param str name: (optional) This is an optional field. If the field is + included it will change the name value for all existing versions of the + template.. + :param str description: (optional) Assign an optional description for the + access group template version. + :param AccessGroupRequest group: (optional) Access Group Component. + :param List[PolicyTemplates] policy_template_references: (optional) The + policy templates associated with the template version. + :param str transaction_id: (optional) An optional transaction id for the + request. + :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 `TemplateVersionResponse` object + """ + + if not template_id: + raise ValueError('template_id must be provided') + if group is not None: + group = convert_model(group) + if policy_template_references is not None: + policy_template_references = [convert_model(x) for x in policy_template_references] + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_template_version', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'description': description, + 'group': group, + 'policy_template_references': policy_template_references, + } + 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 = ['template_id'] + path_param_values = self.encode_path_vars(template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def list_template_versions( + self, + template_id: str, + *, + limit: int = None, + offset: int = None, + **kwargs, + ) -> DetailedResponse: + """ + List template versions. + + List all the versions of an access group template. + + :param str template_id: ID of the template that you want to list all + versions of. + :param int limit: (optional) Return up to this limit of results where limit + is between 0 and 100. + :param int offset: (optional) The offset of the first result item to be + returned. + :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 `ListTemplateVersionsResponse` object + """ + + if not template_id: + raise ValueError('template_id must be provided') + headers = {} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_template_versions', + ) + headers.update(sdk_headers) + + params = { + 'limit': limit, + 'offset': offset, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['template_id'] + path_param_values = self.encode_path_vars(template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def get_template_version( + self, + template_id: str, + version_num: str, + *, + verbose: bool = None, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Get template version. + + Get a specific version of a template. + + :param str template_id: ID of the template to get a specific version of. + :param str version_num: Version number. + :param bool verbose: (optional) If `verbose=true`, IAM resource details are + returned. If performance is a concern, leave the `verbose` parameter off so + that details are not retrieved. + :param str transaction_id: (optional) An optional transaction id for the + request. + :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 `TemplateVersionResponse` object + """ + + if not template_id: + raise ValueError('template_id must be provided') + if not version_num: + raise ValueError('version_num must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_template_version', + ) + headers.update(sdk_headers) + + params = { + 'verbose': verbose, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['template_id', 'version_num'] + path_param_values = self.encode_path_vars(template_id, version_num) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions/{version_num}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def update_template_version( + self, + template_id: str, + version_num: str, + if_match: str, + *, + name: str = None, + description: str = None, + group: 'AccessGroupRequest' = None, + policy_template_references: List['PolicyTemplates'] = None, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Update template version. + + Update a template version. You can only update a version that isn't committed. + Create a new version if you need to update a committed version. + + :param str template_id: ID of the template. + :param str version_num: Version number of the template. + :param str if_match: ETag value of the template version document. + :param str name: (optional) This is an optional field. If the field is + included it will change the name value for all existing versions of the + template.. + :param str description: (optional) Assign an optional description for the + access group template version. + :param AccessGroupRequest group: (optional) Access Group Component. + :param List[PolicyTemplates] policy_template_references: (optional) The + policy templates associated with the template version. + :param str transaction_id: (optional) transaction id in header. + :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 `TemplateVersionResponse` object + """ + + if not template_id: + raise ValueError('template_id must be provided') + if not version_num: + raise ValueError('version_num must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if group is not None: + group = convert_model(group) + if policy_template_references is not None: + policy_template_references = [convert_model(x) for x in policy_template_references] + headers = { + 'If-Match': if_match, + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_template_version', + ) + headers.update(sdk_headers) + + data = { + 'name': name, + 'description': description, + 'group': group, + 'policy_template_references': policy_template_references, + } + 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 = ['template_id', 'version_num'] + path_param_values = self.encode_path_vars(template_id, version_num) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions/{version_num}'.format(**path_param_dict) + request = self.prepare_request( + method='PUT', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_template_version( + self, + template_id: str, + version_num: str, + *, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Delete template version. + + Delete a template version. You must remove all assignments for a template version + before you can delete it. + + :param str template_id: ID of the template to delete. + :param str version_num: version number in path. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not template_id: + raise ValueError('template_id must be provided') + if not version_num: + raise ValueError('version_num must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_template_version', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['template_id', 'version_num'] + path_param_values = self.encode_path_vars(template_id, version_num) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions/{version_num}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def commit_template( + self, + template_id: str, + version_num: str, + if_match: str, + *, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Commit a template. + + Commit a template version. You must do this before you can assign a template + version to child accounts. After you commit the template version, you can't make + any further changes. + + :param str template_id: ID of the template to commit. + :param str version_num: version number in path. + :param str if_match: ETag value of the template version document. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not template_id: + raise ValueError('template_id must be provided') + if not version_num: + raise ValueError('version_num must be provided') + if not if_match: + raise ValueError('if_match must be provided') + headers = { + 'If-Match': if_match, + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='commit_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['template_id', 'version_num'] + path_param_values = self.encode_path_vars(template_id, version_num) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}/versions/{version_num}/commit'.format(**path_param_dict) + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + def get_latest_template_version( + self, + template_id: str, + *, + verbose: bool = None, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Get latest template version. + + Get the latest version of a template. + + :param str template_id: ID of the template to get a specific version of. + :param bool verbose: (optional) If `verbose=true`, IAM resource details are + returned. If performance is a concern, leave the `verbose` parameter off so + that details are not retrieved. + :param str transaction_id: (optional) An optional transaction id for the + request. + :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 `TemplateVersionResponse` object + """ + + if not template_id: + raise ValueError('template_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_latest_template_version', + ) + headers.update(sdk_headers) + + params = { + 'verbose': verbose, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['template_id'] + path_param_values = self.encode_path_vars(template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def delete_template( + self, + template_id: str, + *, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Delete template. + + Endpoint to delete a template. All access assigned by that template is deleted + from all of the accounts where the template was assigned. + + :param str template_id: template id parameter. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not template_id: + raise ValueError('template_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_template', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['template_id'] + path_param_values = self.encode_path_vars(template_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_templates/{template_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + ######################### + # Template assignment operations + ######################### + + def create_assignment( + self, + template_id: str, + template_version: str, + target_type: str, + target: str, + *, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Create assignment. + + Assign a template version to accounts that have enabled enterprise-managed IAM. + You can specify individual accounts, or an entire account group to assign the + template to all current and future child accounts of that account group. + + :param str template_id: The unique identifier of the template to be + assigned. + :param str template_version: The version number of the template to be + assigned. + :param str target_type: The type of the entity to which the template should + be assigned, e.g. 'Account', 'AccountGroup', etc. + :param str target: The unique identifier of the entity to which the + template should be assigned. + :param str transaction_id: (optional) An optional transaction id for the + request. + :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 `TemplateAssignmentResponse` object + """ + + if template_id is None: + raise ValueError('template_id must be provided') + if template_version is None: + raise ValueError('template_version must be provided') + if target_type is None: + raise ValueError('target_type must be provided') + if target is None: + raise ValueError('target must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='create_assignment', + ) + headers.update(sdk_headers) + + data = { + 'template_id': template_id, + 'template_version': template_version, + 'target_type': target_type, + 'target': target, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/group_assignments' + request = self.prepare_request( + method='POST', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def list_assignments( + self, + account_id: str, + *, + template_id: str = None, + template_version: str = None, + target: str = None, + status: str = None, + transaction_id: str = None, + limit: int = None, + offset: int = None, + **kwargs, + ) -> DetailedResponse: + """ + List assignments. + + List template assignments from an enterprise account. + + :param str account_id: Enterprise account ID. + :param str template_id: (optional) Filter results by Template Id. + :param str template_version: (optional) Filter results by Template Version. + :param str target: (optional) Filter results by the assignment target. + :param str status: (optional) Filter results by the assignment status. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param int limit: (optional) Return up to this limit of results where limit + is between 0 and 100. + :param int offset: (optional) The offset of the first result item to be + returned. + :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 `ListTemplateAssignmentResponse` object + """ + + if not account_id: + raise ValueError('account_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_assignments', + ) + headers.update(sdk_headers) + + params = { + 'account_id': account_id, + 'template_id': template_id, + 'template_version': template_version, + 'target': target, + 'status': status, + 'limit': limit, + 'offset': offset, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + url = '/v1/group_assignments' + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def get_assignment( + self, + assignment_id: str, + *, + transaction_id: str = None, + verbose: bool = None, + **kwargs, + ) -> DetailedResponse: + """ + Get assignment. + + Get a specific template assignment. + + :param str assignment_id: Assignment ID. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param bool verbose: (optional) Returns resources access group template + assigned, possible values `true` or `false`. + :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 `TemplateAssignmentVerboseResponse` object + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='get_assignment', + ) + headers.update(sdk_headers) + + params = { + 'verbose': verbose, + } + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='GET', + url=url, + headers=headers, + params=params, + ) + + response = self.send(request, **kwargs) + return response + + def update_assignment( + self, + assignment_id: str, + if_match: str, + template_version: str, + **kwargs, + ) -> DetailedResponse: + """ + Update Assignment. + + Endpoint to update template assignment. + + :param str assignment_id: ID of the Assignment Record. + :param str if_match: Version of the Assignment to be updated. Specify the + version that you retrieved when reading the Assignment. This value helps + identifying parallel usage of this API. Pass * to indicate to update any + version available. This might result in stale updates. + :param str template_version: Template version which shall be applied to the + assignment. + :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 `TemplateAssignmentVerboseResponse` object + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + if not if_match: + raise ValueError('if_match must be provided') + if template_version is None: + raise ValueError('template_version must be provided') + headers = { + 'If-Match': if_match, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='update_assignment', + ) + headers.update(sdk_headers) + + data = { + 'template_version': template_version, + } + data = {k: v for (k, v) in data.items() if v is not None} + data = json.dumps(data) + headers['content-type'] = 'application/json' + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + headers['Accept'] = 'application/json' + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='PATCH', + url=url, + headers=headers, + data=data, + ) + + response = self.send(request, **kwargs) + return response + + def delete_assignment( + self, + assignment_id: str, + *, + transaction_id: str = None, + **kwargs, + ) -> DetailedResponse: + """ + Delete assignment. + + Delete an access group template assignment. + + :param str assignment_id: assignment id path parameter. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param dict headers: A `dict` containing the request headers + :return: A `DetailedResponse` containing the result, headers and HTTP status code. + :rtype: DetailedResponse + """ + + if not assignment_id: + raise ValueError('assignment_id must be provided') + headers = { + 'Transaction-Id': transaction_id, + } + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='delete_assignment', + ) + headers.update(sdk_headers) + + if 'headers' in kwargs: + headers.update(kwargs.get('headers')) + del kwargs['headers'] + + path_param_keys = ['assignment_id'] + path_param_values = self.encode_path_vars(assignment_id) + path_param_dict = dict(zip(path_param_keys, path_param_values)) + url = '/v1/group_assignments/{assignment_id}'.format(**path_param_dict) + request = self.prepare_request( + method='DELETE', + url=url, + headers=headers, + ) + + response = self.send(request, **kwargs) + return response + + +class ListAssignmentsEnums: + """ + Enums for list_assignments parameters. + """ + + class Status(str, Enum): + """ + Filter results by the assignment status. + """ + + ACCEPTED = 'accepted' + IN_PROGRESS = 'in_progress' + SUCCEEDED = 'succeeded' + FAILED = 'failed' + + +############################################################################## +# Models +############################################################################## + + +class AccessActionControls: + """ + Control whether or not access group administrators in child accounts can add access + policies to the enterprise-managed access group in their account. + + :attr bool add: (optional) Action control for adding access policies to an + enterprise-managed access group in a child account. If an access group + administrator in a child account adds a policy, they can always update or remove + it. + """ + + def __init__( + self, + *, + add: bool = None, + ) -> None: + """ + Initialize a AccessActionControls object. + + :param bool add: (optional) Action control for adding access policies to an + enterprise-managed access group in a child account. If an access group + administrator in a child account adds a policy, they can always update or + remove it. + """ + self.add = add + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessActionControls': + """Initialize a AccessActionControls object from a json dictionary.""" + args = {} + if 'add' in _dict: + args['add'] = _dict.get('add') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessActionControls 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, 'add') and self.add is not None: + _dict['add'] = self.add + 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 AccessActionControls object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessActionControls') -> 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: 'AccessActionControls') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessGroupRequest: + """ + Access Group Component. + + :attr str name: Give the access group a unique name that doesn't conflict with + other templates access group name in the given account. This is shown in child + accounts. + :attr str description: (optional) Access group description. This is shown in + child accounts. + :attr Members members: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited to + the child accounts where the template is assigned. + :attr Assertions assertions: (optional) Assertions Input Component. + :attr GroupActionControls action_controls: (optional) Access group action + controls component. + """ + + def __init__( + self, + name: str, + *, + description: str = None, + members: 'Members' = None, + assertions: 'Assertions' = None, + action_controls: 'GroupActionControls' = None, + ) -> None: + """ + Initialize a AccessGroupRequest object. + + :param str name: Give the access group a unique name that doesn't conflict + with other templates access group name in the given account. This is shown + in child accounts. + :param str description: (optional) Access group description. This is shown + in child accounts. + :param Members members: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited + to the child accounts where the template is assigned. + :param Assertions assertions: (optional) Assertions Input Component. + :param GroupActionControls action_controls: (optional) Access group action + controls component. + """ + self.name = name + self.description = description + self.members = members + self.assertions = assertions + self.action_controls = action_controls + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessGroupRequest': + """Initialize a AccessGroupRequest object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in AccessGroupRequest JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + if 'members' in _dict: + args['members'] = Members.from_dict(_dict.get('members')) + if 'assertions' in _dict: + args['assertions'] = Assertions.from_dict(_dict.get('assertions')) + if 'action_controls' in _dict: + args['action_controls'] = GroupActionControls.from_dict(_dict.get('action_controls')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessGroupRequest 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, 'members') and self.members is not None: + if isinstance(self.members, dict): + _dict['members'] = self.members + else: + _dict['members'] = self.members.to_dict() + if hasattr(self, 'assertions') and self.assertions is not None: + if isinstance(self.assertions, dict): + _dict['assertions'] = self.assertions + else: + _dict['assertions'] = self.assertions.to_dict() + if hasattr(self, 'action_controls') and self.action_controls is not None: + if isinstance(self.action_controls, dict): + _dict['action_controls'] = self.action_controls + else: + _dict['action_controls'] = self.action_controls.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 AccessGroupRequest object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessGroupRequest') -> 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: 'AccessGroupRequest') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccessGroupResponse: + """ + Access Group Component. + + :attr str name: Give the access group a unique name that doesn't conflict with + other templates access group name in the given account. This is shown in child + accounts. + :attr str description: (optional) Access group description. This is shown in + child accounts. + :attr Members members: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited to + the child accounts where the template is assigned. + :attr Assertions assertions: (optional) Assertions Input Component. + :attr GroupActionControls action_controls: (optional) Access group action + controls component. + """ + + def __init__( + self, + name: str, + *, + description: str = None, + members: 'Members' = None, + assertions: 'Assertions' = None, + action_controls: 'GroupActionControls' = None, + ) -> None: + """ + Initialize a AccessGroupResponse object. + + :param str name: Give the access group a unique name that doesn't conflict + with other templates access group name in the given account. This is shown + in child accounts. + :param str description: (optional) Access group description. This is shown + in child accounts. + :param Members members: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited + to the child accounts where the template is assigned. + :param Assertions assertions: (optional) Assertions Input Component. + :param GroupActionControls action_controls: (optional) Access group action + controls component. + """ + self.name = name + self.description = description + self.members = members + self.assertions = assertions + self.action_controls = action_controls + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccessGroupResponse': + """Initialize a AccessGroupResponse object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in AccessGroupResponse JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + if 'members' in _dict: + args['members'] = Members.from_dict(_dict.get('members')) + if 'assertions' in _dict: + args['assertions'] = Assertions.from_dict(_dict.get('assertions')) + if 'action_controls' in _dict: + args['action_controls'] = GroupActionControls.from_dict(_dict.get('action_controls')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccessGroupResponse 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, 'members') and self.members is not None: + if isinstance(self.members, dict): + _dict['members'] = self.members + else: + _dict['members'] = self.members.to_dict() + if hasattr(self, 'assertions') and self.assertions is not None: + if isinstance(self.assertions, dict): + _dict['assertions'] = self.assertions + else: + _dict['assertions'] = self.assertions.to_dict() + if hasattr(self, 'action_controls') and self.action_controls is not None: + if isinstance(self.action_controls, dict): + _dict['action_controls'] = self.action_controls + else: + _dict['action_controls'] = self.action_controls.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 AccessGroupResponse object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccessGroupResponse') -> 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: 'AccessGroupResponse') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AccountSettings: + """ + The access groups settings for a specific account. + + :attr str account_id: (optional) The account id of the settings being shown. + :attr datetime last_modified_at: (optional) The timestamp the settings were last + edited at. + :attr str last_modified_by_id: (optional) The `iam_id` of the entity that last + modified the settings. + :attr bool public_access_enabled: (optional) This flag controls the public + access feature within the account. It is set to true by default. Note: When this + flag is set to false, all policies within the account attached to the Public + Access group will be deleted. + """ + + def __init__( + self, + *, + account_id: str = None, + last_modified_at: datetime = None, + last_modified_by_id: str = None, + public_access_enabled: bool = None, + ) -> None: + """ + Initialize a AccountSettings object. + + :param str account_id: (optional) The account id of the settings being + shown. + :param datetime last_modified_at: (optional) The timestamp the settings + were last edited at. + :param str last_modified_by_id: (optional) The `iam_id` of the entity that + last modified the settings. + :param bool public_access_enabled: (optional) This flag controls the public + access feature within the account. It is set to true by default. Note: When + this flag is set to false, all policies within the account attached to the + Public Access group will be deleted. + """ + self.account_id = account_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.public_access_enabled = public_access_enabled + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AccountSettings': + """Initialize a AccountSettings object from a json dictionary.""" + args = {} + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + if 'public_access_enabled' in _dict: + args['public_access_enabled'] = _dict.get('public_access_enabled') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AccountSettings 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, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id + if hasattr(self, 'public_access_enabled') and self.public_access_enabled is not None: + _dict['public_access_enabled'] = self.public_access_enabled + 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 AccountSettings object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AccountSettings') -> 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: 'AccountSettings') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AddGroupMembersRequestMembersItem: + """ + AddGroupMembersRequestMembersItem. + + :attr str iam_id: The IBMid, service ID or trusted profile ID of the member. + :attr str type: The type of the member, must be either "user", "service" or + "profile". + """ + + def __init__( + self, + iam_id: str, + type: str, + ) -> None: + """ + Initialize a AddGroupMembersRequestMembersItem object. + + :param str iam_id: The IBMid, service ID or trusted profile ID of the + member. + :param str type: The type of the member, must be either "user", "service" + or "profile". + """ + self.iam_id = iam_id + self.type = type + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AddGroupMembersRequestMembersItem': + """Initialize a AddGroupMembersRequestMembersItem object from a json dictionary.""" + args = {} + if 'iam_id' in _dict: + args['iam_id'] = _dict.get('iam_id') + else: + raise ValueError('Required property \'iam_id\' not present in AddGroupMembersRequestMembersItem JSON') + if 'type' in _dict: + args['type'] = _dict.get('type') + else: + raise ValueError('Required property \'type\' not present in AddGroupMembersRequestMembersItem JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AddGroupMembersRequestMembersItem 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + 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 AddGroupMembersRequestMembersItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AddGroupMembersRequestMembersItem') -> 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: 'AddGroupMembersRequestMembersItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AddGroupMembersResponse: + """ + The members added to an access group. + + :attr List[AddGroupMembersResponseMembersItem] members: (optional) The members + added to an access group. + """ + + def __init__( + self, + *, + members: List['AddGroupMembersResponseMembersItem'] = None, + ) -> None: + """ + Initialize a AddGroupMembersResponse object. + + :param List[AddGroupMembersResponseMembersItem] members: (optional) The members added to an access group. """ - self.members = members + self.members = members + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AddGroupMembersResponse': + """Initialize a AddGroupMembersResponse object from a json dictionary.""" + args = {} + if 'members' in _dict: + args['members'] = [AddGroupMembersResponseMembersItem.from_dict(v) for v in _dict.get('members')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AddGroupMembersResponse 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, 'members') and self.members is not None: + members_list = [] + for v in self.members: + if isinstance(v, dict): + members_list.append(v) + else: + members_list.append(v.to_dict()) + _dict['members'] = members_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 AddGroupMembersResponse object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AddGroupMembersResponse') -> 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: 'AddGroupMembersResponse') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AddGroupMembersResponseMembersItem: + """ + AddGroupMembersResponseMembersItem. + + :attr str iam_id: (optional) The IBMid or Service Id of the member. + :attr str type: (optional) The member type - either `user`, `service` or + `profile`. + :attr datetime created_at: (optional) The timestamp of when the membership was + created. + :attr str created_by_id: (optional) The `iam_id` of the entity that created the + membership. + :attr int status_code: (optional) The outcome of the operation on this `iam_id`. + :attr str trace: (optional) A transaction-id that can be used for debugging + purposes. + :attr List[Error] errors: (optional) A list of errors that occurred when trying + to add members to a group. + """ + + def __init__( + self, + *, + iam_id: str = None, + type: str = None, + created_at: datetime = None, + created_by_id: str = None, + status_code: int = None, + trace: str = None, + errors: List['Error'] = None, + ) -> None: + """ + Initialize a AddGroupMembersResponseMembersItem object. + + :param str iam_id: (optional) The IBMid or Service Id of the member. + :param str type: (optional) The member type - either `user`, `service` or + `profile`. + :param datetime created_at: (optional) The timestamp of when the membership + was created. + :param str created_by_id: (optional) The `iam_id` of the entity that + created the membership. + :param int status_code: (optional) The outcome of the operation on this + `iam_id`. + :param str trace: (optional) A transaction-id that can be used for + debugging purposes. + :param List[Error] errors: (optional) A list of errors that occurred when + trying to add members to a group. + """ + self.iam_id = iam_id + self.type = type + self.created_at = created_at + self.created_by_id = created_by_id + self.status_code = status_code + self.trace = trace + self.errors = errors + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AddGroupMembersResponseMembersItem': + """Initialize a AddGroupMembersResponseMembersItem object from a json dictionary.""" + args = {} + if 'iam_id' in _dict: + args['iam_id'] = _dict.get('iam_id') + if 'type' in _dict: + args['type'] = _dict.get('type') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + if 'status_code' in _dict: + args['status_code'] = _dict.get('status_code') + if 'trace' in _dict: + args['trace'] = _dict.get('trace') + if 'errors' in _dict: + args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AddGroupMembersResponseMembersItem 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'status_code') and self.status_code is not None: + _dict['status_code'] = self.status_code + if hasattr(self, 'trace') and self.trace is not None: + _dict['trace'] = self.trace + if hasattr(self, 'errors') and self.errors is not None: + errors_list = [] + for v in self.errors: + if isinstance(v, dict): + errors_list.append(v) + else: + errors_list.append(v.to_dict()) + _dict['errors'] = errors_list + 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 AddGroupMembersResponseMembersItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AddGroupMembersResponseMembersItem') -> 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: 'AddGroupMembersResponseMembersItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AddMembershipMultipleGroupsResponse: + """ + The response from the add member to multiple access groups request. + + :attr str iam_id: (optional) The iam_id of a member. + :attr List[AddMembershipMultipleGroupsResponseGroupsItem] groups: (optional) The + list of access groups a member was added to. + """ + + def __init__( + self, + *, + iam_id: str = None, + groups: List['AddMembershipMultipleGroupsResponseGroupsItem'] = None, + ) -> None: + """ + Initialize a AddMembershipMultipleGroupsResponse object. + + :param str iam_id: (optional) The iam_id of a member. + :param List[AddMembershipMultipleGroupsResponseGroupsItem] groups: + (optional) The list of access groups a member was added to. + """ + self.iam_id = iam_id + self.groups = groups + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AddMembershipMultipleGroupsResponse': + """Initialize a AddMembershipMultipleGroupsResponse object from a json dictionary.""" + args = {} + if 'iam_id' in _dict: + args['iam_id'] = _dict.get('iam_id') + if 'groups' in _dict: + args['groups'] = [AddMembershipMultipleGroupsResponseGroupsItem.from_dict(v) for v in _dict.get('groups')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AddMembershipMultipleGroupsResponse 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'groups') and self.groups is not None: + groups_list = [] + for v in self.groups: + if isinstance(v, dict): + groups_list.append(v) + else: + groups_list.append(v.to_dict()) + _dict['groups'] = groups_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 AddMembershipMultipleGroupsResponse object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AddMembershipMultipleGroupsResponse') -> 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: 'AddMembershipMultipleGroupsResponse') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AddMembershipMultipleGroupsResponseGroupsItem: + """ + AddMembershipMultipleGroupsResponseGroupsItem. + + :attr str access_group_id: (optional) The access group that the member is to be + added to. + :attr int status_code: (optional) The outcome of the add membership operation on + this `access_group_id`. + :attr str trace: (optional) A transaction-id that can be used for debugging + purposes. + :attr List[Error] errors: (optional) List of errors encountered when adding + member to access group. + """ + + def __init__( + self, + *, + access_group_id: str = None, + status_code: int = None, + trace: str = None, + errors: List['Error'] = None, + ) -> None: + """ + Initialize a AddMembershipMultipleGroupsResponseGroupsItem object. + + :param str access_group_id: (optional) The access group that the member is + to be added to. + :param int status_code: (optional) The outcome of the add membership + operation on this `access_group_id`. + :param str trace: (optional) A transaction-id that can be used for + debugging purposes. + :param List[Error] errors: (optional) List of errors encountered when + adding member to access group. + """ + self.access_group_id = access_group_id + self.status_code = status_code + self.trace = trace + self.errors = errors + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AddMembershipMultipleGroupsResponseGroupsItem': + """Initialize a AddMembershipMultipleGroupsResponseGroupsItem object from a json dictionary.""" + args = {} + if 'access_group_id' in _dict: + args['access_group_id'] = _dict.get('access_group_id') + if 'status_code' in _dict: + args['status_code'] = _dict.get('status_code') + if 'trace' in _dict: + args['trace'] = _dict.get('trace') + if 'errors' in _dict: + args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AddMembershipMultipleGroupsResponseGroupsItem 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, 'access_group_id') and self.access_group_id is not None: + _dict['access_group_id'] = self.access_group_id + if hasattr(self, 'status_code') and self.status_code is not None: + _dict['status_code'] = self.status_code + if hasattr(self, 'trace') and self.trace is not None: + _dict['trace'] = self.trace + if hasattr(self, 'errors') and self.errors is not None: + errors_list = [] + for v in self.errors: + if isinstance(v, dict): + errors_list.append(v) + else: + errors_list.append(v.to_dict()) + _dict['errors'] = errors_list + 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 AddMembershipMultipleGroupsResponseGroupsItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AddMembershipMultipleGroupsResponseGroupsItem') -> 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: 'AddMembershipMultipleGroupsResponseGroupsItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Assertions: + """ + Assertions Input Component. + + :attr List[AssertionsRule] rules: (optional) Dynamic rules to automatically add + federated users to access groups based on specific identity attributes. + :attr AssertionsActionControls action_controls: (optional) Control whether or + not access group administrators in child accounts can add, remove, and update + dynamic rules for the enterprise-managed access group in their account. The + inner level RuleActionControls override these `remove` and `update` action + controls. + """ + + def __init__( + self, + *, + rules: List['AssertionsRule'] = None, + action_controls: 'AssertionsActionControls' = None, + ) -> None: + """ + Initialize a Assertions object. + + :param List[AssertionsRule] rules: (optional) Dynamic rules to + automatically add federated users to access groups based on specific + identity attributes. + :param AssertionsActionControls action_controls: (optional) Control whether + or not access group administrators in child accounts can add, remove, and + update dynamic rules for the enterprise-managed access group in their + account. The inner level RuleActionControls override these `remove` and + `update` action controls. + """ + self.rules = rules + self.action_controls = action_controls + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Assertions': + """Initialize a Assertions object from a json dictionary.""" + args = {} + if 'rules' in _dict: + args['rules'] = [AssertionsRule.from_dict(v) for v in _dict.get('rules')] + if 'action_controls' in _dict: + args['action_controls'] = AssertionsActionControls.from_dict(_dict.get('action_controls')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Assertions 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, 'rules') and self.rules is not None: + rules_list = [] + for v in self.rules: + if isinstance(v, dict): + rules_list.append(v) + else: + rules_list.append(v.to_dict()) + _dict['rules'] = rules_list + if hasattr(self, 'action_controls') and self.action_controls is not None: + if isinstance(self.action_controls, dict): + _dict['action_controls'] = self.action_controls + else: + _dict['action_controls'] = self.action_controls.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 Assertions object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Assertions') -> 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: 'Assertions') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AssertionsActionControls: + """ + Control whether or not access group administrators in child accounts can add, remove, + and update dynamic rules for the enterprise-managed access group in their account. The + inner level RuleActionControls override these `remove` and `update` action controls. + + :attr bool add: (optional) Action control for adding dynamic rules to an + enterprise-managed access group. If an access group administrator in a child + account adds a dynamic rule, they can always update or remove it. + :attr bool remove: (optional) Action control for removing enterprise-managed + dynamic rules in an enterprise-managed access group. + :attr bool update: (optional) Action control for updating enterprise-managed + dynamic rules in an enterprise-managed access group. + """ + + def __init__( + self, + *, + add: bool = None, + remove: bool = None, + update: bool = None, + ) -> None: + """ + Initialize a AssertionsActionControls object. + + :param bool add: (optional) Action control for adding dynamic rules to an + enterprise-managed access group. If an access group administrator in a + child account adds a dynamic rule, they can always update or remove it. + :param bool remove: (optional) Action control for removing + enterprise-managed dynamic rules in an enterprise-managed access group. + :param bool update: (optional) Action control for updating + enterprise-managed dynamic rules in an enterprise-managed access group. + """ + self.add = add + self.remove = remove + self.update = update + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AssertionsActionControls': + """Initialize a AssertionsActionControls object from a json dictionary.""" + args = {} + if 'add' in _dict: + args['add'] = _dict.get('add') + if 'remove' in _dict: + args['remove'] = _dict.get('remove') + if 'update' in _dict: + args['update'] = _dict.get('update') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AssertionsActionControls 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, 'add') and self.add is not None: + _dict['add'] = self.add + if hasattr(self, 'remove') and self.remove is not None: + _dict['remove'] = self.remove + if hasattr(self, 'update') and self.update is not None: + _dict['update'] = self.update + 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 AssertionsActionControls object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AssertionsActionControls') -> 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: 'AssertionsActionControls') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AssertionsRule: + """ + Rule Input component. + + :attr str name: (optional) Dynamic rule name. + :attr int expiration: (optional) Session duration in hours. Access group + membership is revoked after this time period expires. Users must log back in to + refresh their access group membership. + :attr str realm_name: (optional) The identity provider (IdP) URL. + :attr List[Conditions] conditions: (optional) Conditions of membership. You can + think of this as a key:value pair. + :attr RuleActionControls action_controls: (optional) Control whether or not + access group administrators in child accounts can update and remove this dynamic + rule in the enterprise-managed access group in their account.This overrides + outer level AssertionsActionControls. + """ + + def __init__( + self, + *, + name: str = None, + expiration: int = None, + realm_name: str = None, + conditions: List['Conditions'] = None, + action_controls: 'RuleActionControls' = None, + ) -> None: + """ + Initialize a AssertionsRule object. + + :param str name: (optional) Dynamic rule name. + :param int expiration: (optional) Session duration in hours. Access group + membership is revoked after this time period expires. Users must log back + in to refresh their access group membership. + :param str realm_name: (optional) The identity provider (IdP) URL. + :param List[Conditions] conditions: (optional) Conditions of membership. + You can think of this as a key:value pair. + :param RuleActionControls action_controls: (optional) Control whether or + not access group administrators in child accounts can update and remove + this dynamic rule in the enterprise-managed access group in their + account.This overrides outer level AssertionsActionControls. + """ + self.name = name + self.expiration = expiration + self.realm_name = realm_name + self.conditions = conditions + self.action_controls = action_controls + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AssertionsRule': + """Initialize a AssertionsRule object from a json dictionary.""" + args = {} + if 'name' in _dict: + args['name'] = _dict.get('name') + if 'expiration' in _dict: + args['expiration'] = _dict.get('expiration') + if 'realm_name' in _dict: + args['realm_name'] = _dict.get('realm_name') + if 'conditions' in _dict: + args['conditions'] = [Conditions.from_dict(v) for v in _dict.get('conditions')] + if 'action_controls' in _dict: + args['action_controls'] = RuleActionControls.from_dict(_dict.get('action_controls')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AssertionsRule 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, 'expiration') and self.expiration is not None: + _dict['expiration'] = self.expiration + if hasattr(self, 'realm_name') and self.realm_name is not None: + _dict['realm_name'] = self.realm_name + if hasattr(self, 'conditions') and self.conditions is not None: + conditions_list = [] + for v in self.conditions: + if isinstance(v, dict): + conditions_list.append(v) + else: + conditions_list.append(v.to_dict()) + _dict['conditions'] = conditions_list + if hasattr(self, 'action_controls') and self.action_controls is not None: + if isinstance(self.action_controls, dict): + _dict['action_controls'] = self.action_controls + else: + _dict['action_controls'] = self.action_controls.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 AssertionsRule object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AssertionsRule') -> 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: 'AssertionsRule') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AssignmentResourceAccessGroup: + """ + Assignment Resource Access Group. + + :attr AssignmentResourceEntry group: Assignment resource entry. + :attr List[AssignmentResourceEntry] members: List of member resources of the + group. + :attr List[AssignmentResourceEntry] rules: List of rules associated with the + group. + """ + + def __init__( + self, + group: 'AssignmentResourceEntry', + members: List['AssignmentResourceEntry'], + rules: List['AssignmentResourceEntry'], + ) -> None: + """ + Initialize a AssignmentResourceAccessGroup object. + + :param AssignmentResourceEntry group: Assignment resource entry. + :param List[AssignmentResourceEntry] members: List of member resources of + the group. + :param List[AssignmentResourceEntry] rules: List of rules associated with + the group. + """ + self.group = group + self.members = members + self.rules = rules + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AssignmentResourceAccessGroup': + """Initialize a AssignmentResourceAccessGroup object from a json dictionary.""" + args = {} + if 'group' in _dict: + args['group'] = AssignmentResourceEntry.from_dict(_dict.get('group')) + else: + raise ValueError('Required property \'group\' not present in AssignmentResourceAccessGroup JSON') + if 'members' in _dict: + args['members'] = [AssignmentResourceEntry.from_dict(v) for v in _dict.get('members')] + else: + raise ValueError('Required property \'members\' not present in AssignmentResourceAccessGroup JSON') + if 'rules' in _dict: + args['rules'] = [AssignmentResourceEntry.from_dict(v) for v in _dict.get('rules')] + else: + raise ValueError('Required property \'rules\' not present in AssignmentResourceAccessGroup JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AssignmentResourceAccessGroup 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, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'members') and self.members is not None: + members_list = [] + for v in self.members: + if isinstance(v, dict): + members_list.append(v) + else: + members_list.append(v.to_dict()) + _dict['members'] = members_list + if hasattr(self, 'rules') and self.rules is not None: + rules_list = [] + for v in self.rules: + if isinstance(v, dict): + rules_list.append(v) + else: + rules_list.append(v.to_dict()) + _dict['rules'] = rules_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 AssignmentResourceAccessGroup object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AssignmentResourceAccessGroup') -> 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: 'AssignmentResourceAccessGroup') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class AssignmentResourceEntry: + """ + Assignment resource entry. + + :attr str id: Assignment Resource Entry Id. + :attr str name: (optional) Optional name of the resource. + :attr str version: (optional) Optional version of the resource. + :attr str resource: Resource in assignment resource entry. + :attr str error: Error in assignment resource entry. + :attr str operation: (optional) Optional operation on the resource. + :attr str status: Status of assignment resource entry. + """ + + def __init__( + self, + id: str, + resource: str, + error: str, + status: str, + *, + name: str = None, + version: str = None, + operation: str = None, + ) -> None: + """ + Initialize a AssignmentResourceEntry object. + + :param str id: Assignment Resource Entry Id. + :param str resource: Resource in assignment resource entry. + :param str error: Error in assignment resource entry. + :param str status: Status of assignment resource entry. + :param str name: (optional) Optional name of the resource. + :param str version: (optional) Optional version of the resource. + :param str operation: (optional) Optional operation on the resource. + """ + self.id = id + self.name = name + self.version = version + self.resource = resource + self.error = error + self.operation = operation + self.status = status + + @classmethod + def from_dict(cls, _dict: Dict) -> 'AssignmentResourceEntry': + """Initialize a AssignmentResourceEntry object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in AssignmentResourceEntry JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + if 'version' in _dict: + args['version'] = _dict.get('version') + if 'resource' in _dict: + args['resource'] = _dict.get('resource') + else: + raise ValueError('Required property \'resource\' not present in AssignmentResourceEntry JSON') + if 'error' in _dict: + args['error'] = _dict.get('error') + else: + raise ValueError('Required property \'error\' not present in AssignmentResourceEntry JSON') + if 'operation' in _dict: + args['operation'] = _dict.get('operation') + if 'status' in _dict: + args['status'] = _dict.get('status') + else: + raise ValueError('Required property \'status\' not present in AssignmentResourceEntry JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a AssignmentResourceEntry object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version + if hasattr(self, 'resource') and self.resource is not None: + _dict['resource'] = self.resource + if hasattr(self, 'error') and self.error is not None: + _dict['error'] = self.error + if hasattr(self, 'operation') and self.operation is not None: + _dict['operation'] = self.operation + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this AssignmentResourceEntry object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'AssignmentResourceEntry') -> 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: 'AssignmentResourceEntry') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Conditions: + """ + Condition Input component. + + :attr str claim: (optional) The key in the key:value pair. + :attr str operator: (optional) Compares the claim and the value. + :attr str value: (optional) The value in the key:value pair. + """ + + def __init__( + self, + *, + claim: str = None, + operator: str = None, + value: str = None, + ) -> None: + """ + Initialize a Conditions object. + + :param str claim: (optional) The key in the key:value pair. + :param str operator: (optional) Compares the claim and the value. + :param str value: (optional) The value in the key:value pair. + """ + self.claim = claim + self.operator = operator + self.value = value + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Conditions': + """Initialize a Conditions object from a json dictionary.""" + args = {} + if 'claim' in _dict: + args['claim'] = _dict.get('claim') + if 'operator' in _dict: + args['operator'] = _dict.get('operator') + if 'value' in _dict: + args['value'] = _dict.get('value') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Conditions 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, 'claim') and self.claim is not None: + _dict['claim'] = self.claim + 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 Conditions object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Conditions') -> 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: 'Conditions') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteFromAllGroupsResponse: + """ + The response from the delete member from access groups request. + + :attr str iam_id: (optional) The `iam_id` of the member to removed from groups. + :attr List[DeleteFromAllGroupsResponseGroupsItem] groups: (optional) The groups + the member was removed from. + """ + + def __init__( + self, + *, + iam_id: str = None, + groups: List['DeleteFromAllGroupsResponseGroupsItem'] = None, + ) -> None: + """ + Initialize a DeleteFromAllGroupsResponse object. + + :param str iam_id: (optional) The `iam_id` of the member to removed from + groups. + :param List[DeleteFromAllGroupsResponseGroupsItem] groups: (optional) The + groups the member was removed from. + """ + self.iam_id = iam_id + self.groups = groups + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFromAllGroupsResponse': + """Initialize a DeleteFromAllGroupsResponse object from a json dictionary.""" + args = {} + if 'iam_id' in _dict: + args['iam_id'] = _dict.get('iam_id') + if 'groups' in _dict: + args['groups'] = [DeleteFromAllGroupsResponseGroupsItem.from_dict(v) for v in _dict.get('groups')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFromAllGroupsResponse 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'groups') and self.groups is not None: + groups_list = [] + for v in self.groups: + if isinstance(v, dict): + groups_list.append(v) + else: + groups_list.append(v.to_dict()) + _dict['groups'] = groups_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 DeleteFromAllGroupsResponse object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFromAllGroupsResponse') -> 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: 'DeleteFromAllGroupsResponse') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteFromAllGroupsResponseGroupsItem: + """ + DeleteFromAllGroupsResponseGroupsItem. + + :attr str access_group_id: (optional) The access group that the member is to be + deleted from. + :attr int status_code: (optional) The outcome of the delete operation on this + `access_group_id`. + :attr str trace: (optional) A transaction-id that can be used for debugging + purposes. + :attr List[Error] errors: (optional) A list of errors that occurred when trying + to remove a member from groups. + """ + + def __init__( + self, + *, + access_group_id: str = None, + status_code: int = None, + trace: str = None, + errors: List['Error'] = None, + ) -> None: + """ + Initialize a DeleteFromAllGroupsResponseGroupsItem object. + + :param str access_group_id: (optional) The access group that the member is + to be deleted from. + :param int status_code: (optional) The outcome of the delete operation on + this `access_group_id`. + :param str trace: (optional) A transaction-id that can be used for + debugging purposes. + :param List[Error] errors: (optional) A list of errors that occurred when + trying to remove a member from groups. + """ + self.access_group_id = access_group_id + self.status_code = status_code + self.trace = trace + self.errors = errors + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteFromAllGroupsResponseGroupsItem': + """Initialize a DeleteFromAllGroupsResponseGroupsItem object from a json dictionary.""" + args = {} + if 'access_group_id' in _dict: + args['access_group_id'] = _dict.get('access_group_id') + if 'status_code' in _dict: + args['status_code'] = _dict.get('status_code') + if 'trace' in _dict: + args['trace'] = _dict.get('trace') + if 'errors' in _dict: + args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteFromAllGroupsResponseGroupsItem 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, 'access_group_id') and self.access_group_id is not None: + _dict['access_group_id'] = self.access_group_id + if hasattr(self, 'status_code') and self.status_code is not None: + _dict['status_code'] = self.status_code + if hasattr(self, 'trace') and self.trace is not None: + _dict['trace'] = self.trace + if hasattr(self, 'errors') and self.errors is not None: + errors_list = [] + for v in self.errors: + if isinstance(v, dict): + errors_list.append(v) + else: + errors_list.append(v.to_dict()) + _dict['errors'] = errors_list + 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 DeleteFromAllGroupsResponseGroupsItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteFromAllGroupsResponseGroupsItem') -> 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: 'DeleteFromAllGroupsResponseGroupsItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteGroupBulkMembersResponse: + """ + The access group id and the members removed from it. + + :attr str access_group_id: (optional) The access group id. + :attr List[DeleteGroupBulkMembersResponseMembersItem] members: (optional) The + `iam_id`s removed from the access group. + """ + + def __init__( + self, + *, + access_group_id: str = None, + members: List['DeleteGroupBulkMembersResponseMembersItem'] = None, + ) -> None: + """ + Initialize a DeleteGroupBulkMembersResponse object. + + :param str access_group_id: (optional) The access group id. + :param List[DeleteGroupBulkMembersResponseMembersItem] members: (optional) + The `iam_id`s removed from the access group. + """ + self.access_group_id = access_group_id + self.members = members + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteGroupBulkMembersResponse': + """Initialize a DeleteGroupBulkMembersResponse object from a json dictionary.""" + args = {} + if 'access_group_id' in _dict: + args['access_group_id'] = _dict.get('access_group_id') + if 'members' in _dict: + args['members'] = [DeleteGroupBulkMembersResponseMembersItem.from_dict(v) for v in _dict.get('members')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteGroupBulkMembersResponse 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, 'access_group_id') and self.access_group_id is not None: + _dict['access_group_id'] = self.access_group_id + if hasattr(self, 'members') and self.members is not None: + members_list = [] + for v in self.members: + if isinstance(v, dict): + members_list.append(v) + else: + members_list.append(v.to_dict()) + _dict['members'] = members_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 DeleteGroupBulkMembersResponse object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteGroupBulkMembersResponse') -> 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: 'DeleteGroupBulkMembersResponse') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class DeleteGroupBulkMembersResponseMembersItem: + """ + DeleteGroupBulkMembersResponseMembersItem. + + :attr str iam_id: (optional) The `iam_id` to be deleted. + :attr str trace: (optional) A transaction-id that can be used for debugging + purposes. + :attr int status_code: (optional) The outcome of the delete membership operation + on this `access_group_id`. + :attr List[Error] errors: (optional) A list of errors that occurred when trying + to remove a member from groups. + """ + + def __init__( + self, + *, + iam_id: str = None, + trace: str = None, + status_code: int = None, + errors: List['Error'] = None, + ) -> None: + """ + Initialize a DeleteGroupBulkMembersResponseMembersItem object. + + :param str iam_id: (optional) The `iam_id` to be deleted. + :param str trace: (optional) A transaction-id that can be used for + debugging purposes. + :param int status_code: (optional) The outcome of the delete membership + operation on this `access_group_id`. + :param List[Error] errors: (optional) A list of errors that occurred when + trying to remove a member from groups. + """ + self.iam_id = iam_id + self.trace = trace + self.status_code = status_code + self.errors = errors + + @classmethod + def from_dict(cls, _dict: Dict) -> 'DeleteGroupBulkMembersResponseMembersItem': + """Initialize a DeleteGroupBulkMembersResponseMembersItem object from a json dictionary.""" + args = {} + if 'iam_id' in _dict: + args['iam_id'] = _dict.get('iam_id') + if 'trace' in _dict: + args['trace'] = _dict.get('trace') + if 'status_code' in _dict: + args['status_code'] = _dict.get('status_code') + if 'errors' in _dict: + args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a DeleteGroupBulkMembersResponseMembersItem 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'trace') and self.trace is not None: + _dict['trace'] = self.trace + if hasattr(self, 'status_code') and self.status_code is not None: + _dict['status_code'] = self.status_code + if hasattr(self, 'errors') and self.errors is not None: + errors_list = [] + for v in self.errors: + if isinstance(v, dict): + errors_list.append(v) + else: + errors_list.append(v.to_dict()) + _dict['errors'] = errors_list + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this DeleteGroupBulkMembersResponseMembersItem object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'DeleteGroupBulkMembersResponseMembersItem') -> 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: 'DeleteGroupBulkMembersResponseMembersItem') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Error: + """ + Error contains the code and message for an error returned to the user code is a string + identifying the problem, examples "missing_field", "reserved_value" message is a + string explaining the solution to the problem that was encountered. + + :attr str code: (optional) A human-readable error code represented by a snake + case string. + :attr str message: (optional) A specific error message that details the issue or + an action to take. + """ + + def __init__( + self, + *, + code: str = None, + message: str = None, + ) -> None: + """ + Initialize a Error object. + + :param str code: (optional) A human-readable error code represented by a + snake case string. + :param str message: (optional) A specific error message that details the + issue or an action to take. + """ + self.code = code + self.message = message + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Error': + """Initialize a Error object from a json dictionary.""" + args = {} + if 'code' in _dict: + args['code'] = _dict.get('code') + if 'message' in _dict: + args['message'] = _dict.get('message') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Error object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'code') and self.code is not None: + _dict['code'] = self.code + if hasattr(self, 'message') and self.message is not None: + _dict['message'] = self.message + 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 Error object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Error') -> 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: 'Error') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class Group: + """ + An IAM access group. + + :attr str id: (optional) The group's access group ID. + :attr str name: (optional) The group's name. + :attr str description: (optional) The group's description - if defined. + :attr str account_id: (optional) The account id where the group was created. + :attr datetime created_at: (optional) The timestamp of when the group was + created. + :attr str created_by_id: (optional) The `iam_id` of the entity that created the + group. + :attr datetime last_modified_at: (optional) The timestamp of when the group was + last edited. + :attr str last_modified_by_id: (optional) The `iam_id` of the entity that last + modified the group name or description. + :attr str href: (optional) A url to the given group resource. + :attr bool is_federated: (optional) This is set to true if rules exist for the + group. + """ + + def __init__( + self, + *, + id: str = None, + name: str = None, + description: str = None, + account_id: str = None, + created_at: datetime = None, + created_by_id: str = None, + last_modified_at: datetime = None, + last_modified_by_id: str = None, + href: str = None, + is_federated: bool = None, + ) -> None: + """ + Initialize a Group object. + + :param str id: (optional) The group's access group ID. + :param str name: (optional) The group's name. + :param str description: (optional) The group's description - if defined. + :param str account_id: (optional) The account id where the group was + created. + :param str href: (optional) A url to the given group resource. + :param bool is_federated: (optional) This is set to true if rules exist for + the group. + """ + self.id = id + self.name = name + self.description = description + self.account_id = account_id + self.created_at = created_at + self.created_by_id = created_by_id + self.last_modified_at = last_modified_at + self.last_modified_by_id = last_modified_by_id + self.href = href + self.is_federated = is_federated + + @classmethod + def from_dict(cls, _dict: Dict) -> 'Group': + """Initialize a Group object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + if 'name' in _dict: + args['name'] = _dict.get('name') + if 'description' in _dict: + args['description'] = _dict.get('description') + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + if 'href' in _dict: + args['href'] = _dict.get('href') + if 'is_federated' in _dict: + args['is_federated'] = _dict.get('is_federated') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a Group object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, '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, 'created_at') and getattr(self, 'created_at') is not None: + _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) + if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: + _dict['created_by_id'] = getattr(self, 'created_by_id') + if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: + _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) + if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: + _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'is_federated') and self.is_federated is not None: + _dict['is_federated'] = self.is_federated + 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 Group object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'Group') -> 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: 'Group') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class GroupActionControls: + """ + Access group action controls component. + + :attr AccessActionControls access: (optional) Control whether or not access + group administrators in child accounts can add access policies to the + enterprise-managed access group in their account. + """ + + def __init__( + self, + *, + access: 'AccessActionControls' = None, + ) -> None: + """ + Initialize a GroupActionControls object. + + :param AccessActionControls access: (optional) Control whether or not + access group administrators in child accounts can add access policies to + the enterprise-managed access group in their account. + """ + self.access = access + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GroupActionControls': + """Initialize a GroupActionControls object from a json dictionary.""" + args = {} + if 'access' in _dict: + args['access'] = AccessActionControls.from_dict(_dict.get('access')) + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GroupActionControls 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, 'access') and self.access is not None: + if isinstance(self.access, dict): + _dict['access'] = self.access + else: + _dict['access'] = self.access.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 GroupActionControls object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GroupActionControls') -> 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: 'GroupActionControls') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class GroupMembersList: + """ + The members of a group. + + :attr int limit: Limit on how many items can be returned. + :attr int offset: The offset of the first item returned in the result set. + :attr int total_count: The total number of items that match the query. + :attr HrefStruct first: (optional) A link object. + :attr HrefStruct previous: (optional) A link object. + :attr HrefStruct next: (optional) A link object. + :attr HrefStruct last: (optional) A link object. + :attr List[ListGroupMembersResponseMember] members: (optional) The members of an + access group. + """ + + def __init__( + self, + limit: int, + offset: int, + total_count: int, + *, + first: 'HrefStruct' = None, + previous: 'HrefStruct' = None, + next: 'HrefStruct' = None, + last: 'HrefStruct' = None, + members: List['ListGroupMembersResponseMember'] = None, + ) -> None: + """ + Initialize a GroupMembersList object. + + :param int limit: Limit on how many items can be returned. + :param int offset: The offset of the first item returned in the result set. + :param int total_count: The total number of items that match the query. + :param HrefStruct first: (optional) A link object. + :param HrefStruct previous: (optional) A link object. + :param HrefStruct next: (optional) A link object. + :param HrefStruct last: (optional) A link object. + :param List[ListGroupMembersResponseMember] members: (optional) The members + of an access group. + """ + self.limit = limit + self.offset = offset + self.total_count = total_count + self.first = first + self.previous = previous + self.next = next + self.last = last + self.members = members + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GroupMembersList': + """Initialize a GroupMembersList object from a json dictionary.""" + args = {} + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in GroupMembersList JSON') + if 'offset' in _dict: + args['offset'] = _dict.get('offset') + else: + raise ValueError('Required property \'offset\' not present in GroupMembersList JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in GroupMembersList JSON') + if 'first' in _dict: + args['first'] = HrefStruct.from_dict(_dict.get('first')) + if 'previous' in _dict: + args['previous'] = HrefStruct.from_dict(_dict.get('previous')) + if 'next' in _dict: + args['next'] = HrefStruct.from_dict(_dict.get('next')) + if 'last' in _dict: + args['last'] = HrefStruct.from_dict(_dict.get('last')) + if 'members' in _dict: + args['members'] = [ListGroupMembersResponseMember.from_dict(v) for v in _dict.get('members')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GroupMembersList 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, 'offset') and self.offset is not None: + _dict['offset'] = self.offset + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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, '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, '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, 'last') and self.last is not None: + if isinstance(self.last, dict): + _dict['last'] = self.last + else: + _dict['last'] = self.last.to_dict() + if hasattr(self, 'members') and self.members is not None: + members_list = [] + for v in self.members: + if isinstance(v, dict): + members_list.append(v) + else: + members_list.append(v.to_dict()) + _dict['members'] = members_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 GroupMembersList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GroupMembersList') -> 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: 'GroupMembersList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class GroupTemplate: + """ + Response output for template. + + :attr str id: The ID of the access group template. + :attr str name: The name of the access group template. + :attr str description: The description of the access group template. + :attr str version: The version of the access group template. + :attr bool committed: A boolean indicating whether the access group template is + committed. You must commit a template before you can assign it to child + accounts. + :attr AccessGroupResponse group: Access Group Component. + :attr List[PolicyTemplates] policy_template_references: References to policy + templates assigned to the access group template. + :attr str href: The URL of the access group template resource. + :attr datetime created_at: The date and time when the access group template was + created. + :attr str created_by_id: The ID of the user who created the access group + template. + :attr datetime last_modified_at: The date and time when the access group + template was last modified. + :attr str last_modified_by_id: The ID of the user who last modified the access + group template. + """ + + def __init__( + self, + id: str, + name: str, + description: str, + version: str, + committed: bool, + group: 'AccessGroupResponse', + policy_template_references: List['PolicyTemplates'], + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, + ) -> None: + """ + Initialize a GroupTemplate object. + + :param str id: The ID of the access group template. + :param str name: The name of the access group template. + :param str description: The description of the access group template. + :param str version: The version of the access group template. + :param bool committed: A boolean indicating whether the access group + template is committed. You must commit a template before you can assign it + to child accounts. + :param AccessGroupResponse group: Access Group Component. + :param List[PolicyTemplates] policy_template_references: References to + policy templates assigned to the access group template. + :param str href: The URL of the access group template resource. + :param datetime created_at: The date and time when the access group + template was created. + :param str created_by_id: The ID of the user who created the access group + template. + :param datetime last_modified_at: The date and time when the access group + template was last modified. + :param str last_modified_by_id: The ID of the user who last modified the + access group template. + """ + self.id = id + self.name = name + self.description = description + self.version = version + self.committed = committed + self.group = group + self.policy_template_references = policy_template_references + 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) -> 'GroupTemplate': + """Initialize a GroupTemplate object from a json dictionary.""" + args = {} + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in GroupTemplate JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in GroupTemplate JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + else: + raise ValueError('Required property \'description\' not present in GroupTemplate JSON') + if 'version' in _dict: + args['version'] = _dict.get('version') + else: + raise ValueError('Required property \'version\' not present in GroupTemplate JSON') + if 'committed' in _dict: + args['committed'] = _dict.get('committed') + else: + raise ValueError('Required property \'committed\' not present in GroupTemplate JSON') + if 'group' in _dict: + args['group'] = AccessGroupResponse.from_dict(_dict.get('group')) + else: + raise ValueError('Required property \'group\' not present in GroupTemplate JSON') + if 'policy_template_references' in _dict: + args['policy_template_references'] = [ + PolicyTemplates.from_dict(v) for v in _dict.get('policy_template_references') + ] + else: + raise ValueError('Required property \'policy_template_references\' not present in GroupTemplate JSON') + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in GroupTemplate JSON') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in GroupTemplate JSON') + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError('Required property \'created_by_id\' not present in GroupTemplate JSON') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + else: + raise ValueError('Required property \'last_modified_at\' not present in GroupTemplate JSON') + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + else: + raise ValueError('Required property \'last_modified_by_id\' not present in GroupTemplate JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GroupTemplate object from a json dictionary.""" + return cls.from_dict(_dict) + + def to_dict(self) -> Dict: + """Return a json dictionary representing this model.""" + _dict = {} + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + 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, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'policy_template_references') and self.policy_template_references is not None: + policy_template_references_list = [] + for v in self.policy_template_references: + if isinstance(v, dict): + policy_template_references_list.append(v) + else: + policy_template_references_list.append(v.to_dict()) + _dict['policy_template_references'] = policy_template_references_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this GroupTemplate object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GroupTemplate') -> 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: 'GroupTemplate') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class GroupsList: + """ + The list of access groups returned as part of a response. + + :attr int limit: Limit on how many items can be returned. + :attr int offset: The offset of the first item returned in the result set. + :attr int total_count: The total number of items that match the query. + :attr HrefStruct first: (optional) A link object. + :attr HrefStruct previous: (optional) A link object. + :attr HrefStruct next: (optional) A link object. + :attr HrefStruct last: (optional) A link object. + :attr List[Group] groups: (optional) An array of access groups. + """ + + def __init__( + self, + limit: int, + offset: int, + total_count: int, + *, + first: 'HrefStruct' = None, + previous: 'HrefStruct' = None, + next: 'HrefStruct' = None, + last: 'HrefStruct' = None, + groups: List['Group'] = None, + ) -> None: + """ + Initialize a GroupsList object. + + :param int limit: Limit on how many items can be returned. + :param int offset: The offset of the first item returned in the result set. + :param int total_count: The total number of items that match the query. + :param HrefStruct first: (optional) A link object. + :param HrefStruct previous: (optional) A link object. + :param HrefStruct next: (optional) A link object. + :param HrefStruct last: (optional) A link object. + :param List[Group] groups: (optional) An array of access groups. + """ + self.limit = limit + self.offset = offset + self.total_count = total_count + self.first = first + self.previous = previous + self.next = next + self.last = last + self.groups = groups + + @classmethod + def from_dict(cls, _dict: Dict) -> 'GroupsList': + """Initialize a GroupsList object from a json dictionary.""" + args = {} + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in GroupsList JSON') + if 'offset' in _dict: + args['offset'] = _dict.get('offset') + else: + raise ValueError('Required property \'offset\' not present in GroupsList JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in GroupsList JSON') + if 'first' in _dict: + args['first'] = HrefStruct.from_dict(_dict.get('first')) + if 'previous' in _dict: + args['previous'] = HrefStruct.from_dict(_dict.get('previous')) + if 'next' in _dict: + args['next'] = HrefStruct.from_dict(_dict.get('next')) + if 'last' in _dict: + args['last'] = HrefStruct.from_dict(_dict.get('last')) + if 'groups' in _dict: + args['groups'] = [Group.from_dict(v) for v in _dict.get('groups')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a GroupsList 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, 'offset') and self.offset is not None: + _dict['offset'] = self.offset + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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, '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, '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, 'last') and self.last is not None: + if isinstance(self.last, dict): + _dict['last'] = self.last + else: + _dict['last'] = self.last.to_dict() + if hasattr(self, 'groups') and self.groups is not None: + groups_list = [] + for v in self.groups: + if isinstance(v, dict): + groups_list.append(v) + else: + groups_list.append(v.to_dict()) + _dict['groups'] = groups_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 GroupsList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'GroupsList') -> 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: 'GroupsList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class HrefStruct: + """ + A link object. + + :attr str href: (optional) A string containing the link’s URL. + """ + + def __init__( + self, + *, + href: str = None, + ) -> None: + """ + Initialize a HrefStruct object. + + :param str href: (optional) A string containing the link’s URL. + """ + self.href = href @classmethod - def from_dict(cls, _dict: Dict) -> 'AddGroupMembersResponse': - """Initialize a AddGroupMembersResponse object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'HrefStruct': + """Initialize a HrefStruct object from a json dictionary.""" args = {} - if 'members' in _dict: - args['members'] = [AddGroupMembersResponseMembersItem.from_dict(v) for v in _dict.get('members')] + if 'href' in _dict: + args['href'] = _dict.get('href') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AddGroupMembersResponse object from a json dictionary.""" + """Initialize a HrefStruct 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, 'members') and self.members is not None: - members_list = [] - for v in self.members: - if isinstance(v, dict): - members_list.append(v) - else: - members_list.append(v.to_dict()) - _dict['members'] = members_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href return _dict def _to_dict(self): @@ -1680,36 +4973,39 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AddGroupMembersResponse object.""" + """Return a `str` version of this HrefStruct object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AddGroupMembersResponse') -> bool: + def __eq__(self, other: 'HrefStruct') -> 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: 'AddGroupMembersResponse') -> bool: + def __ne__(self, other: 'HrefStruct') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddGroupMembersResponseMembersItem: +class ListGroupMembersResponseMember: """ - AddGroupMembersResponseMembersItem. + A single member of an access group in a list. :attr str iam_id: (optional) The IBMid or Service Id of the member. :attr str type: (optional) The member type - either `user`, `service` or `profile`. + :attr str membership_type: (optional) The membership type - either `static` or + `dynamic`. + :attr str name: (optional) The user's or service id's name. + :attr str email: (optional) If the member type is user, this is the user's + email. + :attr str description: (optional) If the member type is service, this is the + service id's description. + :attr str href: (optional) A url to the given member resource. :attr datetime created_at: (optional) The timestamp the membership was created at. :attr str created_by_id: (optional) The `iam_id` of the entity that created the membership. - :attr int status_code: (optional) The outcome of the operation on this `iam_id`. - :attr str trace: (optional) A transaction-id that can be used for debugging - purposes. - :attr List[Error] errors: (optional) A list of errors that occurred when trying - to add members to a group. """ def __init__( @@ -1717,85 +5013,216 @@ def __init__( *, iam_id: str = None, type: str = None, + membership_type: str = None, + name: str = None, + email: str = None, + description: str = None, + href: str = None, created_at: datetime = None, created_by_id: str = None, - status_code: int = None, - trace: str = None, - errors: List['Error'] = None, ) -> None: """ - Initialize a AddGroupMembersResponseMembersItem object. + Initialize a ListGroupMembersResponseMember object. :param str iam_id: (optional) The IBMid or Service Id of the member. :param str type: (optional) The member type - either `user`, `service` or `profile`. + :param str membership_type: (optional) The membership type - either + `static` or `dynamic`. + :param str name: (optional) The user's or service id's name. + :param str email: (optional) If the member type is user, this is the user's + email. + :param str description: (optional) If the member type is service, this is + the service id's description. + :param str href: (optional) A url to the given member resource. :param datetime created_at: (optional) The timestamp the membership was created at. :param str created_by_id: (optional) The `iam_id` of the entity that created the membership. - :param int status_code: (optional) The outcome of the operation on this - `iam_id`. - :param str trace: (optional) A transaction-id that can be used for - debugging purposes. - :param List[Error] errors: (optional) A list of errors that occurred when - trying to add members to a group. """ self.iam_id = iam_id self.type = type + self.membership_type = membership_type + self.name = name + self.email = email + self.description = description + self.href = href self.created_at = created_at self.created_by_id = created_by_id - self.status_code = status_code - self.trace = trace - self.errors = errors @classmethod - def from_dict(cls, _dict: Dict) -> 'AddGroupMembersResponseMembersItem': - """Initialize a AddGroupMembersResponseMembersItem object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ListGroupMembersResponseMember': + """Initialize a ListGroupMembersResponseMember object from a json dictionary.""" args = {} if 'iam_id' in _dict: args['iam_id'] = _dict.get('iam_id') if 'type' in _dict: args['type'] = _dict.get('type') + if 'membership_type' in _dict: + args['membership_type'] = _dict.get('membership_type') + if 'name' in _dict: + args['name'] = _dict.get('name') + if 'email' in _dict: + args['email'] = _dict.get('email') + if 'description' in _dict: + args['description'] = _dict.get('description') + if 'href' in _dict: + args['href'] = _dict.get('href') if 'created_at' in _dict: args['created_at'] = string_to_datetime(_dict.get('created_at')) if 'created_by_id' in _dict: args['created_by_id'] = _dict.get('created_by_id') - if 'status_code' in _dict: - args['status_code'] = _dict.get('status_code') - if 'trace' in _dict: - args['trace'] = _dict.get('trace') - if 'errors' in _dict: - args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AddGroupMembersResponseMembersItem object from a json dictionary.""" + """Initialize a ListGroupMembersResponseMember 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, 'iam_id') and self.iam_id is not None: + _dict['iam_id'] = self.iam_id + if hasattr(self, 'type') and self.type is not None: + _dict['type'] = self.type + if hasattr(self, 'membership_type') and self.membership_type is not None: + _dict['membership_type'] = self.membership_type + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, 'email') and self.email is not None: + _dict['email'] = self.email + if hasattr(self, 'description') and self.description is not None: + _dict['description'] = self.description + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + return _dict + + def _to_dict(self): + """Return a json dictionary representing this model.""" + return self.to_dict() + + def __str__(self) -> str: + """Return a `str` version of this ListGroupMembersResponseMember object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'ListGroupMembersResponseMember') -> 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: 'ListGroupMembersResponseMember') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class ListTemplateAssignmentResponse: + """ + Response object containing a list of template assignments. + + :attr int limit: Maximum number of items returned in the response. + :attr int offset: Index of the first item returned in the response. + :attr int total_count: Total number of items matching the query. + :attr HrefStruct first: A link object. + :attr HrefStruct last: A link object. + :attr List[TemplateAssignmentResponse] assignments: List of template + assignments. + """ + + def __init__( + self, + limit: int, + offset: int, + total_count: int, + first: 'HrefStruct', + last: 'HrefStruct', + assignments: List['TemplateAssignmentResponse'], + ) -> None: + """ + Initialize a ListTemplateAssignmentResponse object. + + :param int limit: Maximum number of items returned in the response. + :param int offset: Index of the first item returned in the response. + :param int total_count: Total number of items matching the query. + :param HrefStruct first: A link object. + :param HrefStruct last: A link object. + :param List[TemplateAssignmentResponse] assignments: List of template + assignments. + """ + self.limit = limit + self.offset = offset + self.total_count = total_count + self.first = first + self.last = last + self.assignments = assignments + + @classmethod + def from_dict(cls, _dict: Dict) -> 'ListTemplateAssignmentResponse': + """Initialize a ListTemplateAssignmentResponse object from a json dictionary.""" + args = {} + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in ListTemplateAssignmentResponse JSON') + if 'offset' in _dict: + args['offset'] = _dict.get('offset') + else: + raise ValueError('Required property \'offset\' not present in ListTemplateAssignmentResponse JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in ListTemplateAssignmentResponse JSON') + if 'first' in _dict: + args['first'] = HrefStruct.from_dict(_dict.get('first')) + else: + raise ValueError('Required property \'first\' not present in ListTemplateAssignmentResponse JSON') + if 'last' in _dict: + args['last'] = HrefStruct.from_dict(_dict.get('last')) + else: + raise ValueError('Required property \'last\' not present in ListTemplateAssignmentResponse JSON') + if 'assignments' in _dict: + args['assignments'] = [TemplateAssignmentResponse.from_dict(v) for v in _dict.get('assignments')] + else: + raise ValueError('Required property \'assignments\' not present in ListTemplateAssignmentResponse JSON') + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a ListTemplateAssignmentResponse 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'created_at') and self.created_at is not None: - _dict['created_at'] = datetime_to_string(self.created_at) - if hasattr(self, 'created_by_id') and self.created_by_id is not None: - _dict['created_by_id'] = self.created_by_id - if hasattr(self, 'status_code') and self.status_code is not None: - _dict['status_code'] = self.status_code - if hasattr(self, 'trace') and self.trace is not None: - _dict['trace'] = self.trace - if hasattr(self, 'errors') and self.errors is not None: - errors_list = [] - for v in self.errors: + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'offset') and self.offset is not None: + _dict['offset'] = self.offset + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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, 'last') and self.last is not None: + if isinstance(self.last, dict): + _dict['last'] = self.last + else: + _dict['last'] = self.last.to_dict() + if hasattr(self, 'assignments') and self.assignments is not None: + assignments_list = [] + for v in self.assignments: if isinstance(v, dict): - errors_list.append(v) + assignments_list.append(v) else: - errors_list.append(v.to_dict()) - _dict['errors'] = errors_list + assignments_list.append(v.to_dict()) + _dict['assignments'] = assignments_list return _dict def _to_dict(self): @@ -1803,73 +5230,190 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AddGroupMembersResponseMembersItem object.""" + """Return a `str` version of this ListTemplateAssignmentResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AddGroupMembersResponseMembersItem') -> bool: + def __eq__(self, other: 'ListTemplateAssignmentResponse') -> 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: 'AddGroupMembersResponseMembersItem') -> bool: + def __ne__(self, other: 'ListTemplateAssignmentResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddMembershipMultipleGroupsResponse: +class ListTemplateVersionResponse: """ - The response from the add member to multiple access groups request. - - :attr str iam_id: (optional) The iam_id of a member. - :attr List[AddMembershipMultipleGroupsResponseGroupsItem] groups: (optional) The - list of access groups a member was added to. + Response object for a single access group template version. + + :attr str name: The name of the template. + :attr str description: The description of the template. + :attr str account_id: The ID of the account associated with the template. + :attr str version: The version number of the template. + :attr bool committed: A boolean indicating whether the template is committed or + not. + :attr AccessGroupResponse group: Access Group Component. + :attr List[PolicyTemplates] policy_template_references: A list of policy + templates associated with the template. + :attr str href: The URL to the template resource. + :attr str created_at: The date and time the template was created. + :attr str created_by_id: The ID of the user who created the template. + :attr str last_modified_at: The date and time the template was last modified. + :attr str last_modified_by_id: The ID of the user who last modified the + template. """ def __init__( self, - *, - iam_id: str = None, - groups: List['AddMembershipMultipleGroupsResponseGroupsItem'] = None, + name: str, + description: str, + account_id: str, + version: str, + committed: bool, + group: 'AccessGroupResponse', + policy_template_references: List['PolicyTemplates'], + href: str, + created_at: str, + created_by_id: str, + last_modified_at: str, + last_modified_by_id: str, ) -> None: """ - Initialize a AddMembershipMultipleGroupsResponse object. - - :param str iam_id: (optional) The iam_id of a member. - :param List[AddMembershipMultipleGroupsResponseGroupsItem] groups: - (optional) The list of access groups a member was added to. + Initialize a ListTemplateVersionResponse object. + + :param str name: The name of the template. + :param str description: The description of the template. + :param str account_id: The ID of the account associated with the template. + :param str version: The version number of the template. + :param bool committed: A boolean indicating whether the template is + committed or not. + :param AccessGroupResponse group: Access Group Component. + :param List[PolicyTemplates] policy_template_references: A list of policy + templates associated with the template. + :param str href: The URL to the template resource. + :param str created_at: The date and time the template was created. + :param str created_by_id: The ID of the user who created the template. + :param str last_modified_at: The date and time the template was last + modified. + :param str last_modified_by_id: The ID of the user who last modified the + template. """ - self.iam_id = iam_id - self.groups = groups + self.name = name + self.description = description + self.account_id = account_id + self.version = version + self.committed = committed + self.group = group + self.policy_template_references = policy_template_references + 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) -> 'AddMembershipMultipleGroupsResponse': - """Initialize a AddMembershipMultipleGroupsResponse object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ListTemplateVersionResponse': + """Initialize a ListTemplateVersionResponse object from a json dictionary.""" args = {} - if 'iam_id' in _dict: - args['iam_id'] = _dict.get('iam_id') - if 'groups' in _dict: - args['groups'] = [AddMembershipMultipleGroupsResponseGroupsItem.from_dict(v) for v in _dict.get('groups')] + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in ListTemplateVersionResponse JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + else: + raise ValueError('Required property \'description\' not present in ListTemplateVersionResponse JSON') + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + else: + raise ValueError('Required property \'account_id\' not present in ListTemplateVersionResponse JSON') + if 'version' in _dict: + args['version'] = _dict.get('version') + else: + raise ValueError('Required property \'version\' not present in ListTemplateVersionResponse JSON') + if 'committed' in _dict: + args['committed'] = _dict.get('committed') + else: + raise ValueError('Required property \'committed\' not present in ListTemplateVersionResponse JSON') + if 'group' in _dict: + args['group'] = AccessGroupResponse.from_dict(_dict.get('group')) + else: + raise ValueError('Required property \'group\' not present in ListTemplateVersionResponse JSON') + if 'policy_template_references' in _dict: + args['policy_template_references'] = [ + PolicyTemplates.from_dict(v) for v in _dict.get('policy_template_references') + ] + else: + raise ValueError( + 'Required property \'policy_template_references\' not present in ListTemplateVersionResponse JSON' + ) + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in ListTemplateVersionResponse JSON') + if 'created_at' in _dict: + args['created_at'] = _dict.get('created_at') + else: + raise ValueError('Required property \'created_at\' not present in ListTemplateVersionResponse JSON') + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError('Required property \'created_by_id\' not present in ListTemplateVersionResponse JSON') + if 'last_modified_at' in _dict: + args['last_modified_at'] = _dict.get('last_modified_at') + else: + raise ValueError('Required property \'last_modified_at\' not present in ListTemplateVersionResponse JSON') + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + else: + raise ValueError( + 'Required property \'last_modified_by_id\' not present in ListTemplateVersionResponse JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AddMembershipMultipleGroupsResponse object from a json dictionary.""" + """Initialize a ListTemplateVersionResponse 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'groups') and self.groups is not None: - groups_list = [] - for v in self.groups: + 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, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'policy_template_references') and self.policy_template_references is not None: + policy_template_references_list = [] + for v in self.policy_template_references: if isinstance(v, dict): - groups_list.append(v) + policy_template_references_list.append(v) else: - groups_list.append(v.to_dict()) - _dict['groups'] = groups_list + policy_template_references_list.append(v.to_dict()) + _dict['policy_template_references'] = policy_template_references_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = self.created_at + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = self.last_modified_at + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id return _dict def _to_dict(self): @@ -1877,95 +5421,149 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AddMembershipMultipleGroupsResponse object.""" + """Return a `str` version of this ListTemplateVersionResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AddMembershipMultipleGroupsResponse') -> bool: + def __eq__(self, other: 'ListTemplateVersionResponse') -> 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: 'AddMembershipMultipleGroupsResponse') -> bool: + def __ne__(self, other: 'ListTemplateVersionResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddMembershipMultipleGroupsResponseGroupsItem: +class ListTemplateVersionsResponse: """ - AddMembershipMultipleGroupsResponseGroupsItem. + Response object for listing template versions. - :attr str access_group_id: (optional) The access group that the member is to be - added to. - :attr int status_code: (optional) The outcome of the add membership operation on - this `access_group_id`. - :attr str trace: (optional) A transaction-id that can be used for debugging - purposes. - :attr List[Error] errors: (optional) List of errors encountered when adding - member to access group. + :attr int limit: The maximum number of IAM resources to return. + :attr int offset: The offset of the first IAM resource in the list. + :attr int total_count: The total number of IAM resources in the list. + :attr HrefStruct first: A link object. + :attr HrefStruct previous: (optional) A link object. + :attr HrefStruct next: (optional) A link object. + :attr HrefStruct last: A link object. + :attr List[ListTemplateVersionResponse] group_template_versions: A list of + access group template versions. """ def __init__( self, + limit: int, + offset: int, + total_count: int, + first: 'HrefStruct', + last: 'HrefStruct', + group_template_versions: List['ListTemplateVersionResponse'], *, - access_group_id: str = None, - status_code: int = None, - trace: str = None, - errors: List['Error'] = None, + previous: 'HrefStruct' = None, + next: 'HrefStruct' = None, ) -> None: """ - Initialize a AddMembershipMultipleGroupsResponseGroupsItem object. - - :param str access_group_id: (optional) The access group that the member is - to be added to. - :param int status_code: (optional) The outcome of the add membership - operation on this `access_group_id`. - :param str trace: (optional) A transaction-id that can be used for - debugging purposes. - :param List[Error] errors: (optional) List of errors encountered when - adding member to access group. + Initialize a ListTemplateVersionsResponse object. + + :param int limit: The maximum number of IAM resources to return. + :param int offset: The offset of the first IAM resource in the list. + :param int total_count: The total number of IAM resources in the list. + :param HrefStruct first: A link object. + :param HrefStruct last: A link object. + :param List[ListTemplateVersionResponse] group_template_versions: A list of + access group template versions. + :param HrefStruct previous: (optional) A link object. + :param HrefStruct next: (optional) A link object. """ - self.access_group_id = access_group_id - self.status_code = status_code - self.trace = trace - self.errors = errors + self.limit = limit + self.offset = offset + self.total_count = total_count + self.first = first + self.previous = previous + self.next = next + self.last = last + self.group_template_versions = group_template_versions @classmethod - def from_dict(cls, _dict: Dict) -> 'AddMembershipMultipleGroupsResponseGroupsItem': - """Initialize a AddMembershipMultipleGroupsResponseGroupsItem object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ListTemplateVersionsResponse': + """Initialize a ListTemplateVersionsResponse object from a json dictionary.""" args = {} - if 'access_group_id' in _dict: - args['access_group_id'] = _dict.get('access_group_id') - if 'status_code' in _dict: - args['status_code'] = _dict.get('status_code') - if 'trace' in _dict: - args['trace'] = _dict.get('trace') - if 'errors' in _dict: - args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in ListTemplateVersionsResponse JSON') + if 'offset' in _dict: + args['offset'] = _dict.get('offset') + else: + raise ValueError('Required property \'offset\' not present in ListTemplateVersionsResponse JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in ListTemplateVersionsResponse JSON') + if 'first' in _dict: + args['first'] = HrefStruct.from_dict(_dict.get('first')) + else: + raise ValueError('Required property \'first\' not present in ListTemplateVersionsResponse JSON') + if 'previous' in _dict: + args['previous'] = HrefStruct.from_dict(_dict.get('previous')) + if 'next' in _dict: + args['next'] = HrefStruct.from_dict(_dict.get('next')) + if 'last' in _dict: + args['last'] = HrefStruct.from_dict(_dict.get('last')) + else: + raise ValueError('Required property \'last\' not present in ListTemplateVersionsResponse JSON') + if 'group_template_versions' in _dict: + args['group_template_versions'] = [ + ListTemplateVersionResponse.from_dict(v) for v in _dict.get('group_template_versions') + ] + else: + raise ValueError( + 'Required property \'group_template_versions\' not present in ListTemplateVersionsResponse JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a AddMembershipMultipleGroupsResponseGroupsItem object from a json dictionary.""" + """Initialize a ListTemplateVersionsResponse 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, 'access_group_id') and self.access_group_id is not None: - _dict['access_group_id'] = self.access_group_id - if hasattr(self, 'status_code') and self.status_code is not None: - _dict['status_code'] = self.status_code - if hasattr(self, 'trace') and self.trace is not None: - _dict['trace'] = self.trace - if hasattr(self, 'errors') and self.errors is not None: - errors_list = [] - for v in self.errors: + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'offset') and self.offset is not None: + _dict['offset'] = self.offset + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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, '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, '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, 'last') and self.last is not None: + if isinstance(self.last, dict): + _dict['last'] = self.last + else: + _dict['last'] = self.last.to_dict() + if hasattr(self, 'group_template_versions') and self.group_template_versions is not None: + group_template_versions_list = [] + for v in self.group_template_versions: if isinstance(v, dict): - errors_list.append(v) + group_template_versions_list.append(v) else: - errors_list.append(v.to_dict()) - _dict['errors'] = errors_list + group_template_versions_list.append(v.to_dict()) + _dict['group_template_versions'] = group_template_versions_list return _dict def _to_dict(self): @@ -1973,74 +5571,144 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this AddMembershipMultipleGroupsResponseGroupsItem object.""" + """Return a `str` version of this ListTemplateVersionsResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'AddMembershipMultipleGroupsResponseGroupsItem') -> bool: + def __eq__(self, other: 'ListTemplateVersionsResponse') -> 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: 'AddMembershipMultipleGroupsResponseGroupsItem') -> bool: + def __ne__(self, other: 'ListTemplateVersionsResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteFromAllGroupsResponse: +class ListTemplatesResponse: """ - The response from the delete member from access groups request. + Response object for listing templates. - :attr str iam_id: (optional) The `iam_id` of the member to removed from groups. - :attr List[DeleteFromAllGroupsResponseGroupsItem] groups: (optional) The groups - the member was removed from. + :attr int limit: The maximum number of IAM resources to return. + :attr int offset: The offset of the first IAM resource in the list. + :attr int total_count: The total number of IAM resources in the list. + :attr HrefStruct first: A link object. + :attr HrefStruct previous: (optional) A link object. + :attr HrefStruct next: (optional) A link object. + :attr HrefStruct last: A link object. + :attr List[GroupTemplate] group_templates: A list of access group templates. """ def __init__( self, + limit: int, + offset: int, + total_count: int, + first: 'HrefStruct', + last: 'HrefStruct', + group_templates: List['GroupTemplate'], *, - iam_id: str = None, - groups: List['DeleteFromAllGroupsResponseGroupsItem'] = None, + previous: 'HrefStruct' = None, + next: 'HrefStruct' = None, ) -> None: """ - Initialize a DeleteFromAllGroupsResponse object. - - :param str iam_id: (optional) The `iam_id` of the member to removed from - groups. - :param List[DeleteFromAllGroupsResponseGroupsItem] groups: (optional) The - groups the member was removed from. + Initialize a ListTemplatesResponse object. + + :param int limit: The maximum number of IAM resources to return. + :param int offset: The offset of the first IAM resource in the list. + :param int total_count: The total number of IAM resources in the list. + :param HrefStruct first: A link object. + :param HrefStruct last: A link object. + :param List[GroupTemplate] group_templates: A list of access group + templates. + :param HrefStruct previous: (optional) A link object. + :param HrefStruct next: (optional) A link object. """ - self.iam_id = iam_id - self.groups = groups + self.limit = limit + self.offset = offset + self.total_count = total_count + self.first = first + self.previous = previous + self.next = next + self.last = last + self.group_templates = group_templates @classmethod - def from_dict(cls, _dict: Dict) -> 'DeleteFromAllGroupsResponse': - """Initialize a DeleteFromAllGroupsResponse object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ListTemplatesResponse': + """Initialize a ListTemplatesResponse object from a json dictionary.""" args = {} - if 'iam_id' in _dict: - args['iam_id'] = _dict.get('iam_id') - if 'groups' in _dict: - args['groups'] = [DeleteFromAllGroupsResponseGroupsItem.from_dict(v) for v in _dict.get('groups')] + if 'limit' in _dict: + args['limit'] = _dict.get('limit') + else: + raise ValueError('Required property \'limit\' not present in ListTemplatesResponse JSON') + if 'offset' in _dict: + args['offset'] = _dict.get('offset') + else: + raise ValueError('Required property \'offset\' not present in ListTemplatesResponse JSON') + if 'total_count' in _dict: + args['total_count'] = _dict.get('total_count') + else: + raise ValueError('Required property \'total_count\' not present in ListTemplatesResponse JSON') + if 'first' in _dict: + args['first'] = HrefStruct.from_dict(_dict.get('first')) + else: + raise ValueError('Required property \'first\' not present in ListTemplatesResponse JSON') + if 'previous' in _dict: + args['previous'] = HrefStruct.from_dict(_dict.get('previous')) + if 'next' in _dict: + args['next'] = HrefStruct.from_dict(_dict.get('next')) + if 'last' in _dict: + args['last'] = HrefStruct.from_dict(_dict.get('last')) + else: + raise ValueError('Required property \'last\' not present in ListTemplatesResponse JSON') + if 'group_templates' in _dict: + args['group_templates'] = [GroupTemplate.from_dict(v) for v in _dict.get('group_templates')] + else: + raise ValueError('Required property \'group_templates\' not present in ListTemplatesResponse JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a DeleteFromAllGroupsResponse object from a json dictionary.""" + """Initialize a ListTemplatesResponse 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'groups') and self.groups is not None: - groups_list = [] - for v in self.groups: + if hasattr(self, 'limit') and self.limit is not None: + _dict['limit'] = self.limit + if hasattr(self, 'offset') and self.offset is not None: + _dict['offset'] = self.offset + if hasattr(self, 'total_count') and self.total_count is not None: + _dict['total_count'] = self.total_count + 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, '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, '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, 'last') and self.last is not None: + if isinstance(self.last, dict): + _dict['last'] = self.last + else: + _dict['last'] = self.last.to_dict() + if hasattr(self, 'group_templates') and self.group_templates is not None: + group_templates_list = [] + for v in self.group_templates: if isinstance(v, dict): - groups_list.append(v) + group_templates_list.append(v) else: - groups_list.append(v.to_dict()) - _dict['groups'] = groups_list + group_templates_list.append(v.to_dict()) + _dict['group_templates'] = group_templates_list return _dict def _to_dict(self): @@ -2048,95 +5716,87 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this DeleteFromAllGroupsResponse object.""" + """Return a `str` version of this ListTemplatesResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'DeleteFromAllGroupsResponse') -> bool: + def __eq__(self, other: 'ListTemplatesResponse') -> 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: 'DeleteFromAllGroupsResponse') -> bool: + def __ne__(self, other: 'ListTemplatesResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteFromAllGroupsResponseGroupsItem: +class Members: """ - DeleteFromAllGroupsResponseGroupsItem. - - :attr str access_group_id: (optional) The access group that the member is to be - deleted from. - :attr int status_code: (optional) The outcome of the delete operation on this - `access_group_id`. - :attr str trace: (optional) A transaction-id that can be used for debugging - purposes. - :attr List[Error] errors: (optional) A list of errors that occurred when trying - to remove a member from groups. + Array of enterprise users to add to the template. All enterprise users that you add to + the template must be invited to the child accounts where the template is assigned. + + :attr List[str] users: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited to + the child accounts where the template is assigned. + :attr List[str] services: (optional) Array of service IDs to add to the + template. + :attr MembersActionControls action_controls: (optional) Control whether or not + access group administrators in child accounts can add and remove members from + the enterprise-managed access group in their account. """ def __init__( self, *, - access_group_id: str = None, - status_code: int = None, - trace: str = None, - errors: List['Error'] = None, + users: List[str] = None, + services: List[str] = None, + action_controls: 'MembersActionControls' = None, ) -> None: """ - Initialize a DeleteFromAllGroupsResponseGroupsItem object. - - :param str access_group_id: (optional) The access group that the member is - to be deleted from. - :param int status_code: (optional) The outcome of the delete operation on - this `access_group_id`. - :param str trace: (optional) A transaction-id that can be used for - debugging purposes. - :param List[Error] errors: (optional) A list of errors that occurred when - trying to remove a member from groups. + Initialize a Members object. + + :param List[str] users: (optional) Array of enterprise users to add to the + template. All enterprise users that you add to the template must be invited + to the child accounts where the template is assigned. + :param List[str] services: (optional) Array of service IDs to add to the + template. + :param MembersActionControls action_controls: (optional) Control whether or + not access group administrators in child accounts can add and remove + members from the enterprise-managed access group in their account. """ - self.access_group_id = access_group_id - self.status_code = status_code - self.trace = trace - self.errors = errors + self.users = users + self.services = services + self.action_controls = action_controls @classmethod - def from_dict(cls, _dict: Dict) -> 'DeleteFromAllGroupsResponseGroupsItem': - """Initialize a DeleteFromAllGroupsResponseGroupsItem object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Members': + """Initialize a Members object from a json dictionary.""" args = {} - if 'access_group_id' in _dict: - args['access_group_id'] = _dict.get('access_group_id') - if 'status_code' in _dict: - args['status_code'] = _dict.get('status_code') - if 'trace' in _dict: - args['trace'] = _dict.get('trace') - if 'errors' in _dict: - args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + if 'users' in _dict: + args['users'] = _dict.get('users') + if 'services' in _dict: + args['services'] = _dict.get('services') + if 'action_controls' in _dict: + args['action_controls'] = MembersActionControls.from_dict(_dict.get('action_controls')) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a DeleteFromAllGroupsResponseGroupsItem object from a json dictionary.""" + """Initialize a Members 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, 'access_group_id') and self.access_group_id is not None: - _dict['access_group_id'] = self.access_group_id - if hasattr(self, 'status_code') and self.status_code is not None: - _dict['status_code'] = self.status_code - if hasattr(self, 'trace') and self.trace is not None: - _dict['trace'] = self.trace - if hasattr(self, 'errors') and self.errors is not None: - errors_list = [] - for v in self.errors: - if isinstance(v, dict): - errors_list.append(v) - else: - errors_list.append(v.to_dict()) - _dict['errors'] = errors_list + if hasattr(self, 'users') and self.users is not None: + _dict['users'] = self.users + if hasattr(self, 'services') and self.services is not None: + _dict['services'] = self.services + if hasattr(self, 'action_controls') and self.action_controls is not None: + if isinstance(self.action_controls, dict): + _dict['action_controls'] = self.action_controls + else: + _dict['action_controls'] = self.action_controls.to_dict() return _dict def _to_dict(self): @@ -2144,73 +5804,72 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this DeleteFromAllGroupsResponseGroupsItem object.""" + """Return a `str` version of this Members object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'DeleteFromAllGroupsResponseGroupsItem') -> bool: + def __eq__(self, other: 'Members') -> 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: 'DeleteFromAllGroupsResponseGroupsItem') -> bool: + def __ne__(self, other: 'Members') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteGroupBulkMembersResponse: +class MembersActionControls: """ - The access group id and the members removed from it. - - :attr str access_group_id: (optional) The access group id. - :attr List[DeleteGroupBulkMembersResponseMembersItem] members: (optional) The - `iam_id`s removed from the access group. + Control whether or not access group administrators in child accounts can add and + remove members from the enterprise-managed access group in their account. + + :attr bool add: (optional) Action control for adding child account members to an + enterprise-managed access group. If an access group administrator in a child + account adds a member, they can always remove them. + :attr bool remove: (optional) Action control for removing enterprise-managed + members from an enterprise-managed access group. """ def __init__( self, *, - access_group_id: str = None, - members: List['DeleteGroupBulkMembersResponseMembersItem'] = None, + add: bool = None, + remove: bool = None, ) -> None: """ - Initialize a DeleteGroupBulkMembersResponse object. + Initialize a MembersActionControls object. - :param str access_group_id: (optional) The access group id. - :param List[DeleteGroupBulkMembersResponseMembersItem] members: (optional) - The `iam_id`s removed from the access group. + :param bool add: (optional) Action control for adding child account members + to an enterprise-managed access group. If an access group administrator in + a child account adds a member, they can always remove them. + :param bool remove: (optional) Action control for removing + enterprise-managed members from an enterprise-managed access group. """ - self.access_group_id = access_group_id - self.members = members + self.add = add + self.remove = remove @classmethod - def from_dict(cls, _dict: Dict) -> 'DeleteGroupBulkMembersResponse': - """Initialize a DeleteGroupBulkMembersResponse object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'MembersActionControls': + """Initialize a MembersActionControls object from a json dictionary.""" args = {} - if 'access_group_id' in _dict: - args['access_group_id'] = _dict.get('access_group_id') - if 'members' in _dict: - args['members'] = [DeleteGroupBulkMembersResponseMembersItem.from_dict(v) for v in _dict.get('members')] + if 'add' in _dict: + args['add'] = _dict.get('add') + if 'remove' in _dict: + args['remove'] = _dict.get('remove') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a DeleteGroupBulkMembersResponse object from a json dictionary.""" + """Initialize a MembersActionControls 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, 'access_group_id') and self.access_group_id is not None: - _dict['access_group_id'] = self.access_group_id - if hasattr(self, 'members') and self.members is not None: - members_list = [] - for v in self.members: - if isinstance(v, dict): - members_list.append(v) - else: - members_list.append(v.to_dict()) - _dict['members'] = members_list + if hasattr(self, 'add') and self.add is not None: + _dict['add'] = self.add + if hasattr(self, 'remove') and self.remove is not None: + _dict['remove'] = self.remove return _dict def _to_dict(self): @@ -2218,93 +5877,65 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this DeleteGroupBulkMembersResponse object.""" + """Return a `str` version of this MembersActionControls object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'DeleteGroupBulkMembersResponse') -> bool: + def __eq__(self, other: 'MembersActionControls') -> 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: 'DeleteGroupBulkMembersResponse') -> bool: + def __ne__(self, other: 'MembersActionControls') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteGroupBulkMembersResponseMembersItem: +class PolicyTemplates: """ - DeleteGroupBulkMembersResponseMembersItem. + Policy Templates Input component. - :attr str iam_id: (optional) The `iam_id` to be deleted. - :attr str trace: (optional) A transaction-id that can be used for debugging - purposes. - :attr int status_code: (optional) The outcome of the delete membership operation - on this `access_group_id`. - :attr List[Error] errors: (optional) A list of errors that occurred when trying - to remove a member from groups. + :attr str id: (optional) Policy template ID. + :attr str version: (optional) Policy template version. """ def __init__( self, *, - iam_id: str = None, - trace: str = None, - status_code: int = None, - errors: List['Error'] = None, + id: str = None, + version: str = None, ) -> None: """ - Initialize a DeleteGroupBulkMembersResponseMembersItem object. + Initialize a PolicyTemplates object. - :param str iam_id: (optional) The `iam_id` to be deleted. - :param str trace: (optional) A transaction-id that can be used for - debugging purposes. - :param int status_code: (optional) The outcome of the delete membership - operation on this `access_group_id`. - :param List[Error] errors: (optional) A list of errors that occurred when - trying to remove a member from groups. + :param str id: (optional) Policy template ID. + :param str version: (optional) Policy template version. """ - self.iam_id = iam_id - self.trace = trace - self.status_code = status_code - self.errors = errors + self.id = id + self.version = version @classmethod - def from_dict(cls, _dict: Dict) -> 'DeleteGroupBulkMembersResponseMembersItem': - """Initialize a DeleteGroupBulkMembersResponseMembersItem object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'PolicyTemplates': + """Initialize a PolicyTemplates object from a json dictionary.""" args = {} - if 'iam_id' in _dict: - args['iam_id'] = _dict.get('iam_id') - if 'trace' in _dict: - args['trace'] = _dict.get('trace') - if 'status_code' in _dict: - args['status_code'] = _dict.get('status_code') - if 'errors' in _dict: - args['errors'] = [Error.from_dict(v) for v in _dict.get('errors')] + if 'id' in _dict: + args['id'] = _dict.get('id') + if 'version' in _dict: + args['version'] = _dict.get('version') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a DeleteGroupBulkMembersResponseMembersItem object from a json dictionary.""" + """Initialize a PolicyTemplates 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'trace') and self.trace is not None: - _dict['trace'] = self.trace - if hasattr(self, 'status_code') and self.status_code is not None: - _dict['status_code'] = self.status_code - if hasattr(self, 'errors') and self.errors is not None: - errors_list = [] - for v in self.errors: - if isinstance(v, dict): - errors_list.append(v) - else: - errors_list.append(v.to_dict()) - _dict['errors'] = errors_list + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'version') and self.version is not None: + _dict['version'] = self.version return _dict def _to_dict(self): @@ -2312,71 +5943,90 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this DeleteGroupBulkMembersResponseMembersItem object.""" + """Return a `str` version of this PolicyTemplates object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'DeleteGroupBulkMembersResponseMembersItem') -> bool: + def __eq__(self, other: 'PolicyTemplates') -> 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: 'DeleteGroupBulkMembersResponseMembersItem') -> bool: + def __ne__(self, other: 'PolicyTemplates') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Error: +class ResourceListWithTargetAccountID: """ - Error contains the code and message for an error returned to the user code is a string - identifying the problem, examples "missing_field", "reserved_value" message is a - string explaining the solution to the problem that was encountered. - - :attr str code: (optional) A human-readable error code represented by a snake - case string. - :attr str message: (optional) A specific error message that details the issue or - an action to take. + Object containing details of a resource list with target account ID. + + :attr str target: (optional) The ID of the entity that the resource list applies + to. + :attr AssignmentResourceAccessGroup group: (optional) Assignment Resource Access + Group. + :attr List[AssignmentResourceEntry] policy_template_references: (optional) List + of policy template references for the resource list. """ def __init__( self, *, - code: str = None, - message: str = None, + target: str = None, + group: 'AssignmentResourceAccessGroup' = None, + policy_template_references: List['AssignmentResourceEntry'] = None, ) -> None: """ - Initialize a Error object. - - :param str code: (optional) A human-readable error code represented by a - snake case string. - :param str message: (optional) A specific error message that details the - issue or an action to take. + Initialize a ResourceListWithTargetAccountID object. + + :param str target: (optional) The ID of the entity that the resource list + applies to. + :param AssignmentResourceAccessGroup group: (optional) Assignment Resource + Access Group. + :param List[AssignmentResourceEntry] policy_template_references: (optional) + List of policy template references for the resource list. """ - self.code = code - self.message = message + self.target = target + self.group = group + self.policy_template_references = policy_template_references @classmethod - def from_dict(cls, _dict: Dict) -> 'Error': - """Initialize a Error object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'ResourceListWithTargetAccountID': + """Initialize a ResourceListWithTargetAccountID object from a json dictionary.""" args = {} - if 'code' in _dict: - args['code'] = _dict.get('code') - if 'message' in _dict: - args['message'] = _dict.get('message') + if 'target' in _dict: + args['target'] = _dict.get('target') + if 'group' in _dict: + args['group'] = AssignmentResourceAccessGroup.from_dict(_dict.get('group')) + if 'policy_template_references' in _dict: + args['policy_template_references'] = [ + AssignmentResourceEntry.from_dict(v) for v in _dict.get('policy_template_references') + ] return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Error object from a json dictionary.""" + """Initialize a ResourceListWithTargetAccountID object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'code') and self.code is not None: - _dict['code'] = self.code - if hasattr(self, 'message') and self.message is not None: - _dict['message'] = self.message + if hasattr(self, 'target') and self.target is not None: + _dict['target'] = self.target + if hasattr(self, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'policy_template_references') and self.policy_template_references is not None: + policy_template_references_list = [] + for v in self.policy_template_references: + if isinstance(v, dict): + policy_template_references_list.append(v) + else: + policy_template_references_list.append(v.to_dict()) + _dict['policy_template_references'] = policy_template_references_list return _dict def _to_dict(self): @@ -2384,38 +6034,43 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Error object.""" + """Return a `str` version of this ResourceListWithTargetAccountID object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Error') -> bool: + def __eq__(self, other: 'ResourceListWithTargetAccountID') -> 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: 'Error') -> bool: + def __ne__(self, other: 'ResourceListWithTargetAccountID') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Group: +class Rule: """ - An IAM access group. + A dynamic rule of an access group. - :attr str id: (optional) The group's access group ID. - :attr str name: (optional) The group's name. - :attr str description: (optional) The group's description - if defined. - :attr str account_id: (optional) The account id where the group was created. - :attr datetime created_at: (optional) The timestamp the group was created at. + :attr str id: (optional) The rule id. + :attr str name: (optional) The name of the rule. + :attr int expiration: (optional) Session duration in hours. Access group + membership is revoked after this time period expires. Users must log back in to + refresh their access group membership. Must be between 1 and 24. + :attr str realm_name: (optional) The URL of the identity provider. + :attr str access_group_id: (optional) The group id that the dynamic rule is + assigned to. + :attr str account_id: (optional) The account id that the group is in. + :attr List[RuleConditions] conditions: (optional) A list of conditions that + identities must satisfy to gain access group membership. + :attr datetime created_at: (optional) The timestamp for when the rule was + created. :attr str created_by_id: (optional) The `iam_id` of the entity that created the - group. - :attr datetime last_modified_at: (optional) The timestamp the group was last - edited at. - :attr str last_modified_by_id: (optional) The `iam_id` of the entity that last - modified the group name or description. - :attr str href: (optional) A url to the given group resource. - :attr bool is_federated: (optional) This is set to true if rules exist for the - group. + dynamic rule. + :attr datetime last_modified_at: (optional) The timestamp for when the dynamic + rule was last edited. + :attr str last_modified_by_id: (optional) The IAM id that last modified the + rule. """ def __init__( @@ -2423,50 +6078,69 @@ def __init__( *, id: str = None, name: str = None, - description: str = None, + expiration: int = None, + realm_name: str = None, + access_group_id: str = None, account_id: str = None, + conditions: List['RuleConditions'] = None, created_at: datetime = None, created_by_id: str = None, last_modified_at: datetime = None, last_modified_by_id: str = None, - href: str = None, - is_federated: bool = None, ) -> None: """ - Initialize a Group object. + Initialize a Rule object. - :param str id: (optional) The group's access group ID. - :param str name: (optional) The group's name. - :param str description: (optional) The group's description - if defined. - :param str account_id: (optional) The account id where the group was + :param str id: (optional) The rule id. + :param str name: (optional) The name of the rule. + :param int expiration: (optional) Session duration in hours. Access group + membership is revoked after this time period expires. Users must log back + in to refresh their access group membership. Must be between 1 and 24. + :param str realm_name: (optional) The URL of the identity provider. + :param str access_group_id: (optional) The group id that the dynamic rule + is assigned to. + :param str account_id: (optional) The account id that the group is in. + :param List[RuleConditions] conditions: (optional) A list of conditions + that identities must satisfy to gain access group membership. + :param datetime created_at: (optional) The timestamp for when the rule was created. - :param str href: (optional) A url to the given group resource. - :param bool is_federated: (optional) This is set to true if rules exist for - the group. + :param str created_by_id: (optional) The `iam_id` of the entity that + created the dynamic rule. + :param datetime last_modified_at: (optional) The timestamp for when the + dynamic rule was last edited. + :param str last_modified_by_id: (optional) The IAM id that last modified + the rule. """ self.id = id self.name = name - self.description = description + self.expiration = expiration + self.realm_name = realm_name + self.access_group_id = access_group_id self.account_id = account_id + self.conditions = conditions self.created_at = created_at self.created_by_id = created_by_id self.last_modified_at = last_modified_at self.last_modified_by_id = last_modified_by_id - self.href = href - self.is_federated = is_federated @classmethod - def from_dict(cls, _dict: Dict) -> 'Group': - """Initialize a Group object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'Rule': + """Initialize a Rule object from a json dictionary.""" args = {} if 'id' in _dict: args['id'] = _dict.get('id') if 'name' in _dict: args['name'] = _dict.get('name') - if 'description' in _dict: - args['description'] = _dict.get('description') + if 'expiration' in _dict: + args['expiration'] = _dict.get('expiration') + if 'realm_name' in _dict: + args['realm_name'] = _dict.get('realm_name') + if 'access_group_id' in _dict: + args['access_group_id'] = _dict.get('access_group_id') if 'account_id' in _dict: args['account_id'] = _dict.get('account_id') + if 'conditions' in _dict: + args['conditions'] = [RuleConditions.from_dict(v) for v in _dict.get('conditions')] if 'created_at' in _dict: args['created_at'] = string_to_datetime(_dict.get('created_at')) if 'created_by_id' in _dict: @@ -2475,15 +6149,11 @@ def from_dict(cls, _dict: Dict) -> 'Group': args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) if 'last_modified_by_id' in _dict: args['last_modified_by_id'] = _dict.get('last_modified_by_id') - if 'href' in _dict: - args['href'] = _dict.get('href') - if 'is_federated' in _dict: - args['is_federated'] = _dict.get('is_federated') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Group object from a json dictionary.""" + """Initialize a Rule object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -2493,162 +6163,30 @@ def to_dict(self) -> Dict: _dict['id'] = self.id 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, 'expiration') and self.expiration is not None: + _dict['expiration'] = self.expiration + if hasattr(self, 'realm_name') and self.realm_name is not None: + _dict['realm_name'] = self.realm_name + if hasattr(self, 'access_group_id') and self.access_group_id is not None: + _dict['access_group_id'] = self.access_group_id if hasattr(self, 'account_id') and self.account_id is not None: _dict['account_id'] = self.account_id - if hasattr(self, 'created_at') and getattr(self, 'created_at') is not None: - _dict['created_at'] = datetime_to_string(getattr(self, 'created_at')) - if hasattr(self, 'created_by_id') and getattr(self, 'created_by_id') is not None: - _dict['created_by_id'] = getattr(self, 'created_by_id') - if hasattr(self, 'last_modified_at') and getattr(self, 'last_modified_at') is not None: - _dict['last_modified_at'] = datetime_to_string(getattr(self, 'last_modified_at')) - if hasattr(self, 'last_modified_by_id') and getattr(self, 'last_modified_by_id') is not None: - _dict['last_modified_by_id'] = getattr(self, 'last_modified_by_id') - if hasattr(self, 'href') and self.href is not None: - _dict['href'] = self.href - if hasattr(self, 'is_federated') and self.is_federated is not None: - _dict['is_federated'] = self.is_federated - 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 Group object.""" - return json.dumps(self.to_dict(), indent=2) - - def __eq__(self, other: 'Group') -> 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: 'Group') -> bool: - """Return `true` when self and other are not equal, false otherwise.""" - return not self == other - - -class GroupMembersList: - """ - The members of a group. - - :attr int limit: Limit on how many items can be returned. - :attr int offset: The offset of the first item returned in the result set. - :attr int total_count: The total number of items that match the query. - :attr HrefStruct first: (optional) A link object. - :attr HrefStruct previous: (optional) A link object. - :attr HrefStruct next: (optional) A link object. - :attr HrefStruct last: (optional) A link object. - :attr List[ListGroupMembersResponseMember] members: (optional) The members of an - access group. - """ - - def __init__( - self, - limit: int, - offset: int, - total_count: int, - *, - first: 'HrefStruct' = None, - previous: 'HrefStruct' = None, - next: 'HrefStruct' = None, - last: 'HrefStruct' = None, - members: List['ListGroupMembersResponseMember'] = None, - ) -> None: - """ - Initialize a GroupMembersList object. - - :param int limit: Limit on how many items can be returned. - :param int offset: The offset of the first item returned in the result set. - :param int total_count: The total number of items that match the query. - :param HrefStruct first: (optional) A link object. - :param HrefStruct previous: (optional) A link object. - :param HrefStruct next: (optional) A link object. - :param HrefStruct last: (optional) A link object. - :param List[ListGroupMembersResponseMember] members: (optional) The members - of an access group. - """ - self.limit = limit - self.offset = offset - self.total_count = total_count - self.first = first - self.previous = previous - self.next = next - self.last = last - self.members = members - - @classmethod - def from_dict(cls, _dict: Dict) -> 'GroupMembersList': - """Initialize a GroupMembersList object from a json dictionary.""" - args = {} - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in GroupMembersList JSON') - if 'offset' in _dict: - args['offset'] = _dict.get('offset') - else: - raise ValueError('Required property \'offset\' not present in GroupMembersList JSON') - if 'total_count' in _dict: - args['total_count'] = _dict.get('total_count') - else: - raise ValueError('Required property \'total_count\' not present in GroupMembersList JSON') - if 'first' in _dict: - args['first'] = HrefStruct.from_dict(_dict.get('first')) - if 'previous' in _dict: - args['previous'] = HrefStruct.from_dict(_dict.get('previous')) - if 'next' in _dict: - args['next'] = HrefStruct.from_dict(_dict.get('next')) - if 'last' in _dict: - args['last'] = HrefStruct.from_dict(_dict.get('last')) - if 'members' in _dict: - args['members'] = [ListGroupMembersResponseMember.from_dict(v) for v in _dict.get('members')] - return cls(**args) - - @classmethod - def _from_dict(cls, _dict): - """Initialize a GroupMembersList 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, 'offset') and self.offset is not None: - _dict['offset'] = self.offset - if hasattr(self, 'total_count') and self.total_count is not None: - _dict['total_count'] = self.total_count - 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, '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, '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, 'last') and self.last is not None: - if isinstance(self.last, dict): - _dict['last'] = self.last - else: - _dict['last'] = self.last.to_dict() - if hasattr(self, 'members') and self.members is not None: - members_list = [] - for v in self.members: + if hasattr(self, 'conditions') and self.conditions is not None: + conditions_list = [] + for v in self.conditions: if isinstance(v, dict): - members_list.append(v) + conditions_list.append(v) else: - members_list.append(v.to_dict()) - _dict['members'] = members_list + conditions_list.append(v.to_dict()) + _dict['conditions'] = conditions_list + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id return _dict def _to_dict(self): @@ -2656,137 +6194,71 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GroupMembersList object.""" + """Return a `str` version of this Rule object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GroupMembersList') -> bool: + def __eq__(self, other: 'Rule') -> 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: 'GroupMembersList') -> bool: + def __ne__(self, other: 'Rule') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GroupsList: +class RuleActionControls: """ - The list of access groups returned as part of a response. - - :attr int limit: Limit on how many items can be returned. - :attr int offset: The offset of the first item returned in the result set. - :attr int total_count: The total number of items that match the query. - :attr HrefStruct first: (optional) A link object. - :attr HrefStruct previous: (optional) A link object. - :attr HrefStruct next: (optional) A link object. - :attr HrefStruct last: (optional) A link object. - :attr List[Group] groups: (optional) An array of access groups. + Control whether or not access group administrators in child accounts can update and + remove this dynamic rule in the enterprise-managed access group in their account.This + overrides outer level AssertionsActionControls. + + :attr bool remove: (optional) Action control for removing this + enterprise-managed dynamic rule. + :attr bool update: (optional) Action control for updating this + enterprise-managed dynamic rule. """ def __init__( self, - limit: int, - offset: int, - total_count: int, *, - first: 'HrefStruct' = None, - previous: 'HrefStruct' = None, - next: 'HrefStruct' = None, - last: 'HrefStruct' = None, - groups: List['Group'] = None, + remove: bool = None, + update: bool = None, ) -> None: """ - Initialize a GroupsList object. + Initialize a RuleActionControls object. - :param int limit: Limit on how many items can be returned. - :param int offset: The offset of the first item returned in the result set. - :param int total_count: The total number of items that match the query. - :param HrefStruct first: (optional) A link object. - :param HrefStruct previous: (optional) A link object. - :param HrefStruct next: (optional) A link object. - :param HrefStruct last: (optional) A link object. - :param List[Group] groups: (optional) An array of access groups. + :param bool remove: (optional) Action control for removing this + enterprise-managed dynamic rule. + :param bool update: (optional) Action control for updating this + enterprise-managed dynamic rule. """ - self.limit = limit - self.offset = offset - self.total_count = total_count - self.first = first - self.previous = previous - self.next = next - self.last = last - self.groups = groups + self.remove = remove + self.update = update @classmethod - def from_dict(cls, _dict: Dict) -> 'GroupsList': - """Initialize a GroupsList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RuleActionControls': + """Initialize a RuleActionControls object from a json dictionary.""" args = {} - if 'limit' in _dict: - args['limit'] = _dict.get('limit') - else: - raise ValueError('Required property \'limit\' not present in GroupsList JSON') - if 'offset' in _dict: - args['offset'] = _dict.get('offset') - else: - raise ValueError('Required property \'offset\' not present in GroupsList JSON') - if 'total_count' in _dict: - args['total_count'] = _dict.get('total_count') - else: - raise ValueError('Required property \'total_count\' not present in GroupsList JSON') - if 'first' in _dict: - args['first'] = HrefStruct.from_dict(_dict.get('first')) - if 'previous' in _dict: - args['previous'] = HrefStruct.from_dict(_dict.get('previous')) - if 'next' in _dict: - args['next'] = HrefStruct.from_dict(_dict.get('next')) - if 'last' in _dict: - args['last'] = HrefStruct.from_dict(_dict.get('last')) - if 'groups' in _dict: - args['groups'] = [Group.from_dict(v) for v in _dict.get('groups')] + if 'remove' in _dict: + args['remove'] = _dict.get('remove') + if 'update' in _dict: + args['update'] = _dict.get('update') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a GroupsList object from a json dictionary.""" + """Initialize a RuleActionControls 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, 'offset') and self.offset is not None: - _dict['offset'] = self.offset - if hasattr(self, 'total_count') and self.total_count is not None: - _dict['total_count'] = self.total_count - 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, '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, '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, 'last') and self.last is not None: - if isinstance(self.last, dict): - _dict['last'] = self.last - else: - _dict['last'] = self.last.to_dict() - if hasattr(self, 'groups') and self.groups is not None: - groups_list = [] - for v in self.groups: - if isinstance(v, dict): - groups_list.append(v) - else: - groups_list.append(v.to_dict()) - _dict['groups'] = groups_list + if hasattr(self, 'remove') and self.remove is not None: + _dict['remove'] = self.remove + if hasattr(self, 'update') and self.update is not None: + _dict['update'] = self.update return _dict def _to_dict(self): @@ -2794,57 +6266,82 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this GroupsList object.""" + """Return a `str` version of this RuleActionControls object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'GroupsList') -> bool: + def __eq__(self, other: 'RuleActionControls') -> 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: 'GroupsList') -> bool: + def __ne__(self, other: 'RuleActionControls') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class HrefStruct: +class RuleConditions: """ - A link object. + The conditions of a dynamic rule. - :attr str href: (optional) A string containing the link’s URL. + :attr str claim: The claim to evaluate against. This will be found in the `ext` + claims of a user's login request. + :attr str operator: The operation to perform on the claim. + :attr str value: The stringified JSON value that the claim is compared to using + the operator. """ def __init__( self, - *, - href: str = None, + claim: str, + operator: str, + value: str, ) -> None: """ - Initialize a HrefStruct object. + Initialize a RuleConditions object. - :param str href: (optional) A string containing the link’s URL. + :param str claim: The claim to evaluate against. This will be found in the + `ext` claims of a user's login request. + :param str operator: The operation to perform on the claim. + :param str value: The stringified JSON value that the claim is compared to + using the operator. """ - self.href = href + self.claim = claim + self.operator = operator + self.value = value @classmethod - def from_dict(cls, _dict: Dict) -> 'HrefStruct': - """Initialize a HrefStruct object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'RuleConditions': + """Initialize a RuleConditions object from a json dictionary.""" args = {} - if 'href' in _dict: - args['href'] = _dict.get('href') + if 'claim' in _dict: + args['claim'] = _dict.get('claim') + else: + raise ValueError('Required property \'claim\' not present in RuleConditions JSON') + if 'operator' in _dict: + args['operator'] = _dict.get('operator') + else: + raise ValueError('Required property \'operator\' not present in RuleConditions JSON') + if 'value' in _dict: + args['value'] = _dict.get('value') + else: + raise ValueError('Required property \'value\' not present in RuleConditions JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a HrefStruct object from a json dictionary.""" + """Initialize a RuleConditions object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} - if hasattr(self, 'href') and self.href is not None: - _dict['href'] = self.href + if hasattr(self, 'claim') and self.claim is not None: + _dict['claim'] = self.claim + 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): @@ -2852,133 +6349,268 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this HrefStruct object.""" + """Return a `str` version of this RuleConditions object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'HrefStruct') -> bool: + def __eq__(self, other: 'RuleConditions') -> 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: 'HrefStruct') -> bool: + def __ne__(self, other: 'RuleConditions') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class OperatorEnum(str, Enum): + """ + The operation to perform on the claim. + """ -class ListGroupMembersResponseMember: + EQUALS = 'EQUALS' + EQUALS_IGNORE_CASE = 'EQUALS_IGNORE_CASE' + IN = 'IN' + NOT_EQUALS_IGNORE_CASE = 'NOT_EQUALS_IGNORE_CASE' + NOT_EQUALS = 'NOT_EQUALS' + CONTAINS = 'CONTAINS' + + +class RulesList: """ - A single member of an access group in a list. + A list of dynamic rules attached to the access group. - :attr str iam_id: (optional) The IBMid or Service Id of the member. - :attr str type: (optional) The member type - either `user`, `service` or - `profile`. - :attr str membership_type: (optional) The membership type - either `static` or - `dynamic`. - :attr str name: (optional) The user's or service id's name. - :attr str email: (optional) If the member type is user, this is the user's - email. - :attr str description: (optional) If the member type is service, this is the - service id's description. - :attr str href: (optional) A url to the given member resource. - :attr datetime created_at: (optional) The timestamp the membership was created - at. - :attr str created_by_id: (optional) The `iam_id` of the entity that created the - membership. + :attr List[Rule] rules: (optional) A list of dynamic rules. """ def __init__( self, *, - iam_id: str = None, - type: str = None, - membership_type: str = None, - name: str = None, - email: str = None, - description: str = None, - href: str = None, - created_at: datetime = None, - created_by_id: str = None, + rules: List['Rule'] = None, + ) -> None: + """ + Initialize a RulesList object. + + :param List[Rule] rules: (optional) A list of dynamic rules. + """ + self.rules = rules + + @classmethod + def from_dict(cls, _dict: Dict) -> 'RulesList': + """Initialize a RulesList object from a json dictionary.""" + args = {} + if 'rules' in _dict: + args['rules'] = [Rule.from_dict(v) for v in _dict.get('rules')] + return cls(**args) + + @classmethod + def _from_dict(cls, _dict): + """Initialize a RulesList 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, 'rules') and self.rules is not None: + rules_list = [] + for v in self.rules: + if isinstance(v, dict): + rules_list.append(v) + else: + rules_list.append(v.to_dict()) + _dict['rules'] = rules_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 RulesList object.""" + return json.dumps(self.to_dict(), indent=2) + + def __eq__(self, other: 'RulesList') -> 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: 'RulesList') -> bool: + """Return `true` when self and other are not equal, false otherwise.""" + return not self == other + + +class TemplateAssignmentResponse: + """ + Response object containing the details of a template assignment. + + :attr str id: The ID of the assignment. + :attr str account_id: The ID of the account that the assignment belongs to. + :attr str template_id: The ID of the template that the assignment is based on. + :attr str template_version: The version of the template that the assignment is + based on. + :attr str target_type: The type of the entity that the assignment applies to. + :attr str target: The ID of the entity that the assignment applies to. + :attr str operation: The operation that the assignment applies to (e.g. + 'assign', 'update', 'remove'). + :attr str status: The status of the assignment (e.g. 'accepted', 'in_progress', + 'succeeded', 'failed', 'superseded'). + :attr str href: The URL of the assignment resource. + :attr datetime created_at: The date and time when the assignment was created. + :attr str created_by_id: The user or system that created the assignment. + :attr datetime last_modified_at: The date and time when the assignment was last + updated. + :attr str last_modified_by_id: The user or system that last updated the + assignment. + """ + + def __init__( + self, + id: str, + account_id: str, + template_id: str, + template_version: str, + target_type: str, + target: str, + operation: str, + status: str, + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, ) -> None: """ - Initialize a ListGroupMembersResponseMember object. - - :param str iam_id: (optional) The IBMid or Service Id of the member. - :param str type: (optional) The member type - either `user`, `service` or - `profile`. - :param str membership_type: (optional) The membership type - either - `static` or `dynamic`. - :param str name: (optional) The user's or service id's name. - :param str email: (optional) If the member type is user, this is the user's - email. - :param str description: (optional) If the member type is service, this is - the service id's description. - :param str href: (optional) A url to the given member resource. - :param datetime created_at: (optional) The timestamp the membership was - created at. - :param str created_by_id: (optional) The `iam_id` of the entity that - created the membership. + Initialize a TemplateAssignmentResponse object. + + :param str id: The ID of the assignment. + :param str account_id: The ID of the account that the assignment belongs + to. + :param str template_id: The ID of the template that the assignment is based + on. + :param str template_version: The version of the template that the + assignment is based on. + :param str target_type: The type of the entity that the assignment applies + to. + :param str target: The ID of the entity that the assignment applies to. + :param str operation: The operation that the assignment applies to (e.g. + 'assign', 'update', 'remove'). + :param str status: The status of the assignment (e.g. 'accepted', + 'in_progress', 'succeeded', 'failed', 'superseded'). + :param str href: The URL of the assignment resource. + :param datetime created_at: The date and time when the assignment was + created. + :param str created_by_id: The user or system that created the assignment. + :param datetime last_modified_at: The date and time when the assignment was + last updated. + :param str last_modified_by_id: The user or system that last updated the + assignment. """ - self.iam_id = iam_id - self.type = type - self.membership_type = membership_type - self.name = name - self.email = email - self.description = description + self.id = id + self.account_id = account_id + self.template_id = template_id + self.template_version = template_version + self.target_type = target_type + self.target = target + self.operation = operation + self.status = status 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) -> 'ListGroupMembersResponseMember': - """Initialize a ListGroupMembersResponseMember object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateAssignmentResponse': + """Initialize a TemplateAssignmentResponse object from a json dictionary.""" args = {} - if 'iam_id' in _dict: - args['iam_id'] = _dict.get('iam_id') - if 'type' in _dict: - args['type'] = _dict.get('type') - if 'membership_type' in _dict: - args['membership_type'] = _dict.get('membership_type') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'email' in _dict: - args['email'] = _dict.get('email') - if 'description' in _dict: - args['description'] = _dict.get('description') + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in TemplateAssignmentResponse JSON') + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + else: + raise ValueError('Required property \'account_id\' not present in TemplateAssignmentResponse JSON') + if 'template_id' in _dict: + args['template_id'] = _dict.get('template_id') + else: + raise ValueError('Required property \'template_id\' not present in TemplateAssignmentResponse JSON') + if 'template_version' in _dict: + args['template_version'] = _dict.get('template_version') + else: + raise ValueError('Required property \'template_version\' not present in TemplateAssignmentResponse JSON') + if 'target_type' in _dict: + args['target_type'] = _dict.get('target_type') + else: + raise ValueError('Required property \'target_type\' not present in TemplateAssignmentResponse JSON') + if 'target' in _dict: + args['target'] = _dict.get('target') + else: + raise ValueError('Required property \'target\' not present in TemplateAssignmentResponse JSON') + if 'operation' in _dict: + args['operation'] = _dict.get('operation') + else: + raise ValueError('Required property \'operation\' not present in TemplateAssignmentResponse JSON') + if 'status' in _dict: + args['status'] = _dict.get('status') + else: + raise ValueError('Required property \'status\' not present in TemplateAssignmentResponse JSON') if 'href' in _dict: args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TemplateAssignmentResponse JSON') if 'created_at' in _dict: args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TemplateAssignmentResponse JSON') if 'created_by_id' in _dict: args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError('Required property \'created_by_id\' not present in TemplateAssignmentResponse JSON') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + else: + raise ValueError('Required property \'last_modified_at\' not present in TemplateAssignmentResponse JSON') + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + else: + raise ValueError('Required property \'last_modified_by_id\' not present in TemplateAssignmentResponse JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a ListGroupMembersResponseMember object from a json dictionary.""" + """Initialize a TemplateAssignmentResponse 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, 'iam_id') and self.iam_id is not None: - _dict['iam_id'] = self.iam_id - if hasattr(self, 'type') and self.type is not None: - _dict['type'] = self.type - if hasattr(self, 'membership_type') and self.membership_type is not None: - _dict['membership_type'] = self.membership_type - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'email') and self.email is not None: - _dict['email'] = self.email - if hasattr(self, 'description') and self.description is not None: - _dict['description'] = self.description + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'account_id') and self.account_id is not None: + _dict['account_id'] = self.account_id + 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, '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, 'operation') and self.operation is not None: + _dict['operation'] = self.operation + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status if hasattr(self, 'href') and self.href is not None: _dict['href'] = self.href if hasattr(self, 'created_at') and self.created_at is not None: _dict['created_at'] = datetime_to_string(self.created_at) if hasattr(self, 'created_by_id') and self.created_by_id is not None: _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id return _dict def _to_dict(self): @@ -2986,122 +6618,207 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this ListGroupMembersResponseMember object.""" + """Return a `str` version of this TemplateAssignmentResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'ListGroupMembersResponseMember') -> bool: + def __eq__(self, other: 'TemplateAssignmentResponse') -> 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: 'ListGroupMembersResponseMember') -> bool: + def __ne__(self, other: 'TemplateAssignmentResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class TargetTypeEnum(str, Enum): + """ + The type of the entity that the assignment applies to. + """ -class Rule: - """ - A rule of an access group. + ACCOUNT = 'Account' + ACCOUNTGROUP = 'AccountGroup' - :attr str id: (optional) The rule id. - :attr str name: (optional) The name of the rule. - :attr int expiration: (optional) The number of hours that the rule lives for - (Must be between 1 and 24). - :attr str realm_name: (optional) The url of the identity provider. - :attr str access_group_id: (optional) The group id that the rule is assigned to. - :attr str account_id: (optional) The account id that the group is in. - :attr List[RuleConditions] conditions: (optional) A list of conditions the rule - must satisfy. - :attr datetime created_at: (optional) The timestamp the rule was created at. - :attr str created_by_id: (optional) The `iam_id` of the entity that created the - rule. - :attr datetime last_modified_at: (optional) The timestamp the rule was last - edited at. - :attr str last_modified_by_id: (optional) The IAM id that last modified the - rule. + class OperationEnum(str, Enum): + """ + The operation that the assignment applies to (e.g. 'assign', 'update', 'remove'). + """ + + ASSIGN = 'assign' + UPDATE = 'update' + REMOVE = 'remove' + + class StatusEnum(str, Enum): + """ + The status of the assignment (e.g. 'accepted', 'in_progress', 'succeeded', + 'failed', 'superseded'). + """ + + ACCEPTED = 'accepted' + IN_PROGRESS = 'in_progress' + SUCCEEDED = 'succeeded' + FAILED = 'failed' + SUPERSEDED = 'superseded' + + +class TemplateAssignmentVerboseResponse: + """ + Response object containing the details of a template assignment. + + :attr str id: The ID of the assignment. + :attr str account_id: The ID of the account that the assignment belongs to. + :attr str template_id: The ID of the template that the assignment is based on. + :attr str template_version: The version of the template that the assignment is + based on. + :attr str target_type: The type of the entity that the assignment applies to. + :attr str target: The ID of the entity that the assignment applies to. + :attr str operation: The operation that the assignment applies to (e.g. + 'create', 'update', 'delete'). + :attr str status: The status of the assignment (e.g. 'pending', 'success', + 'failure'). + :attr List[ResourceListWithTargetAccountID] resources: (optional) List of + resources for the assignment. + :attr str href: The URL of the assignment resource. + :attr datetime created_at: The date and time when the assignment was created. + :attr str created_by_id: The user or system that created the assignment. + :attr datetime last_modified_at: The date and time when the assignment was last + updated. + :attr str last_modified_by_id: The user or system that last updated the + assignment. """ def __init__( self, + id: str, + account_id: str, + template_id: str, + template_version: str, + target_type: str, + target: str, + operation: str, + status: str, + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, *, - id: str = None, - name: str = None, - expiration: int = None, - realm_name: str = None, - access_group_id: str = None, - account_id: str = None, - conditions: List['RuleConditions'] = None, - created_at: datetime = None, - created_by_id: str = None, - last_modified_at: datetime = None, - last_modified_by_id: str = None, + resources: List['ResourceListWithTargetAccountID'] = None, ) -> None: """ - Initialize a Rule object. - - :param str id: (optional) The rule id. - :param str name: (optional) The name of the rule. - :param int expiration: (optional) The number of hours that the rule lives - for (Must be between 1 and 24). - :param str realm_name: (optional) The url of the identity provider. - :param str access_group_id: (optional) The group id that the rule is - assigned to. - :param str account_id: (optional) The account id that the group is in. - :param List[RuleConditions] conditions: (optional) A list of conditions the - rule must satisfy. - :param datetime created_at: (optional) The timestamp the rule was created - at. - :param str created_by_id: (optional) The `iam_id` of the entity that - created the rule. - :param datetime last_modified_at: (optional) The timestamp the rule was - last edited at. - :param str last_modified_by_id: (optional) The IAM id that last modified - the rule. + Initialize a TemplateAssignmentVerboseResponse object. + + :param str id: The ID of the assignment. + :param str account_id: The ID of the account that the assignment belongs + to. + :param str template_id: The ID of the template that the assignment is based + on. + :param str template_version: The version of the template that the + assignment is based on. + :param str target_type: The type of the entity that the assignment applies + to. + :param str target: The ID of the entity that the assignment applies to. + :param str operation: The operation that the assignment applies to (e.g. + 'create', 'update', 'delete'). + :param str status: The status of the assignment (e.g. 'pending', 'success', + 'failure'). + :param str href: The URL of the assignment resource. + :param datetime created_at: The date and time when the assignment was + created. + :param str created_by_id: The user or system that created the assignment. + :param datetime last_modified_at: The date and time when the assignment was + last updated. + :param str last_modified_by_id: The user or system that last updated the + assignment. + :param List[ResourceListWithTargetAccountID] resources: (optional) List of + resources for the assignment. """ self.id = id - self.name = name - self.expiration = expiration - self.realm_name = realm_name - self.access_group_id = access_group_id self.account_id = account_id - self.conditions = conditions + self.template_id = template_id + self.template_version = template_version + self.target_type = target_type + self.target = target + self.operation = operation + self.status = status + 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 @classmethod - def from_dict(cls, _dict: Dict) -> 'Rule': - """Initialize a Rule object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateAssignmentVerboseResponse': + """Initialize a TemplateAssignmentVerboseResponse object from a json dictionary.""" args = {} if 'id' in _dict: args['id'] = _dict.get('id') - if 'name' in _dict: - args['name'] = _dict.get('name') - if 'expiration' in _dict: - args['expiration'] = _dict.get('expiration') - if 'realm_name' in _dict: - args['realm_name'] = _dict.get('realm_name') - if 'access_group_id' in _dict: - args['access_group_id'] = _dict.get('access_group_id') + else: + raise ValueError('Required property \'id\' not present in TemplateAssignmentVerboseResponse JSON') if 'account_id' in _dict: args['account_id'] = _dict.get('account_id') - if 'conditions' in _dict: - args['conditions'] = [RuleConditions.from_dict(v) for v in _dict.get('conditions')] + else: + raise ValueError('Required property \'account_id\' not present in TemplateAssignmentVerboseResponse JSON') + if 'template_id' in _dict: + args['template_id'] = _dict.get('template_id') + else: + raise ValueError('Required property \'template_id\' not present in TemplateAssignmentVerboseResponse JSON') + if 'template_version' in _dict: + args['template_version'] = _dict.get('template_version') + else: + raise ValueError( + 'Required property \'template_version\' not present in TemplateAssignmentVerboseResponse JSON' + ) + if 'target_type' in _dict: + args['target_type'] = _dict.get('target_type') + else: + raise ValueError('Required property \'target_type\' not present in TemplateAssignmentVerboseResponse JSON') + if 'target' in _dict: + args['target'] = _dict.get('target') + else: + raise ValueError('Required property \'target\' not present in TemplateAssignmentVerboseResponse JSON') + if 'operation' in _dict: + args['operation'] = _dict.get('operation') + else: + raise ValueError('Required property \'operation\' not present in TemplateAssignmentVerboseResponse JSON') + if 'status' in _dict: + args['status'] = _dict.get('status') + else: + raise ValueError('Required property \'status\' not present in TemplateAssignmentVerboseResponse JSON') + if 'resources' in _dict: + args['resources'] = [ResourceListWithTargetAccountID.from_dict(v) for v in _dict.get('resources')] + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TemplateAssignmentVerboseResponse JSON') if 'created_at' in _dict: args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TemplateAssignmentVerboseResponse JSON') if 'created_by_id' in _dict: args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError( + 'Required property \'created_by_id\' not present in TemplateAssignmentVerboseResponse JSON' + ) if 'last_modified_at' in _dict: args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + else: + raise ValueError( + 'Required property \'last_modified_at\' not present in TemplateAssignmentVerboseResponse JSON' + ) if 'last_modified_by_id' in _dict: args['last_modified_by_id'] = _dict.get('last_modified_by_id') + else: + raise ValueError( + 'Required property \'last_modified_by_id\' not present in TemplateAssignmentVerboseResponse JSON' + ) return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a Rule object from a json dictionary.""" + """Initialize a TemplateAssignmentVerboseResponse object from a json dictionary.""" return cls.from_dict(_dict) def to_dict(self) -> Dict: @@ -3109,24 +6826,30 @@ def to_dict(self) -> Dict: _dict = {} if hasattr(self, 'id') and self.id is not None: _dict['id'] = self.id - if hasattr(self, 'name') and self.name is not None: - _dict['name'] = self.name - if hasattr(self, 'expiration') and self.expiration is not None: - _dict['expiration'] = self.expiration - if hasattr(self, 'realm_name') and self.realm_name is not None: - _dict['realm_name'] = self.realm_name - if hasattr(self, 'access_group_id') and self.access_group_id is not None: - _dict['access_group_id'] = self.access_group_id if hasattr(self, 'account_id') and self.account_id is not None: _dict['account_id'] = self.account_id - if hasattr(self, 'conditions') and self.conditions is not None: - conditions_list = [] - for v in self.conditions: + 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, '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, 'operation') and self.operation is not None: + _dict['operation'] = self.operation + if hasattr(self, 'status') and self.status is not None: + _dict['status'] = self.status + if hasattr(self, 'resources') and self.resources is not None: + resources_list = [] + for v in self.resources: if isinstance(v, dict): - conditions_list.append(v) + resources_list.append(v) else: - conditions_list.append(v.to_dict()) - _dict['conditions'] = conditions_list + resources_list.append(v.to_dict()) + _dict['resources'] = resources_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href if hasattr(self, 'created_at') and self.created_at is not None: _dict['created_at'] = datetime_to_string(self.created_at) if hasattr(self, 'created_by_id') and self.created_by_id is not None: @@ -3142,82 +6865,205 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this Rule object.""" + """Return a `str` version of this TemplateAssignmentVerboseResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'Rule') -> bool: + def __eq__(self, other: 'TemplateAssignmentVerboseResponse') -> 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: 'Rule') -> bool: + def __ne__(self, other: 'TemplateAssignmentVerboseResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RuleConditions: +class TemplateResponse: """ - The conditions of a rule. - - :attr str claim: The claim to evaluate against. This will be found in the `ext` - claims of a user's login request. - :attr str operator: The operation to perform on the claim. - :attr str value: The stringified JSON value that the claim is compared to using - the operator. + Response output for template. + + :attr str id: The ID of the access group template. + :attr str name: The name of the access group template. + :attr str description: The description of the access group template. + :attr str account_id: The ID of the account to which the access group template + is assigned. + :attr str version: The version of the access group template. + :attr bool committed: A boolean indicating whether the access group template is + committed. You must commit a template before you can assign it to child + accounts. + :attr AccessGroupResponse group: Access Group Component. + :attr List[PolicyTemplates] policy_template_references: References to policy + templates assigned to the access group template. + :attr str href: The URL of the access group template resource. + :attr datetime created_at: The date and time when the access group template was + created. + :attr str created_by_id: The ID of the user who created the access group + template. + :attr datetime last_modified_at: The date and time when the access group + template was last modified. + :attr str last_modified_by_id: The ID of the user who last modified the access + group template. """ def __init__( self, - claim: str, - operator: str, - value: str, + id: str, + name: str, + description: str, + account_id: str, + version: str, + committed: bool, + group: 'AccessGroupResponse', + policy_template_references: List['PolicyTemplates'], + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, ) -> None: """ - Initialize a RuleConditions object. - - :param str claim: The claim to evaluate against. This will be found in the - `ext` claims of a user's login request. - :param str operator: The operation to perform on the claim. - :param str value: The stringified JSON value that the claim is compared to - using the operator. + Initialize a TemplateResponse object. + + :param str id: The ID of the access group template. + :param str name: The name of the access group template. + :param str description: The description of the access group template. + :param str account_id: The ID of the account to which the access group + template is assigned. + :param str version: The version of the access group template. + :param bool committed: A boolean indicating whether the access group + template is committed. You must commit a template before you can assign it + to child accounts. + :param AccessGroupResponse group: Access Group Component. + :param List[PolicyTemplates] policy_template_references: References to + policy templates assigned to the access group template. + :param str href: The URL of the access group template resource. + :param datetime created_at: The date and time when the access group + template was created. + :param str created_by_id: The ID of the user who created the access group + template. + :param datetime last_modified_at: The date and time when the access group + template was last modified. + :param str last_modified_by_id: The ID of the user who last modified the + access group template. """ - self.claim = claim - self.operator = operator - self.value = value + self.id = id + self.name = name + self.description = description + self.account_id = account_id + self.version = version + self.committed = committed + self.group = group + self.policy_template_references = policy_template_references + 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) -> 'RuleConditions': - """Initialize a RuleConditions object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateResponse': + """Initialize a TemplateResponse object from a json dictionary.""" args = {} - if 'claim' in _dict: - args['claim'] = _dict.get('claim') + if 'id' in _dict: + args['id'] = _dict.get('id') else: - raise ValueError('Required property \'claim\' not present in RuleConditions JSON') - if 'operator' in _dict: - args['operator'] = _dict.get('operator') + raise ValueError('Required property \'id\' not present in TemplateResponse JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TemplateResponse JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + else: + raise ValueError('Required property \'description\' not present in TemplateResponse JSON') + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + else: + raise ValueError('Required property \'account_id\' not present in TemplateResponse JSON') + if 'version' in _dict: + args['version'] = _dict.get('version') + else: + raise ValueError('Required property \'version\' not present in TemplateResponse JSON') + if 'committed' in _dict: + args['committed'] = _dict.get('committed') + else: + raise ValueError('Required property \'committed\' not present in TemplateResponse JSON') + if 'group' in _dict: + args['group'] = AccessGroupResponse.from_dict(_dict.get('group')) + else: + raise ValueError('Required property \'group\' not present in TemplateResponse JSON') + if 'policy_template_references' in _dict: + args['policy_template_references'] = [ + PolicyTemplates.from_dict(v) for v in _dict.get('policy_template_references') + ] + else: + raise ValueError('Required property \'policy_template_references\' not present in TemplateResponse JSON') + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TemplateResponse JSON') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TemplateResponse JSON') + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError('Required property \'created_by_id\' not present in TemplateResponse JSON') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) else: - raise ValueError('Required property \'operator\' not present in RuleConditions JSON') - if 'value' in _dict: - args['value'] = _dict.get('value') + raise ValueError('Required property \'last_modified_at\' not present in TemplateResponse JSON') + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') else: - raise ValueError('Required property \'value\' not present in RuleConditions JSON') + raise ValueError('Required property \'last_modified_by_id\' not present in TemplateResponse JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RuleConditions object from a json dictionary.""" + """Initialize a TemplateResponse 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, 'claim') and self.claim is not None: - _dict['claim'] = self.claim - 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, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, '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, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'policy_template_references') and self.policy_template_references is not None: + policy_template_references_list = [] + for v in self.policy_template_references: + if isinstance(v, dict): + policy_template_references_list.append(v) + else: + policy_template_references_list.append(v.to_dict()) + _dict['policy_template_references'] = policy_template_references_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id return _dict def _to_dict(self): @@ -3225,75 +7071,207 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RuleConditions object.""" + """Return a `str` version of this TemplateResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RuleConditions') -> bool: + def __eq__(self, other: 'TemplateResponse') -> 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: 'RuleConditions') -> bool: + def __ne__(self, other: 'TemplateResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other - class OperatorEnum(str, Enum): - """ - The operation to perform on the claim. - """ - - EQUALS = 'EQUALS' - EQUALS_IGNORE_CASE = 'EQUALS_IGNORE_CASE' - IN = 'IN' - NOT_EQUALS_IGNORE_CASE = 'NOT_EQUALS_IGNORE_CASE' - NOT_EQUALS = 'NOT_EQUALS' - CONTAINS = 'CONTAINS' - -class RulesList: +class TemplateVersionResponse: """ - A list of rules attached to the access group. - - :attr List[Rule] rules: (optional) A list of rules. + Response output for template. + + :attr str id: The ID of the access group template. + :attr str name: The name of the access group template. + :attr str description: The description of the access group template. + :attr str account_id: The ID of the account to which the access group template + is assigned. + :attr str version: The version of the access group template. + :attr bool committed: A boolean indicating whether the access group template is + committed. You must commit a template before you can assign it to child + accounts. + :attr AccessGroupResponse group: Access Group Component. + :attr List[PolicyTemplates] policy_template_references: References to policy + templates assigned to the access group template. + :attr str href: The URL of the access group template resource. + :attr datetime created_at: The date and time when the access group template was + created. + :attr str created_by_id: The ID of the user who created the access group + template. + :attr datetime last_modified_at: The date and time when the access group + template was last modified. + :attr str last_modified_by_id: The ID of the user who last modified the access + group template. """ def __init__( self, - *, - rules: List['Rule'] = None, + id: str, + name: str, + description: str, + account_id: str, + version: str, + committed: bool, + group: 'AccessGroupResponse', + policy_template_references: List['PolicyTemplates'], + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, ) -> None: """ - Initialize a RulesList object. - - :param List[Rule] rules: (optional) A list of rules. + Initialize a TemplateVersionResponse object. + + :param str id: The ID of the access group template. + :param str name: The name of the access group template. + :param str description: The description of the access group template. + :param str account_id: The ID of the account to which the access group + template is assigned. + :param str version: The version of the access group template. + :param bool committed: A boolean indicating whether the access group + template is committed. You must commit a template before you can assign it + to child accounts. + :param AccessGroupResponse group: Access Group Component. + :param List[PolicyTemplates] policy_template_references: References to + policy templates assigned to the access group template. + :param str href: The URL of the access group template resource. + :param datetime created_at: The date and time when the access group + template was created. + :param str created_by_id: The ID of the user who created the access group + template. + :param datetime last_modified_at: The date and time when the access group + template was last modified. + :param str last_modified_by_id: The ID of the user who last modified the + access group template. """ - self.rules = rules + self.id = id + self.name = name + self.description = description + self.account_id = account_id + self.version = version + self.committed = committed + self.group = group + self.policy_template_references = policy_template_references + 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) -> 'RulesList': - """Initialize a RulesList object from a json dictionary.""" + def from_dict(cls, _dict: Dict) -> 'TemplateVersionResponse': + """Initialize a TemplateVersionResponse object from a json dictionary.""" args = {} - if 'rules' in _dict: - args['rules'] = [Rule.from_dict(v) for v in _dict.get('rules')] + if 'id' in _dict: + args['id'] = _dict.get('id') + else: + raise ValueError('Required property \'id\' not present in TemplateVersionResponse JSON') + if 'name' in _dict: + args['name'] = _dict.get('name') + else: + raise ValueError('Required property \'name\' not present in TemplateVersionResponse JSON') + if 'description' in _dict: + args['description'] = _dict.get('description') + else: + raise ValueError('Required property \'description\' not present in TemplateVersionResponse JSON') + if 'account_id' in _dict: + args['account_id'] = _dict.get('account_id') + else: + raise ValueError('Required property \'account_id\' not present in TemplateVersionResponse JSON') + if 'version' in _dict: + args['version'] = _dict.get('version') + else: + raise ValueError('Required property \'version\' not present in TemplateVersionResponse JSON') + if 'committed' in _dict: + args['committed'] = _dict.get('committed') + else: + raise ValueError('Required property \'committed\' not present in TemplateVersionResponse JSON') + if 'group' in _dict: + args['group'] = AccessGroupResponse.from_dict(_dict.get('group')) + else: + raise ValueError('Required property \'group\' not present in TemplateVersionResponse JSON') + if 'policy_template_references' in _dict: + args['policy_template_references'] = [ + PolicyTemplates.from_dict(v) for v in _dict.get('policy_template_references') + ] + else: + raise ValueError( + 'Required property \'policy_template_references\' not present in TemplateVersionResponse JSON' + ) + if 'href' in _dict: + args['href'] = _dict.get('href') + else: + raise ValueError('Required property \'href\' not present in TemplateVersionResponse JSON') + if 'created_at' in _dict: + args['created_at'] = string_to_datetime(_dict.get('created_at')) + else: + raise ValueError('Required property \'created_at\' not present in TemplateVersionResponse JSON') + if 'created_by_id' in _dict: + args['created_by_id'] = _dict.get('created_by_id') + else: + raise ValueError('Required property \'created_by_id\' not present in TemplateVersionResponse JSON') + if 'last_modified_at' in _dict: + args['last_modified_at'] = string_to_datetime(_dict.get('last_modified_at')) + else: + raise ValueError('Required property \'last_modified_at\' not present in TemplateVersionResponse JSON') + if 'last_modified_by_id' in _dict: + args['last_modified_by_id'] = _dict.get('last_modified_by_id') + else: + raise ValueError('Required property \'last_modified_by_id\' not present in TemplateVersionResponse JSON') return cls(**args) @classmethod def _from_dict(cls, _dict): - """Initialize a RulesList object from a json dictionary.""" + """Initialize a TemplateVersionResponse 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, 'rules') and self.rules is not None: - rules_list = [] - for v in self.rules: + if hasattr(self, 'id') and self.id is not None: + _dict['id'] = self.id + if hasattr(self, 'name') and self.name is not None: + _dict['name'] = self.name + if hasattr(self, '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, 'group') and self.group is not None: + if isinstance(self.group, dict): + _dict['group'] = self.group + else: + _dict['group'] = self.group.to_dict() + if hasattr(self, 'policy_template_references') and self.policy_template_references is not None: + policy_template_references_list = [] + for v in self.policy_template_references: if isinstance(v, dict): - rules_list.append(v) + policy_template_references_list.append(v) else: - rules_list.append(v.to_dict()) - _dict['rules'] = rules_list + policy_template_references_list.append(v.to_dict()) + _dict['policy_template_references'] = policy_template_references_list + if hasattr(self, 'href') and self.href is not None: + _dict['href'] = self.href + if hasattr(self, 'created_at') and self.created_at is not None: + _dict['created_at'] = datetime_to_string(self.created_at) + if hasattr(self, 'created_by_id') and self.created_by_id is not None: + _dict['created_by_id'] = self.created_by_id + if hasattr(self, 'last_modified_at') and self.last_modified_at is not None: + _dict['last_modified_at'] = datetime_to_string(self.last_modified_at) + if hasattr(self, 'last_modified_by_id') and self.last_modified_by_id is not None: + _dict['last_modified_by_id'] = self.last_modified_by_id return _dict def _to_dict(self): @@ -3301,16 +7279,16 @@ def _to_dict(self): return self.to_dict() def __str__(self) -> str: - """Return a `str` version of this RulesList object.""" + """Return a `str` version of this TemplateVersionResponse object.""" return json.dumps(self.to_dict(), indent=2) - def __eq__(self, other: 'RulesList') -> bool: + def __eq__(self, other: 'TemplateVersionResponse') -> 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: 'RulesList') -> bool: + def __ne__(self, other: 'TemplateVersionResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other @@ -3465,9 +7443,9 @@ def __init__( Transaction-Id and the value is anything that you choose. If no transaction ID is passed in, then a random ID is generated. :param str membership_type: (optional) Filters members by membership type. - Membership type can be either `static`, `dynamic` or `all`. `static` lists - those members explicitly added to the access group, `dynamic` lists those - members part of access group via dynamic rules at the moment. `all` lists + Filter by `static`, `dynamic` or `all`. `static` lists the members + explicitly added to the access group, and `dynamic` lists the members that + are part of the access group at that time via dynamic rules. `all` lists both static and dynamic members. :param int limit: (optional) Return up to this limit of results where limit is between 0 and 100. @@ -3536,3 +7514,153 @@ def get_all(self) -> List[dict]: next_page = self.get_next() results.extend(next_page) return results + + +class TemplatesPager: + """ + TemplatesPager can be used to simplify the use of the "list_templates" method. + """ + + def __init__( + self, + *, + client: IamAccessGroupsV2, + account_id: str, + transaction_id: str = None, + limit: int = None, + verbose: bool = None, + ) -> None: + """ + Initialize a TemplatesPager object. + :param str account_id: Enterprise account ID. + :param str transaction_id: (optional) An optional transaction id for the + request. + :param int limit: (optional) Return up to this limit of results where limit + is between 0 and 100. + :param bool verbose: (optional) If `verbose=true`, IAM resource details are + returned. If performance is a concern, leave the `verbose` parameter off so + that details are not retrieved. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._account_id = account_id + self._transaction_id = transaction_id + self._limit = limit + self._verbose = verbose + + 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 GroupTemplate. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_templates( + account_id=self._account_id, + transaction_id=self._transaction_id, + limit=self._limit, + verbose=self._verbose, + offset=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = get_query_param(next_page_link.get('href'), 'offset') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('group_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 GroupTemplate. + :rtype: List[dict] + """ + results = [] + while self.has_next(): + next_page = self.get_next() + results.extend(next_page) + return results + + +class TemplateVersionsPager: + """ + TemplateVersionsPager can be used to simplify the use of the "list_template_versions" method. + """ + + def __init__( + self, + *, + client: IamAccessGroupsV2, + template_id: str, + limit: int = None, + ) -> None: + """ + Initialize a TemplateVersionsPager object. + :param str template_id: ID of the template that you want to list all + versions of. + :param int limit: (optional) Return up to this limit of results where limit + is between 0 and 100. + """ + self._has_next = True + self._client = client + self._page_context = {'next': None} + self._template_id = template_id + 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 ListTemplateVersionResponse. + :rtype: List[dict] + """ + if not self.has_next(): + raise StopIteration(message='No more results available') + + result = self._client.list_template_versions( + template_id=self._template_id, + limit=self._limit, + offset=self._page_context.get('next'), + ).get_result() + + next = None + next_page_link = result.get('next') + if next_page_link is not None: + next = get_query_param(next_page_link.get('href'), 'offset') + self._page_context['next'] = next + if next is None: + self._has_next = False + + return result.get('group_template_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 ListTemplateVersionResponse. + :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_access_groups_v2.py b/test/integration/test_iam_access_groups_v2.py index ef0c8abd..deaaa869 100644 --- a/test/integration/test_iam_access_groups_v2.py +++ b/test/integration/test_iam_access_groups_v2.py @@ -1,6 +1,5 @@ -# coding: utf-8 - -# Copyright 2019, 2022 IBM All Rights Reserved. +# -*- coding: utf-8 -*- +# (C) Copyright IBM Corp. 2023. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,9 +14,12 @@ # limitations under the License. """ - This class contains an integration test for the IAM Access Groups service. +Integration Tests for IamAccessGroupsV2 """ +from ibm_cloud_sdk_core import * +import os +import time import pytest import os import os.path @@ -51,6 +53,8 @@ def setup_class(cls): cls.config = read_external_sources(IamAccessGroupsV2.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.testAccountId = cls.config.get('TEST_ACCOUNT_ID') + cls.testPolicyTemplateId = cls.config.get('TEST_POLICY_TEMPLATE_ID') + cls.testAccountGroupId = cls.config.get('TEST_ACCOUNT_GROUP_ID') assert cls.testAccountId is not None cls.etagHeader = "ETag" @@ -65,6 +69,11 @@ def setup_class(cls): cls.testClaimRuleId = "" cls.testClaimRuleETag = "" cls.testAccountSettings = AccountSettings() + cls.testTemplateId = "" + cls.testTemplateEtag = "" + cls.testTemplateLatestEtag = "" + cls.testAssignmentId = "" + cls.testAssignmentEtag = "" print('Setup complete.') @@ -536,3 +545,445 @@ def test_18_update_account_settings(self): assert result is not None assert result.account_id == self.testAccountId assert result.public_access_enabled == self.testAccountSettings.public_access_enabled + + @needscredentials + def test_create_template(self): + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = { + 'add': True, + 'remove': False, + } + # Construct a dict representation of a MembersInput model + members_input_model = { + 'users': ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + # Construct a dict representation of a ConditionInput model + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + # Construct a dict representation of a RulesActionControls model + rules_action_controls_model = { + 'remove': False, + 'update': False, + } + # Construct a dict representation of a RuleInput model + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + 'action_controls': rules_action_controls_model, + } + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = { + 'add': False, + 'remove': True, + 'update': True, + } + # Construct a dict representation of a AssertionsInput model + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = { + 'add': False, + } + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = { + 'access': access_action_controls_model, + } + # Construct a dict representation of a AccessGroupInput model + access_group_input_model = { + 'name': 'IAM Admin Group', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + # Construct a dict representation of a PolicyTemplatesInput model + policy_templates_input_model = { + 'id': self.testPolicyTemplateId, + 'version': '1', + } + + response = self.iam_access_groups_service.create_template( + name='IAM Admin Group template', + account_id=self.testAccountId, + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + transaction_id='testString', + ) + + assert response.get_status_code() == 201 + create_template_response = response.get_result() + assert create_template_response is not None + self.__class__.testTemplateId = create_template_response['id'] + + @needscredentials + def test_list_templates(self): + response = self.iam_access_groups_service.list_templates( + account_id=self.testAccountId, + transaction_id='testString', + limit=50, + offset=0, + verbose=True, + ) + + assert response.get_status_code() == 200 + list_templates_response = response.get_result() + assert list_templates_response is not None + + @needscredentials + def test_list_templates_with_pager(self): + all_results = [] + + # Test get_next(). + pager = TemplatesPager( + client=self.iam_access_groups_service, + account_id=self.testAccountId, + transaction_id='testString', + limit=50, + verbose=True, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + # Test get_all(). + pager = TemplatesPager( + client=self.iam_access_groups_service, + account_id=self.testAccountId, + transaction_id='testString', + limit=50, + verbose=True, + ) + all_items = pager.get_all() + assert all_items is not None + + assert len(all_results) == len(all_items) + print(f'\nlist_templates() returned a total of {len(all_results)} items(s) using TemplatesPager.') + + @needscredentials + def test_create_template_version(self): + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = { + 'add': True, + 'remove': False, + } + # Construct a dict representation of a MembersInput model + members_input_model = { + 'users': ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + # Construct a dict representation of a ConditionInput model + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + # Construct a dict representation of a RulesActionControls model + rules_action_controls_model = { + 'remove': True, + 'update': True, + } + # Construct a dict representation of a RuleInput model + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + 'action_controls': rules_action_controls_model, + } + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = { + 'add': False, + 'remove': True, + 'update': True, + } + # Construct a dict representation of a AssertionsInput model + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = { + 'add': False, + } + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = { + 'access': access_action_controls_model, + } + # Construct a dict representation of a AccessGroupInput model + access_group_input_model = { + 'name': 'IAM Admin Group 8', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + # Construct a dict representation of a PolicyTemplatesInput model + policy_templates_input_model = { + 'id': self.testPolicyTemplateId, + 'version': '1', + } + + response = self.iam_access_groups_service.create_template_version( + template_id=self.testTemplateId, + name='IAM Admin Group template 2', + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + transaction_id='testString', + ) + + assert response.get_status_code() == 201 + create_template_response = response.get_result() + assert create_template_response is not None + + @needscredentials + def test_list_template_versions(self): + response = self.iam_access_groups_service.list_template_versions( + template_id=self.testTemplateId, + limit=100, + offset=0, + ) + + assert response.get_status_code() == 200 + list_template_versions_response = response.get_result() + assert list_template_versions_response is not None + + @needscredentials + def test_list_template_versions_with_pager(self): + all_results = [] + + # Test get_next(). + pager = TemplateVersionsPager( + client=self.iam_access_groups_service, + template_id=self.testTemplateId, + limit=100, + ) + while pager.has_next(): + next_page = pager.get_next() + assert next_page is not None + all_results.extend(next_page) + + # Test get_all(). + pager = TemplateVersionsPager( + client=self.iam_access_groups_service, + template_id=self.testTemplateId, + limit=100, + ) + all_items = pager.get_all() + assert all_items is not None + + assert len(all_results) == len(all_items) + print( + f'\nlist_template_versions() returned a total of {len(all_results)} items(s) using TemplateVersionsPager.' + ) + + @needscredentials + def test_get_template_version(self): + response = self.iam_access_groups_service.get_template_version( + template_id=self.testTemplateId, + version_num='1', + transaction_id='testString', + ) + + assert response.get_status_code() == 200 + create_template_response = response.get_result() + assert create_template_response is not None + + self.__class__.testTemplateEtag = response.get_headers().get(self.etagHeader) + + @needscredentials + def test_update_template_version(self): + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = { + 'add': True, + 'remove': False, + } + # Construct a dict representation of a MembersInput model + members_input_model = { + 'users': ['IBMid-665000T8WY'], + 'action_controls': members_action_controls_model, + } + # Construct a dict representation of a ConditionInput model + condition_input_model = { + 'claim': 'blueGroup', + 'operator': 'CONTAINS', + 'value': '\"test-bluegroup-saml\"', + } + # Construct a dict representation of a RulesActionControls model + rules_action_controls_model = { + 'remove': False, + 'update': False, + } + # Construct a dict representation of a RuleInput model + rule_input_model = { + 'name': 'Manager group rule', + 'expiration': 12, + 'realm_name': 'https://idp.example.org/SAML2', + 'conditions': [condition_input_model], + 'action_controls': rules_action_controls_model, + } + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = { + 'add': False, + 'remove': True, + 'update': True, + } + # Construct a dict representation of a AssertionsInput model + assertions_input_model = { + 'rules': [rule_input_model], + 'action_controls': assertions_action_controls_model, + } + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = { + 'add': False, + } + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = { + 'access': access_action_controls_model, + } + # Construct a dict representation of a AccessGroupInput model + access_group_input_model = { + 'name': 'IAM Admin Group 8', + 'description': 'This access group template allows admin access to all IAM platform services in the account.', + 'members': members_input_model, + 'assertions': assertions_input_model, + 'action_controls': group_action_controls_model, + } + # Construct a dict representation of a PolicyTemplatesInput model + policy_templates_input_model = { + 'id': self.testPolicyTemplateId, + 'version': '1', + } + + response = self.iam_access_groups_service.update_template_version( + template_id=self.testTemplateId, + version_num='1', + if_match=self.testTemplateEtag, + name='IAM Admin Group template 2', + description='This access group template allows admin access to all IAM platform services in the account.', + group=access_group_input_model, + policy_template_references=[policy_templates_input_model], + transaction_id='83adf5bd-de790caa3', + ) + + assert response.get_status_code() == 201 + create_template_response = response.get_result() + assert create_template_response is not None + + @needscredentials + def test_get_latest_template_version(self): + response = self.iam_access_groups_service.get_latest_template_version( + template_id=self.testTemplateId, + transaction_id='testString', + ) + + assert response.get_status_code() == 200 + create_template_response = response.get_result() + assert create_template_response is not None + + self.__class__.testTemplateLatestEtag = response.get_headers().get(self.etagHeader) + + @needscredentials + def test_commit_template(self): + response = self.iam_access_groups_service.commit_template( + template_id=self.testTemplateId, + version_num='2', + if_match=self.testTemplateLatestEtag, + transaction_id='testString', + ) + + assert response.get_status_code() == 204 + + @needscredentials + def test_create_assignment(self): + response = self.iam_access_groups_service.create_assignment( + template_id=self.testTemplateId, + template_version='2', + target_type='AccountGroup', + target=self.testAccountGroupId, + transaction_id='testString', + ) + + assert response.get_status_code() == 202 + template_create_assignment_response = response.get_result() + assert template_create_assignment_response is not None + + self.__class__.testAssignmentId = template_create_assignment_response['id'] + time.sleep(60) + + @needscredentials + def test_list_assignments(self): + response = self.iam_access_groups_service.list_assignments( + account_id=self.testTemplateId, + ) + + assert response.get_status_code() == 200 + templates_list_assignment_response = response.get_result() + assert templates_list_assignment_response is not None + + @needscredentials + def test_get_assignment(self): + response = self.iam_access_groups_service.get_assignment( + assignment_id=self.testAssignmentId, + transaction_id='testString', + ) + + assert response.get_status_code() == 200 + get_assignment_response = response.get_result() + assert get_assignment_response is not None + + self.__class__.testAssignmentEtag = response.get_headers().get(self.etagHeader) + + @needscredentials + def test_update_assignment(self): + response = self.iam_access_groups_service.update_assignment( + assignment_id=self.testAssignmentId, + if_match=self.testAssignmentEtag, + template_version="2", + ) + + assert response.get_status_code() == 202 + update_template_assignment_response = response.get_result() + assert update_template_assignment_response is not None + + time.sleep(60) + + @needscredentials + def test_delete_assignment(self): + response = self.iam_access_groups_service.delete_assignment( + assignment_id=self.testAssignmentId, + transaction_id='testString', + ) + + assert response.get_status_code() == 202 + + time.sleep(90) + + @needscredentials + def test_delete_template_version(self): + response = self.iam_access_groups_service.delete_template_version( + template_id=self.testTemplateId, + version_num='2', + transaction_id='testString', + ) + + assert response.get_status_code() == 204 + + @needscredentials + def test_delete_template(self): + response = self.iam_access_groups_service.delete_template( + template_id=self.testTemplateId, + transaction_id='testString', + ) + + assert response.get_status_code() == 204 diff --git a/test/unit/test_iam_access_groups_v2.py b/test/unit/test_iam_access_groups_v2.py index 3116ddda..c9299ce5 100644 --- a/test/unit/test_iam_access_groups_v2.py +++ b/test/unit/test_iam_access_groups_v2.py @@ -272,8 +272,8 @@ def test_list_access_groups_all_params(self): iam_id = 'testString' search = 'testString' membership_type = 'static' - limit = 100 - offset = 38 + limit = 50 + offset = 0 sort = 'name' show_federated = False hide_public_access = False @@ -1202,8 +1202,8 @@ def test_list_access_group_members_all_params(self): access_group_id = 'testString' transaction_id = 'testString' membership_type = 'static' - limit = 100 - offset = 38 + limit = 50 + offset = 0 type = 'testString' verbose = False sort = 'testString' @@ -1810,7 +1810,7 @@ def test_add_member_to_multiple_access_groups_all_params(self): account_id = 'testString' iam_id = 'testString' type = 'user' - groups = ['access-group-id-1'] + groups = ['AccessGroupId-b0d32f56-f85c-4bf1-af37-7bbd92b1b2b3'] transaction_id = 'testString' # Invoke method @@ -1833,7 +1833,7 @@ def test_add_member_to_multiple_access_groups_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['type'] == 'user' - assert req_body['groups'] == ['access-group-id-1'] + assert req_body['groups'] == ['AccessGroupId-b0d32f56-f85c-4bf1-af37-7bbd92b1b2b3'] def test_add_member_to_multiple_access_groups_all_params_with_retries(self): # Enable retries and run test_add_member_to_multiple_access_groups_all_params. @@ -1864,7 +1864,7 @@ def test_add_member_to_multiple_access_groups_required_params(self): account_id = 'testString' iam_id = 'testString' type = 'user' - groups = ['access-group-id-1'] + groups = ['AccessGroupId-b0d32f56-f85c-4bf1-af37-7bbd92b1b2b3'] # Invoke method response = _service.add_member_to_multiple_access_groups( @@ -1885,7 +1885,7 @@ def test_add_member_to_multiple_access_groups_required_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['type'] == 'user' - assert req_body['groups'] == ['access-group-id-1'] + assert req_body['groups'] == ['AccessGroupId-b0d32f56-f85c-4bf1-af37-7bbd92b1b2b3'] def test_add_member_to_multiple_access_groups_required_params_with_retries(self): # Enable retries and run test_add_member_to_multiple_access_groups_required_params. @@ -1916,7 +1916,7 @@ def test_add_member_to_multiple_access_groups_value_error(self): account_id = 'testString' iam_id = 'testString' type = 'user' - groups = ['access-group-id-1'] + groups = ['AccessGroupId-b0d32f56-f85c-4bf1-af37-7bbd92b1b2b3'] # Pass in all but one required param and check for a ValueError req_param_dict = { @@ -3016,206 +3016,2891 @@ def test_update_account_settings_value_error_with_retries(self): # End of Service: AccountSettings ############################################################################## - ############################################################################## -# Start of Model Tests +# Start of Service: TemplateOperations ############################################################################## # region -class TestModel_AccountSettings: +class TestNewInstance: """ - Test Class for AccountSettings + Test Class for new_instance """ - def test_account_settings_serialization(self): + def test_new_instance(self): """ - Test serialization/deserialization for AccountSettings + new_instance() """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' - # Construct a json representation of a AccountSettings model - account_settings_model_json = {} - account_settings_model_json['account_id'] = 'testString' - account_settings_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' - account_settings_model_json['last_modified_by_id'] = 'testString' - account_settings_model_json['public_access_enabled'] = True - - # Construct a model instance of AccountSettings by calling from_dict on the json representation - account_settings_model = AccountSettings.from_dict(account_settings_model_json) - assert account_settings_model != False - - # Construct a model instance of AccountSettings by calling from_dict on the json representation - account_settings_model_dict = AccountSettings.from_dict(account_settings_model_json).__dict__ - account_settings_model2 = AccountSettings(**account_settings_model_dict) + service = IamAccessGroupsV2.new_instance( + service_name='TEST_SERVICE', + ) - # Verify the model instances are equivalent - assert account_settings_model == account_settings_model2 + assert service is not None + assert isinstance(service, IamAccessGroupsV2) - # Convert model instance back to dict and verify no loss of data - account_settings_model_json2 = account_settings_model.to_dict() - assert account_settings_model_json2 == account_settings_model_json + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = IamAccessGroupsV2.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) -class TestModel_AddGroupMembersRequestMembersItem: +class TestCreateTemplate: """ - Test Class for AddGroupMembersRequestMembersItem + Test Class for create_template """ - def test_add_group_members_request_members_item_serialization(self): + @responses.activate + def test_create_template_all_params(self): """ - Test serialization/deserialization for AddGroupMembersRequestMembersItem + create_template() """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) - # Construct a json representation of a AddGroupMembersRequestMembersItem model - add_group_members_request_members_item_model_json = {} - add_group_members_request_members_item_model_json['iam_id'] = 'testString' - add_group_members_request_members_item_model_json['type'] = 'testString' + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = {} + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = False + + # Construct a dict representation of a Members model + members_model = {} + members_model['users'] = ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'] + members_model['services'] = ['iam-ServiceId-345', 'iam-ServiceId-456'] + members_model['action_controls'] = members_action_controls_model + + # Construct a dict representation of a Conditions model + conditions_model = {} + conditions_model['claim'] = 'blueGroup' + conditions_model['operator'] = 'CONTAINS' + conditions_model['value'] = 'test-bluegroup-saml' + + # Construct a dict representation of a RuleActionControls model + rule_action_controls_model = {} + rule_action_controls_model['remove'] = False + rule_action_controls_model['update'] = False + + # Construct a dict representation of a AssertionsRule model + assertions_rule_model = {} + assertions_rule_model['name'] = 'Manager group rule' + assertions_rule_model['expiration'] = 12 + assertions_rule_model['realm_name'] = 'https://idp.example.org/SAML2' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = {} + assertions_action_controls_model['add'] = False + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a dict representation of a Assertions model + assertions_model = {} + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = {} + access_action_controls_model['add'] = False + + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = {} + group_action_controls_model['access'] = access_action_controls_model + + # Construct a dict representation of a AccessGroupRequest model + access_group_request_model = {} + access_group_request_model['name'] = 'IAM Admin Group' + access_group_request_model[ + 'description' + ] = 'This access group template allows admin access to all IAM platform services in the account.' + access_group_request_model['members'] = members_model + access_group_request_model['assertions'] = assertions_model + access_group_request_model['action_controls'] = group_action_controls_model + + # Construct a dict representation of a PolicyTemplates model + policy_templates_model = {} + policy_templates_model['id'] = 'policyTemplateId-123' + policy_templates_model['version'] = '1' - # Construct a model instance of AddGroupMembersRequestMembersItem by calling from_dict on the json representation - add_group_members_request_members_item_model = AddGroupMembersRequestMembersItem.from_dict( - add_group_members_request_members_item_model_json - ) - assert add_group_members_request_members_item_model != False + # Set up parameter values + name = 'IAM Admin Group template' + account_id = 'accountID-123' + description = 'This access group template allows admin access to all IAM platform services in the account.' + group = access_group_request_model + policy_template_references = [policy_templates_model] + transaction_id = 'testString' - # Construct a model instance of AddGroupMembersRequestMembersItem by calling from_dict on the json representation - add_group_members_request_members_item_model_dict = AddGroupMembersRequestMembersItem.from_dict( - add_group_members_request_members_item_model_json - ).__dict__ - add_group_members_request_members_item_model2 = AddGroupMembersRequestMembersItem( - **add_group_members_request_members_item_model_dict + # Invoke method + response = _service.create_template( + name, + account_id, + description=description, + group=group, + policy_template_references=policy_template_references, + transaction_id=transaction_id, + headers={}, ) - # Verify the model instances are equivalent - assert add_group_members_request_members_item_model == add_group_members_request_members_item_model2 - - # Convert model instance back to dict and verify no loss of data - add_group_members_request_members_item_model_json2 = add_group_members_request_members_item_model.to_dict() - assert add_group_members_request_members_item_model_json2 == add_group_members_request_members_item_model_json + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'IAM Admin Group template' + assert req_body['account_id'] == 'accountID-123' + assert ( + req_body['description'] + == 'This access group template allows admin access to all IAM platform services in the account.' + ) + assert req_body['group'] == access_group_request_model + assert req_body['policy_template_references'] == [policy_templates_model] + def test_create_template_all_params_with_retries(self): + # Enable retries and run test_create_template_all_params. + _service.enable_retries() + self.test_create_template_all_params() -class TestModel_AddGroupMembersResponse: - """ - Test Class for AddGroupMembersResponse - """ + # Disable retries and run test_create_template_all_params. + _service.disable_retries() + self.test_create_template_all_params() - def test_add_group_members_response_serialization(self): + @responses.activate + def test_create_template_required_params(self): """ - Test serialization/deserialization for AddGroupMembersResponse + test_create_template_required_params() """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) - # Construct dict forms of any model objects needed in order to build this model. - - error_model = {} # Error - error_model['code'] = 'testString' - error_model['message'] = 'testString' - - add_group_members_response_members_item_model = {} # AddGroupMembersResponseMembersItem - add_group_members_response_members_item_model['iam_id'] = 'testString' - add_group_members_response_members_item_model['type'] = 'testString' - add_group_members_response_members_item_model['created_at'] = '2019-01-01T12:00:00Z' - add_group_members_response_members_item_model['created_by_id'] = 'testString' - add_group_members_response_members_item_model['status_code'] = 38 - add_group_members_response_members_item_model['trace'] = 'testString' - add_group_members_response_members_item_model['errors'] = [error_model] - - # Construct a json representation of a AddGroupMembersResponse model - add_group_members_response_model_json = {} - add_group_members_response_model_json['members'] = [add_group_members_response_members_item_model] - - # Construct a model instance of AddGroupMembersResponse by calling from_dict on the json representation - add_group_members_response_model = AddGroupMembersResponse.from_dict(add_group_members_response_model_json) - assert add_group_members_response_model != False + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = {} + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = False + + # Construct a dict representation of a Members model + members_model = {} + members_model['users'] = ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'] + members_model['services'] = ['iam-ServiceId-345', 'iam-ServiceId-456'] + members_model['action_controls'] = members_action_controls_model + + # Construct a dict representation of a Conditions model + conditions_model = {} + conditions_model['claim'] = 'blueGroup' + conditions_model['operator'] = 'CONTAINS' + conditions_model['value'] = 'test-bluegroup-saml' + + # Construct a dict representation of a RuleActionControls model + rule_action_controls_model = {} + rule_action_controls_model['remove'] = False + rule_action_controls_model['update'] = False + + # Construct a dict representation of a AssertionsRule model + assertions_rule_model = {} + assertions_rule_model['name'] = 'Manager group rule' + assertions_rule_model['expiration'] = 12 + assertions_rule_model['realm_name'] = 'https://idp.example.org/SAML2' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = {} + assertions_action_controls_model['add'] = False + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a dict representation of a Assertions model + assertions_model = {} + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = {} + access_action_controls_model['add'] = False + + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = {} + group_action_controls_model['access'] = access_action_controls_model + + # Construct a dict representation of a AccessGroupRequest model + access_group_request_model = {} + access_group_request_model['name'] = 'IAM Admin Group' + access_group_request_model[ + 'description' + ] = 'This access group template allows admin access to all IAM platform services in the account.' + access_group_request_model['members'] = members_model + access_group_request_model['assertions'] = assertions_model + access_group_request_model['action_controls'] = group_action_controls_model + + # Construct a dict representation of a PolicyTemplates model + policy_templates_model = {} + policy_templates_model['id'] = 'policyTemplateId-123' + policy_templates_model['version'] = '1' - # Construct a model instance of AddGroupMembersResponse by calling from_dict on the json representation - add_group_members_response_model_dict = AddGroupMembersResponse.from_dict( - add_group_members_response_model_json - ).__dict__ - add_group_members_response_model2 = AddGroupMembersResponse(**add_group_members_response_model_dict) + # Set up parameter values + name = 'IAM Admin Group template' + account_id = 'accountID-123' + description = 'This access group template allows admin access to all IAM platform services in the account.' + group = access_group_request_model + policy_template_references = [policy_templates_model] - # Verify the model instances are equivalent - assert add_group_members_response_model == add_group_members_response_model2 + # Invoke method + response = _service.create_template( + name, + account_id, + description=description, + group=group, + policy_template_references=policy_template_references, + headers={}, + ) - # Convert model instance back to dict and verify no loss of data - add_group_members_response_model_json2 = add_group_members_response_model.to_dict() - assert add_group_members_response_model_json2 == add_group_members_response_model_json + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'IAM Admin Group template' + assert req_body['account_id'] == 'accountID-123' + assert ( + req_body['description'] + == 'This access group template allows admin access to all IAM platform services in the account.' + ) + assert req_body['group'] == access_group_request_model + assert req_body['policy_template_references'] == [policy_templates_model] + def test_create_template_required_params_with_retries(self): + # Enable retries and run test_create_template_required_params. + _service.enable_retries() + self.test_create_template_required_params() -class TestModel_AddGroupMembersResponseMembersItem: - """ - Test Class for AddGroupMembersResponseMembersItem - """ + # Disable retries and run test_create_template_required_params. + _service.disable_retries() + self.test_create_template_required_params() - def test_add_group_members_response_members_item_serialization(self): + @responses.activate + def test_create_template_value_error(self): """ - Test serialization/deserialization for AddGroupMembersResponseMembersItem + test_create_template_value_error() """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) - # Construct dict forms of any model objects needed in order to build this model. - - error_model = {} # Error - error_model['code'] = 'testString' - error_model['message'] = 'testString' - - # Construct a json representation of a AddGroupMembersResponseMembersItem model - add_group_members_response_members_item_model_json = {} - add_group_members_response_members_item_model_json['iam_id'] = 'testString' - add_group_members_response_members_item_model_json['type'] = 'testString' - add_group_members_response_members_item_model_json['created_at'] = '2019-01-01T12:00:00Z' - add_group_members_response_members_item_model_json['created_by_id'] = 'testString' - add_group_members_response_members_item_model_json['status_code'] = 38 - add_group_members_response_members_item_model_json['trace'] = 'testString' - add_group_members_response_members_item_model_json['errors'] = [error_model] + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = {} + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = False + + # Construct a dict representation of a Members model + members_model = {} + members_model['users'] = ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'] + members_model['services'] = ['iam-ServiceId-345', 'iam-ServiceId-456'] + members_model['action_controls'] = members_action_controls_model + + # Construct a dict representation of a Conditions model + conditions_model = {} + conditions_model['claim'] = 'blueGroup' + conditions_model['operator'] = 'CONTAINS' + conditions_model['value'] = 'test-bluegroup-saml' + + # Construct a dict representation of a RuleActionControls model + rule_action_controls_model = {} + rule_action_controls_model['remove'] = False + rule_action_controls_model['update'] = False + + # Construct a dict representation of a AssertionsRule model + assertions_rule_model = {} + assertions_rule_model['name'] = 'Manager group rule' + assertions_rule_model['expiration'] = 12 + assertions_rule_model['realm_name'] = 'https://idp.example.org/SAML2' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = {} + assertions_action_controls_model['add'] = False + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a dict representation of a Assertions model + assertions_model = {} + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = {} + access_action_controls_model['add'] = False + + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = {} + group_action_controls_model['access'] = access_action_controls_model + + # Construct a dict representation of a AccessGroupRequest model + access_group_request_model = {} + access_group_request_model['name'] = 'IAM Admin Group' + access_group_request_model[ + 'description' + ] = 'This access group template allows admin access to all IAM platform services in the account.' + access_group_request_model['members'] = members_model + access_group_request_model['assertions'] = assertions_model + access_group_request_model['action_controls'] = group_action_controls_model + + # Construct a dict representation of a PolicyTemplates model + policy_templates_model = {} + policy_templates_model['id'] = 'policyTemplateId-123' + policy_templates_model['version'] = '1' - # Construct a model instance of AddGroupMembersResponseMembersItem by calling from_dict on the json representation - add_group_members_response_members_item_model = AddGroupMembersResponseMembersItem.from_dict( - add_group_members_response_members_item_model_json - ) - assert add_group_members_response_members_item_model != False + # Set up parameter values + name = 'IAM Admin Group template' + account_id = 'accountID-123' + description = 'This access group template allows admin access to all IAM platform services in the account.' + group = access_group_request_model + policy_template_references = [policy_templates_model] - # Construct a model instance of AddGroupMembersResponseMembersItem by calling from_dict on the json representation - add_group_members_response_members_item_model_dict = AddGroupMembersResponseMembersItem.from_dict( - add_group_members_response_members_item_model_json - ).__dict__ - add_group_members_response_members_item_model2 = AddGroupMembersResponseMembersItem( - **add_group_members_response_members_item_model_dict - ) + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "name": name, + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_template(**req_copy) - # Verify the model instances are equivalent - assert add_group_members_response_members_item_model == add_group_members_response_members_item_model2 + def test_create_template_value_error_with_retries(self): + # Enable retries and run test_create_template_value_error. + _service.enable_retries() + self.test_create_template_value_error() - # Convert model instance back to dict and verify no loss of data - add_group_members_response_members_item_model_json2 = add_group_members_response_members_item_model.to_dict() - assert add_group_members_response_members_item_model_json2 == add_group_members_response_members_item_model_json + # Disable retries and run test_create_template_value_error. + _service.disable_retries() + self.test_create_template_value_error() -class TestModel_AddMembershipMultipleGroupsResponse: +class TestListTemplates: """ - Test Class for AddMembershipMultipleGroupsResponse + Test Class for list_templates """ - def test_add_membership_multiple_groups_response_serialization(self): + @responses.activate + def test_list_templates_all_params(self): """ - Test serialization/deserialization for AddMembershipMultipleGroupsResponse + list_templates() """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_templates": [{"id": "id", "name": "name", "description": "description", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) - # Construct dict forms of any model objects needed in order to build this model. - - error_model = {} # Error - error_model['code'] = 'testString' - error_model['message'] = 'testString' + # Set up parameter values + account_id = 'accountID-123' + transaction_id = 'testString' + limit = 50 + offset = 0 + verbose = True - add_membership_multiple_groups_response_groups_item_model = {} # AddMembershipMultipleGroupsResponseGroupsItem - add_membership_multiple_groups_response_groups_item_model['access_group_id'] = 'testString' - add_membership_multiple_groups_response_groups_item_model['status_code'] = 38 - add_membership_multiple_groups_response_groups_item_model['trace'] = 'testString' - add_membership_multiple_groups_response_groups_item_model['errors'] = [error_model] + # Invoke method + response = _service.list_templates( + account_id, + transaction_id=transaction_id, + limit=limit, + offset=offset, + verbose=verbose, + headers={}, + ) - # Construct a json representation of a AddMembershipMultipleGroupsResponse model - add_membership_multiple_groups_response_model_json = {} - add_membership_multiple_groups_response_model_json['iam_id'] = 'testString' - add_membership_multiple_groups_response_model_json['groups'] = [ - add_membership_multiple_groups_response_groups_item_model - ] + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'offset={}'.format(offset) in query_string + assert 'verbose={}'.format('true' if verbose else 'false') in query_string + + def test_list_templates_all_params_with_retries(self): + # Enable retries and run test_list_templates_all_params. + _service.enable_retries() + self.test_list_templates_all_params() + + # Disable retries and run test_list_templates_all_params. + _service.disable_retries() + self.test_list_templates_all_params() + + @responses.activate + def test_list_templates_required_params(self): + """ + test_list_templates_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_templates": [{"id": "id", "name": "name", "description": "description", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'accountID-123' + + # Invoke method + response = _service.list_templates( + account_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + + def test_list_templates_required_params_with_retries(self): + # Enable retries and run test_list_templates_required_params. + _service.enable_retries() + self.test_list_templates_required_params() + + # Disable retries and run test_list_templates_required_params. + _service.disable_retries() + self.test_list_templates_required_params() + + @responses.activate + def test_list_templates_value_error(self): + """ + test_list_templates_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_templates": [{"id": "id", "name": "name", "description": "description", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'accountID-123' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_templates(**req_copy) + + def test_list_templates_value_error_with_retries(self): + # Enable retries and run test_list_templates_value_error. + _service.enable_retries() + self.test_list_templates_value_error() + + # Disable retries and run test_list_templates_value_error. + _service.disable_retries() + self.test_list_templates_value_error() + + @responses.activate + def test_list_templates_with_pager_get_next(self): + """ + test_list_templates_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/group_templates') + mock_response1 = '{"group_templates":[{"id":"id","name":"name","description":"description","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"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"}],"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1}' + mock_response2 = '{"group_templates":[{"id":"id","name":"name","description":"description","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"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 = TemplatesPager( + client=_service, + account_id='accountID-123', + transaction_id='testString', + limit=50, + verbose=True, + ) + 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_templates_with_pager_get_all(self): + """ + test_list_templates_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/group_templates') + mock_response1 = '{"group_templates":[{"id":"id","name":"name","description":"description","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"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"}],"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1}' + mock_response2 = '{"group_templates":[{"id":"id","name":"name","description":"description","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"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 = TemplatesPager( + client=_service, + account_id='accountID-123', + transaction_id='testString', + limit=50, + verbose=True, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestCreateTemplateVersion: + """ + Test Class for create_template_version + """ + + @responses.activate + def test_create_template_version_all_params(self): + """ + create_template_version() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = {} + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = False + + # Construct a dict representation of a Members model + members_model = {} + members_model['users'] = ['IBMid-50PJGPKYJJ', 'IBMid-665000T8WY'] + members_model['services'] = ['iam-ServiceId-345'] + members_model['action_controls'] = members_action_controls_model + + # Construct a dict representation of a Conditions model + conditions_model = {} + conditions_model['claim'] = 'blueGroup' + conditions_model['operator'] = 'CONTAINS' + conditions_model['value'] = 'test-bluegroup-saml' + + # Construct a dict representation of a RuleActionControls model + rule_action_controls_model = {} + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + # Construct a dict representation of a AssertionsRule model + assertions_rule_model = {} + assertions_rule_model['name'] = 'Manager group rule' + assertions_rule_model['expiration'] = 12 + assertions_rule_model['realm_name'] = 'https://idp.example.org/SAML2' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = {} + assertions_action_controls_model['add'] = False + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a dict representation of a Assertions model + assertions_model = {} + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = {} + access_action_controls_model['add'] = False + + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = {} + group_action_controls_model['access'] = access_action_controls_model + + # Construct a dict representation of a AccessGroupRequest model + access_group_request_model = {} + access_group_request_model['name'] = 'IAM Admin Group 8' + access_group_request_model[ + 'description' + ] = 'This access group template allows admin access to all IAM platform services in the account.' + access_group_request_model['members'] = members_model + access_group_request_model['assertions'] = assertions_model + access_group_request_model['action_controls'] = group_action_controls_model + + # Construct a dict representation of a PolicyTemplates model + policy_templates_model = {} + policy_templates_model['id'] = 'policyTemplateId-123' + policy_templates_model['version'] = '1' + + # Set up parameter values + template_id = 'testString' + name = 'IAM Admin Group template 2' + description = 'This access group template allows admin access to all IAM platform services in the account.' + group = access_group_request_model + policy_template_references = [policy_templates_model] + transaction_id = 'testString' + + # Invoke method + response = _service.create_template_version( + template_id, + name=name, + description=description, + group=group, + policy_template_references=policy_template_references, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'IAM Admin Group template 2' + assert ( + req_body['description'] + == 'This access group template allows admin access to all IAM platform services in the account.' + ) + assert req_body['group'] == access_group_request_model + assert req_body['policy_template_references'] == [policy_templates_model] + + def test_create_template_version_all_params_with_retries(self): + # Enable retries and run test_create_template_version_all_params. + _service.enable_retries() + self.test_create_template_version_all_params() + + # Disable retries and run test_create_template_version_all_params. + _service.disable_retries() + self.test_create_template_version_all_params() + + @responses.activate + def test_create_template_version_required_params(self): + """ + test_create_template_version_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + template_id = 'testString' + + # Invoke method + response = _service.create_template_version( + template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + + def test_create_template_version_required_params_with_retries(self): + # Enable retries and run test_create_template_version_required_params. + _service.enable_retries() + self.test_create_template_version_required_params() + + # Disable retries and run test_create_template_version_required_params. + _service.disable_retries() + self.test_create_template_version_required_params() + + @responses.activate + def test_create_template_version_value_error(self): + """ + test_create_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.POST, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_template_version(**req_copy) + + def test_create_template_version_value_error_with_retries(self): + # Enable retries and run test_create_template_version_value_error. + _service.enable_retries() + self.test_create_template_version_value_error() + + # Disable retries and run test_create_template_version_value_error. + _service.disable_retries() + self.test_create_template_version_value_error() + + +class TestListTemplateVersions: + """ + Test Class for list_template_versions + """ + + @responses.activate + def test_list_template_versions_all_params(self): + """ + list_template_versions() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_template_versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "href": "href", "created_at": "created_at", "created_by_id": "created_by_id", "last_modified_at": "last_modified_at", "last_modified_by_id": "last_modified_by_id"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + limit = 100 + offset = 0 + + # Invoke method + response = _service.list_template_versions( + template_id, + limit=limit, + offset=offset, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'limit={}'.format(limit) in query_string + assert 'offset={}'.format(offset) in query_string + + def test_list_template_versions_all_params_with_retries(self): + # Enable retries and run test_list_template_versions_all_params. + _service.enable_retries() + self.test_list_template_versions_all_params() + + # Disable retries and run test_list_template_versions_all_params. + _service.disable_retries() + self.test_list_template_versions_all_params() + + @responses.activate + def test_list_template_versions_required_params(self): + """ + test_list_template_versions_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_template_versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "href": "href", "created_at": "created_at", "created_by_id": "created_by_id", "last_modified_at": "last_modified_at", "last_modified_by_id": "last_modified_by_id"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + + # Invoke method + response = _service.list_template_versions( + template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_list_template_versions_required_params_with_retries(self): + # Enable retries and run test_list_template_versions_required_params. + _service.enable_retries() + self.test_list_template_versions_required_params() + + # Disable retries and run test_list_template_versions_required_params. + _service.disable_retries() + self.test_list_template_versions_required_params() + + @responses.activate + def test_list_template_versions_value_error(self): + """ + test_list_template_versions_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "group_template_versions": [{"name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "href": "href", "created_at": "created_at", "created_by_id": "created_by_id", "last_modified_at": "last_modified_at", "last_modified_by_id": "last_modified_by_id"}]}' + responses.add( + responses.GET, + url, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_template_versions(**req_copy) + + def test_list_template_versions_value_error_with_retries(self): + # Enable retries and run test_list_template_versions_value_error. + _service.enable_retries() + self.test_list_template_versions_value_error() + + # Disable retries and run test_list_template_versions_value_error. + _service.disable_retries() + self.test_list_template_versions_value_error() + + @responses.activate + def test_list_template_versions_with_pager_get_next(self): + """ + test_list_template_versions_with_pager_get_next() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"group_template_versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"href":"href","created_at":"created_at","created_by_id":"created_by_id","last_modified_at":"last_modified_at","last_modified_by_id":"last_modified_by_id"}],"limit":1}' + mock_response2 = '{"total_count":2,"group_template_versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"href":"href","created_at":"created_at","created_by_id":"created_by_id","last_modified_at":"last_modified_at","last_modified_by_id":"last_modified_by_id"}],"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 = TemplateVersionsPager( + client=_service, + template_id='testString', + limit=100, + ) + 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_template_versions_with_pager_get_all(self): + """ + test_list_template_versions_with_pager_get_all() + """ + # Set up a two-page mock response + url = preprocess_url('/v1/group_templates/testString/versions') + mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"group_template_versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"href":"href","created_at":"created_at","created_by_id":"created_by_id","last_modified_at":"last_modified_at","last_modified_by_id":"last_modified_by_id"}],"limit":1}' + mock_response2 = '{"total_count":2,"group_template_versions":[{"name":"name","description":"description","account_id":"account_id","version":"version","committed":false,"group":{"name":"name","description":"description","members":{"users":["users"],"services":["services"],"action_controls":{"add":false,"remove":true}},"assertions":{"rules":[{"name":"name","expiration":10,"realm_name":"realm_name","conditions":[{"claim":"claim","operator":"operator","value":"value"}],"action_controls":{"remove":true,"update":true}}],"action_controls":{"add":false,"remove":true,"update":true}},"action_controls":{"access":{"add":false}}},"policy_template_references":[{"id":"id","version":"version"}],"href":"href","created_at":"created_at","created_by_id":"created_by_id","last_modified_at":"last_modified_at","last_modified_by_id":"last_modified_by_id"}],"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 = TemplateVersionsPager( + client=_service, + template_id='testString', + limit=100, + ) + all_results = pager.get_all() + assert all_results is not None + assert len(all_results) == 2 + + +class TestGetTemplateVersion: + """ + Test Class for get_template_version + """ + + @responses.activate + def test_get_template_version_all_params(self): + """ + get_template_version() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + verbose = True + transaction_id = 'testString' + + # Invoke method + response = _service.get_template_version( + template_id, + version_num, + verbose=verbose, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'verbose={}'.format('true' if verbose else 'false') in query_string + + def test_get_template_version_all_params_with_retries(self): + # Enable retries and run test_get_template_version_all_params. + _service.enable_retries() + self.test_get_template_version_all_params() + + # Disable retries and run test_get_template_version_all_params. + _service.disable_retries() + self.test_get_template_version_all_params() + + @responses.activate + def test_get_template_version_required_params(self): + """ + test_get_template_version_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + + # Invoke method + response = _service.get_template_version( + template_id, + version_num, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_template_version_required_params_with_retries(self): + # Enable retries and run test_get_template_version_required_params. + _service.enable_retries() + self.test_get_template_version_required_params() + + # Disable retries and run test_get_template_version_required_params. + _service.disable_retries() + self.test_get_template_version_required_params() + + @responses.activate + def test_get_template_version_value_error(self): + """ + test_get_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + "version_num": version_num, + } + 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_template_version(**req_copy) + + def test_get_template_version_value_error_with_retries(self): + # Enable retries and run test_get_template_version_value_error. + _service.enable_retries() + self.test_get_template_version_value_error() + + # Disable retries and run test_get_template_version_value_error. + _service.disable_retries() + self.test_get_template_version_value_error() + + +class TestUpdateTemplateVersion: + """ + Test Class for update_template_version + """ + + @responses.activate + def test_update_template_version_all_params(self): + """ + update_template_version() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.PUT, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Construct a dict representation of a MembersActionControls model + members_action_controls_model = {} + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = False + + # Construct a dict representation of a Members model + members_model = {} + members_model['users'] = ['IBMid-665000T8WY'] + members_model['services'] = ['iam-ServiceId-e371b0e5-1c80-48e3-bf12-c6a8ef2b1a11'] + members_model['action_controls'] = members_action_controls_model + + # Construct a dict representation of a Conditions model + conditions_model = {} + conditions_model['claim'] = 'blueGroup' + conditions_model['operator'] = 'CONTAINS' + conditions_model['value'] = 'test-bluegroup-saml' + + # Construct a dict representation of a RuleActionControls model + rule_action_controls_model = {} + rule_action_controls_model['remove'] = False + rule_action_controls_model['update'] = False + + # Construct a dict representation of a AssertionsRule model + assertions_rule_model = {} + assertions_rule_model['name'] = 'Manager group rule' + assertions_rule_model['expiration'] = 12 + assertions_rule_model['realm_name'] = 'https://idp.example.org/SAML2' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + # Construct a dict representation of a AssertionsActionControls model + assertions_action_controls_model = {} + assertions_action_controls_model['add'] = False + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a dict representation of a Assertions model + assertions_model = {} + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + # Construct a dict representation of a AccessActionControls model + access_action_controls_model = {} + access_action_controls_model['add'] = False + + # Construct a dict representation of a GroupActionControls model + group_action_controls_model = {} + group_action_controls_model['access'] = access_action_controls_model + + # Construct a dict representation of a AccessGroupRequest model + access_group_request_model = {} + access_group_request_model['name'] = 'IAM Admin Group 8' + access_group_request_model[ + 'description' + ] = 'This access group template allows admin access to all IAM platform services in the account.' + access_group_request_model['members'] = members_model + access_group_request_model['assertions'] = assertions_model + access_group_request_model['action_controls'] = group_action_controls_model + + # Construct a dict representation of a PolicyTemplates model + policy_templates_model = {} + policy_templates_model['id'] = 'policyTemplateId-123' + policy_templates_model['version'] = '1' + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + name = 'IAM Admin Group template 2' + description = 'This access group template allows admin access to all IAM platform services in the account.' + group = access_group_request_model + policy_template_references = [policy_templates_model] + transaction_id = '83adf5bd-de790caa3' + + # Invoke method + response = _service.update_template_version( + template_id, + version_num, + if_match, + name=name, + description=description, + group=group, + policy_template_references=policy_template_references, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['name'] == 'IAM Admin Group template 2' + assert ( + req_body['description'] + == 'This access group template allows admin access to all IAM platform services in the account.' + ) + assert req_body['group'] == access_group_request_model + assert req_body['policy_template_references'] == [policy_templates_model] + + def test_update_template_version_all_params_with_retries(self): + # Enable retries and run test_update_template_version_all_params. + _service.enable_retries() + self.test_update_template_version_all_params() + + # Disable retries and run test_update_template_version_all_params. + _service.disable_retries() + self.test_update_template_version_all_params() + + @responses.activate + def test_update_template_version_required_params(self): + """ + test_update_template_version_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.PUT, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + + # Invoke method + response = _service.update_template_version( + template_id, + version_num, + if_match, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 201 + + def test_update_template_version_required_params_with_retries(self): + # Enable retries and run test_update_template_version_required_params. + _service.enable_retries() + self.test_update_template_version_required_params() + + # Disable retries and run test_update_template_version_required_params. + _service.disable_retries() + self.test_update_template_version_required_params() + + @responses.activate + def test_update_template_version_value_error(self): + """ + test_update_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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.PUT, + url, + body=mock_response, + content_type='application/json', + status=201, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + "version_num": version_num, + "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_template_version(**req_copy) + + def test_update_template_version_value_error_with_retries(self): + # Enable retries and run test_update_template_version_value_error. + _service.enable_retries() + self.test_update_template_version_value_error() + + # Disable retries and run test_update_template_version_value_error. + _service.disable_retries() + self.test_update_template_version_value_error() + + +class TestDeleteTemplateVersion: + """ + Test Class for delete_template_version + """ + + @responses.activate + def test_delete_template_version_all_params(self): + """ + delete_template_version() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + transaction_id = 'testString' + + # Invoke method + response = _service.delete_template_version( + template_id, + version_num, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_template_version_all_params_with_retries(self): + # Enable retries and run test_delete_template_version_all_params. + _service.enable_retries() + self.test_delete_template_version_all_params() + + # Disable retries and run test_delete_template_version_all_params. + _service.disable_retries() + self.test_delete_template_version_all_params() + + @responses.activate + def test_delete_template_version_required_params(self): + """ + test_delete_template_version_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + + # Invoke method + response = _service.delete_template_version( + template_id, + version_num, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_template_version_required_params_with_retries(self): + # Enable retries and run test_delete_template_version_required_params. + _service.enable_retries() + self.test_delete_template_version_required_params() + + # Disable retries and run test_delete_template_version_required_params. + _service.disable_retries() + self.test_delete_template_version_required_params() + + @responses.activate + def test_delete_template_version_value_error(self): + """ + test_delete_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + "version_num": version_num, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_template_version(**req_copy) + + def test_delete_template_version_value_error_with_retries(self): + # Enable retries and run test_delete_template_version_value_error. + _service.enable_retries() + self.test_delete_template_version_value_error() + + # Disable retries and run test_delete_template_version_value_error. + _service.disable_retries() + self.test_delete_template_version_value_error() + + +class TestCommitTemplate: + """ + Test Class for commit_template + """ + + @responses.activate + def test_commit_template_all_params(self): + """ + commit_template() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + transaction_id = 'testString' + + # Invoke method + response = _service.commit_template( + template_id, + version_num, + if_match, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_commit_template_all_params_with_retries(self): + # Enable retries and run test_commit_template_all_params. + _service.enable_retries() + self.test_commit_template_all_params() + + # Disable retries and run test_commit_template_all_params. + _service.disable_retries() + self.test_commit_template_all_params() + + @responses.activate + def test_commit_template_required_params(self): + """ + test_commit_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + + # Invoke method + response = _service.commit_template( + template_id, + version_num, + if_match, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_commit_template_required_params_with_retries(self): + # Enable retries and run test_commit_template_required_params. + _service.enable_retries() + self.test_commit_template_required_params() + + # Disable retries and run test_commit_template_required_params. + _service.disable_retries() + self.test_commit_template_required_params() + + @responses.activate + def test_commit_template_value_error(self): + """ + test_commit_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString/versions/testString/commit') + responses.add( + responses.POST, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + version_num = 'testString' + if_match = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + "version_num": version_num, + "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.commit_template(**req_copy) + + def test_commit_template_value_error_with_retries(self): + # Enable retries and run test_commit_template_value_error. + _service.enable_retries() + self.test_commit_template_value_error() + + # Disable retries and run test_commit_template_value_error. + _service.disable_retries() + self.test_commit_template_value_error() + + +class TestGetLatestTemplateVersion: + """ + Test Class for get_latest_template_version + """ + + @responses.activate + def test_get_latest_template_version_all_params(self): + """ + get_latest_template_version() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + verbose = True + transaction_id = 'testString' + + # Invoke method + response = _service.get_latest_template_version( + template_id, + verbose=verbose, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'verbose={}'.format('true' if verbose else 'false') in query_string + + def test_get_latest_template_version_all_params_with_retries(self): + # Enable retries and run test_get_latest_template_version_all_params. + _service.enable_retries() + self.test_get_latest_template_version_all_params() + + # Disable retries and run test_get_latest_template_version_all_params. + _service.disable_retries() + self.test_get_latest_template_version_all_params() + + @responses.activate + def test_get_latest_template_version_required_params(self): + """ + test_get_latest_template_version_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + + # Invoke method + response = _service.get_latest_template_version( + template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_latest_template_version_required_params_with_retries(self): + # Enable retries and run test_get_latest_template_version_required_params. + _service.enable_retries() + self.test_get_latest_template_version_required_params() + + # Disable retries and run test_get_latest_template_version_required_params. + _service.disable_retries() + self.test_get_latest_template_version_required_params() + + @responses.activate + def test_get_latest_template_version_value_error(self): + """ + test_get_latest_template_version_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "version": "version", "committed": false, "group": {"name": "name", "description": "description", "members": {"users": ["users"], "services": ["services"], "action_controls": {"add": false, "remove": true}}, "assertions": {"rules": [{"name": "name", "expiration": 10, "realm_name": "realm_name", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}], "action_controls": {"remove": true, "update": true}}], "action_controls": {"add": false, "remove": true, "update": true}}, "action_controls": {"access": {"add": false}}}, "policy_template_references": [{"id": "id", "version": "version"}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_latest_template_version(**req_copy) + + def test_get_latest_template_version_value_error_with_retries(self): + # Enable retries and run test_get_latest_template_version_value_error. + _service.enable_retries() + self.test_get_latest_template_version_value_error() + + # Disable retries and run test_get_latest_template_version_value_error. + _service.disable_retries() + self.test_get_latest_template_version_value_error() + + +class TestDeleteTemplate: + """ + Test Class for delete_template + """ + + @responses.activate + def test_delete_template_all_params(self): + """ + delete_template() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + transaction_id = 'testString' + + # Invoke method + response = _service.delete_template( + template_id, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_template_all_params_with_retries(self): + # Enable retries and run test_delete_template_all_params. + _service.enable_retries() + self.test_delete_template_all_params() + + # Disable retries and run test_delete_template_all_params. + _service.disable_retries() + self.test_delete_template_all_params() + + @responses.activate + def test_delete_template_required_params(self): + """ + test_delete_template_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + + # Invoke method + response = _service.delete_template( + template_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 204 + + def test_delete_template_required_params_with_retries(self): + # Enable retries and run test_delete_template_required_params. + _service.enable_retries() + self.test_delete_template_required_params() + + # Disable retries and run test_delete_template_required_params. + _service.disable_retries() + self.test_delete_template_required_params() + + @responses.activate + def test_delete_template_value_error(self): + """ + test_delete_template_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_templates/testString') + responses.add( + responses.DELETE, + url, + status=204, + ) + + # Set up parameter values + template_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_template(**req_copy) + + def test_delete_template_value_error_with_retries(self): + # Enable retries and run test_delete_template_value_error. + _service.enable_retries() + self.test_delete_template_value_error() + + # Disable retries and run test_delete_template_value_error. + _service.disable_retries() + self.test_delete_template_value_error() + + +# endregion +############################################################################## +# End of Service: TemplateOperations +############################################################################## + +############################################################################## +# Start of Service: TemplateAssignmentOperations +############################################################################## +# region + + +class TestNewInstance: + """ + Test Class for new_instance + """ + + def test_new_instance(self): + """ + new_instance() + """ + os.environ['TEST_SERVICE_AUTH_TYPE'] = 'noAuth' + + service = IamAccessGroupsV2.new_instance( + service_name='TEST_SERVICE', + ) + + assert service is not None + assert isinstance(service, IamAccessGroupsV2) + + def test_new_instance_without_authenticator(self): + """ + new_instance_without_authenticator() + """ + with pytest.raises(ValueError, match='authenticator must be provided'): + service = IamAccessGroupsV2.new_instance( + service_name='TEST_SERVICE_NOT_FOUND', + ) + + +class TestCreateAssignment: + """ + Test Class for create_assignment + """ + + @responses.activate + def test_create_assignment_all_params(self): + """ + create_assignment() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + template_id = 'AccessGroupTemplateId-4be4' + template_version = '1' + target_type = 'AccountGroup' + target = '0a45594d0f-123' + transaction_id = 'testString' + + # Invoke method + response = _service.create_assignment( + template_id, + template_version, + target_type, + target, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['template_id'] == 'AccessGroupTemplateId-4be4' + assert req_body['template_version'] == '1' + assert req_body['target_type'] == 'AccountGroup' + assert req_body['target'] == '0a45594d0f-123' + + def test_create_assignment_all_params_with_retries(self): + # Enable retries and run test_create_assignment_all_params. + _service.enable_retries() + self.test_create_assignment_all_params() + + # Disable retries and run test_create_assignment_all_params. + _service.disable_retries() + self.test_create_assignment_all_params() + + @responses.activate + def test_create_assignment_required_params(self): + """ + test_create_assignment_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + template_id = 'AccessGroupTemplateId-4be4' + template_version = '1' + target_type = 'AccountGroup' + target = '0a45594d0f-123' + + # Invoke method + response = _service.create_assignment( + template_id, + template_version, + target_type, + target, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['template_id'] == 'AccessGroupTemplateId-4be4' + assert req_body['template_version'] == '1' + assert req_body['target_type'] == 'AccountGroup' + assert req_body['target'] == '0a45594d0f-123' + + def test_create_assignment_required_params_with_retries(self): + # Enable retries and run test_create_assignment_required_params. + _service.enable_retries() + self.test_create_assignment_required_params() + + # Disable retries and run test_create_assignment_required_params. + _service.disable_retries() + self.test_create_assignment_required_params() + + @responses.activate + def test_create_assignment_value_error(self): + """ + test_create_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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.POST, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + template_id = 'AccessGroupTemplateId-4be4' + template_version = '1' + target_type = 'AccountGroup' + target = '0a45594d0f-123' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "template_id": template_id, + "template_version": template_version, + "target_type": target_type, + "target": target, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.create_assignment(**req_copy) + + def test_create_assignment_value_error_with_retries(self): + # Enable retries and run test_create_assignment_value_error. + _service.enable_retries() + self.test_create_assignment_value_error() + + # Disable retries and run test_create_assignment_value_error. + _service.disable_retries() + self.test_create_assignment_value_error() + + +class TestListAssignments: + """ + Test Class for list_assignments + """ + + @responses.activate + def test_list_assignments_all_params(self): + """ + list_assignments() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "last": {"href": "href"}, "assignments": [{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'accountID-123' + template_id = 'testString' + template_version = 'testString' + target = 'testString' + status = 'accepted' + transaction_id = 'testString' + limit = 50 + offset = 0 + + # Invoke method + response = _service.list_assignments( + account_id, + template_id=template_id, + template_version=template_version, + target=target, + status=status, + transaction_id=transaction_id, + limit=limit, + offset=offset, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + assert 'template_id={}'.format(template_id) in query_string + assert 'template_version={}'.format(template_version) in query_string + assert 'target={}'.format(target) in query_string + assert 'status={}'.format(status) in query_string + assert 'limit={}'.format(limit) in query_string + assert 'offset={}'.format(offset) in query_string + + def test_list_assignments_all_params_with_retries(self): + # Enable retries and run test_list_assignments_all_params. + _service.enable_retries() + self.test_list_assignments_all_params() + + # Disable retries and run test_list_assignments_all_params. + _service.disable_retries() + self.test_list_assignments_all_params() + + @responses.activate + def test_list_assignments_required_params(self): + """ + test_list_assignments_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "last": {"href": "href"}, "assignments": [{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'accountID-123' + + # Invoke method + response = _service.list_assignments( + account_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'account_id={}'.format(account_id) in query_string + + def test_list_assignments_required_params_with_retries(self): + # Enable retries and run test_list_assignments_required_params. + _service.enable_retries() + self.test_list_assignments_required_params() + + # Disable retries and run test_list_assignments_required_params. + _service.disable_retries() + self.test_list_assignments_required_params() + + @responses.activate + def test_list_assignments_value_error(self): + """ + test_list_assignments_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments') + mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "last": {"href": "href"}, "assignments": [{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "Account", "target": "target", "operation": "assign", "status": "accepted", "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + account_id = 'accountID-123' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "account_id": account_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.list_assignments(**req_copy) + + def test_list_assignments_value_error_with_retries(self): + # Enable retries and run test_list_assignments_value_error. + _service.enable_retries() + self.test_list_assignments_value_error() + + # Disable retries and run test_list_assignments_value_error. + _service.disable_retries() + self.test_list_assignments_value_error() + + +class TestGetAssignment: + """ + Test Class for get_assignment + """ + + @responses.activate + def test_get_assignment_all_params(self): + """ + get_assignment() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "target_type", "target": "target", "operation": "operation", "status": "status", "resources": [{"target": "target", "group": {"group": {"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}, "members": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}], "rules": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}, "policy_template_references": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + transaction_id = 'testString' + verbose = False + + # Invoke method + response = _service.get_assignment( + assignment_id, + transaction_id=transaction_id, + verbose=verbose, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + # Validate query params + query_string = responses.calls[0].request.url.split('?', 1)[1] + query_string = urllib.parse.unquote_plus(query_string) + assert 'verbose={}'.format('true' if verbose else 'false') in query_string + + def test_get_assignment_all_params_with_retries(self): + # Enable retries and run test_get_assignment_all_params. + _service.enable_retries() + self.test_get_assignment_all_params() + + # Disable retries and run test_get_assignment_all_params. + _service.disable_retries() + self.test_get_assignment_all_params() + + @responses.activate + def test_get_assignment_required_params(self): + """ + test_get_assignment_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "target_type", "target": "target", "operation": "operation", "status": "status", "resources": [{"target": "target", "group": {"group": {"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}, "members": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}], "rules": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}, "policy_template_references": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Invoke method + response = _service.get_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 200 + + def test_get_assignment_required_params_with_retries(self): + # Enable retries and run test_get_assignment_required_params. + _service.enable_retries() + self.test_get_assignment_required_params() + + # Disable retries and run test_get_assignment_required_params. + _service.disable_retries() + self.test_get_assignment_required_params() + + @responses.activate + def test_get_assignment_value_error(self): + """ + test_get_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "target_type", "target": "target", "operation": "operation", "status": "status", "resources": [{"target": "target", "group": {"group": {"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}, "members": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}], "rules": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}, "policy_template_references": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}], "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, + body=mock_response, + content_type='application/json', + status=200, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.get_assignment(**req_copy) + + def test_get_assignment_value_error_with_retries(self): + # Enable retries and run test_get_assignment_value_error. + _service.enable_retries() + self.test_get_assignment_value_error() + + # Disable retries and run test_get_assignment_value_error. + _service.disable_retries() + self.test_get_assignment_value_error() + + +class TestUpdateAssignment: + """ + Test Class for update_assignment + """ + + @responses.activate + def test_update_assignment_all_params(self): + """ + update_assignment() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "target_type", "target": "target", "operation": "operation", "status": "status", "resources": [{"target": "target", "group": {"group": {"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}, "members": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}], "rules": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}, "policy_template_references": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}], "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.PATCH, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + assignment_id = 'testString' + if_match = 'testString' + template_version = '1' + + # Invoke method + response = _service.update_assignment( + assignment_id, + if_match, + template_version, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + # Validate body params + req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) + assert req_body['template_version'] == '1' + + def test_update_assignment_all_params_with_retries(self): + # Enable retries and run test_update_assignment_all_params. + _service.enable_retries() + self.test_update_assignment_all_params() + + # Disable retries and run test_update_assignment_all_params. + _service.disable_retries() + self.test_update_assignment_all_params() + + @responses.activate + def test_update_assignment_value_error(self): + """ + test_update_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + mock_response = '{"id": "id", "account_id": "account_id", "template_id": "template_id", "template_version": "template_version", "target_type": "target_type", "target": "target", "operation": "operation", "status": "status", "resources": [{"target": "target", "group": {"group": {"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}, "members": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}], "rules": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}, "policy_template_references": [{"id": "id", "name": "name", "version": "version", "resource": "resource", "error": "error", "operation": "operation", "status": "status"}]}], "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.PATCH, + url, + body=mock_response, + content_type='application/json', + status=202, + ) + + # Set up parameter values + assignment_id = 'testString' + if_match = 'testString' + template_version = '1' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + "if_match": if_match, + "template_version": template_version, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.update_assignment(**req_copy) + + def test_update_assignment_value_error_with_retries(self): + # Enable retries and run test_update_assignment_value_error. + _service.enable_retries() + self.test_update_assignment_value_error() + + # Disable retries and run test_update_assignment_value_error. + _service.disable_retries() + self.test_update_assignment_value_error() + + +class TestDeleteAssignment: + """ + Test Class for delete_assignment + """ + + @responses.activate + def test_delete_assignment_all_params(self): + """ + delete_assignment() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + assignment_id = 'testString' + transaction_id = 'testString' + + # Invoke method + response = _service.delete_assignment( + assignment_id, + transaction_id=transaction_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_assignment_all_params_with_retries(self): + # Enable retries and run test_delete_assignment_all_params. + _service.enable_retries() + self.test_delete_assignment_all_params() + + # Disable retries and run test_delete_assignment_all_params. + _service.disable_retries() + self.test_delete_assignment_all_params() + + @responses.activate + def test_delete_assignment_required_params(self): + """ + test_delete_assignment_required_params() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Invoke method + response = _service.delete_assignment( + assignment_id, + headers={}, + ) + + # Check for correct operation + assert len(responses.calls) == 1 + assert response.status_code == 202 + + def test_delete_assignment_required_params_with_retries(self): + # Enable retries and run test_delete_assignment_required_params. + _service.enable_retries() + self.test_delete_assignment_required_params() + + # Disable retries and run test_delete_assignment_required_params. + _service.disable_retries() + self.test_delete_assignment_required_params() + + @responses.activate + def test_delete_assignment_value_error(self): + """ + test_delete_assignment_value_error() + """ + # Set up mock + url = preprocess_url('/v1/group_assignments/testString') + responses.add( + responses.DELETE, + url, + status=202, + ) + + # Set up parameter values + assignment_id = 'testString' + + # Pass in all but one required param and check for a ValueError + req_param_dict = { + "assignment_id": assignment_id, + } + for param in req_param_dict.keys(): + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} + with pytest.raises(ValueError): + _service.delete_assignment(**req_copy) + + def test_delete_assignment_value_error_with_retries(self): + # Enable retries and run test_delete_assignment_value_error. + _service.enable_retries() + self.test_delete_assignment_value_error() + + # Disable retries and run test_delete_assignment_value_error. + _service.disable_retries() + self.test_delete_assignment_value_error() + + +# endregion +############################################################################## +# End of Service: TemplateAssignmentOperations +############################################################################## + + +############################################################################## +# Start of Model Tests +############################################################################## +# region + + +class TestModel_AccessActionControls: + """ + Test Class for AccessActionControls + """ + + def test_access_action_controls_serialization(self): + """ + Test serialization/deserialization for AccessActionControls + """ + + # Construct a json representation of a AccessActionControls model + access_action_controls_model_json = {} + access_action_controls_model_json['add'] = True + + # Construct a model instance of AccessActionControls by calling from_dict on the json representation + access_action_controls_model = AccessActionControls.from_dict(access_action_controls_model_json) + assert access_action_controls_model != False + + # Construct a model instance of AccessActionControls by calling from_dict on the json representation + access_action_controls_model_dict = AccessActionControls.from_dict(access_action_controls_model_json).__dict__ + access_action_controls_model2 = AccessActionControls(**access_action_controls_model_dict) + + # Verify the model instances are equivalent + assert access_action_controls_model == access_action_controls_model2 + + # Convert model instance back to dict and verify no loss of data + access_action_controls_model_json2 = access_action_controls_model.to_dict() + assert access_action_controls_model_json2 == access_action_controls_model_json + + +class TestModel_AccessGroupRequest: + """ + Test Class for AccessGroupRequest + """ + + def test_access_group_request_serialization(self): + """ + Test serialization/deserialization for AccessGroupRequest + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + # Construct a json representation of a AccessGroupRequest model + access_group_request_model_json = {} + access_group_request_model_json['name'] = 'testString' + access_group_request_model_json['description'] = 'testString' + access_group_request_model_json['members'] = members_model + access_group_request_model_json['assertions'] = assertions_model + access_group_request_model_json['action_controls'] = group_action_controls_model + + # Construct a model instance of AccessGroupRequest by calling from_dict on the json representation + access_group_request_model = AccessGroupRequest.from_dict(access_group_request_model_json) + assert access_group_request_model != False + + # Construct a model instance of AccessGroupRequest by calling from_dict on the json representation + access_group_request_model_dict = AccessGroupRequest.from_dict(access_group_request_model_json).__dict__ + access_group_request_model2 = AccessGroupRequest(**access_group_request_model_dict) + + # Verify the model instances are equivalent + assert access_group_request_model == access_group_request_model2 + + # Convert model instance back to dict and verify no loss of data + access_group_request_model_json2 = access_group_request_model.to_dict() + assert access_group_request_model_json2 == access_group_request_model_json + + +class TestModel_AccessGroupResponse: + """ + Test Class for AccessGroupResponse + """ + + def test_access_group_response_serialization(self): + """ + Test serialization/deserialization for AccessGroupResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + # Construct a json representation of a AccessGroupResponse model + access_group_response_model_json = {} + access_group_response_model_json['name'] = 'testString' + access_group_response_model_json['description'] = 'testString' + access_group_response_model_json['members'] = members_model + access_group_response_model_json['assertions'] = assertions_model + access_group_response_model_json['action_controls'] = group_action_controls_model + + # Construct a model instance of AccessGroupResponse by calling from_dict on the json representation + access_group_response_model = AccessGroupResponse.from_dict(access_group_response_model_json) + assert access_group_response_model != False + + # Construct a model instance of AccessGroupResponse by calling from_dict on the json representation + access_group_response_model_dict = AccessGroupResponse.from_dict(access_group_response_model_json).__dict__ + access_group_response_model2 = AccessGroupResponse(**access_group_response_model_dict) + + # Verify the model instances are equivalent + assert access_group_response_model == access_group_response_model2 + + # Convert model instance back to dict and verify no loss of data + access_group_response_model_json2 = access_group_response_model.to_dict() + assert access_group_response_model_json2 == access_group_response_model_json + + +class TestModel_AccountSettings: + """ + Test Class for AccountSettings + """ + + def test_account_settings_serialization(self): + """ + Test serialization/deserialization for AccountSettings + """ + + # Construct a json representation of a AccountSettings model + account_settings_model_json = {} + account_settings_model_json['account_id'] = 'testString' + account_settings_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + account_settings_model_json['last_modified_by_id'] = 'testString' + account_settings_model_json['public_access_enabled'] = True + + # Construct a model instance of AccountSettings by calling from_dict on the json representation + account_settings_model = AccountSettings.from_dict(account_settings_model_json) + assert account_settings_model != False + + # Construct a model instance of AccountSettings by calling from_dict on the json representation + account_settings_model_dict = AccountSettings.from_dict(account_settings_model_json).__dict__ + account_settings_model2 = AccountSettings(**account_settings_model_dict) + + # Verify the model instances are equivalent + assert account_settings_model == account_settings_model2 + + # Convert model instance back to dict and verify no loss of data + account_settings_model_json2 = account_settings_model.to_dict() + assert account_settings_model_json2 == account_settings_model_json + + +class TestModel_AddGroupMembersRequestMembersItem: + """ + Test Class for AddGroupMembersRequestMembersItem + """ + + def test_add_group_members_request_members_item_serialization(self): + """ + Test serialization/deserialization for AddGroupMembersRequestMembersItem + """ + + # Construct a json representation of a AddGroupMembersRequestMembersItem model + add_group_members_request_members_item_model_json = {} + add_group_members_request_members_item_model_json['iam_id'] = 'testString' + add_group_members_request_members_item_model_json['type'] = 'testString' + + # Construct a model instance of AddGroupMembersRequestMembersItem by calling from_dict on the json representation + add_group_members_request_members_item_model = AddGroupMembersRequestMembersItem.from_dict( + add_group_members_request_members_item_model_json + ) + assert add_group_members_request_members_item_model != False + + # Construct a model instance of AddGroupMembersRequestMembersItem by calling from_dict on the json representation + add_group_members_request_members_item_model_dict = AddGroupMembersRequestMembersItem.from_dict( + add_group_members_request_members_item_model_json + ).__dict__ + add_group_members_request_members_item_model2 = AddGroupMembersRequestMembersItem( + **add_group_members_request_members_item_model_dict + ) + + # Verify the model instances are equivalent + assert add_group_members_request_members_item_model == add_group_members_request_members_item_model2 + + # Convert model instance back to dict and verify no loss of data + add_group_members_request_members_item_model_json2 = add_group_members_request_members_item_model.to_dict() + assert add_group_members_request_members_item_model_json2 == add_group_members_request_members_item_model_json + + +class TestModel_AddGroupMembersResponse: + """ + Test Class for AddGroupMembersResponse + """ + + def test_add_group_members_response_serialization(self): + """ + Test serialization/deserialization for AddGroupMembersResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + error_model = {} # Error + error_model['code'] = 'testString' + error_model['message'] = 'testString' + + add_group_members_response_members_item_model = {} # AddGroupMembersResponseMembersItem + add_group_members_response_members_item_model['iam_id'] = 'testString' + add_group_members_response_members_item_model['type'] = 'testString' + add_group_members_response_members_item_model['created_at'] = '2019-01-01T12:00:00Z' + add_group_members_response_members_item_model['created_by_id'] = 'testString' + add_group_members_response_members_item_model['status_code'] = 38 + add_group_members_response_members_item_model['trace'] = 'testString' + add_group_members_response_members_item_model['errors'] = [error_model] + + # Construct a json representation of a AddGroupMembersResponse model + add_group_members_response_model_json = {} + add_group_members_response_model_json['members'] = [add_group_members_response_members_item_model] + + # Construct a model instance of AddGroupMembersResponse by calling from_dict on the json representation + add_group_members_response_model = AddGroupMembersResponse.from_dict(add_group_members_response_model_json) + assert add_group_members_response_model != False + + # Construct a model instance of AddGroupMembersResponse by calling from_dict on the json representation + add_group_members_response_model_dict = AddGroupMembersResponse.from_dict( + add_group_members_response_model_json + ).__dict__ + add_group_members_response_model2 = AddGroupMembersResponse(**add_group_members_response_model_dict) + + # Verify the model instances are equivalent + assert add_group_members_response_model == add_group_members_response_model2 + + # Convert model instance back to dict and verify no loss of data + add_group_members_response_model_json2 = add_group_members_response_model.to_dict() + assert add_group_members_response_model_json2 == add_group_members_response_model_json + + +class TestModel_AddGroupMembersResponseMembersItem: + """ + Test Class for AddGroupMembersResponseMembersItem + """ + + def test_add_group_members_response_members_item_serialization(self): + """ + Test serialization/deserialization for AddGroupMembersResponseMembersItem + """ + + # Construct dict forms of any model objects needed in order to build this model. + + error_model = {} # Error + error_model['code'] = 'testString' + error_model['message'] = 'testString' + + # Construct a json representation of a AddGroupMembersResponseMembersItem model + add_group_members_response_members_item_model_json = {} + add_group_members_response_members_item_model_json['iam_id'] = 'testString' + add_group_members_response_members_item_model_json['type'] = 'testString' + add_group_members_response_members_item_model_json['created_at'] = '2019-01-01T12:00:00Z' + add_group_members_response_members_item_model_json['created_by_id'] = 'testString' + add_group_members_response_members_item_model_json['status_code'] = 38 + add_group_members_response_members_item_model_json['trace'] = 'testString' + add_group_members_response_members_item_model_json['errors'] = [error_model] + + # Construct a model instance of AddGroupMembersResponseMembersItem by calling from_dict on the json representation + add_group_members_response_members_item_model = AddGroupMembersResponseMembersItem.from_dict( + add_group_members_response_members_item_model_json + ) + assert add_group_members_response_members_item_model != False + + # Construct a model instance of AddGroupMembersResponseMembersItem by calling from_dict on the json representation + add_group_members_response_members_item_model_dict = AddGroupMembersResponseMembersItem.from_dict( + add_group_members_response_members_item_model_json + ).__dict__ + add_group_members_response_members_item_model2 = AddGroupMembersResponseMembersItem( + **add_group_members_response_members_item_model_dict + ) + + # Verify the model instances are equivalent + assert add_group_members_response_members_item_model == add_group_members_response_members_item_model2 + + # Convert model instance back to dict and verify no loss of data + add_group_members_response_members_item_model_json2 = add_group_members_response_members_item_model.to_dict() + assert add_group_members_response_members_item_model_json2 == add_group_members_response_members_item_model_json + + +class TestModel_AddMembershipMultipleGroupsResponse: + """ + Test Class for AddMembershipMultipleGroupsResponse + """ + + def test_add_membership_multiple_groups_response_serialization(self): + """ + Test serialization/deserialization for AddMembershipMultipleGroupsResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + error_model = {} # Error + error_model['code'] = 'testString' + error_model['message'] = 'testString' + + add_membership_multiple_groups_response_groups_item_model = {} # AddMembershipMultipleGroupsResponseGroupsItem + add_membership_multiple_groups_response_groups_item_model['access_group_id'] = 'testString' + add_membership_multiple_groups_response_groups_item_model['status_code'] = 38 + add_membership_multiple_groups_response_groups_item_model['trace'] = 'testString' + add_membership_multiple_groups_response_groups_item_model['errors'] = [error_model] + + # Construct a json representation of a AddMembershipMultipleGroupsResponse model + add_membership_multiple_groups_response_model_json = {} + add_membership_multiple_groups_response_model_json['iam_id'] = 'testString' + add_membership_multiple_groups_response_model_json['groups'] = [ + add_membership_multiple_groups_response_groups_item_model + ] # Construct a model instance of AddMembershipMultipleGroupsResponse by calling from_dict on the json representation add_membership_multiple_groups_response_model = AddMembershipMultipleGroupsResponse.from_dict( @@ -3281,19 +5966,271 @@ def test_add_membership_multiple_groups_response_groups_item_serialization(self) ) # Verify the model instances are equivalent - assert ( - add_membership_multiple_groups_response_groups_item_model - == add_membership_multiple_groups_response_groups_item_model2 - ) + assert ( + add_membership_multiple_groups_response_groups_item_model + == add_membership_multiple_groups_response_groups_item_model2 + ) + + # Convert model instance back to dict and verify no loss of data + add_membership_multiple_groups_response_groups_item_model_json2 = ( + add_membership_multiple_groups_response_groups_item_model.to_dict() + ) + assert ( + add_membership_multiple_groups_response_groups_item_model_json2 + == add_membership_multiple_groups_response_groups_item_model_json + ) + + +class TestModel_Assertions: + """ + Test Class for Assertions + """ + + def test_assertions_serialization(self): + """ + Test serialization/deserialization for Assertions + """ + + # Construct dict forms of any model objects needed in order to build this model. + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + # Construct a json representation of a Assertions model + assertions_model_json = {} + assertions_model_json['rules'] = [assertions_rule_model] + assertions_model_json['action_controls'] = assertions_action_controls_model + + # Construct a model instance of Assertions by calling from_dict on the json representation + assertions_model = Assertions.from_dict(assertions_model_json) + assert assertions_model != False + + # Construct a model instance of Assertions by calling from_dict on the json representation + assertions_model_dict = Assertions.from_dict(assertions_model_json).__dict__ + assertions_model2 = Assertions(**assertions_model_dict) + + # Verify the model instances are equivalent + assert assertions_model == assertions_model2 + + # Convert model instance back to dict and verify no loss of data + assertions_model_json2 = assertions_model.to_dict() + assert assertions_model_json2 == assertions_model_json + + +class TestModel_AssertionsActionControls: + """ + Test Class for AssertionsActionControls + """ + + def test_assertions_action_controls_serialization(self): + """ + Test serialization/deserialization for AssertionsActionControls + """ + + # Construct a json representation of a AssertionsActionControls model + assertions_action_controls_model_json = {} + assertions_action_controls_model_json['add'] = True + assertions_action_controls_model_json['remove'] = True + assertions_action_controls_model_json['update'] = True + + # Construct a model instance of AssertionsActionControls by calling from_dict on the json representation + assertions_action_controls_model = AssertionsActionControls.from_dict(assertions_action_controls_model_json) + assert assertions_action_controls_model != False + + # Construct a model instance of AssertionsActionControls by calling from_dict on the json representation + assertions_action_controls_model_dict = AssertionsActionControls.from_dict( + assertions_action_controls_model_json + ).__dict__ + assertions_action_controls_model2 = AssertionsActionControls(**assertions_action_controls_model_dict) + + # Verify the model instances are equivalent + assert assertions_action_controls_model == assertions_action_controls_model2 + + # Convert model instance back to dict and verify no loss of data + assertions_action_controls_model_json2 = assertions_action_controls_model.to_dict() + assert assertions_action_controls_model_json2 == assertions_action_controls_model_json + + +class TestModel_AssertionsRule: + """ + Test Class for AssertionsRule + """ + + def test_assertions_rule_serialization(self): + """ + Test serialization/deserialization for AssertionsRule + """ + + # Construct dict forms of any model objects needed in order to build this model. + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + # Construct a json representation of a AssertionsRule model + assertions_rule_model_json = {} + assertions_rule_model_json['name'] = 'testString' + assertions_rule_model_json['expiration'] = 38 + assertions_rule_model_json['realm_name'] = 'testString' + assertions_rule_model_json['conditions'] = [conditions_model] + assertions_rule_model_json['action_controls'] = rule_action_controls_model + + # Construct a model instance of AssertionsRule by calling from_dict on the json representation + assertions_rule_model = AssertionsRule.from_dict(assertions_rule_model_json) + assert assertions_rule_model != False + + # Construct a model instance of AssertionsRule by calling from_dict on the json representation + assertions_rule_model_dict = AssertionsRule.from_dict(assertions_rule_model_json).__dict__ + assertions_rule_model2 = AssertionsRule(**assertions_rule_model_dict) + + # Verify the model instances are equivalent + assert assertions_rule_model == assertions_rule_model2 + + # Convert model instance back to dict and verify no loss of data + assertions_rule_model_json2 = assertions_rule_model.to_dict() + assert assertions_rule_model_json2 == assertions_rule_model_json + + +class TestModel_AssignmentResourceAccessGroup: + """ + Test Class for AssignmentResourceAccessGroup + """ + + def test_assignment_resource_access_group_serialization(self): + """ + Test serialization/deserialization for AssignmentResourceAccessGroup + """ + + # Construct dict forms of any model objects needed in order to build this model. + + assignment_resource_entry_model = {} # AssignmentResourceEntry + assignment_resource_entry_model['id'] = 'testString' + assignment_resource_entry_model['name'] = 'testString' + assignment_resource_entry_model['version'] = 'testString' + assignment_resource_entry_model['resource'] = 'testString' + assignment_resource_entry_model['error'] = 'testString' + assignment_resource_entry_model['operation'] = 'testString' + assignment_resource_entry_model['status'] = 'testString' + + # Construct a json representation of a AssignmentResourceAccessGroup model + assignment_resource_access_group_model_json = {} + assignment_resource_access_group_model_json['group'] = assignment_resource_entry_model + assignment_resource_access_group_model_json['members'] = [assignment_resource_entry_model] + assignment_resource_access_group_model_json['rules'] = [assignment_resource_entry_model] + + # Construct a model instance of AssignmentResourceAccessGroup by calling from_dict on the json representation + assignment_resource_access_group_model = AssignmentResourceAccessGroup.from_dict( + assignment_resource_access_group_model_json + ) + assert assignment_resource_access_group_model != False + + # Construct a model instance of AssignmentResourceAccessGroup by calling from_dict on the json representation + assignment_resource_access_group_model_dict = AssignmentResourceAccessGroup.from_dict( + assignment_resource_access_group_model_json + ).__dict__ + assignment_resource_access_group_model2 = AssignmentResourceAccessGroup( + **assignment_resource_access_group_model_dict + ) + + # Verify the model instances are equivalent + assert assignment_resource_access_group_model == assignment_resource_access_group_model2 + + # Convert model instance back to dict and verify no loss of data + assignment_resource_access_group_model_json2 = assignment_resource_access_group_model.to_dict() + assert assignment_resource_access_group_model_json2 == assignment_resource_access_group_model_json + + +class TestModel_AssignmentResourceEntry: + """ + Test Class for AssignmentResourceEntry + """ + + def test_assignment_resource_entry_serialization(self): + """ + Test serialization/deserialization for AssignmentResourceEntry + """ + + # Construct a json representation of a AssignmentResourceEntry model + assignment_resource_entry_model_json = {} + assignment_resource_entry_model_json['id'] = 'testString' + assignment_resource_entry_model_json['name'] = 'testString' + assignment_resource_entry_model_json['version'] = 'testString' + assignment_resource_entry_model_json['resource'] = 'testString' + assignment_resource_entry_model_json['error'] = 'testString' + assignment_resource_entry_model_json['operation'] = 'testString' + assignment_resource_entry_model_json['status'] = 'testString' + + # Construct a model instance of AssignmentResourceEntry by calling from_dict on the json representation + assignment_resource_entry_model = AssignmentResourceEntry.from_dict(assignment_resource_entry_model_json) + assert assignment_resource_entry_model != False + + # Construct a model instance of AssignmentResourceEntry by calling from_dict on the json representation + assignment_resource_entry_model_dict = AssignmentResourceEntry.from_dict( + assignment_resource_entry_model_json + ).__dict__ + assignment_resource_entry_model2 = AssignmentResourceEntry(**assignment_resource_entry_model_dict) + + # Verify the model instances are equivalent + assert assignment_resource_entry_model == assignment_resource_entry_model2 + + # Convert model instance back to dict and verify no loss of data + assignment_resource_entry_model_json2 = assignment_resource_entry_model.to_dict() + assert assignment_resource_entry_model_json2 == assignment_resource_entry_model_json + + +class TestModel_Conditions: + """ + Test Class for Conditions + """ + + def test_conditions_serialization(self): + """ + Test serialization/deserialization for Conditions + """ + + # Construct a json representation of a Conditions model + conditions_model_json = {} + conditions_model_json['claim'] = 'testString' + conditions_model_json['operator'] = 'testString' + conditions_model_json['value'] = 'testString' + + # Construct a model instance of Conditions by calling from_dict on the json representation + conditions_model = Conditions.from_dict(conditions_model_json) + assert conditions_model != False + + # Construct a model instance of Conditions by calling from_dict on the json representation + conditions_model_dict = Conditions.from_dict(conditions_model_json).__dict__ + conditions_model2 = Conditions(**conditions_model_dict) + + # Verify the model instances are equivalent + assert conditions_model == conditions_model2 # Convert model instance back to dict and verify no loss of data - add_membership_multiple_groups_response_groups_item_model_json2 = ( - add_membership_multiple_groups_response_groups_item_model.to_dict() - ) - assert ( - add_membership_multiple_groups_response_groups_item_model_json2 - == add_membership_multiple_groups_response_groups_item_model_json - ) + conditions_model_json2 = conditions_model.to_dict() + assert conditions_model_json2 == conditions_model_json class TestModel_DeleteFromAllGroupsResponse: @@ -3567,6 +6504,41 @@ def test_group_serialization(self): assert group_model_json2 == group_model_json +class TestModel_GroupActionControls: + """ + Test Class for GroupActionControls + """ + + def test_group_action_controls_serialization(self): + """ + Test serialization/deserialization for GroupActionControls + """ + + # Construct dict forms of any model objects needed in order to build this model. + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + # Construct a json representation of a GroupActionControls model + group_action_controls_model_json = {} + group_action_controls_model_json['access'] = access_action_controls_model + + # Construct a model instance of GroupActionControls by calling from_dict on the json representation + group_action_controls_model = GroupActionControls.from_dict(group_action_controls_model_json) + assert group_action_controls_model != False + + # Construct a model instance of GroupActionControls by calling from_dict on the json representation + group_action_controls_model_dict = GroupActionControls.from_dict(group_action_controls_model_json).__dict__ + group_action_controls_model2 = GroupActionControls(**group_action_controls_model_dict) + + # Verify the model instances are equivalent + assert group_action_controls_model == group_action_controls_model2 + + # Convert model instance back to dict and verify no loss of data + group_action_controls_model_json2 = group_action_controls_model.to_dict() + assert group_action_controls_model_json2 == group_action_controls_model_json + + class TestModel_GroupMembersList: """ Test Class for GroupMembersList @@ -3620,6 +6592,100 @@ def test_group_members_list_serialization(self): assert group_members_list_model_json2 == group_members_list_model_json +class TestModel_GroupTemplate: + """ + Test Class for GroupTemplate + """ + + def test_group_template_serialization(self): + """ + Test serialization/deserialization for GroupTemplate + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + # Construct a json representation of a GroupTemplate model + group_template_model_json = {} + group_template_model_json['id'] = 'testString' + group_template_model_json['name'] = 'testString' + group_template_model_json['description'] = 'testString' + group_template_model_json['version'] = 'testString' + group_template_model_json['committed'] = True + group_template_model_json['group'] = access_group_response_model + group_template_model_json['policy_template_references'] = [policy_templates_model] + group_template_model_json['href'] = 'testString' + group_template_model_json['created_at'] = '2019-01-01T12:00:00Z' + group_template_model_json['created_by_id'] = 'testString' + group_template_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + group_template_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of GroupTemplate by calling from_dict on the json representation + group_template_model = GroupTemplate.from_dict(group_template_model_json) + assert group_template_model != False + + # Construct a model instance of GroupTemplate by calling from_dict on the json representation + group_template_model_dict = GroupTemplate.from_dict(group_template_model_json).__dict__ + group_template_model2 = GroupTemplate(**group_template_model_dict) + + # Verify the model instances are equivalent + assert group_template_model == group_template_model2 + + # Convert model instance back to dict and verify no loss of data + group_template_model_json2 = group_template_model.to_dict() + assert group_template_model_json2 == group_template_model_json + + class TestModel_GroupsList: """ Test Class for GroupsList @@ -3744,6 +6810,545 @@ def test_list_group_members_response_member_serialization(self): assert list_group_members_response_member_model_json2 == list_group_members_response_member_model_json +class TestModel_ListTemplateAssignmentResponse: + """ + Test Class for ListTemplateAssignmentResponse + """ + + def test_list_template_assignment_response_serialization(self): + """ + Test serialization/deserialization for ListTemplateAssignmentResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + href_struct_model = {} # HrefStruct + href_struct_model['href'] = 'testString' + + template_assignment_response_model = {} # TemplateAssignmentResponse + template_assignment_response_model['id'] = 'testString' + template_assignment_response_model['account_id'] = 'testString' + template_assignment_response_model['template_id'] = 'testString' + template_assignment_response_model['template_version'] = 'testString' + template_assignment_response_model['target_type'] = 'Account' + template_assignment_response_model['target'] = 'testString' + template_assignment_response_model['operation'] = 'assign' + template_assignment_response_model['status'] = 'accepted' + template_assignment_response_model['href'] = 'testString' + template_assignment_response_model['created_at'] = '2019-01-01T12:00:00Z' + template_assignment_response_model['created_by_id'] = 'testString' + template_assignment_response_model['last_modified_at'] = '2019-01-01T12:00:00Z' + template_assignment_response_model['last_modified_by_id'] = 'testString' + + # Construct a json representation of a ListTemplateAssignmentResponse model + list_template_assignment_response_model_json = {} + list_template_assignment_response_model_json['limit'] = 26 + list_template_assignment_response_model_json['offset'] = 26 + list_template_assignment_response_model_json['total_count'] = 26 + list_template_assignment_response_model_json['first'] = href_struct_model + list_template_assignment_response_model_json['last'] = href_struct_model + list_template_assignment_response_model_json['assignments'] = [template_assignment_response_model] + + # Construct a model instance of ListTemplateAssignmentResponse by calling from_dict on the json representation + list_template_assignment_response_model = ListTemplateAssignmentResponse.from_dict( + list_template_assignment_response_model_json + ) + assert list_template_assignment_response_model != False + + # Construct a model instance of ListTemplateAssignmentResponse by calling from_dict on the json representation + list_template_assignment_response_model_dict = ListTemplateAssignmentResponse.from_dict( + list_template_assignment_response_model_json + ).__dict__ + list_template_assignment_response_model2 = ListTemplateAssignmentResponse( + **list_template_assignment_response_model_dict + ) + + # Verify the model instances are equivalent + assert list_template_assignment_response_model == list_template_assignment_response_model2 + + # Convert model instance back to dict and verify no loss of data + list_template_assignment_response_model_json2 = list_template_assignment_response_model.to_dict() + assert list_template_assignment_response_model_json2 == list_template_assignment_response_model_json + + +class TestModel_ListTemplateVersionResponse: + """ + Test Class for ListTemplateVersionResponse + """ + + def test_list_template_version_response_serialization(self): + """ + Test serialization/deserialization for ListTemplateVersionResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + # Construct a json representation of a ListTemplateVersionResponse model + list_template_version_response_model_json = {} + list_template_version_response_model_json['name'] = 'testString' + list_template_version_response_model_json['description'] = 'testString' + list_template_version_response_model_json['account_id'] = 'testString' + list_template_version_response_model_json['version'] = 'testString' + list_template_version_response_model_json['committed'] = True + list_template_version_response_model_json['group'] = access_group_response_model + list_template_version_response_model_json['policy_template_references'] = [policy_templates_model] + list_template_version_response_model_json['href'] = 'testString' + list_template_version_response_model_json['created_at'] = 'testString' + list_template_version_response_model_json['created_by_id'] = 'testString' + list_template_version_response_model_json['last_modified_at'] = 'testString' + list_template_version_response_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of ListTemplateVersionResponse by calling from_dict on the json representation + list_template_version_response_model = ListTemplateVersionResponse.from_dict( + list_template_version_response_model_json + ) + assert list_template_version_response_model != False + + # Construct a model instance of ListTemplateVersionResponse by calling from_dict on the json representation + list_template_version_response_model_dict = ListTemplateVersionResponse.from_dict( + list_template_version_response_model_json + ).__dict__ + list_template_version_response_model2 = ListTemplateVersionResponse(**list_template_version_response_model_dict) + + # Verify the model instances are equivalent + assert list_template_version_response_model == list_template_version_response_model2 + + # Convert model instance back to dict and verify no loss of data + list_template_version_response_model_json2 = list_template_version_response_model.to_dict() + assert list_template_version_response_model_json2 == list_template_version_response_model_json + + +class TestModel_ListTemplateVersionsResponse: + """ + Test Class for ListTemplateVersionsResponse + """ + + def test_list_template_versions_response_serialization(self): + """ + Test serialization/deserialization for ListTemplateVersionsResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + href_struct_model = {} # HrefStruct + href_struct_model['href'] = 'testString' + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + list_template_version_response_model = {} # ListTemplateVersionResponse + list_template_version_response_model['name'] = 'testString' + list_template_version_response_model['description'] = 'testString' + list_template_version_response_model['account_id'] = 'testString' + list_template_version_response_model['version'] = 'testString' + list_template_version_response_model['committed'] = True + list_template_version_response_model['group'] = access_group_response_model + list_template_version_response_model['policy_template_references'] = [policy_templates_model] + list_template_version_response_model['href'] = 'testString' + list_template_version_response_model['created_at'] = 'testString' + list_template_version_response_model['created_by_id'] = 'testString' + list_template_version_response_model['last_modified_at'] = 'testString' + list_template_version_response_model['last_modified_by_id'] = 'testString' + + # Construct a json representation of a ListTemplateVersionsResponse model + list_template_versions_response_model_json = {} + list_template_versions_response_model_json['limit'] = 38 + list_template_versions_response_model_json['offset'] = 38 + list_template_versions_response_model_json['total_count'] = 38 + list_template_versions_response_model_json['first'] = href_struct_model + list_template_versions_response_model_json['previous'] = href_struct_model + list_template_versions_response_model_json['next'] = href_struct_model + list_template_versions_response_model_json['last'] = href_struct_model + list_template_versions_response_model_json['group_template_versions'] = [list_template_version_response_model] + + # Construct a model instance of ListTemplateVersionsResponse by calling from_dict on the json representation + list_template_versions_response_model = ListTemplateVersionsResponse.from_dict( + list_template_versions_response_model_json + ) + assert list_template_versions_response_model != False + + # Construct a model instance of ListTemplateVersionsResponse by calling from_dict on the json representation + list_template_versions_response_model_dict = ListTemplateVersionsResponse.from_dict( + list_template_versions_response_model_json + ).__dict__ + list_template_versions_response_model2 = ListTemplateVersionsResponse( + **list_template_versions_response_model_dict + ) + + # Verify the model instances are equivalent + assert list_template_versions_response_model == list_template_versions_response_model2 + + # Convert model instance back to dict and verify no loss of data + list_template_versions_response_model_json2 = list_template_versions_response_model.to_dict() + assert list_template_versions_response_model_json2 == list_template_versions_response_model_json + + +class TestModel_ListTemplatesResponse: + """ + Test Class for ListTemplatesResponse + """ + + def test_list_templates_response_serialization(self): + """ + Test serialization/deserialization for ListTemplatesResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + href_struct_model = {} # HrefStruct + href_struct_model['href'] = 'testString' + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + group_template_model = {} # GroupTemplate + group_template_model['id'] = 'testString' + group_template_model['name'] = 'testString' + group_template_model['description'] = 'testString' + group_template_model['version'] = 'testString' + group_template_model['committed'] = True + group_template_model['group'] = access_group_response_model + group_template_model['policy_template_references'] = [policy_templates_model] + group_template_model['href'] = 'testString' + group_template_model['created_at'] = '2019-01-01T12:00:00Z' + group_template_model['created_by_id'] = 'testString' + group_template_model['last_modified_at'] = '2019-01-01T12:00:00Z' + group_template_model['last_modified_by_id'] = 'testString' + + # Construct a json representation of a ListTemplatesResponse model + list_templates_response_model_json = {} + list_templates_response_model_json['limit'] = 38 + list_templates_response_model_json['offset'] = 38 + list_templates_response_model_json['total_count'] = 38 + list_templates_response_model_json['first'] = href_struct_model + list_templates_response_model_json['previous'] = href_struct_model + list_templates_response_model_json['next'] = href_struct_model + list_templates_response_model_json['last'] = href_struct_model + list_templates_response_model_json['group_templates'] = [group_template_model] + + # Construct a model instance of ListTemplatesResponse by calling from_dict on the json representation + list_templates_response_model = ListTemplatesResponse.from_dict(list_templates_response_model_json) + assert list_templates_response_model != False + + # Construct a model instance of ListTemplatesResponse by calling from_dict on the json representation + list_templates_response_model_dict = ListTemplatesResponse.from_dict( + list_templates_response_model_json + ).__dict__ + list_templates_response_model2 = ListTemplatesResponse(**list_templates_response_model_dict) + + # Verify the model instances are equivalent + assert list_templates_response_model == list_templates_response_model2 + + # Convert model instance back to dict and verify no loss of data + list_templates_response_model_json2 = list_templates_response_model.to_dict() + assert list_templates_response_model_json2 == list_templates_response_model_json + + +class TestModel_Members: + """ + Test Class for Members + """ + + def test_members_serialization(self): + """ + Test serialization/deserialization for Members + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + # Construct a json representation of a Members model + members_model_json = {} + members_model_json['users'] = ['testString'] + members_model_json['services'] = ['testString'] + members_model_json['action_controls'] = members_action_controls_model + + # Construct a model instance of Members by calling from_dict on the json representation + members_model = Members.from_dict(members_model_json) + assert members_model != False + + # Construct a model instance of Members by calling from_dict on the json representation + members_model_dict = Members.from_dict(members_model_json).__dict__ + members_model2 = Members(**members_model_dict) + + # Verify the model instances are equivalent + assert members_model == members_model2 + + # Convert model instance back to dict and verify no loss of data + members_model_json2 = members_model.to_dict() + assert members_model_json2 == members_model_json + + +class TestModel_MembersActionControls: + """ + Test Class for MembersActionControls + """ + + def test_members_action_controls_serialization(self): + """ + Test serialization/deserialization for MembersActionControls + """ + + # Construct a json representation of a MembersActionControls model + members_action_controls_model_json = {} + members_action_controls_model_json['add'] = True + members_action_controls_model_json['remove'] = True + + # Construct a model instance of MembersActionControls by calling from_dict on the json representation + members_action_controls_model = MembersActionControls.from_dict(members_action_controls_model_json) + assert members_action_controls_model != False + + # Construct a model instance of MembersActionControls by calling from_dict on the json representation + members_action_controls_model_dict = MembersActionControls.from_dict( + members_action_controls_model_json + ).__dict__ + members_action_controls_model2 = MembersActionControls(**members_action_controls_model_dict) + + # Verify the model instances are equivalent + assert members_action_controls_model == members_action_controls_model2 + + # Convert model instance back to dict and verify no loss of data + members_action_controls_model_json2 = members_action_controls_model.to_dict() + assert members_action_controls_model_json2 == members_action_controls_model_json + + +class TestModel_PolicyTemplates: + """ + Test Class for PolicyTemplates + """ + + def test_policy_templates_serialization(self): + """ + Test serialization/deserialization for PolicyTemplates + """ + + # Construct a json representation of a PolicyTemplates model + policy_templates_model_json = {} + policy_templates_model_json['id'] = 'testString' + policy_templates_model_json['version'] = 'testString' + + # Construct a model instance of PolicyTemplates by calling from_dict on the json representation + policy_templates_model = PolicyTemplates.from_dict(policy_templates_model_json) + assert policy_templates_model != False + + # Construct a model instance of PolicyTemplates by calling from_dict on the json representation + policy_templates_model_dict = PolicyTemplates.from_dict(policy_templates_model_json).__dict__ + policy_templates_model2 = PolicyTemplates(**policy_templates_model_dict) + + # Verify the model instances are equivalent + assert policy_templates_model == policy_templates_model2 + + # Convert model instance back to dict and verify no loss of data + policy_templates_model_json2 = policy_templates_model.to_dict() + assert policy_templates_model_json2 == policy_templates_model_json + + +class TestModel_ResourceListWithTargetAccountID: + """ + Test Class for ResourceListWithTargetAccountID + """ + + def test_resource_list_with_target_account_id_serialization(self): + """ + Test serialization/deserialization for ResourceListWithTargetAccountID + """ + + # Construct dict forms of any model objects needed in order to build this model. + + assignment_resource_entry_model = {} # AssignmentResourceEntry + assignment_resource_entry_model['id'] = 'testString' + assignment_resource_entry_model['name'] = 'testString' + assignment_resource_entry_model['version'] = 'testString' + assignment_resource_entry_model['resource'] = 'testString' + assignment_resource_entry_model['error'] = 'testString' + assignment_resource_entry_model['operation'] = 'testString' + assignment_resource_entry_model['status'] = 'testString' + + assignment_resource_access_group_model = {} # AssignmentResourceAccessGroup + assignment_resource_access_group_model['group'] = assignment_resource_entry_model + assignment_resource_access_group_model['members'] = [assignment_resource_entry_model] + assignment_resource_access_group_model['rules'] = [assignment_resource_entry_model] + + # Construct a json representation of a ResourceListWithTargetAccountID model + resource_list_with_target_account_id_model_json = {} + resource_list_with_target_account_id_model_json['target'] = 'testString' + resource_list_with_target_account_id_model_json['group'] = assignment_resource_access_group_model + resource_list_with_target_account_id_model_json['policy_template_references'] = [ + assignment_resource_entry_model + ] + + # Construct a model instance of ResourceListWithTargetAccountID by calling from_dict on the json representation + resource_list_with_target_account_id_model = ResourceListWithTargetAccountID.from_dict( + resource_list_with_target_account_id_model_json + ) + assert resource_list_with_target_account_id_model != False + + # Construct a model instance of ResourceListWithTargetAccountID by calling from_dict on the json representation + resource_list_with_target_account_id_model_dict = ResourceListWithTargetAccountID.from_dict( + resource_list_with_target_account_id_model_json + ).__dict__ + resource_list_with_target_account_id_model2 = ResourceListWithTargetAccountID( + **resource_list_with_target_account_id_model_dict + ) + + # Verify the model instances are equivalent + assert resource_list_with_target_account_id_model == resource_list_with_target_account_id_model2 + + # Convert model instance back to dict and verify no loss of data + resource_list_with_target_account_id_model_json2 = resource_list_with_target_account_id_model.to_dict() + assert resource_list_with_target_account_id_model_json2 == resource_list_with_target_account_id_model_json + + class TestModel_Rule: """ Test Class for Rule @@ -3791,6 +7396,37 @@ def test_rule_serialization(self): assert rule_model_json2 == rule_model_json +class TestModel_RuleActionControls: + """ + Test Class for RuleActionControls + """ + + def test_rule_action_controls_serialization(self): + """ + Test serialization/deserialization for RuleActionControls + """ + + # Construct a json representation of a RuleActionControls model + rule_action_controls_model_json = {} + rule_action_controls_model_json['remove'] = True + rule_action_controls_model_json['update'] = True + + # Construct a model instance of RuleActionControls by calling from_dict on the json representation + rule_action_controls_model = RuleActionControls.from_dict(rule_action_controls_model_json) + assert rule_action_controls_model != False + + # Construct a model instance of RuleActionControls by calling from_dict on the json representation + rule_action_controls_model_dict = RuleActionControls.from_dict(rule_action_controls_model_json).__dict__ + rule_action_controls_model2 = RuleActionControls(**rule_action_controls_model_dict) + + # Verify the model instances are equivalent + assert rule_action_controls_model == rule_action_controls_model2 + + # Convert model instance back to dict and verify no loss of data + rule_action_controls_model_json2 = rule_action_controls_model.to_dict() + assert rule_action_controls_model_json2 == rule_action_controls_model_json + + class TestModel_RuleConditions: """ Test Class for RuleConditions @@ -3873,6 +7509,314 @@ def test_rules_list_serialization(self): assert rules_list_model_json2 == rules_list_model_json +class TestModel_TemplateAssignmentResponse: + """ + Test Class for TemplateAssignmentResponse + """ + + def test_template_assignment_response_serialization(self): + """ + Test serialization/deserialization for TemplateAssignmentResponse + """ + + # Construct a json representation of a TemplateAssignmentResponse model + template_assignment_response_model_json = {} + template_assignment_response_model_json['id'] = 'testString' + template_assignment_response_model_json['account_id'] = 'testString' + template_assignment_response_model_json['template_id'] = 'testString' + template_assignment_response_model_json['template_version'] = 'testString' + template_assignment_response_model_json['target_type'] = 'Account' + template_assignment_response_model_json['target'] = 'testString' + template_assignment_response_model_json['operation'] = 'assign' + template_assignment_response_model_json['status'] = 'accepted' + template_assignment_response_model_json['href'] = 'testString' + template_assignment_response_model_json['created_at'] = '2019-01-01T12:00:00Z' + template_assignment_response_model_json['created_by_id'] = 'testString' + template_assignment_response_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + template_assignment_response_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of TemplateAssignmentResponse by calling from_dict on the json representation + template_assignment_response_model = TemplateAssignmentResponse.from_dict( + template_assignment_response_model_json + ) + assert template_assignment_response_model != False + + # Construct a model instance of TemplateAssignmentResponse by calling from_dict on the json representation + template_assignment_response_model_dict = TemplateAssignmentResponse.from_dict( + template_assignment_response_model_json + ).__dict__ + template_assignment_response_model2 = TemplateAssignmentResponse(**template_assignment_response_model_dict) + + # Verify the model instances are equivalent + assert template_assignment_response_model == template_assignment_response_model2 + + # Convert model instance back to dict and verify no loss of data + template_assignment_response_model_json2 = template_assignment_response_model.to_dict() + assert template_assignment_response_model_json2 == template_assignment_response_model_json + + +class TestModel_TemplateAssignmentVerboseResponse: + """ + Test Class for TemplateAssignmentVerboseResponse + """ + + def test_template_assignment_verbose_response_serialization(self): + """ + Test serialization/deserialization for TemplateAssignmentVerboseResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + assignment_resource_entry_model = {} # AssignmentResourceEntry + assignment_resource_entry_model['id'] = 'testString' + assignment_resource_entry_model['name'] = 'testString' + assignment_resource_entry_model['version'] = 'testString' + assignment_resource_entry_model['resource'] = 'testString' + assignment_resource_entry_model['error'] = 'testString' + assignment_resource_entry_model['operation'] = 'testString' + assignment_resource_entry_model['status'] = 'testString' + + assignment_resource_access_group_model = {} # AssignmentResourceAccessGroup + assignment_resource_access_group_model['group'] = assignment_resource_entry_model + assignment_resource_access_group_model['members'] = [assignment_resource_entry_model] + assignment_resource_access_group_model['rules'] = [assignment_resource_entry_model] + + resource_list_with_target_account_id_model = {} # ResourceListWithTargetAccountID + resource_list_with_target_account_id_model['target'] = 'testString' + resource_list_with_target_account_id_model['group'] = assignment_resource_access_group_model + resource_list_with_target_account_id_model['policy_template_references'] = [assignment_resource_entry_model] + + # Construct a json representation of a TemplateAssignmentVerboseResponse model + template_assignment_verbose_response_model_json = {} + template_assignment_verbose_response_model_json['id'] = 'testString' + template_assignment_verbose_response_model_json['account_id'] = 'testString' + template_assignment_verbose_response_model_json['template_id'] = 'testString' + template_assignment_verbose_response_model_json['template_version'] = 'testString' + template_assignment_verbose_response_model_json['target_type'] = 'testString' + template_assignment_verbose_response_model_json['target'] = 'testString' + template_assignment_verbose_response_model_json['operation'] = 'testString' + template_assignment_verbose_response_model_json['status'] = 'testString' + template_assignment_verbose_response_model_json['resources'] = [resource_list_with_target_account_id_model] + template_assignment_verbose_response_model_json['href'] = 'testString' + template_assignment_verbose_response_model_json['created_at'] = '2019-01-01T12:00:00Z' + template_assignment_verbose_response_model_json['created_by_id'] = 'testString' + template_assignment_verbose_response_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + template_assignment_verbose_response_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of TemplateAssignmentVerboseResponse by calling from_dict on the json representation + template_assignment_verbose_response_model = TemplateAssignmentVerboseResponse.from_dict( + template_assignment_verbose_response_model_json + ) + assert template_assignment_verbose_response_model != False + + # Construct a model instance of TemplateAssignmentVerboseResponse by calling from_dict on the json representation + template_assignment_verbose_response_model_dict = TemplateAssignmentVerboseResponse.from_dict( + template_assignment_verbose_response_model_json + ).__dict__ + template_assignment_verbose_response_model2 = TemplateAssignmentVerboseResponse( + **template_assignment_verbose_response_model_dict + ) + + # Verify the model instances are equivalent + assert template_assignment_verbose_response_model == template_assignment_verbose_response_model2 + + # Convert model instance back to dict and verify no loss of data + template_assignment_verbose_response_model_json2 = template_assignment_verbose_response_model.to_dict() + assert template_assignment_verbose_response_model_json2 == template_assignment_verbose_response_model_json + + +class TestModel_TemplateResponse: + """ + Test Class for TemplateResponse + """ + + def test_template_response_serialization(self): + """ + Test serialization/deserialization for TemplateResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + # Construct a json representation of a TemplateResponse model + template_response_model_json = {} + template_response_model_json['id'] = 'testString' + template_response_model_json['name'] = 'testString' + template_response_model_json['description'] = 'testString' + template_response_model_json['account_id'] = 'testString' + template_response_model_json['version'] = 'testString' + template_response_model_json['committed'] = True + template_response_model_json['group'] = access_group_response_model + template_response_model_json['policy_template_references'] = [policy_templates_model] + template_response_model_json['href'] = 'testString' + template_response_model_json['created_at'] = '2019-01-01T12:00:00Z' + template_response_model_json['created_by_id'] = 'testString' + template_response_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + template_response_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of TemplateResponse by calling from_dict on the json representation + template_response_model = TemplateResponse.from_dict(template_response_model_json) + assert template_response_model != False + + # Construct a model instance of TemplateResponse by calling from_dict on the json representation + template_response_model_dict = TemplateResponse.from_dict(template_response_model_json).__dict__ + template_response_model2 = TemplateResponse(**template_response_model_dict) + + # Verify the model instances are equivalent + assert template_response_model == template_response_model2 + + # Convert model instance back to dict and verify no loss of data + template_response_model_json2 = template_response_model.to_dict() + assert template_response_model_json2 == template_response_model_json + + +class TestModel_TemplateVersionResponse: + """ + Test Class for TemplateVersionResponse + """ + + def test_template_version_response_serialization(self): + """ + Test serialization/deserialization for TemplateVersionResponse + """ + + # Construct dict forms of any model objects needed in order to build this model. + + members_action_controls_model = {} # MembersActionControls + members_action_controls_model['add'] = True + members_action_controls_model['remove'] = True + + members_model = {} # Members + members_model['users'] = ['testString'] + members_model['services'] = ['testString'] + members_model['action_controls'] = members_action_controls_model + + conditions_model = {} # Conditions + conditions_model['claim'] = 'testString' + conditions_model['operator'] = 'testString' + conditions_model['value'] = 'testString' + + rule_action_controls_model = {} # RuleActionControls + rule_action_controls_model['remove'] = True + rule_action_controls_model['update'] = True + + assertions_rule_model = {} # AssertionsRule + assertions_rule_model['name'] = 'testString' + assertions_rule_model['expiration'] = 38 + assertions_rule_model['realm_name'] = 'testString' + assertions_rule_model['conditions'] = [conditions_model] + assertions_rule_model['action_controls'] = rule_action_controls_model + + assertions_action_controls_model = {} # AssertionsActionControls + assertions_action_controls_model['add'] = True + assertions_action_controls_model['remove'] = True + assertions_action_controls_model['update'] = True + + assertions_model = {} # Assertions + assertions_model['rules'] = [assertions_rule_model] + assertions_model['action_controls'] = assertions_action_controls_model + + access_action_controls_model = {} # AccessActionControls + access_action_controls_model['add'] = True + + group_action_controls_model = {} # GroupActionControls + group_action_controls_model['access'] = access_action_controls_model + + access_group_response_model = {} # AccessGroupResponse + access_group_response_model['name'] = 'testString' + access_group_response_model['description'] = 'testString' + access_group_response_model['members'] = members_model + access_group_response_model['assertions'] = assertions_model + access_group_response_model['action_controls'] = group_action_controls_model + + policy_templates_model = {} # PolicyTemplates + policy_templates_model['id'] = 'testString' + policy_templates_model['version'] = 'testString' + + # Construct a json representation of a TemplateVersionResponse model + template_version_response_model_json = {} + template_version_response_model_json['id'] = 'testString' + template_version_response_model_json['name'] = 'testString' + template_version_response_model_json['description'] = 'testString' + template_version_response_model_json['account_id'] = 'testString' + template_version_response_model_json['version'] = 'testString' + template_version_response_model_json['committed'] = True + template_version_response_model_json['group'] = access_group_response_model + template_version_response_model_json['policy_template_references'] = [policy_templates_model] + template_version_response_model_json['href'] = 'testString' + template_version_response_model_json['created_at'] = '2019-01-01T12:00:00Z' + template_version_response_model_json['created_by_id'] = 'testString' + template_version_response_model_json['last_modified_at'] = '2019-01-01T12:00:00Z' + template_version_response_model_json['last_modified_by_id'] = 'testString' + + # Construct a model instance of TemplateVersionResponse by calling from_dict on the json representation + template_version_response_model = TemplateVersionResponse.from_dict(template_version_response_model_json) + assert template_version_response_model != False + + # Construct a model instance of TemplateVersionResponse by calling from_dict on the json representation + template_version_response_model_dict = TemplateVersionResponse.from_dict( + template_version_response_model_json + ).__dict__ + template_version_response_model2 = TemplateVersionResponse(**template_version_response_model_dict) + + # Verify the model instances are equivalent + assert template_version_response_model == template_version_response_model2 + + # Convert model instance back to dict and verify no loss of data + template_version_response_model_json2 = template_version_response_model.to_dict() + assert template_version_response_model_json2 == template_version_response_model_json + + # endregion ############################################################################## # End of Model Tests