diff --git a/Makefile b/Makefile index 9adfe101..c726535d 100644 --- a/Makefile +++ b/Makefile @@ -32,4 +32,7 @@ test-examples: python -m pytest examples lint: - ./pylint.sh + ./pylint.sh && black --check . + +lint-fix: + black . diff --git a/examples/__init__.py b/examples/__init__.py index 17f28909..14c60d4d 100644 --- a/examples/__init__.py +++ b/examples/__init__.py @@ -2,4 +2,4 @@ """Examples""" -# this file is present so that pylint will lint-check the files in this directory \ No newline at end of file +# this file is present so that pylint will lint-check the files in this directory diff --git a/examples/test_case_management_v1_examples.py b/examples/test_case_management_v1_examples.py index 5ec56475..6ba55a5d 100644 --- a/examples/test_case_management_v1_examples.py +++ b/examples/test_case_management_v1_examples.py @@ -51,7 +51,7 @@ # Start of Examples for Service: CaseManagementV1 ############################################################################## # region -class TestCaseManagementV1Examples(): +class TestCaseManagementV1Examples: """ Example Test Class for CaseManagementV1 """ @@ -64,16 +64,14 @@ def setup_class(cls): # begin-common - case_management_service = CaseManagementV1.new_instance( - ) + case_management_service = CaseManagementV1.new_instance() # end-common assert case_management_service is not None # Load the configuration global config - config = read_external_sources( - CaseManagementV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(CaseManagementV1.DEFAULT_SERVICE_NAME) global resource_crn resource_crn = config['RESOURCE_CRN'] @@ -93,14 +91,8 @@ def test_create_case_example(self): print('\ncreate_case() result:') # begin-createCase - offering_type = OfferingType( - group='crn_service_name', - key='cloud-object-storage' - ) - offering_payload = Offering( - name='Cloud Object Storage', - type=offering_type - ) + offering_type = OfferingType(group='crn_service_name', key='cloud-object-storage') + offering_payload = Offering(name='Cloud Object Storage', type=offering_type) case = case_management_service.create_case( type='technical', @@ -141,10 +133,7 @@ def test_get_case_example(self): GetCaseEnums.Fields.CREATED_BY, ] - case = case_management_service.get_case( - case_number=case_number, - fields=fields_to_return - ).get_result() + case = case_management_service.get_case(case_number=case_number, fields=fields_to_return).get_result() print(json.dumps(case, indent=2)) @@ -187,8 +176,7 @@ def test_add_comment_example(self): # begin-addComment comment = case_management_service.add_comment( - case_number=case_number, - comment='This is an example comment.' + case_number=case_number, comment='This is an example comment.' ).get_result() print(json.dumps(comment, indent=2)) @@ -209,9 +197,7 @@ def test_add_watchlist_example(self): print('\nadd_watchlist() result:') # begin-addWatchlist - watchlist_users = [ - User(realm='IBMid', user_id='abc@ibm.com') - ] + watchlist_users = [User(realm='IBMid', user_id='abc@ibm.com')] watchlist_add_response = case_management_service.add_watchlist( case_number=case_number, @@ -236,9 +222,7 @@ def test_remove_watchlist_example(self): print('\nremove_watchlist() result:') # begin-removeWatchlist - watchlist_users = [ - User(realm='IBMid', user_id='abc@ibm.com') - ] + watchlist_users = [User(realm='IBMid', user_id='abc@ibm.com')] watchlist = case_management_service.remove_watchlist( case_number=case_number, @@ -355,8 +339,7 @@ def test_delete_file_example(self): # begin-deleteFile attachment_list = case_management_service.delete_file( - case_number=case_number, - file_id=attachment_id + case_number=case_number, file_id=attachment_id ).get_result() print(json.dumps(attachment_list, indent=2)) @@ -384,8 +367,7 @@ def test_update_case_status_example(self): } case = case_management_service.update_case_status( - case_number=case_number, - status_payload=status_payload_model + case_number=case_number, status_payload=status_payload_model ).get_result() print(json.dumps(case, indent=2)) @@ -395,6 +377,7 @@ def test_update_case_status_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: CaseManagementV1 diff --git a/examples/test_catalog_management_v1_examples.py b/examples/test_catalog_management_v1_examples.py index 6f546546..2c460b2d 100644 --- a/examples/test_catalog_management_v1_examples.py +++ b/examples/test_catalog_management_v1_examples.py @@ -57,7 +57,7 @@ # Start of Examples for Service: CatalogManagementV1 ############################################################################## # region -class TestCatalogManagementV1Examples(): +class TestCatalogManagementV1Examples: """ Example Test Class for CatalogManagementV1 """ @@ -116,10 +116,7 @@ def test_create_catalog_example(self): # begin-create_catalog catalog = self.catalog_management_service.create_catalog( - label='Catalog Management Service', - tags=['python', 'sdk'], - kind='vpe', - owning_account=account_id + label='Catalog Management Service', tags=['python', 'sdk'], kind='vpe', owning_account=account_id ).get_result() print(json.dumps(catalog, indent=2)) @@ -141,9 +138,7 @@ def test_get_catalog_example(self): print('\nget_catalog() result:') # begin-get_catalog - catalog = self.catalog_management_service.get_catalog( - catalog_identifier=catalog_id - ).get_result() + catalog = self.catalog_management_service.get_catalog(catalog_identifier=catalog_id).get_result() print(json.dumps(catalog, indent=2)) @@ -205,8 +200,7 @@ def test_create_offering_example(self): # begin-create_offering offering = self.catalog_management_service.create_offering( - catalog_identifier=catalog_id, - name='offering-name' + catalog_identifier=catalog_id, name='offering-name' ).get_result() print(json.dumps(offering, indent=2)) @@ -229,8 +223,7 @@ def test_get_offering_example(self): # begin-get_offering offering = self.catalog_management_service.get_offering( - catalog_identifier=catalog_id, - offering_id=offering_id + catalog_identifier=catalog_id, offering_id=offering_id ).get_result() print(json.dumps(offering, indent=2)) @@ -251,10 +244,7 @@ def test_replace_offering_example(self): # begin-replace_offering offering = self.catalog_management_service.replace_offering( - catalog_identifier=catalog_id, - offering_id=offering_id, - id=offering_id, - name='updated-offering-name' + catalog_identifier=catalog_id, offering_id=offering_id, id=offering_id, name='updated-offering-name' ).get_result() print(json.dumps(offering, indent=2)) @@ -275,9 +265,7 @@ def test_list_offerings_example(self): # pager offering_search_result = self.catalog_management_service.list_offerings( - catalog_identifier=catalog_id, - limit=100, - offset=0 + catalog_identifier=catalog_id, limit=100, offset=0 ).get_result() print(json.dumps(offering_search_result, indent=2)) @@ -305,7 +293,7 @@ def test_import_offering_example(self): offering_id=offering_id, target_version='0.0.2', repo_type='git_public', - x_auth_token=git_auth_token_for_public_repo + x_auth_token=git_auth_token_for_public_repo, ).get_result() print(json.dumps(offering, indent=2)) @@ -373,7 +361,7 @@ def test_create_object_example(self): parent_id='us-south', kind='vpe', publish=publish_object_model, - state=state_model + state=state_model, ).get_result() print(json.dumps(catalog_object, indent=2)) @@ -396,8 +384,7 @@ def test_get_offering_audit_example(self): # begin-get_offering_audit audit_log = self.catalog_management_service.get_offering_audit( - catalog_identifier=catalog_id, - offering_id=offering_id + catalog_identifier=catalog_id, offering_id=offering_id ).get_result() print(json.dumps(audit_log, indent=2)) @@ -434,13 +421,10 @@ def test_update_catalog_account_example(self): try: # begin-update_catalog_account - include_all_account_filter = { - 'include_all': True - } + include_all_account_filter = {'include_all': True} response = self.catalog_management_service.update_catalog_account( - account_id=account_id, - account_filters=[include_all_account_filter] + account_id=account_id, account_filters=[include_all_account_filter] ) # end-update_catalog_account @@ -496,9 +480,7 @@ def test_get_catalog_audit_example(self): print('\nget_catalog_audit() result:') # begin-get_catalog_audit - audit_log = self.catalog_management_service.get_catalog_audit( - catalog_identifier=catalog_id - ).get_result() + audit_log = self.catalog_management_service.get_catalog_audit(catalog_identifier=catalog_id).get_result() print(json.dumps(audit_log, indent=2)) @@ -540,7 +522,7 @@ def test_import_offering_version_example(self): target_kinds=['roks'], zipurl='https://github.com/rhm-samples/node-red-operator/blob/master/node-red-operator/bundle/0.0.2/node-red-operator.v0.0.2.clusterserviceversion.yaml', target_version='0.0.3', - repo_type='git_public' + repo_type='git_public', ).get_result() print(json.dumps(offering, indent=2)) @@ -561,9 +543,7 @@ def test_replace_offering_icon_example(self): # begin-replace_offering_icon offering = self.catalog_management_service.replace_offering_icon( - catalog_identifier=catalog_id, - offering_id=offering_id, - file_name='offering_icon.png' + catalog_identifier=catalog_id, offering_id=offering_id, file_name='offering_icon.png' ).get_result() print(json.dumps(offering, indent=2)) @@ -584,10 +564,7 @@ def test_update_offering_ibm_example(self): # begin-update_offering_ibm approval_result = self.catalog_management_service.update_offering_ibm( - catalog_identifier=catalog_id, - offering_id=offering_id, - approval_type='allow_request', - approved='true' + catalog_identifier=catalog_id, offering_id=offering_id, approval_type='allow_request', approved='true' ).get_result() print(json.dumps(approval_result, indent=2)) @@ -614,7 +591,7 @@ def test_get_offering_updates_example(self): version='0.0.2', cluster_id=cluster_id, region='us-south', - namespace='application-development-namespace' + namespace='application-development-namespace', ).get_result() print(json.dumps(list_version_update_descriptor, indent=2)) @@ -634,9 +611,7 @@ def test_get_offering_about_example(self): print('\nget_offering_about() result:') # begin-get_offering_about - result = self.catalog_management_service.get_offering_about( - version_loc_id=version_locator_id - ).get_result() + result = self.catalog_management_service.get_offering_about(version_loc_id=version_locator_id).get_result() print(json.dumps(result, indent=2)) @@ -656,8 +631,7 @@ def test_get_offering_license_example(self): # begin-get_offering_license result = self.catalog_management_service.get_offering_license( - version_loc_id=version_locator_id, - license_id='license-id' + version_loc_id=version_locator_id, license_id='license-id' ).get_result() print(json.dumps(result, indent=2)) @@ -696,9 +670,7 @@ def test_deprecate_version_example(self): try: # begin-deprecate_version - response = self.catalog_management_service.deprecate_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.deprecate_version(version_loc_id=version_locator_id) # end-deprecate_version print('\ndeprecate_version() response status code: ', response.get_status_code()) @@ -715,9 +687,7 @@ def test_account_publish_version_example(self): try: # begin-account_publish_version - response = self.catalog_management_service.account_publish_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.account_publish_version(version_loc_id=version_locator_id) # end-account_publish_version print('\naccount_publish_version() response status code: ', response.get_status_code()) @@ -734,9 +704,7 @@ def test_ibm_publish_version_example(self): try: # begin-ibm_publish_version - response = self.catalog_management_service.ibm_publish_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.ibm_publish_version(version_loc_id=version_locator_id) # end-ibm_publish_version print('\nibm_publish_version() response status code: ', response.get_status_code()) @@ -753,9 +721,7 @@ def test_public_publish_version_example(self): try: # begin-public_publish_version - response = self.catalog_management_service.public_publish_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.public_publish_version(version_loc_id=version_locator_id) # end-public_publish_version print('\npublic_publish_version() response status code: ', response.get_status_code()) @@ -772,9 +738,7 @@ def test_commit_version_example(self): try: # begin-commit_version - response = self.catalog_management_service.commit_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.commit_version(version_loc_id=version_locator_id) # end-commit_version print('\ncommit_version() response status code: ', response.get_status_code()) @@ -792,8 +756,7 @@ def test_copy_version_example(self): # begin-copy_version response = self.catalog_management_service.copy_version( - version_loc_id=version_locator_id, - target_kinds=['roks'] + version_loc_id=version_locator_id, target_kinds=['roks'] ) # end-copy_version @@ -832,9 +795,7 @@ def test_get_version_example(self): print('\nget_version() result:') # begin-get_version - offering = self.catalog_management_service.get_version( - version_loc_id=version_locator_id - ).get_result() + offering = self.catalog_management_service.get_version(version_loc_id=version_locator_id).get_result() print(json.dumps(offering, indent=2)) @@ -854,9 +815,7 @@ def test_get_cluster_example(self): # begin-get_cluster cluster_info = self.catalog_management_service.get_cluster( - cluster_id=cluster_id, - region='us-south', - x_auth_refresh_token=bearer_token + cluster_id=cluster_id, region='us-south', x_auth_refresh_token=bearer_token ).get_result() print(json.dumps(cluster_info, indent=2)) @@ -877,9 +836,7 @@ def test_get_namespaces_example(self): # begin-get_namespaces namespace_search_result = self.catalog_management_service.get_namespaces( - cluster_id=cluster_id, - region='us-south', - x_auth_refresh_token=bearer_token + cluster_id=cluster_id, region='us-south', x_auth_refresh_token=bearer_token ).get_result() print(json.dumps(namespace_search_result, indent=2)) @@ -904,7 +861,7 @@ def test_deploy_operators_example(self): cluster_id=cluster_id, region='us-south', all_namespaces=True, - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ).get_result() print(json.dumps(list_operator_deploy_result, indent=2)) @@ -928,7 +885,7 @@ def test_list_operators_example(self): x_auth_refresh_token=bearer_token, cluster_id=cluster_id, region='us-south', - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ).get_result() print(json.dumps(list_operator_deploy_result, indent=2)) @@ -953,7 +910,7 @@ def test_replace_operators_example(self): cluster_id=cluster_id, region='us-south', all_namespaces=True, - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ).get_result() print(json.dumps(list_operator_deploy_result, indent=2)) @@ -977,7 +934,7 @@ def test_install_version_example(self): x_auth_refresh_token=bearer_token, cluster_id=cluster_id, region='us-south', - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ) # end-install_version @@ -1000,7 +957,7 @@ def test_preinstall_version_example(self): x_auth_refresh_token=bearer_token, cluster_id=cluster_id, region='us-south', - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ) # end-preinstall_version @@ -1023,7 +980,7 @@ def test_get_preinstall_example(self): version_loc_id=version_locator_id, x_auth_refresh_token=bearer_token, cluster_id=cluster_id, - region='us-south' + region='us-south', ).get_result() print(json.dumps(install_status, indent=2)) @@ -1047,7 +1004,7 @@ def test_validate_install_example(self): x_auth_refresh_token=bearer_token, cluster_id=cluster_id, region='us-south', - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ) # end-validate_install @@ -1066,8 +1023,7 @@ def test_get_validation_status_example(self): # begin-get_validation_status validation = self.catalog_management_service.get_validation_status( - version_loc_id=version_locator_id, - x_auth_refresh_token=bearer_token + version_loc_id=version_locator_id, x_auth_refresh_token=bearer_token ).get_result() print(json.dumps(validation, indent=2)) @@ -1108,11 +1064,7 @@ def test_search_objects_example(self): # begin-search_objects object_search_result = self.catalog_management_service.search_objects( - query='name: object*', - collapse=True, - digest=True, - limit=100, - offset=0 + query='name: object*', collapse=True, digest=True, limit=100, offset=0 ).get_result() print(json.dumps(object_search_result, indent=2)) @@ -1132,9 +1084,7 @@ def test_list_objects_example(self): # begin-list_objects object_list_result = self.catalog_management_service.list_objects( - catalog_identifier=catalog_id, - limit=100, - offset=0 + catalog_identifier=catalog_id, limit=100, offset=0 ).get_result() print(json.dumps(object_list_result, indent=2)) @@ -1161,7 +1111,7 @@ def test_replace_object_example(self): name='updated-object-name', parent_id='us-south', kind='vpe', - catalog_id=catalog_id + catalog_id=catalog_id, ).get_result() print(json.dumps(catalog_object, indent=2)) @@ -1181,8 +1131,7 @@ def test_get_object_example(self): # begin-get_object catalog_object = self.catalog_management_service.get_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ).get_result() print(json.dumps(catalog_object, indent=2)) @@ -1202,8 +1151,7 @@ def test_get_object_audit_example(self): # begin-get_object_audit audit_log = self.catalog_management_service.get_object_audit( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ).get_result() print(json.dumps(audit_log, indent=2)) @@ -1222,8 +1170,7 @@ def test_account_publish_object_example(self): # begin-account_publish_object response = self.catalog_management_service.account_publish_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ) # end-account_publish_object @@ -1242,8 +1189,7 @@ def test_shared_publish_object_example(self): # begin-shared_publish_object response = self.catalog_management_service.shared_publish_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ) # end-shared_publish_object @@ -1262,8 +1208,7 @@ def test_ibm_publish_object_example(self): # begin-ibm_publish_object response = self.catalog_management_service.ibm_publish_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ) # end-ibm_publish_object @@ -1282,8 +1227,7 @@ def test_public_publish_object_example(self): # begin-public_publish_object response = self.catalog_management_service.public_publish_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ) # end-public_publish_object @@ -1301,9 +1245,7 @@ def test_create_object_access_example(self): # begin-create_object_access response = self.catalog_management_service.create_object_access( - catalog_identifier=catalog_id, - object_identifier=object_id, - account_identifier=account_id + catalog_identifier=catalog_id, object_identifier=object_id, account_identifier=account_id ) # end-create_object_access @@ -1322,9 +1264,7 @@ def test_get_object_access_example(self): # begin-get_object_access object_access = self.catalog_management_service.get_object_access( - catalog_identifier=catalog_id, - object_identifier=object_id, - account_identifier=account_id + catalog_identifier=catalog_id, object_identifier=object_id, account_identifier=account_id ).get_result() print(json.dumps(object_access, indent=2)) @@ -1344,9 +1284,7 @@ def test_add_object_access_list_example(self): # begin-add_object_access_list access_list_bulk_response = self.catalog_management_service.add_object_access_list( - catalog_identifier=catalog_id, - object_identifier=object_id, - accounts=[account_id] + catalog_identifier=catalog_id, object_identifier=object_id, accounts=[account_id] ).get_result() print(json.dumps(access_list_bulk_response, indent=2)) @@ -1366,8 +1304,7 @@ def test_get_object_access_list_example(self): # begin-get_object_access_list object_access_list_result = self.catalog_management_service.get_object_access_list( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ).get_result() print(json.dumps(object_access_list_result, indent=2)) @@ -1397,7 +1334,7 @@ def test_create_offering_instance_example(self): version='0.0.2', cluster_id=cluster_id, cluster_region='us-south', - cluster_all_namespaces=True + cluster_all_namespaces=True, ).get_result() print(json.dumps(offering_instance, indent=2)) @@ -1451,7 +1388,7 @@ def test_put_offering_instance_example(self): version='0.0.2', cluster_id=cluster_id, cluster_region='us-south', - cluster_all_namespaces=True + cluster_all_namespaces=True, ).get_result() print(json.dumps(offering_instance, indent=2)) @@ -1469,9 +1406,7 @@ def test_delete_version_example(self): try: # begin-delete_version - response = self.catalog_management_service.delete_version( - version_loc_id=version_locator_id - ) + response = self.catalog_management_service.delete_version(version_loc_id=version_locator_id) # end-delete_version print('\ndelete_version() response status code: ', response.get_status_code()) @@ -1492,7 +1427,7 @@ def test_delete_operators_example(self): x_auth_refresh_token=bearer_token, cluster_id=cluster_id, region='us-south', - version_locator_id=version_locator_id + version_locator_id=version_locator_id, ) # end-delete_operators @@ -1511,8 +1446,7 @@ def test_delete_offering_instance_example(self): # begin-delete_offering_instance response = self.catalog_management_service.delete_offering_instance( - instance_identifier=offering_instance_id, - x_auth_refresh_token=bearer_token + instance_identifier=offering_instance_id, x_auth_refresh_token=bearer_token ) # end-delete_offering_instance @@ -1531,9 +1465,7 @@ def test_delete_object_access_list_example(self): # begin-delete_object_access_list access_list_bulk_response = self.catalog_management_service.delete_object_access_list( - catalog_identifier=catalog_id, - object_identifier=object_id, - accounts=[account_id] + catalog_identifier=catalog_id, object_identifier=object_id, accounts=[account_id] ).get_result() print(json.dumps(access_list_bulk_response, indent=2)) @@ -1552,9 +1484,7 @@ def test_delete_object_access_example(self): # begin-delete_object_access response = self.catalog_management_service.delete_object_access( - catalog_identifier=catalog_id, - object_identifier=object_id, - account_identifier=account_id + catalog_identifier=catalog_id, object_identifier=object_id, account_identifier=account_id ) # end-delete_object_access @@ -1572,8 +1502,7 @@ def test_delete_object_example(self): # begin-delete_object response = self.catalog_management_service.delete_object( - catalog_identifier=catalog_id, - object_identifier=object_id + catalog_identifier=catalog_id, object_identifier=object_id ) # end-delete_object @@ -1591,8 +1520,7 @@ def test_delete_offering_example(self): # begin-delete_offering response = self.catalog_management_service.delete_offering( - catalog_identifier=catalog_id, - offering_id=offering_id + catalog_identifier=catalog_id, offering_id=offering_id ) # end-delete_offering @@ -1609,9 +1537,7 @@ def test_delete_catalog_example(self): try: # begin-delete_catalog - response = self.catalog_management_service.delete_catalog( - catalog_identifier=catalog_id - ) + response = self.catalog_management_service.delete_catalog(catalog_identifier=catalog_id) # end-delete_catalog print('\ndelete_catalog() response status code: ', response.get_status_code()) @@ -1619,6 +1545,7 @@ def test_delete_catalog_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: CatalogManagementV1 diff --git a/examples/test_context_based_restrictions_v1_examples.py b/examples/test_context_based_restrictions_v1_examples.py index baf21814..a94e804a 100644 --- a/examples/test_context_based_restrictions_v1_examples.py +++ b/examples/test_context_based_restrictions_v1_examples.py @@ -57,7 +57,7 @@ # Start of Examples for Service: ContextBasedRestrictionsV1 ############################################################################## # region -class TestContextBasedRestrictionsV1Examples(): +class TestContextBasedRestrictionsV1Examples: """ Example Test Class for ContextBasedRestrictionsV1 """ @@ -70,8 +70,7 @@ def setup_class(cls): # begin-common - context_based_restrictions_service = ContextBasedRestrictionsV1.new_instance( - ) + context_based_restrictions_service = ContextBasedRestrictionsV1.new_instance() # end-common assert context_based_restrictions_service is not None @@ -125,7 +124,7 @@ def test_create_zone_example(self): 'ref': { 'account_id': account_id, 'service_name': 'cloud-object-storage', - } + }, } excluded_ip_address_model = { 'type': 'ipAddress', @@ -135,7 +134,13 @@ def test_create_zone_example(self): zone = context_based_restrictions_service.create_zone( name='an example of zone', account_id=account_id, - addresses=[ip_address_model, ip_range_address_model, subnet_address_model, vpc_address_model, service_ref_address_model], + addresses=[ + ip_address_model, + ip_range_address_model, + subnet_address_model, + vpc_address_model, + service_ref_address_model, + ], excluded=[excluded_ip_address_model], description='this is an example of zone', ).get_result() @@ -158,9 +163,7 @@ def test_list_zones_example(self): print('\nlist_zones() result:') # begin-list_zones - zone_list = context_based_restrictions_service.list_zones( - account_id=account_id - ).get_result() + zone_list = context_based_restrictions_service.list_zones(account_id=account_id).get_result() print(json.dumps(zone_list, indent=2)) @@ -178,9 +181,7 @@ def test_get_zone_example(self): print('\nget_zone() result:') # begin-get_zone - get_zone_response = context_based_restrictions_service.get_zone( - zone_id=zone_id - ) + get_zone_response = context_based_restrictions_service.get_zone(zone_id=zone_id) zone = get_zone_response.get_result() print(json.dumps(zone, indent=2)) @@ -231,7 +232,9 @@ def test_list_available_serviceref_targets_example(self): print('\nlist_available_serviceref_targets() result:') # begin-list_available_serviceref_targets - service_ref_target_list = context_based_restrictions_service.list_available_serviceref_targets().get_result() + service_ref_target_list = ( + context_based_restrictions_service.list_available_serviceref_targets().get_result() + ) print(json.dumps(service_ref_target_list, indent=2)) @@ -276,7 +279,7 @@ def test_create_rule_example(self): contexts=[rule_context_model], resources=[resource_model], description='this is an example of rule', - enforcement_mode='enabled' + enforcement_mode='enabled', ).get_result() print(json.dumps(rule, indent=2)) @@ -297,9 +300,7 @@ def test_list_rules_example(self): print('\nlist_rules() result:') # begin-list_rules - rule_list = context_based_restrictions_service.list_rules( - account_id=account_id - ).get_result() + rule_list = context_based_restrictions_service.list_rules(account_id=account_id).get_result() print(json.dumps(rule_list, indent=2)) @@ -317,9 +318,7 @@ def test_get_rule_example(self): print('\nget_rule() result:') # begin-get_rule - get_rule_response = context_based_restrictions_service.get_rule( - rule_id=rule_id - ) + get_rule_response = context_based_restrictions_service.get_rule(rule_id=rule_id) rule = get_rule_response.get_result() print(json.dumps(rule, indent=2)) @@ -375,7 +374,7 @@ def test_replace_rule_example(self): contexts=[rule_context_model], resources=[resource_model], description='this is an example of updated rule', - enforcement_mode='disabled' + enforcement_mode='disabled', ).get_result() print(json.dumps(rule, indent=2)) @@ -433,9 +432,7 @@ def test_delete_rule_example(self): try: # begin-delete_rule - response = context_based_restrictions_service.delete_rule( - rule_id=rule_id - ) + response = context_based_restrictions_service.delete_rule(rule_id=rule_id) # end-delete_rule print('\ndelete_rule() response status code: ', response.get_status_code()) @@ -451,9 +448,7 @@ def test_delete_zone_example(self): try: # begin-delete_zone - response = context_based_restrictions_service.delete_zone( - zone_id=zone_id - ) + response = context_based_restrictions_service.delete_zone(zone_id=zone_id) # end-delete_zone print('\ndelete_zone() response status code: ', response.get_status_code()) @@ -461,6 +456,7 @@ def test_delete_zone_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: ContextBasedRestrictionsV1 diff --git a/examples/test_enterprise_billing_units_v1_examples.py b/examples/test_enterprise_billing_units_v1_examples.py index b137045f..6ff6e0d2 100644 --- a/examples/test_enterprise_billing_units_v1_examples.py +++ b/examples/test_enterprise_billing_units_v1_examples.py @@ -52,7 +52,7 @@ # Start of Examples for Service: EnterpriseBillingUnitsV1 ############################################################################## # region -class TestEnterpriseBillingUnitsV1Examples(): +class TestEnterpriseBillingUnitsV1Examples: """ Example Test Class for EnterpriseBillingUnitsV1 """ @@ -65,8 +65,7 @@ def setup_class(cls): # begin-common - enterprise_billing_units_service = EnterpriseBillingUnitsV1.new_instance( - ) + enterprise_billing_units_service = EnterpriseBillingUnitsV1.new_instance() # end-common assert enterprise_billing_units_service is not None @@ -74,8 +73,7 @@ def setup_class(cls): # Load the configuration global config, enterprise_id, billing_unit_id - config = read_external_sources( - EnterpriseBillingUnitsV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(EnterpriseBillingUnitsV1.DEFAULT_SERVICE_NAME) enterprise_id = config['ENTERPRISE_ID'] billing_unit_id = config['BILLING_UNIT_ID'] @@ -83,8 +81,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_get_billing_unit_example(self): @@ -98,7 +96,8 @@ def test_get_billing_unit_example(self): # begin-get_billing_unit billing_unit = enterprise_billing_units_service.get_billing_unit( - billing_unit_id=billing_unit_id).get_result() + billing_unit_id=billing_unit_id + ).get_result() print(json.dumps(billing_unit, indent=2)) @@ -118,7 +117,8 @@ def test_list_billing_units_example(self): # begin-list_billing_units billing_units_list = enterprise_billing_units_service.list_billing_units( - enterprise_id=enterprise_id).get_result() + enterprise_id=enterprise_id + ).get_result() print(json.dumps(billing_units_list, indent=2)) @@ -138,7 +138,8 @@ def test_list_billing_options_example(self): # begin-list_billing_options billing_options_list = enterprise_billing_units_service.list_billing_options( - billing_unit_id=billing_unit_id).get_result() + billing_unit_id=billing_unit_id + ).get_result() print(json.dumps(billing_options_list, indent=2)) @@ -159,7 +160,8 @@ def test_get_credit_pools_example(self): # begin-get_credit_pools credit_pools_list = enterprise_billing_units_service.get_credit_pools( - billing_unit_id=billing_unit_id, type='PLATFORM').get_result() + billing_unit_id=billing_unit_id, type='PLATFORM' + ).get_result() print(json.dumps(credit_pools_list, indent=2)) @@ -168,6 +170,7 @@ def test_get_credit_pools_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: EnterpriseBillingUnitsV1 diff --git a/examples/test_enterprise_management_v1_examples.py b/examples/test_enterprise_management_v1_examples.py index 72100271..78fa64dc 100644 --- a/examples/test_enterprise_management_v1_examples.py +++ b/examples/test_enterprise_management_v1_examples.py @@ -59,7 +59,7 @@ # Start of Examples for Service: EnterpriseManagementV1 ############################################################################## # region -class TestEnterpriseManagementV1Examples(): +class TestEnterpriseManagementV1Examples: """ Example Test Class for EnterpriseManagementV1 """ @@ -79,8 +79,7 @@ def setup_class(cls): # Load the configuration global config - config = read_external_sources( - EnterpriseManagementV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(EnterpriseManagementV1.DEFAULT_SERVICE_NAME) global enterprise_id enterprise_id = config['ENTERPRISE_ID'] @@ -107,8 +106,9 @@ def test_create_account_group_example(self): assert enterprise_account_iam_id is not None try: - parent_crn = 'crn:v1:bluemix:public:enterprise::a/' + \ - enterprise_account_id + '::enterprise:' + enterprise_id + parent_crn = ( + 'crn:v1:bluemix:public:enterprise::a/' + enterprise_account_id + '::enterprise:' + enterprise_id + ) print('\ncreate_account_group() result:') # begin-create_account_group @@ -124,8 +124,7 @@ def test_create_account_group_example(self): # end-create_account_group global account_group_id - account_group_id = create_account_group_response.get( - 'account_group_id') + account_group_id = create_account_group_response.get('account_group_id') create_parent_account_group_response = enterprise_management_service.create_account_group( parent=parent_crn, @@ -134,8 +133,7 @@ def test_create_account_group_example(self): ).get_result() global new_parent_account_group_id - new_parent_account_group_id = create_parent_account_group_response.get( - 'account_group_id') + new_parent_account_group_id = create_parent_account_group_response.get('account_group_id') except ApiException as e: pytest.fail(str(e)) @@ -208,8 +206,7 @@ def test_update_account_group_example(self): # end-update_account_group - print('\nupdate_account_group() response status code: ', - response.get_status_code()) + print('\nupdate_account_group() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -222,8 +219,9 @@ def test_create_account_example(self): assert account_group_id is not None try: - parent_crn = 'crn:v1:bluemix:public:enterprise::a/' + \ - enterprise_account_id + '::account-group:' + account_group_id + parent_crn = ( + 'crn:v1:bluemix:public:enterprise::a/' + enterprise_account_id + '::account-group:' + account_group_id + ) print('\ncreate_account() result:') # begin-create_account @@ -263,8 +261,7 @@ def test_import_account_to_enterprise_example(self): # end-import_account_to_enterprise - print('\nimport_account_to_enterprise() response status code: ', - response.get_status_code()) + print('\nimport_account_to_enterprise() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -327,8 +324,12 @@ def test_update_account_example(self): assert new_parent_account_group_id is not None try: - new_parent_crn = 'crn:v1:bluemix:public:enterprise::a/' + \ - enterprise_account_id + '::account-group:' + new_parent_account_group_id + new_parent_crn = ( + 'crn:v1:bluemix:public:enterprise::a/' + + enterprise_account_id + + '::account-group:' + + new_parent_account_group_id + ) # begin-update_account @@ -339,8 +340,7 @@ def test_update_account_example(self): # end-update_account - print('\nupdate_account() response status code: ', - response.get_status_code()) + print('\nupdate_account() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -410,9 +410,7 @@ def test_get_enterprise_example(self): print('\nget_enterprise() result:') # begin-get_enterprise - enterprise = enterprise_management_service.get_enterprise( - enterprise_id=enterprise_id - ).get_result() + enterprise = enterprise_management_service.get_enterprise(enterprise_id=enterprise_id).get_result() print(json.dumps(enterprise, indent=2)) @@ -440,12 +438,12 @@ def test_update_enterprise_example(self): # end-update_enterprise - print('\nupdate_enterprise() response status code: ', - response.get_status_code()) + print('\nupdate_enterprise() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: EnterpriseManagementV1 diff --git a/examples/test_enterprise_usage_reports_v1_examples.py b/examples/test_enterprise_usage_reports_v1_examples.py index 720c5ce5..90a7e40e 100644 --- a/examples/test_enterprise_usage_reports_v1_examples.py +++ b/examples/test_enterprise_usage_reports_v1_examples.py @@ -54,7 +54,7 @@ # region -class TestEnterpriseUsageReportsV1Examples(): +class TestEnterpriseUsageReportsV1Examples: """ Example Test Class for EnterpriseUsageReportsV1 """ @@ -74,8 +74,7 @@ def setup_class(cls): # Load the configuration global config - config = read_external_sources( - EnterpriseUsageReportsV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(EnterpriseUsageReportsV1.DEFAULT_SERVICE_NAME) global enterprise_id enterprise_id = config.get("ENTERPRISE_ID") @@ -118,6 +117,7 @@ def test_get_resource_usage_report_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: EnterpriseUsageReportsV1 diff --git a/examples/test_global_catalog_v1_examples.py b/examples/test_global_catalog_v1_examples.py index 1e85d8b9..faa10fb7 100644 --- a/examples/test_global_catalog_v1_examples.py +++ b/examples/test_global_catalog_v1_examples.py @@ -48,10 +48,11 @@ # Start of Examples for Service: GlobalCatalogV1 ############################################################################## # region -class TestGlobalCatalogV1Examples(): +class TestGlobalCatalogV1Examples: """ Example Test Class for GlobalCatalogV1 """ + @classmethod def setup_class(cls): global global_catalog_service @@ -68,8 +69,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_create_catalog_entry_example(self): @@ -108,9 +109,7 @@ def test_create_catalog_entry_example(self): catalog_entry = global_catalog_service.create_catalog_entry( name='exampleWebStarter123', kind=CatalogEntry.KindEnum.TEMPLATE, - overview_ui={ - 'en': overview_model_EN - }, + overview_ui={'en': overview_model_EN}, images=image_model, disabled=False, tags=['example-tag-1', 'example-tag-2'], @@ -274,8 +273,7 @@ def test_restore_catalog_entry_example(self): # end-restore_catalog_entry - print('\nrestore_catalog_entry() response status code: ', - response.get_status_code()) + print('\nrestore_catalog_entry() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -321,12 +319,10 @@ def test_update_visibility_example(self): # end-update_visibility - print('\nupdate_visibility() response status code: ', - response.get_status_code()) + print('\nupdate_visibility() response status code: ', response.get_status_code()) except ApiException as e: - print( - 'update_visibility() returned the following error: {0}'.format(str(e.message))) + print('update_visibility() returned the following error: {0}'.format(str(e.message))) @needscredentials def test_get_pricing_example(self): @@ -387,8 +383,7 @@ def test_upload_artifact_example(self): try: # begin-upload_artifact - artifact_contents = io.BytesIO( - b'This is an example artifact associated with a catalog entry.') + artifact_contents = io.BytesIO(b'This is an example artifact associated with a catalog entry.') response = global_catalog_service.upload_artifact( object_id=catalog_entry_id, @@ -399,8 +394,7 @@ def test_upload_artifact_example(self): # end-upload_artifact - print('\nupload_artifact() response status code: ', - response.get_status_code()) + print('\nupload_artifact() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -443,8 +437,7 @@ def test_list_artifacts_example(self): print('\nlist_artifacts() result:') # begin-list_artifacts - artifacts = global_catalog_service.list_artifacts( - object_id=catalog_entry_id).get_result() + artifacts = global_catalog_service.list_artifacts(object_id=catalog_entry_id).get_result() print(json.dumps(artifacts, indent=2)) @@ -471,8 +464,7 @@ def test_delete_artifact_example(self): # end-delete_artifact - print('\ndelete_artifact() response status code: ', - response.get_status_code()) + print('\ndelete_artifact() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -488,13 +480,11 @@ def test_delete_catalog_entry_example(self): try: # begin-delete_catalog_entry - response = global_catalog_service.delete_catalog_entry( - id=catalog_entry_id).get_result() + response = global_catalog_service.delete_catalog_entry(id=catalog_entry_id).get_result() # end-delete_catalog_entry - print('\ndelete_catalog_entry() response status code: ', - response.get_status_code()) + print('\ndelete_catalog_entry() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) diff --git a/examples/test_global_search_v2_examples.py b/examples/test_global_search_v2_examples.py index 6e05643a..41b753c6 100644 --- a/examples/test_global_search_v2_examples.py +++ b/examples/test_global_search_v2_examples.py @@ -45,10 +45,11 @@ # Start of Examples for Service: GlobalSearchV2 ############################################################################## # region -class TestGlobalSearchV2Examples(): +class TestGlobalSearchV2Examples: """ Example Test Class for GlobalSearchV2 """ + @classmethod def setup_class(cls): global global_search_service @@ -65,8 +66,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_search_example(self): @@ -77,8 +78,7 @@ def test_search_example(self): print('\nsearch() result:') # begin-search - response = global_search_service.search(query='GST-sdk-*', - fields=['*']) + response = global_search_service.search(query='GST-sdk-*', fields=['*']) scan_result = response.get_result() print(json.dumps(scan_result, indent=2)) @@ -97,8 +97,7 @@ def test_get_supported_types_example(self): print('\nget_supported_types() result:') # begin-get_supported_types - supported_types_list = global_search_service.get_supported_types( - ).get_result() + supported_types_list = global_search_service.get_supported_types().get_result() print(json.dumps(supported_types_list, indent=2)) diff --git a/examples/test_global_tagging_v1_examples.py b/examples/test_global_tagging_v1_examples.py index c33be3d4..8633764a 100644 --- a/examples/test_global_tagging_v1_examples.py +++ b/examples/test_global_tagging_v1_examples.py @@ -48,10 +48,11 @@ # Start of Examples for Service: GlobalTaggingV1 ############################################################################## # region -class TestGlobalTaggingV1Examples(): +class TestGlobalTaggingV1Examples: """ Example Test Class for GlobalTaggingV1 """ + @classmethod def setup_class(cls): global global_tagging_service @@ -67,8 +68,7 @@ def setup_class(cls): # Load the configuration global config - config = read_external_sources( - GlobalTaggingV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(GlobalTaggingV1.DEFAULT_SERVICE_NAME) global resource_crn resource_crn = config.get("RESOURCE_CRN") @@ -76,8 +76,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_create_tag_example(self): @@ -89,8 +89,8 @@ def test_create_tag_example(self): # begin-create_tag create_tag_results = global_tagging_service.create_tag( - tag_names=['env:example-access-tag'], - tag_type='access').get_result() + tag_names=['env:example-access-tag'], tag_type='access' + ).get_result() print(json.dumps(create_tag_results, indent=2)) @@ -109,11 +109,8 @@ def test_list_tags_example(self): # begin-list_tags tag_list = global_tagging_service.list_tags( - tag_type='user', - attached_only=True, - full_data=True, - providers=['ghost'], - order_by_name='asc').get_result() + tag_type='user', attached_only=True, full_data=True, providers=['ghost'], order_by_name='asc' + ).get_result() print(json.dumps(tag_list, indent=2)) @@ -134,9 +131,8 @@ def test_attach_tag_example(self): resource_model = {'resource_id': resource_crn} tag_results = global_tagging_service.attach_tag( - resources=[resource_model], - tag_names=['tag_test_1', 'tag_test_2'], - tag_type='user').get_result() + resources=[resource_model], tag_names=['tag_test_1', 'tag_test_2'], tag_type='user' + ).get_result() print(json.dumps(tag_results, indent=2)) @@ -157,9 +153,8 @@ def test_detach_tag_example(self): resource_model = {'resource_id': resource_crn} tag_results = global_tagging_service.detach_tag( - resources=[resource_model], - tag_names=['tag_test_1', 'tag_test_2'], - tag_type='user').get_result() + resources=[resource_model], tag_names=['tag_test_1', 'tag_test_2'], tag_type='user' + ).get_result() print(json.dumps(tag_results, indent=2)) @@ -178,8 +173,8 @@ def test_delete_tag_example(self): # begin-delete_tag delete_tag_results = global_tagging_service.delete_tag( - tag_name='env:example-access-tag', - tag_type='access').get_result() + tag_name='env:example-access-tag', tag_type='access' + ).get_result() print(json.dumps(delete_tag_results, indent=2)) @@ -197,8 +192,7 @@ def test_delete_tag_all_example(self): print('\ndelete_tag_all() result:') # begin-delete_tag_all - delete_tags_result = global_tagging_service.delete_tag_all( - tag_type='user').get_result() + delete_tags_result = global_tagging_service.delete_tag_all(tag_type='user').get_result() print(json.dumps(delete_tags_result, indent=2)) diff --git a/examples/test_iam_access_groups_v2_examples.py b/examples/test_iam_access_groups_v2_examples.py index 41891015..abd6630d 100644 --- a/examples/test_iam_access_groups_v2_examples.py +++ b/examples/test_iam_access_groups_v2_examples.py @@ -56,7 +56,7 @@ # region -class TestIamAccessGroupsV2Examples(): +class TestIamAccessGroupsV2Examples: """ Example Test Class for IamAccessGroupsV2 """ @@ -76,8 +76,7 @@ def setup_class(cls): # Load the configuration global config, test_account_id, test_profile_id - config = read_external_sources( - IamAccessGroupsV2.DEFAULT_SERVICE_NAME) + config = read_external_sources(IamAccessGroupsV2.DEFAULT_SERVICE_NAME) test_account_id = config['TEST_ACCOUNT_ID'] test_profile_id = config['TEST_PROFILE_ID'] @@ -97,9 +96,7 @@ def test_create_access_group_example(self): # begin-create_access_group group = iam_access_groups_service.create_access_group( - account_id=test_account_id, - name='Managers', - description='Group for managers' + account_id=test_account_id, name='Managers', description='Group for managers' ).get_result() print(json.dumps(group, indent=2)) @@ -121,9 +118,7 @@ def test_get_access_group_example(self): print('\nget_access_group() result:') # begin-get_access_group - response = iam_access_groups_service.get_access_group( - access_group_id=test_group_id - ) + response = iam_access_groups_service.get_access_group(access_group_id=test_group_id) group = response.get_result() print(json.dumps(group, indent=2)) @@ -148,7 +143,7 @@ def test_update_access_group_example(self): access_group_id=test_group_id, if_match=test_group_etag, name='Awesome Managers', - description='Group for awesome managers' + description='Group for awesome managers', ).get_result() print(json.dumps(group, indent=2)) @@ -191,17 +186,13 @@ def test_add_members_to_access_group_example(self): try: print('\nadd_members_to_access_group() result:') # begin-add_members_to_access_group - member1 = AddGroupMembersRequestMembersItem( - iam_id='IBMid-user1', type='user') - member2 = AddGroupMembersRequestMembersItem( - iam_id='iam-ServiceId-123', type='service') - member3 = AddGroupMembersRequestMembersItem( - iam_id=test_profile_id, type='profile') + member1 = AddGroupMembersRequestMembersItem(iam_id='IBMid-user1', type='user') + member2 = AddGroupMembersRequestMembersItem(iam_id='iam-ServiceId-123', type='service') + member3 = AddGroupMembersRequestMembersItem(iam_id=test_profile_id, type='profile') members = [member1, member2, member3] add_group_members_response = iam_access_groups_service.add_members_to_access_group( - access_group_id=test_group_id, - members=members + access_group_id=test_group_id, members=members ).get_result() print(json.dumps(add_group_members_response, indent=2)) @@ -220,8 +211,7 @@ def test_is_member_of_access_group_example(self): # begin-is_member_of_access_group response = iam_access_groups_service.is_member_of_access_group( - access_group_id=test_group_id, - iam_id='IBMid-user1' + access_group_id=test_group_id, iam_id='IBMid-user1' ) # end-is_member_of_access_group @@ -264,8 +254,7 @@ def test_remove_member_from_access_group_example(self): # begin-remove_member_from_access_group response = iam_access_groups_service.remove_member_from_access_group( - access_group_id=test_group_id, - iam_id='IBMid-user1' + access_group_id=test_group_id, iam_id='IBMid-user1' ) # end-remove_member_from_access_group @@ -284,8 +273,7 @@ def test_remove_members_from_access_group_example(self): # begin-remove_members_from_access_group delete_group_bulk_members_response = iam_access_groups_service.remove_members_from_access_group( - access_group_id=test_group_id, - members=['iam-ServiceId-123'] + access_group_id=test_group_id, members=['iam-ServiceId-123'] ).get_result() print(json.dumps(delete_group_bulk_members_response, indent=2)) @@ -305,8 +293,7 @@ def test_remove_profile_members_from_access_group_example(self): # begin-remove_members_from_access_group delete_group_bulk_members_response = iam_access_groups_service.remove_members_from_access_group( - access_group_id=test_group_id, - members=[test_profile_id] + access_group_id=test_group_id, members=[test_profile_id] ).get_result() print(json.dumps(delete_group_bulk_members_response, indent=2)) @@ -326,10 +313,7 @@ def test_add_member_to_multiple_access_groups_example(self): # begin-add_member_to_multiple_access_groups add_membership_multiple_groups_response = iam_access_groups_service.add_member_to_multiple_access_groups( - account_id=test_account_id, - iam_id='IBMid-user1', - type='user', - groups=[test_group_id] + account_id=test_account_id, iam_id='IBMid-user1', type='user', groups=[test_group_id] ).get_result() print(json.dumps(add_membership_multiple_groups_response, indent=2)) @@ -349,8 +333,7 @@ def test_remove_member_from_all_access_groups_example(self): # begin-remove_member_from_all_access_groups delete_from_all_groups_response = iam_access_groups_service.remove_member_from_all_access_groups( - account_id=test_account_id, - iam_id='IBMid-user1' + account_id=test_account_id, iam_id='IBMid-user1' ).get_result() print(json.dumps(delete_from_all_groups_response, indent=2)) @@ -369,18 +352,14 @@ def test_add_access_group_rule_example(self): print('\nadd_access_group_rule() result:') # begin-add_access_group_rule - rule_conditions_model = { - 'claim': 'isManager', - 'operator': 'EQUALS', - 'value': 'true' - } + rule_conditions_model = {'claim': 'isManager', 'operator': 'EQUALS', 'value': 'true'} rule = iam_access_groups_service.add_access_group_rule( access_group_id=test_group_id, name='Manager group rule', expiration=12, realm_name='https://idp.example.org/SAML2"', - conditions=[rule_conditions_model] + conditions=[rule_conditions_model], ).get_result() print(json.dumps(rule, indent=2)) @@ -402,8 +381,7 @@ def test_get_access_group_rule_example(self): # begin-get_access_group_rule response = iam_access_groups_service.get_access_group_rule( - access_group_id=test_group_id, - rule_id=test_claim_rule_id + access_group_id=test_group_id, rule_id=test_claim_rule_id ) rule = response.get_result() @@ -425,11 +403,7 @@ def test_replace_access_group_rule_example(self): print('\nreplace_access_group_rule() result:') # begin-replace_access_group_rule - rule_conditions_model = { - 'claim': 'isManager', - 'operator': 'EQUALS', - 'value': 'true' - } + rule_conditions_model = {'claim': 'isManager', 'operator': 'EQUALS', 'value': 'true'} rule = iam_access_groups_service.replace_access_group_rule( access_group_id=test_group_id, @@ -438,7 +412,7 @@ def test_replace_access_group_rule_example(self): name='Manager group rule', expiration=24, realm_name='https://idp.example.org/SAML2a', - conditions=[rule_conditions_model] + conditions=[rule_conditions_model], ).get_result() print(json.dumps(rule, indent=2)) @@ -457,9 +431,7 @@ def test_list_access_group_rules_example(self): print('\nlist_access_group_rules() result:') # begin-list_access_group_rules - rules_list = iam_access_groups_service.list_access_group_rules( - access_group_id=test_group_id - ).get_result() + rules_list = iam_access_groups_service.list_access_group_rules(access_group_id=test_group_id).get_result() print(json.dumps(rules_list, indent=2)) @@ -477,8 +449,7 @@ def test_remove_access_group_rule_example(self): # begin-remove_access_group_rule response = iam_access_groups_service.remove_access_group_rule( - access_group_id=test_group_id, - rule_id=test_claim_rule_id + access_group_id=test_group_id, rule_id=test_claim_rule_id ) # end-remove_access_group_rule @@ -496,9 +467,7 @@ def test_get_account_settings_example(self): print('\nget_account_settings() result:') # begin-get_account_settings - account_settings = iam_access_groups_service.get_account_settings( - account_id=test_account_id - ).get_result() + account_settings = iam_access_groups_service.get_account_settings(account_id=test_account_id).get_result() print(json.dumps(account_settings, indent=2)) @@ -517,8 +486,7 @@ def test_update_account_settings_example(self): # begin-update_account_settings account_settings = iam_access_groups_service.update_account_settings( - account_id=test_account_id, - public_access_enabled=True + account_id=test_account_id, public_access_enabled=True ).get_result() print(json.dumps(account_settings, indent=2)) @@ -536,9 +504,7 @@ def test_delete_access_group_example(self): try: # begin-delete_access_group - response = iam_access_groups_service.delete_access_group( - access_group_id=test_group_id - ) + response = iam_access_groups_service.delete_access_group(access_group_id=test_group_id) # end-delete_access_group print('\ndelete_access_group() response status code:' + str(response.get_status_code())) @@ -546,6 +512,7 @@ def test_delete_access_group_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: IamAccessGroupsV2 diff --git a/examples/test_iam_identity_v1_examples.py b/examples/test_iam_identity_v1_examples.py index 29a45bad..f4dc47d9 100644 --- a/examples/test_iam_identity_v1_examples.py +++ b/examples/test_iam_identity_v1_examples.py @@ -72,7 +72,7 @@ # Start of Examples for Service: IamIdentityV1 ############################################################################## # region -class TestIamIdentityV1Examples(): +class TestIamIdentityV1Examples: """ Example Test Class for IamIdentityV1 """ @@ -120,10 +120,7 @@ def test_create_api_key_example(self): print('\ncreate_api_key() result:') # begin-create_api_key - api_key = iam_identity_service.create_api_key( - name=apikey_name, - iam_id=iam_id - ).get_result() + api_key = iam_identity_service.create_api_key(name=apikey_name, iam_id=iam_id).get_result() apikey_id = api_key['id'] @@ -146,9 +143,7 @@ def test_list_api_keys_example(self): # begin-list_api_keys api_key_list = iam_identity_service.list_api_keys( - account_id=account_id, - iam_id=iam_id, - include_history=True + account_id=account_id, iam_id=iam_id, include_history=True ).get_result() print(json.dumps(api_key_list, indent=2)) @@ -169,9 +164,7 @@ def test_get_api_keys_details_example(self): print('\nget_api_keys_details() result:') # begin-get_api_keys_details - api_key = iam_identity_service.get_api_keys_details( - iam_api_key=apikey - ).get_result() + api_key = iam_identity_service.get_api_keys_details(iam_api_key=apikey).get_result() print(json.dumps(api_key, indent=2)) @@ -218,9 +211,7 @@ def test_update_api_key_example(self): # begin-update_api_key api_key = iam_identity_service.update_api_key( - id=apikey_id, - if_match=apikey_etag, - description='This is an updated description' + id=apikey_id, if_match=apikey_etag, description='This is an updated description' ).get_result() print(json.dumps(api_key, indent=2)) @@ -263,7 +254,6 @@ def test_unlock_api_key_example(self): # end-unlock_api_key print('\nunlock_api_key() response status code: ', response.get_status_code()) - except ApiException as e: pytest.fail(str(e)) @@ -297,9 +287,7 @@ def test_create_service_id_example(self): # begin-create_service_id service_id = iam_identity_service.create_service_id( - account_id=account_id, - name=serviceid_name, - description='Example ServiceId' + account_id=account_id, name=serviceid_name, description='Example ServiceId' ).get_result() svc_id = service_id['id'] @@ -352,8 +340,7 @@ def test_list_service_ids_example(self): # begin-list_service_ids service_id_list = iam_identity_service.list_service_ids( - account_id=account_id, - name=serviceid_name + account_id=account_id, name=serviceid_name ).get_result() print(json.dumps(service_id_list, indent=2)) @@ -375,9 +362,7 @@ def test_update_service_id_example(self): # begin-update_service_id service_id = iam_identity_service.update_service_id( - id=svc_id, - if_match=svc_id_etag, - description='This is an updated description' + id=svc_id, if_match=svc_id_etag, description='This is an updated description' ).get_result() print(json.dumps(service_id, indent=2)) @@ -452,9 +437,7 @@ def test_create_profile_example(self): # begin-create_profile profile = iam_identity_service.create_profile( - name="example profile", - description="example profile", - account_id=account_id + name="example profile", description="example profile", account_id=account_id ).get_result() profile_id = profile['id'] @@ -503,10 +486,7 @@ def test_list_profiles_example(self): print('\nlist_profiles() result:') # begin-list_profiles - profile_list = iam_identity_service.list_profiles( - account_id=account_id, - include_history=True - ).get_result() + profile_list = iam_identity_service.list_profiles(account_id=account_id, include_history=True).get_result() print(json.dumps(profile_list, indent=2)) @@ -527,9 +507,7 @@ def test_update_profile_example(self): # begin-update_profile profile = iam_identity_service.update_profile( - profile_id=profile_id, - if_match=profile_etag, - description='This is an updated description' + profile_id=profile_id, if_match=profile_etag, description='This is an updated description' ).get_result() print(json.dumps(profile, indent=2)) @@ -555,12 +533,12 @@ def test_create_claim_rule_example(self): profile_claim_rule_conditions_model['value'] = '\"cloud-docs-dev\"' claimRule = iam_identity_service.create_claim_rule( - profile_id = profile_id, - type = 'Profile-SAML', - realm_name = 'https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', - expiration = 43200, - conditions = [profile_claim_rule_conditions_model] - ).get_result() + profile_id=profile_id, + type='Profile-SAML', + realm_name='https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', + expiration=43200, + conditions=[profile_claim_rule_conditions_model], + ).get_result() claimRule_id = claimRule['id'] @@ -582,10 +560,7 @@ def test_get_claim_rule_example(self): print('\nget_claim_rule() result:') # begin-get_claim_rule - response = iam_identity_service.get_claim_rule( - profile_id= profile_id, - rule_id= claimRule_id - ) + response = iam_identity_service.get_claim_rule(profile_id=profile_id, rule_id=claimRule_id) claimRule_etag = response.get_headers()['Etag'] claimRule = response.get_result() @@ -636,13 +611,13 @@ def test_update_claim_rule_example(self): profile_claim_rule_conditions_model['value'] = '\"Europe_Group\"' claimRule = iam_identity_service.update_claim_rule( - profile_id = profile_id, - rule_id = claimRule_id, - if_match = claimRule_etag, - expiration = 33200, - conditions = [profile_claim_rule_conditions_model], - type = 'Profile-SAML', - realm_name = 'https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', + profile_id=profile_id, + rule_id=claimRule_id, + if_match=claimRule_etag, + expiration=33200, + conditions=[profile_claim_rule_conditions_model], + type='Profile-SAML', + realm_name='https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', ).get_result() print(json.dumps(claimRule, indent=2)) @@ -681,15 +656,14 @@ def test_create_link_example(self): # begin-create_link CreateProfileLinkRequestLink = {} - CreateProfileLinkRequestLink['crn'] = 'crn:v1:staging:public:iam-identity::a/18e3020749ce4744b0b472466d61fdb4::computeresource:Fake-Compute-Resource' + CreateProfileLinkRequestLink[ + 'crn' + ] = 'crn:v1:staging:public:iam-identity::a/18e3020749ce4744b0b472466d61fdb4::computeresource:Fake-Compute-Resource' CreateProfileLinkRequestLink['namespace'] = 'default' CreateProfileLinkRequestLink['name'] = 'nice name' link = iam_identity_service.create_link( - profile_id = profile_id, - name = 'nice link', - cr_type = 'ROKS_SA', - link = CreateProfileLinkRequestLink + profile_id=profile_id, name='nice link', cr_type='ROKS_SA', link=CreateProfileLinkRequestLink ).get_result() link_id = link['id'] @@ -712,10 +686,7 @@ def test_get_link_example(self): print('\nget_link() result:') # begin-get_link - response = iam_identity_service.get_link( - profile_id= profile_id, - link_id= link_id - ) + response = iam_identity_service.get_link(profile_id=profile_id, link_id=link_id) link = response.get_result() @@ -795,9 +766,7 @@ def test_get_account_settings_example(self): print('\nget_account_settings() result:') # begin-getAccountSettings - response = iam_identity_service.get_account_settings( - account_id=account_id - ) + response = iam_identity_service.get_account_settings(account_id=account_id) settings = response.get_result() account_settings_etag = response.get_headers()['Etag'] @@ -835,6 +804,7 @@ def test_update_account_settings_example(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials def test_create_report(self): """ @@ -856,6 +826,7 @@ def test_create_report(self): except ApiException as e: pytest.fail(str(e)) + @needscredentials def test_get_report(self): """ @@ -877,6 +848,7 @@ def test_get_report(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: IamIdentityV1 diff --git a/examples/test_iam_policy_management_v1_examples.py b/examples/test_iam_policy_management_v1_examples.py index ba981b3a..40c99a3c 100644 --- a/examples/test_iam_policy_management_v1_examples.py +++ b/examples/test_iam_policy_management_v1_examples.py @@ -58,7 +58,7 @@ # region -class TestIamPolicyManagementV1Examples(): +class TestIamPolicyManagementV1Examples: """ Example Test Class for IamPolicyManagementV1 """ @@ -71,16 +71,14 @@ def setup_class(cls): # begin-common - iam_policy_management_service = IamPolicyManagementV1.new_instance( - ) + iam_policy_management_service = IamPolicyManagementV1.new_instance() # end-common assert iam_policy_management_service is not None # Load the configuration global config, example_account_id - config = read_external_sources( - IamPolicyManagementV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(IamPolicyManagementV1.DEFAULT_SERVICE_NAME) example_account_id = config['TEST_ACCOUNT_ID'] print('Setup complete.') @@ -100,26 +98,17 @@ def test_create_policy_example(self): print('\ncreate_policy() result:') # begin-create_policy - policy_subjects = PolicySubject( - attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) - policy_roles = PolicyRole( - role_id='crn:v1:bluemix:public:iam::::role:Viewer') - account_id_resource_attribute = ResourceAttribute( - name='accountId', value=example_account_id) - service_name_resource_attribute = ResourceAttribute( - name='serviceType', value='service') - policy_resource_tag = ResourceTag( - name='project', value='prototype') + policy_subjects = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) + policy_roles = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Viewer') + account_id_resource_attribute = ResourceAttribute(name='accountId', value=example_account_id) + service_name_resource_attribute = ResourceAttribute(name='serviceType', value='service') + policy_resource_tag = ResourceTag(name='project', value='prototype') policy_resources = PolicyResource( - attributes=[account_id_resource_attribute, - service_name_resource_attribute], - tags=[policy_resource_tag]) + attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] + ) policy = iam_policy_management_service.create_policy( - type='access', - subjects=[policy_subjects], - roles=[policy_roles], - resources=[policy_resources] + type='access', subjects=[policy_subjects], roles=[policy_roles], resources=[policy_resources] ).get_result() print(json.dumps(policy, indent=2)) @@ -142,9 +131,7 @@ def test_get_policy_example(self): print('\nget_policy() result:') # begin-get_policy - response = iam_policy_management_service.get_policy( - policy_id=example_policy_id - ) + response = iam_policy_management_service.get_policy(policy_id=example_policy_id) policy = response.get_result() print(json.dumps(policy, indent=2)) @@ -167,20 +154,14 @@ def test_update_policy_example(self): print('\nupdate_policy() result:') # begin-update_policy - policy_subjects = PolicySubject( - attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) - account_id_resource_attribute = ResourceAttribute( - name='accountId', value=example_account_id) - service_name_resource_attribute = ResourceAttribute( - name='serviceType', value='service') - policy_resource_tag = ResourceTag( - name='project', value='prototype') + policy_subjects = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=example_user_id)]) + account_id_resource_attribute = ResourceAttribute(name='accountId', value=example_account_id) + service_name_resource_attribute = ResourceAttribute(name='serviceType', value='service') + policy_resource_tag = ResourceTag(name='project', value='prototype') policy_resources = PolicyResource( - attributes=[account_id_resource_attribute, - service_name_resource_attribute], - tags=[policy_resource_tag]) - updated_policy_roles = PolicyRole( - role_id='crn:v1:bluemix:public:iam::::role:Editor') + attributes=[account_id_resource_attribute, service_name_resource_attribute], tags=[policy_resource_tag] + ) + updated_policy_roles = PolicyRole(role_id='crn:v1:bluemix:public:iam::::role:Editor') response = iam_policy_management_service.update_policy( type='access', @@ -188,7 +169,7 @@ def test_update_policy_example(self): if_match=example_policy_etag, subjects=[policy_subjects], roles=[updated_policy_roles], - resources=[policy_resources] + resources=[policy_resources], ) policy = response.get_result() @@ -212,9 +193,7 @@ def test_patch_policy_example(self): # begin-patch_policy policy = iam_policy_management_service.patch_policy( - policy_id=example_policy_id, - if_match=example_updated_policy_etag, - state='active' + policy_id=example_policy_id, if_match=example_updated_policy_etag, state='active' ).get_result() print(json.dumps(policy, indent=2)) @@ -255,9 +234,7 @@ def test_delete_policy_example(self): print('\ndelete_policy() result:') # begin-delete_policy - response = iam_policy_management_service.delete_policy( - policy_id=example_policy_id - ).get_result() + response = iam_policy_management_service.delete_policy(policy_id=example_policy_id).get_result() print(json.dumps(response, indent=2)) @@ -282,7 +259,7 @@ def test_create_role_example(self): actions=['iam-groups.groups.read'], name='ExampleRoleIAMGroups', account_id=example_account_id, - service_name=example_service_name + service_name=example_service_name, ).get_result() print(json.dumps(custom_role, indent=2)) @@ -305,9 +282,7 @@ def test_get_role_example(self): print('\nget_role() result:') # begin-get_role - response = iam_policy_management_service.get_role( - role_id=example_custom_role_id - ) + response = iam_policy_management_service.get_role(role_id=example_custom_role_id) custom_role = response.get_result() print(json.dumps(custom_role, indent=2)) @@ -329,12 +304,9 @@ def test_update_role_example(self): print('\nupdate_role() result:') # begin-update_role - updated_role_actions = [ - 'iam-groups.groups.read', 'iam-groups.groups.list'] + updated_role_actions = ['iam-groups.groups.read', 'iam-groups.groups.list'] custom_role = iam_policy_management_service.update_role( - role_id=example_custom_role_id, - if_match=example_custom_role_etag, - actions=updated_role_actions + role_id=example_custom_role_id, if_match=example_custom_role_etag, actions=updated_role_actions ).get_result() print(json.dumps(custom_role, indent=2)) @@ -354,9 +326,7 @@ def test_list_roles_example(self): print('\nlist_roles() result:') # begin-list_roles - role_list = iam_policy_management_service.list_roles( - account_id=example_account_id - ).get_result() + role_list = iam_policy_management_service.list_roles(account_id=example_account_id).get_result() print(json.dumps(role_list, indent=2)) @@ -375,9 +345,7 @@ def test_delete_role_example(self): print('\ndelete_role() result:') # begin-delete_role - response = iam_policy_management_service.delete_role( - role_id=example_custom_role_id - ).get_result() + response = iam_policy_management_service.delete_role(role_id=example_custom_role_id).get_result() print(json.dumps(response, indent=2)) @@ -386,6 +354,7 @@ def test_delete_role_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: IamPolicyManagementV1 diff --git a/examples/test_ibm_cloud_shell_v1_examples.py b/examples/test_ibm_cloud_shell_v1_examples.py index 70e9b62c..6d96fb3a 100644 --- a/examples/test_ibm_cloud_shell_v1_examples.py +++ b/examples/test_ibm_cloud_shell_v1_examples.py @@ -48,7 +48,7 @@ # Start of Examples for Service: IbmCloudShellV1 ############################################################################## # region -class TestIbmCloudShellV1Examples(): +class TestIbmCloudShellV1Examples: """ Example Test Class for IbmCloudShellV1 """ @@ -61,8 +61,7 @@ def setup_class(cls): # begin-common - ibm_cloud_shell_service = IbmCloudShellV1.new_instance( - ) + ibm_cloud_shell_service = IbmCloudShellV1.new_instance() # end-common assert ibm_cloud_shell_service is not None @@ -92,9 +91,7 @@ def test_get_account_settings_example(self): print('\nget_account_settings() result:') # begin-get_account_settings - account_settings = ibm_cloud_shell_service.get_account_settings( - account_id=account_id - ).get_result() + account_settings = ibm_cloud_shell_service.get_account_settings(account_id=account_id).get_result() print(json.dumps(account_settings, indent=2)) @@ -114,27 +111,31 @@ def test_update_account_settings_example(self): print('\nupdate_account_settings() result:') # begin-update_account_settings - feature_model = [{ - 'enabled': True, - 'key': 'server.file_manager', - }, - { - 'enabled': True, - 'key': 'server.web_preview', - }] - - region_setting_model = [{ - 'enabled': True, - 'key': 'eu-de', - }, - { - 'enabled': True, - 'key': 'jp-tok', - }, - { - 'enabled': True, - 'key': 'us-south', - }] + feature_model = [ + { + 'enabled': True, + 'key': 'server.file_manager', + }, + { + 'enabled': True, + 'key': 'server.web_preview', + }, + ] + + region_setting_model = [ + { + 'enabled': True, + 'key': 'eu-de', + }, + { + 'enabled': True, + 'key': 'jp-tok', + }, + { + 'enabled': True, + 'key': 'us-south', + }, + ] account_settings = ibm_cloud_shell_service.update_account_settings( account_id=account_id, @@ -143,7 +144,7 @@ def test_update_account_settings_example(self): default_enable_new_regions=True, enabled=True, features=feature_model, - regions=region_setting_model + regions=region_setting_model, ).get_result() print(json.dumps(account_settings, indent=2)) @@ -153,6 +154,7 @@ def test_update_account_settings_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: IbmCloudShellV1 diff --git a/examples/test_open_service_broker_v1_examples.py b/examples/test_open_service_broker_v1_examples.py index 027398ca..72f5ba4c 100644 --- a/examples/test_open_service_broker_v1_examples.py +++ b/examples/test_open_service_broker_v1_examples.py @@ -66,7 +66,7 @@ # Start of Examples for Service: OpenServiceBrokerV1 ############################################################################## # region -class TestOpenServiceBrokerV1Examples(): +class TestOpenServiceBrokerV1Examples: """ Example Test Class for OpenServiceBrokerV1 """ @@ -79,16 +79,14 @@ def setup_class(cls): # begin-common - open_service_broker_service = OpenServiceBrokerV1.new_instance( - ) + open_service_broker_service = OpenServiceBrokerV1.new_instance() # end-common assert open_service_broker_service is not None # Load the configuration global config - config = read_external_sources( - OpenServiceBrokerV1.DEFAULT_SERVICE_NAME) + config = read_external_sources(OpenServiceBrokerV1.DEFAULT_SERVICE_NAME) global instanceId instanceId = config['RESOURCE_INSTANCE_ID'] @@ -131,9 +129,7 @@ def test_get_service_instance_state_example(self): print('\nget_service_instance_state() result:') # begin-get_service_instance_state - response = open_service_broker_service.get_service_instance_state( - instance_id=instanceId - ).get_result() + response = open_service_broker_service.get_service_instance_state(instance_id=instanceId).get_result() print(json.dumps(response, indent=2)) @@ -154,10 +150,7 @@ def test_replace_service_instance_state_example(self): # begin-replace_service_instance_state response = open_service_broker_service.replace_service_instance_state( - instance_id=instanceId, - enabled=False, - initiator_id=initiatorId, - reason_code=reasonCode + instance_id=instanceId, enabled=False, initiator_id=initiatorId, reason_code=reasonCode ).get_result() print(json.dumps(response, indent=2)) @@ -178,11 +171,7 @@ def test_replace_service_instance_example(self): print('\nreplace_service_instance() result:') # begin-replace_service_instance - context = Context( - account_id=accountId, - crn=instanceId, - platform='ibmcloud' - ) + context = Context(account_id=accountId, crn=instanceId, platform='ibmcloud') pars = {} response = open_service_broker_service.replace_service_instance( instance_id=instanceId, @@ -192,7 +181,7 @@ def test_replace_service_instance_example(self): space_guid=spaceGuid, context=context, parameters=pars, - accepts_incomplete=True + accepts_incomplete=True, ).get_result() print(json.dumps(response, indent=2)) @@ -213,11 +202,7 @@ def test_update_service_instance_example(self): print('\nupdate_service_instance() result:') # begin-update_service_instance - context = Context( - account_id=accountId, - crn=instanceId, - platform='ibmcloud' - ) + context = Context(account_id=accountId, crn=instanceId, platform='ibmcloud') pars = {} prevValues = {} response = open_service_broker_service.update_service_instance( @@ -227,7 +212,7 @@ def test_update_service_instance_example(self): context=context, parameters=pars, previous_values=prevValues, - accepts_incomplete=True + accepts_incomplete=True, ).get_result() print(json.dumps(response, indent=2)) @@ -268,10 +253,7 @@ def test_get_last_operation_example(self): # begin-get_last_operation response = open_service_broker_service.get_last_operation( - instance_id=instanceId, - operation = operation, - plan_id = planId, - service_id = serviceId + instance_id=instanceId, operation=operation, plan_id=planId, service_id=serviceId ).get_result() print(json.dumps(response, indent=2)) @@ -292,10 +274,7 @@ def test_replace_service_binding_example(self): print('\nreplace_service_binding() result:') # begin-replace_service_binding - bindResource = BindResource( - account_id=accountId, - serviceid_crn=appGuid - ) + bindResource = BindResource(account_id=accountId, serviceid_crn=appGuid) pars = {} response = open_service_broker_service.replace_service_binding( binding_id=bindingId, @@ -303,7 +282,7 @@ def test_replace_service_binding_example(self): plan_id=planId, service_id=serviceId, bind_resource=bindResource, - parameters=pars + parameters=pars, ).get_result() print(json.dumps(response, indent=2)) @@ -362,6 +341,7 @@ def test_delete_service_binding_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: OpenServiceBrokerV1 diff --git a/examples/test_resource_controller_v2_examples.py b/examples/test_resource_controller_v2_examples.py index 0973a178..b3a6e3bc 100644 --- a/examples/test_resource_controller_v2_examples.py +++ b/examples/test_resource_controller_v2_examples.py @@ -74,7 +74,7 @@ # region -class TestResourceControllerV2Examples(): +class TestResourceControllerV2Examples: """ Example Test Class for ResourceControllerV2 """ @@ -94,8 +94,7 @@ def setup_class(cls): # Load the configuration global config - config = read_external_sources( - ResourceControllerV2.DEFAULT_SERVICE_NAME) + config = read_external_sources(ResourceControllerV2.DEFAULT_SERVICE_NAME) global resource_group resource_group = config['RESOURCE_GROUP'] @@ -132,7 +131,7 @@ def test_create_resource_instance_example(self): name=resource_instance_name, target=target_region, resource_group=resource_group, - resource_plan_id=resource_plan_id + resource_plan_id=resource_plan_id, ).get_result() print(json.dumps(resource_instance, indent=2)) @@ -154,9 +153,7 @@ def test_get_resource_instance_example(self): print('\nget_resource_instance() result:') # begin-get_resource_instance - resource_instance = resource_controller_service.get_resource_instance( - id=instance_guid - ).get_result() + resource_instance = resource_controller_service.get_resource_instance(id=instance_guid).get_result() print(json.dumps(resource_instance, indent=2)) @@ -200,13 +197,9 @@ def test_update_resource_instance_example(self): print('\nupdate_resource_instance() result:') # begin-update_resource_instance - parameters = { - 'exampleProperty': 'exampleValue' - } + parameters = {'exampleProperty': 'exampleValue'} resource_instance = resource_controller_service.update_resource_instance( - id=instance_guid, - name=resource_instance_update_name, - parameters=parameters + id=instance_guid, name=resource_instance_update_name, parameters=parameters ).get_result() print(json.dumps(resource_instance, indent=2)) @@ -227,9 +220,7 @@ def test_create_resource_alias_example(self): # begin-create_resource_alias resource_alias = resource_controller_service.create_resource_alias( - name=alias_name, - source=instance_guid, - target=alias_target_crn + name=alias_name, source=instance_guid, target=alias_target_crn ).get_result() print(json.dumps(resource_alias, indent=2)) @@ -251,9 +242,7 @@ def test_get_resource_alias_example(self): print('\nget_resource_alias() result:') # begin-get_resource_alias - resource_alias = resource_controller_service.get_resource_alias( - id=alias_guid - ).get_result() + resource_alias = resource_controller_service.get_resource_alias(id=alias_guid).get_result() print(json.dumps(resource_alias, indent=2)) @@ -299,8 +288,7 @@ def test_update_resource_alias_example(self): # begin-update_resource_alias resource_alias = resource_controller_service.update_resource_alias( - id=alias_guid, - name=alias_update_name + id=alias_guid, name=alias_update_name ).get_result() print(json.dumps(resource_alias, indent=2)) @@ -346,14 +334,9 @@ def test_create_resource_binding_example(self): print('\ncreate_resource_binding() result:') # begin-create_resource_binding - parameters = { - 'exampleParameter': 'exampleValue' - } + parameters = {'exampleParameter': 'exampleValue'} resource_binding = resource_controller_service.create_resource_binding( - source=alias_guid, - target=binding_target_crn, - name=binding_name, - parameters=parameters + source=alias_guid, target=binding_target_crn, name=binding_name, parameters=parameters ).get_result() print(json.dumps(resource_binding, indent=2)) @@ -375,11 +358,13 @@ def test_get_resource_binding_example(self): print('\nget_resource_binding() result:') # begin-get_resource_binding - resource_binding = resource_controller_service.get_resource_binding( - id=binding_guid - ).get_result() + resource_binding = resource_controller_service.get_resource_binding(id=binding_guid).get_result() if resource_binding.get('credentials') and resource_binding.get('credentials').get('REDACTED'): - print("Credentials are redacted with code:", resource_binding.get('credentials').get('REDACTED'), ".The User doesn't have the correct access to view the credentials. Refer to the API documentation for additional details.") + print( + "Credentials are redacted with code:", + resource_binding.get('credentials').get('REDACTED'), + ".The User doesn't have the correct access to view the credentials. Refer to the API documentation for additional details.", + ) print(json.dumps(resource_binding, indent=2)) # end-get_resource_binding @@ -424,8 +409,7 @@ def test_update_resource_binding_example(self): # begin-update_resource_binding resource_binding = resource_controller_service.update_resource_binding( - id=binding_guid, - name=binding_update_name + id=binding_guid, name=binding_update_name ).get_result() print(json.dumps(resource_binding, indent=2)) @@ -471,13 +455,9 @@ def test_create_resource_key_example(self): print('\ncreate_resource_key() result:') # begin-create_resource_key - parameters = { - 'exampleParameter': 'exampleValue' - } + parameters = {'exampleParameter': 'exampleValue'} resource_key = resource_controller_service.create_resource_key( - name=key_name, - source=instance_guid, - parameters=parameters + name=key_name, source=instance_guid, parameters=parameters ).get_result() print(json.dumps(resource_key, indent=2)) @@ -499,11 +479,13 @@ def test_get_resource_key_example(self): print('\nget_resource_key() result:') # begin-get_resource_key - resource_key = resource_controller_service.get_resource_key( - id=instance_key_guid - ).get_result() + resource_key = resource_controller_service.get_resource_key(id=instance_key_guid).get_result() if resource_key.get('credentials') and resource_key.get('credentials').get('REDACTED'): - print("Credentials are redacted with code:", resource_key.get('credentials').get('REDACTED'), ".The User doesn't have the correct access to view the credentials. Refer to the API documentation for additional details.") + print( + "Credentials are redacted with code:", + resource_key.get('credentials').get('REDACTED'), + ".The User doesn't have the correct access to view the credentials. Refer to the API documentation for additional details.", + ) print(json.dumps(resource_key, indent=2)) @@ -549,8 +531,7 @@ def test_update_resource_key_example(self): # begin-update_resource_key resource_key = resource_controller_service.update_resource_key( - id=instance_key_guid, - name=key_update_name + id=instance_key_guid, name=key_update_name ).get_result() print(json.dumps(resource_key, indent=2)) @@ -595,12 +576,10 @@ def test_delete_resource_binding_example(self): global binding_guid # begin-delete_resource_binding - response = resource_controller_service.delete_resource_binding( - id=binding_guid) + response = resource_controller_service.delete_resource_binding(id=binding_guid) # end-delete_resource_binding - print('\ndelete_resource_binding() response status code: ', - response.get_status_code()) + print('\ndelete_resource_binding() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -614,12 +593,10 @@ def test_delete_resource_key_example(self): global instance_key_guid # begin-delete_resource_key - response = resource_controller_service.delete_resource_key( - id=instance_key_guid) + response = resource_controller_service.delete_resource_key(id=instance_key_guid) # end-delete_resource_key - print('\ndelete_resource_key() response status code: ', - response.get_status_code()) + print('\ndelete_resource_key() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -633,13 +610,10 @@ def test_delete_resource_alias_example(self): global alias_guid # begin-delete_resource_alias - response = resource_controller_service.delete_resource_alias( - id=alias_guid - ) + response = resource_controller_service.delete_resource_alias(id=alias_guid) # end-delete_resource_alias - print('\ndelete_resource_alias() response status code: ', - response.get_status_code()) + print('\ndelete_resource_alias() response status code: ', response.get_status_code()) except ApiException as e: pytest.fail(str(e)) @@ -654,9 +628,7 @@ def test_lock_resource_instance_example(self): print('\nlock_resource_instance() result:') # begin-lock_resource_instance - resource_instance = resource_controller_service.lock_resource_instance( - id=instance_guid - ).get_result() + resource_instance = resource_controller_service.lock_resource_instance(id=instance_guid).get_result() print(json.dumps(resource_instance, indent=2)) @@ -675,9 +647,7 @@ def test_unlock_resource_instance_example(self): print('\nunlock_resource_instance() result:') # begin-unlock_resource_instance - resource_instance = resource_controller_service.unlock_resource_instance( - id=instance_guid - ).get_result() + resource_instance = resource_controller_service.unlock_resource_instance(id=instance_guid).get_result() print(json.dumps(resource_instance, indent=2)) @@ -695,14 +665,10 @@ def test_delete_resource_instance_example(self): global instance_guid # begin-delete_resource_instance - response = resource_controller_service.delete_resource_instance( - id=instance_guid, - recursive=False - ) + response = resource_controller_service.delete_resource_instance(id=instance_guid, recursive=False) # end-delete_resource_instance - print('\ndelete_resource_instance() response status code: ', - response.get_status_code()) + print('\ndelete_resource_instance() response status code: ', response.get_status_code()) # wait for reclamation object to be created time.sleep(20) @@ -720,9 +686,7 @@ def test_list_reclamations_example(self): print('\nlist_reclamations() result:') # begin-list_reclamations - reclamations_list = resource_controller_service.list_reclamations( - account_id=account_id - ).get_result() + reclamations_list = resource_controller_service.list_reclamations(account_id=account_id).get_result() print(json.dumps(reclamations_list, indent=2)) @@ -747,8 +711,7 @@ def test_run_reclamation_action_example(self): # begin-run_reclamation_action reclamation = resource_controller_service.run_reclamation_action( - id=reclamation_id, - action_name='reclaim' + id=reclamation_id, action_name='reclaim' ).get_result() print(json.dumps(reclamation, indent=2)) @@ -780,6 +743,7 @@ def test_cancel_lastop_resource_instance_example(self): else: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: ResourceControllerV2 diff --git a/examples/test_resource_manager_v2_examples.py b/examples/test_resource_manager_v2_examples.py index 3fa3d703..1ab4b676 100644 --- a/examples/test_resource_manager_v2_examples.py +++ b/examples/test_resource_manager_v2_examples.py @@ -51,7 +51,7 @@ # Start of Examples for Service: ResourceManagerV2 ############################################################################## # region -class TestResourceManagerV2Examples(): +class TestResourceManagerV2Examples: """ Example Test Class for ResourceManagerV2 """ diff --git a/examples/test_usage_metering_v4_examples.py b/examples/test_usage_metering_v4_examples.py index 0e31e48b..51b1fd16 100644 --- a/examples/test_usage_metering_v4_examples.py +++ b/examples/test_usage_metering_v4_examples.py @@ -47,10 +47,11 @@ # Start of Examples for Service: UsageMeteringV4 ############################################################################## # region -class TestUsageMeteringV4Examples(): +class TestUsageMeteringV4Examples: """ Example Test Class for UsageMeteringV4 """ + @classmethod def setup_class(cls): global usage_metering_service @@ -67,8 +68,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_report_resource_usage_example(self): @@ -119,8 +120,8 @@ def test_report_resource_usage_example(self): } response_accepted = usage_metering_service.report_resource_usage( - resource_id=resource_id, - resource_usage=[resource_instance_usage_model]).get_result() + resource_id=resource_id, resource_usage=[resource_instance_usage_model] + ).get_result() print(json.dumps(response_accepted, indent=2)) diff --git a/examples/test_usage_reports_v4_examples.py b/examples/test_usage_reports_v4_examples.py index 07a5b5c4..d91c64cf 100644 --- a/examples/test_usage_reports_v4_examples.py +++ b/examples/test_usage_reports_v4_examples.py @@ -56,7 +56,7 @@ # region -class TestUsageReportsV4Examples(): +class TestUsageReportsV4Examples: """ Example Test Class for UsageReportsV4 """ @@ -69,8 +69,7 @@ def setup_class(cls): # begin-common - usage_reports_service = UsageReportsV4.new_instance( - ) + usage_reports_service = UsageReportsV4.new_instance() # end-common assert usage_reports_service is not None @@ -115,8 +114,7 @@ def test_get_account_summary_example(self): # begin-get_account_summary account_summary = usage_reports_service.get_account_summary( - account_id=account_id, - billingmonth=billing_month + account_id=account_id, billingmonth=billing_month ).get_result() print(json.dumps(account_summary, indent=2)) @@ -138,8 +136,7 @@ def test_get_account_usage_example(self): # begin-get_account_usage account_usage = usage_reports_service.get_account_usage( - account_id=account_id, - billingmonth=billing_month + account_id=account_id, billingmonth=billing_month ).get_result() print(json.dumps(account_usage, indent=2)) @@ -161,9 +158,7 @@ def test_get_resource_group_usage_example(self): # begin-get_resource_group_usage resource_group_usage = usage_reports_service.get_resource_group_usage( - account_id=account_id, - resource_group_id=resource_group_id, - billingmonth=billing_month + account_id=account_id, resource_group_id=resource_group_id, billingmonth=billing_month ).get_result() print(json.dumps(resource_group_usage, indent=2)) @@ -185,9 +180,7 @@ def test_get_org_usage_example(self): # begin-get_org_usage org_usage = usage_reports_service.get_org_usage( - account_id=account_id, - organization_id=org_id, - billingmonth=billing_month + account_id=account_id, organization_id=org_id, billingmonth=billing_month ).get_result() print(json.dumps(org_usage, indent=2)) @@ -209,8 +202,7 @@ def test_get_resource_usage_account_example(self): # begin-get_resource_usage_account instances_usage = usage_reports_service.get_resource_usage_account( - account_id=account_id, - billingmonth=billing_month + account_id=account_id, billingmonth=billing_month ).get_result() print(json.dumps(instances_usage, indent=2)) @@ -232,9 +224,7 @@ def test_get_resource_usage_resource_group_example(self): # begin-get_resource_usage_resource_group instances_usage = usage_reports_service.get_resource_usage_resource_group( - account_id=account_id, - resource_group_id=resource_group_id, - billingmonth=billing_month + account_id=account_id, resource_group_id=resource_group_id, billingmonth=billing_month ).get_result() print(json.dumps(instances_usage, indent=2)) @@ -256,9 +246,7 @@ def test_get_resource_usage_org_example(self): # begin-get_resource_usage_org instances_usage = usage_reports_service.get_resource_usage_org( - account_id=account_id, - organization_id=org_id, - billingmonth=billing_month + account_id=account_id, organization_id=org_id, billingmonth=billing_month ).get_result() print(json.dumps(instances_usage, indent=2)) @@ -268,6 +256,7 @@ def test_get_resource_usage_org_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: UsageReportsV4 diff --git a/examples/test_user_management_v1_examples.py b/examples/test_user_management_v1_examples.py index aeb12fd0..27b6d1cb 100644 --- a/examples/test_user_management_v1_examples.py +++ b/examples/test_user_management_v1_examples.py @@ -66,7 +66,7 @@ # Start of Examples for Service: UserManagementV1 ############################################################################## # region -class TestUserManagementV1Examples(): +class TestUserManagementV1Examples: """ Example Test Class for UserManagementV1 """ @@ -94,9 +94,7 @@ def setup_class(cls): # Load the configuration global config - config = read_external_sources( - UserManagementV1.DEFAULT_SERVICE_NAME - ) + config = read_external_sources(UserManagementV1.DEFAULT_SERVICE_NAME) global account_id account_id = config['ACCOUNT_ID'] @@ -134,10 +132,7 @@ def test_invite_users_example(self): print('\ninvite_users() result:') # begin-invite_users - invite_user_model = { - 'email': member_email, - 'account_role': 'Member' - } + invite_user_model = {'email': member_email, 'account_role': 'Member'} role_model = {'role_id': viewer_role_id} @@ -147,17 +142,13 @@ def test_invite_users_example(self): resource_model = {'attributes': [attribute_model, attribute_model2]} - invite_user_iam_policy_model = { - 'type': 'access', - 'roles': [role_model], - 'resources': [resource_model] - } + invite_user_iam_policy_model = {'type': 'access', 'roles': [role_model], 'resources': [resource_model]} invite_user_response = user_management_admin_service.invite_users( account_id=account_id, users=[invite_user_model], iam_policy=[invite_user_iam_policy_model], - access_groups=[access_group_id] + access_groups=[access_group_id], ).get_result() print(json.dumps(invite_user_response, indent=2)) @@ -323,6 +314,7 @@ def test_update_user_settings_example(self): except ApiException as e: pytest.fail(str(e)) + # endregion ############################################################################## # End of Examples for Service: UserManagementV1 diff --git a/ibm_platform_services/case_management_v1.py b/ibm_platform_services/case_management_v1.py index b47ede4a..0a837b0a 100644 --- a/ibm_platform_services/case_management_v1.py +++ b/ibm_platform_services/case_management_v1.py @@ -40,6 +40,7 @@ # Service ############################################################################## + class CaseManagementV1(BaseService): """The Case Management V1 service.""" @@ -47,23 +48,23 @@ class CaseManagementV1(BaseService): DEFAULT_SERVICE_NAME = 'case_management' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'CaseManagementV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'CaseManagementV1': """ Return a new client for the Case Management service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Case Management service. @@ -71,17 +72,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # default ######################### - - def get_cases(self, + def get_cases( + self, *, offset: int = None, limit: int = None, @@ -89,7 +87,7 @@ def get_cases(self, sort: str = None, status: List[str] = None, fields: List[str] = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get cases in account. @@ -110,9 +108,9 @@ def get_cases(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_cases') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_cases' + ) headers.update(sdk_headers) params = { @@ -121,7 +119,7 @@ def get_cases(self, 'search': search, 'sort': sort, 'status': convert_list(status), - 'fields': convert_list(fields) + 'fields': convert_list(fields), } if 'headers' in kwargs: @@ -130,16 +128,13 @@ def get_cases(self, headers['Accept'] = 'application/json' url = '/cases' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_case(self, + def create_case( + self, type: str, subject: str, description: str, @@ -151,7 +146,7 @@ def create_case(self, watchlist: List['User'] = None, invoice_number: str = None, sla_credit_request: bool = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Create a case. @@ -199,9 +194,9 @@ def create_case(self, if watchlist is not None: watchlist = [convert_model(x) for x in watchlist] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_case') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_case' + ) headers.update(sdk_headers) data = { @@ -214,7 +209,7 @@ def create_case(self, 'resources': resources, 'watchlist': watchlist, 'invoice_number': invoice_number, - 'sla_credit_request': sla_credit_request + 'sla_credit_request': sla_credit_request, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -226,21 +221,12 @@ def create_case(self, headers['Accept'] = 'application/json' url = '/cases' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_case(self, - case_number: str, - *, - fields: List[str] = None, - **kwargs - ) -> DetailedResponse: + def get_case(self, case_number: str, *, fields: List[str] = None, **kwargs) -> DetailedResponse: """ Get a case in account. @@ -257,14 +243,12 @@ def get_case(self, if not case_number: raise ValueError('case_number must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_case') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_case' + ) headers.update(sdk_headers) - params = { - 'fields': convert_list(fields) - } + params = {'fields': convert_list(fields)} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -275,20 +259,12 @@ def get_case(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_case_status(self, - case_number: str, - status_payload: 'StatusPayload', - **kwargs - ) -> DetailedResponse: + def update_case_status(self, case_number: str, status_payload: 'StatusPayload', **kwargs) -> DetailedResponse: """ Update case status. @@ -308,9 +284,9 @@ def update_case_status(self, if isinstance(status_payload, StatusPayload): status_payload = convert_model(status_payload) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_case_status') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_case_status' + ) headers.update(sdk_headers) data = json.dumps(status_payload) @@ -325,20 +301,12 @@ def update_case_status(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/status'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def add_comment(self, - case_number: str, - comment: str, - **kwargs - ) -> DetailedResponse: + def add_comment(self, case_number: str, comment: str, **kwargs) -> DetailedResponse: """ Add comment to case. @@ -356,14 +324,12 @@ def add_comment(self, if comment is None: raise ValueError('comment must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='add_comment') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='add_comment' + ) headers.update(sdk_headers) - data = { - 'comment': comment - } + data = {'comment': comment} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -377,21 +343,12 @@ def add_comment(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/comments'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def add_watchlist(self, - case_number: str, - *, - watchlist: List['User'] = None, - **kwargs - ) -> DetailedResponse: + def add_watchlist(self, case_number: str, *, watchlist: List['User'] = None, **kwargs) -> DetailedResponse: """ Add users to watchlist of case. @@ -412,14 +369,12 @@ def add_watchlist(self, if watchlist is not None: watchlist = [convert_model(x) for x in watchlist] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='add_watchlist') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='add_watchlist' + ) headers.update(sdk_headers) - data = { - 'watchlist': watchlist - } + data = {'watchlist': watchlist} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -433,21 +388,12 @@ def add_watchlist(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/watchlist'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def remove_watchlist(self, - case_number: str, - *, - watchlist: List['User'] = None, - **kwargs - ) -> DetailedResponse: + def remove_watchlist(self, case_number: str, *, watchlist: List['User'] = None, **kwargs) -> DetailedResponse: """ Remove users from watchlist of case. @@ -466,14 +412,12 @@ def remove_watchlist(self, if watchlist is not None: watchlist = [convert_model(x) for x in watchlist] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='remove_watchlist') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='remove_watchlist' + ) headers.update(sdk_headers) - data = { - 'watchlist': watchlist - } + data = {'watchlist': watchlist} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -487,23 +431,13 @@ def remove_watchlist(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/watchlist'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='DELETE', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def add_resource(self, - case_number: str, - *, - crn: str = None, - type: str = None, - id: float = None, - note: str = None, - **kwargs + def add_resource( + self, case_number: str, *, crn: str = None, type: str = None, id: float = None, note: str = None, **kwargs ) -> DetailedResponse: """ Add a resource to case. @@ -527,17 +461,12 @@ def add_resource(self, if not case_number: raise ValueError('case_number must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='add_resource') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='add_resource' + ) headers.update(sdk_headers) - data = { - 'crn': crn, - 'type': type, - 'id': id, - 'note': note - } + data = {'crn': crn, 'type': type, 'id': id, 'note': note} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -551,20 +480,12 @@ def add_resource(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/resources'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def upload_file(self, - case_number: str, - file: List[BinaryIO], - **kwargs - ) -> DetailedResponse: + def upload_file(self, case_number: str, file: List[BinaryIO], **kwargs) -> DetailedResponse: """ Add attachments to a support case. @@ -584,9 +505,9 @@ def upload_file(self, if file is None: raise ValueError('file must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='upload_file') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='upload_file' + ) headers.update(sdk_headers) form_data = [] @@ -604,20 +525,12 @@ def upload_file(self, path_param_values = self.encode_path_vars(case_number) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/attachments'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - files=form_data) + request = self.prepare_request(method='PUT', url=url, headers=headers, files=form_data) response = self.send(request, **kwargs) return response - - def download_file(self, - case_number: str, - file_id: str, - **kwargs - ) -> DetailedResponse: + def download_file(self, case_number: str, file_id: str, **kwargs) -> DetailedResponse: """ Download an attachment. @@ -635,9 +548,9 @@ def download_file(self, if not file_id: raise ValueError('file_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='download_file') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='download_file' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -649,19 +562,12 @@ def download_file(self, path_param_values = self.encode_path_vars(case_number, file_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/attachments/{file_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_file(self, - case_number: str, - file_id: str, - **kwargs - ) -> DetailedResponse: + def delete_file(self, case_number: str, file_id: str, **kwargs) -> DetailedResponse: """ Remove attachment from case. @@ -679,9 +585,9 @@ def delete_file(self, if not file_id: raise ValueError('file_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_file') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_file' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -693,9 +599,7 @@ def delete_file(self, path_param_values = self.encode_path_vars(case_number, file_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/cases/{case_number}/attachments/{file_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -710,16 +614,19 @@ class Status(str, Enum): """ Case status filter. """ + NEW = 'new' IN_PROGRESS = 'in_progress' WAITING_ON_CLIENT = 'waiting_on_client' RESOLUTION_PROVIDED = 'resolution_provided' RESOLVED = 'resolved' CLOSED = 'closed' + class Fields(str, Enum): """ Selected fields of interest instead of all of the case information. """ + NUMBER = 'number' SHORT_DESCRIPTION = 'short_description' DESCRIPTION = 'description' @@ -753,6 +660,7 @@ class Fields(str, Enum): """ Selected fields of interest instead of all of the case information. """ + NUMBER = 'number' SHORT_DESCRIPTION = 'short_description' DESCRIPTION = 'description' @@ -782,7 +690,7 @@ class Fields(str, Enum): ############################################################################## -class Attachment(): +class Attachment: """ Details of an attachment. @@ -793,13 +701,15 @@ class Attachment(): :attr str url: (optional) URL of the attachment used to download. """ - def __init__(self, - *, - id: str = None, - filename: str = None, - size_in_bytes: int = None, - created_at: str = None, - url: str = None) -> None: + def __init__( + self, + *, + id: str = None, + filename: str = None, + size_in_bytes: int = None, + created_at: str = None, + url: str = None, + ) -> None: """ Initialize a Attachment object. @@ -869,16 +779,15 @@ def __ne__(self, other: 'Attachment') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AttachmentList(): + +class AttachmentList: """ List of attachments in the case. :attr List[Attachment] attachments: (optional) New attachments array. """ - def __init__(self, - *, - attachments: List['Attachment'] = None) -> None: + def __init__(self, *, attachments: List['Attachment'] = None) -> None: """ Initialize a AttachmentList object. @@ -924,7 +833,8 @@ def __ne__(self, other: 'AttachmentList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Case(): + +class Case: """ The support case. @@ -955,28 +865,30 @@ class Case(): sorted in chronological order. """ - def __init__(self, - *, - number: str = None, - short_description: str = None, - description: str = None, - created_at: str = None, - created_by: 'User' = None, - updated_at: str = None, - updated_by: 'User' = None, - contact_type: str = None, - contact: 'User' = None, - status: str = None, - severity: float = None, - support_tier: str = None, - resolution: str = None, - close_notes: str = None, - eu: 'CaseEu' = None, - watchlist: List['User'] = None, - attachments: List['Attachment'] = None, - offering: 'Offering' = None, - resources: List['Resource'] = None, - comments: List['Comment'] = None) -> None: + def __init__( + self, + *, + number: str = None, + short_description: str = None, + description: str = None, + created_at: str = None, + created_by: 'User' = None, + updated_at: str = None, + updated_by: 'User' = None, + contact_type: str = None, + contact: 'User' = None, + status: str = None, + severity: float = None, + support_tier: str = None, + resolution: str = None, + close_notes: str = None, + eu: 'CaseEu' = None, + watchlist: List['User'] = None, + attachments: List['Attachment'] = None, + offering: 'Offering' = None, + resources: List['Resource'] = None, + comments: List['Comment'] = None, + ) -> None: """ Initialize a Case object. @@ -1147,21 +1059,22 @@ class ContactTypeEnum(str, Enum): """ Name of the console to interact with the contact. """ + CLOUD_SUPPORT_CENTER = 'Cloud Support Center' IMS_CONSOLE = 'IMS Console' - class SupportTierEnum(str, Enum): """ Support tier of the account. """ + FREE = 'Free' BASIC = 'Basic' STANDARD = 'Standard' PREMIUM = 'Premium' -class CaseEu(): +class CaseEu: """ EU support. @@ -1169,10 +1082,7 @@ class CaseEu(): :attr str data_center: (optional) Information about the data center. """ - def __init__(self, - *, - support: bool = None, - data_center: str = None) -> None: + def __init__(self, *, support: bool = None, data_center: str = None) -> None: """ Initialize a CaseEu object. @@ -1225,7 +1135,8 @@ def __ne__(self, other: 'CaseEu') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CaseList(): + +class CaseList: """ Response of a GET /cases request. @@ -1241,14 +1152,16 @@ class CaseList(): :attr List[Case] cases: (optional) List of cases. """ - def __init__(self, - *, - total_count: int = None, - first: 'PaginationLink' = None, - next: 'PaginationLink' = None, - previous: 'PaginationLink' = None, - last: 'PaginationLink' = None, - cases: List['Case'] = None) -> None: + def __init__( + self, + *, + total_count: int = None, + first: 'PaginationLink' = None, + next: 'PaginationLink' = None, + previous: 'PaginationLink' = None, + last: 'PaginationLink' = None, + cases: List['Case'] = None, + ) -> None: """ Initialize a CaseList object. @@ -1329,7 +1242,8 @@ def __ne__(self, other: 'CaseList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CasePayloadEu(): + +class CasePayloadEu: """ Specify if the case should be treated as EU regulated. Only one of the following properties is required. Call EU support utility endpoint to determine which property @@ -1340,10 +1254,7 @@ class CasePayloadEu(): data center, then pass the data center id to mark a case as EU supported. """ - def __init__(self, - *, - supported: bool = None, - data_center: int = None) -> None: + def __init__(self, *, supported: bool = None, data_center: int = None) -> None: """ Initialize a CasePayloadEu object. @@ -1398,7 +1309,8 @@ def __ne__(self, other: 'CasePayloadEu') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Comment(): + +class Comment: """ A comment in a case. @@ -1407,11 +1319,7 @@ class Comment(): :attr User added_by: (optional) User info in a case. """ - def __init__(self, - *, - value: str = None, - added_at: str = None, - added_by: 'User' = None) -> None: + def __init__(self, *, value: str = None, added_at: str = None, added_by: 'User' = None) -> None: """ Initialize a Comment object. @@ -1469,7 +1377,8 @@ def __ne__(self, other: 'Comment') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Offering(): + +class Offering: """ Offering details. @@ -1477,9 +1386,7 @@ class Offering(): :attr OfferingType type: Offering type. """ - def __init__(self, - name: str, - type: 'OfferingType') -> None: + def __init__(self, name: str, type: 'OfferingType') -> None: """ Initialize a Offering object. @@ -1535,7 +1442,8 @@ def __ne__(self, other: 'Offering') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OfferingType(): + +class OfferingType: """ Offering type. @@ -1547,12 +1455,7 @@ class OfferingType(): identify the offering. """ - def __init__(self, - group: str, - key: str, - *, - kind: str = None, - id: str = None) -> None: + def __init__(self, group: str, key: str, *, kind: str = None, id: str = None) -> None: """ Initialize a OfferingType object. @@ -1627,20 +1530,19 @@ class GroupEnum(str, Enum): Offering type group. "crn_service_name" is preferred over "category" as the latter is legacy and will be deprecated in the future. """ + CRN_SERVICE_NAME = 'crn_service_name' CATEGORY = 'category' -class PaginationLink(): +class PaginationLink: """ Container for URL pointer to related pages of cases. :attr str href: (optional) URL to related pages of cases. """ - def __init__(self, - *, - href: str = None) -> None: + def __init__(self, *, href: str = None) -> None: """ Initialize a PaginationLink object. @@ -1686,7 +1588,8 @@ def __ne__(self, other: 'PaginationLink') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ A resource record of a case. @@ -1697,13 +1600,9 @@ class Resource(): :attr str note: (optional) Note about resource. """ - def __init__(self, - *, - crn: str = None, - name: str = None, - type: str = None, - url: str = None, - note: str = None) -> None: + def __init__( + self, *, crn: str = None, name: str = None, type: str = None, url: str = None, note: str = None + ) -> None: """ Initialize a Resource object. @@ -1773,7 +1672,8 @@ def __ne__(self, other: 'Resource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourcePayload(): + +class ResourcePayload: """ Payload to add a resource to a case. @@ -1786,12 +1686,7 @@ class ResourcePayload(): :attr str note: (optional) A note about this resource. """ - def __init__(self, - *, - crn: str = None, - type: str = None, - id: float = None, - note: str = None) -> None: + def __init__(self, *, crn: str = None, type: str = None, id: float = None, note: str = None) -> None: """ Initialize a ResourcePayload object. @@ -1858,22 +1753,23 @@ def __ne__(self, other: 'ResourcePayload') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class StatusPayload(): + +class StatusPayload: """ Payload to update status of the case. :attr str action: action to perform on the case. """ - def __init__(self, - action: str) -> None: + def __init__(self, action: str) -> None: """ Initialize a StatusPayload object. :param str action: action to perform on the case. """ msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['ResolvePayload', 'UnresolvePayload', 'AcceptPayload'])) + ", ".join(['ResolvePayload', 'UnresolvePayload', 'AcceptPayload']) + ) raise Exception(msg) @classmethod @@ -1882,9 +1778,10 @@ def from_dict(cls, _dict: Dict) -> 'StatusPayload': disc_class = cls._get_class_by_discriminator(_dict) if disc_class != cls: return disc_class.from_dict(_dict) - msg = ("Cannot convert dictionary into an instance of base class 'StatusPayload'. " + - "The discriminator value should map to a valid subclass: {1}").format( - ", ".join(['ResolvePayload', 'UnresolvePayload', 'AcceptPayload'])) + msg = ( + "Cannot convert dictionary into an instance of base class 'StatusPayload'. " + + "The discriminator value should map to a valid subclass: {1}" + ).format(", ".join(['ResolvePayload', 'UnresolvePayload', 'AcceptPayload'])) raise Exception(msg) @classmethod @@ -1914,12 +1811,13 @@ class ActionEnum(str, Enum): """ action to perform on the case. """ + RESOLVE = 'resolve' UNRESOLVE = 'unresolve' ACCEPT = 'accept' -class User(): +class User: """ User info in a case. @@ -1928,11 +1826,7 @@ class User(): :attr str user_id: unique user ID in the realm specified by the type. """ - def __init__(self, - realm: str, - user_id: str, - *, - name: str = None) -> None: + def __init__(self, realm: str, user_id: str, *, name: str = None) -> None: """ Initialize a User object. @@ -1997,21 +1891,20 @@ class RealmEnum(str, Enum): """ the ID realm. """ + IBMID = 'IBMid' SL = 'SL' BSS = 'BSS' -class Watchlist(): +class Watchlist: """ Payload to add/remove users to/from the case watchlist. :attr List[User] watchlist: (optional) Array of user ID objects. """ - def __init__(self, - *, - watchlist: List['User'] = None) -> None: + def __init__(self, *, watchlist: List['User'] = None) -> None: """ Initialize a Watchlist object. @@ -2057,7 +1950,8 @@ def __ne__(self, other: 'Watchlist') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class WatchlistAddResponse(): + +class WatchlistAddResponse: """ Response of a request when adding to watchlist. @@ -2065,10 +1959,7 @@ class WatchlistAddResponse(): :attr List[User] failed: (optional) List of failed to add user. """ - def __init__(self, - *, - added: List['User'] = None, - failed: List['User'] = None) -> None: + def __init__(self, *, added: List['User'] = None, failed: List['User'] = None) -> None: """ Initialize a WatchlistAddResponse object. @@ -2120,6 +2011,7 @@ def __ne__(self, other: 'WatchlistAddResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class AcceptPayload(StatusPayload): """ Payload to accept the proposed resolution of the case. @@ -2128,10 +2020,7 @@ class AcceptPayload(StatusPayload): :attr str comment: (optional) Comment about accepting the proposed resolution. """ - def __init__(self, - action: str, - *, - comment: str = None) -> None: + def __init__(self, action: str, *, comment: str = None) -> None: """ Initialize a AcceptPayload object. @@ -2191,6 +2080,7 @@ class ActionEnum(str, Enum): """ action to perform on the case. """ + RESOLVE = 'resolve' UNRESOLVE = 'unresolve' ACCEPT = 'accept' @@ -2212,11 +2102,7 @@ class ResolvePayload(StatusPayload): * 8: Solution provided by IBM support engineer. """ - def __init__(self, - action: str, - resolution_code: int, - *, - comment: str = None) -> None: + def __init__(self, action: str, resolution_code: int, *, comment: str = None) -> None: """ Initialize a ResolvePayload object. @@ -2290,6 +2176,7 @@ class ActionEnum(str, Enum): """ action to perform on the case. """ + RESOLVE = 'resolve' UNRESOLVE = 'unresolve' ACCEPT = 'accept' @@ -2303,9 +2190,7 @@ class UnresolvePayload(StatusPayload): :attr str comment: Comment why the case should be unresolved. """ - def __init__(self, - action: str, - comment: str) -> None: + def __init__(self, action: str, comment: str) -> None: """ Initialize a UnresolvePayload object. @@ -2366,12 +2251,13 @@ class ActionEnum(str, Enum): """ action to perform on the case. """ + RESOLVE = 'resolve' UNRESOLVE = 'unresolve' ACCEPT = 'accept' -class FileWithMetadata(): +class FileWithMetadata: """ A file with its associated metadata. @@ -2380,11 +2266,7 @@ class FileWithMetadata(): :attr str content_type: (optional) The content type of the file. """ - def __init__(self, - data: BinaryIO, - *, - filename: str = None, - content_type: str = None) -> None: + def __init__(self, data: BinaryIO, *, filename: str = None, content_type: str = None) -> None: """ Initialize a FileWithMetadata object. @@ -2444,23 +2326,26 @@ def __ne__(self, other: 'FileWithMetadata') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + ############################################################################## # Pagers ############################################################################## -class GetCasesPager(): + +class GetCasesPager: """ GetCasesPager can be used to simplify the use of the "get_cases" method. """ - def __init__(self, - *, - client: CaseManagementV1, - limit: int = None, - search: str = None, - sort: str = None, - status: List[str] = None, - fields: List[str] = None, + def __init__( + self, + *, + client: CaseManagementV1, + limit: int = None, + search: str = None, + sort: str = None, + status: List[str] = None, + fields: List[str] = None, ) -> None: """ Initialize a GetCasesPager object. @@ -2474,7 +2359,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._limit = limit self._search = search self._sort = sort diff --git a/ibm_platform_services/catalog_management_v1.py b/ibm_platform_services/catalog_management_v1.py index 1c84940c..a26a6c38 100644 --- a/ibm_platform_services/catalog_management_v1.py +++ b/ibm_platform_services/catalog_management_v1.py @@ -41,6 +41,7 @@ # Service ############################################################################## + class CatalogManagementV1(BaseService): """The Catalog Management V1 service.""" @@ -48,23 +49,23 @@ class CatalogManagementV1(BaseService): DEFAULT_SERVICE_NAME = 'catalog_management' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'CatalogManagementV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'CatalogManagementV1': """ Return a new client for the Catalog Management service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Catalog Management service. @@ -72,19 +73,13 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Account ######################### - - def get_catalog_account(self, - **kwargs - ) -> DetailedResponse: + def get_catalog_account(self, **kwargs) -> DetailedResponse: """ Get catalog account settings. @@ -96,9 +91,9 @@ def get_catalog_account(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog_account') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog_account' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -106,20 +101,13 @@ def get_catalog_account(self, headers['Accept'] = 'application/json' url = '/catalogaccount' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_catalog_account(self, - *, - id: str = None, - hide_ibm_cloud_catalog: bool = None, - account_filters: 'Filters' = None, - **kwargs + def update_catalog_account( + self, *, id: str = None, hide_ibm_cloud_catalog: bool = None, account_filters: 'Filters' = None, **kwargs ) -> DetailedResponse: """ Update account settings. @@ -139,16 +127,12 @@ def update_catalog_account(self, if account_filters is not None: account_filters = convert_model(account_filters) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_catalog_account') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_catalog_account' + ) headers.update(sdk_headers) - data = { - 'id': id, - 'hide_IBM_cloud_catalog': hide_ibm_cloud_catalog, - 'account_filters': account_filters - } + data = {'id': id, 'hide_IBM_cloud_catalog': hide_ibm_cloud_catalog, 'account_filters': account_filters} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -157,18 +141,12 @@ def update_catalog_account(self, headers.update(kwargs.get('headers')) url = '/catalogaccount' - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_catalog_account_audit(self, - **kwargs - ) -> DetailedResponse: + def get_catalog_account_audit(self, **kwargs) -> DetailedResponse: """ Get catalog account audit log. @@ -180,9 +158,9 @@ def get_catalog_account_audit(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog_account_audit') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog_account_audit' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -190,19 +168,12 @@ def get_catalog_account_audit(self, headers['Accept'] = 'application/json' url = '/catalogaccount/audit' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_catalog_account_filters(self, - *, - catalog: str = None, - **kwargs - ) -> DetailedResponse: + def get_catalog_account_filters(self, *, catalog: str = None, **kwargs) -> DetailedResponse: """ Get catalog account filters. @@ -216,24 +187,19 @@ def get_catalog_account_filters(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog_account_filters') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog_account_filters' + ) headers.update(sdk_headers) - params = { - 'catalog': catalog - } + params = {'catalog': catalog} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/catalogaccount/filters' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -242,10 +208,7 @@ def get_catalog_account_filters(self, # Catalogs ######################### - - def list_catalogs(self, - **kwargs - ) -> DetailedResponse: + def list_catalogs(self, **kwargs) -> DetailedResponse: """ Get list of catalogs. @@ -258,9 +221,9 @@ def list_catalogs(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_catalogs') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_catalogs' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -268,15 +231,13 @@ def list_catalogs(self, headers['Accept'] = 'application/json' url = '/catalogs' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def create_catalog(self, + def create_catalog( + self, *, id: str = None, rev: str = None, @@ -331,9 +292,9 @@ def create_catalog(self, if syndication_settings is not None: syndication_settings = convert_model(syndication_settings) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_catalog') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_catalog' + ) headers.update(sdk_headers) data = { @@ -349,7 +310,7 @@ def create_catalog(self, 'owning_account': owning_account, 'catalog_filters': catalog_filters, 'syndication_settings': syndication_settings, - 'kind': kind + 'kind': kind, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -360,19 +321,12 @@ def create_catalog(self, headers['Accept'] = 'application/json' url = '/catalogs' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_catalog(self, - catalog_identifier: str, - **kwargs - ) -> DetailedResponse: + def get_catalog(self, catalog_identifier: str, **kwargs) -> DetailedResponse: """ Get catalog. @@ -388,9 +342,9 @@ def get_catalog(self, if catalog_identifier is None: raise ValueError('catalog_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -401,15 +355,13 @@ def get_catalog(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_catalog(self, + def replace_catalog( + self, catalog_identifier: str, *, id: str = None, @@ -468,9 +420,9 @@ def replace_catalog(self, if syndication_settings is not None: syndication_settings = convert_model(syndication_settings) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_catalog') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_catalog' + ) headers.update(sdk_headers) data = { @@ -486,7 +438,7 @@ def replace_catalog(self, 'owning_account': owning_account, 'catalog_filters': catalog_filters, 'syndication_settings': syndication_settings, - 'kind': kind + 'kind': kind, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -500,19 +452,12 @@ def replace_catalog(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_catalog(self, - catalog_identifier: str, - **kwargs - ) -> DetailedResponse: + def delete_catalog(self, catalog_identifier: str, **kwargs) -> DetailedResponse: """ Delete catalog. @@ -527,9 +472,9 @@ def delete_catalog(self, if catalog_identifier is None: raise ValueError('catalog_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_catalog') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_catalog' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -539,18 +484,12 @@ def delete_catalog(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_catalog_audit(self, - catalog_identifier: str, - **kwargs - ) -> DetailedResponse: + def get_catalog_audit(self, catalog_identifier: str, **kwargs) -> DetailedResponse: """ Get catalog audit log. @@ -565,9 +504,9 @@ def get_catalog_audit(self, if catalog_identifier is None: raise ValueError('catalog_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog_audit') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog_audit' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -578,9 +517,7 @@ def get_catalog_audit(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/audit'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -589,8 +526,8 @@ def get_catalog_audit(self, # Offerings ######################### - - def get_consumption_offerings(self, + def get_consumption_offerings( + self, *, digest: bool = None, catalog: str = None, @@ -629,9 +566,9 @@ def get_consumption_offerings(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_consumption_offerings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_consumption_offerings' + ) headers.update(sdk_headers) params = { @@ -640,7 +577,7 @@ def get_consumption_offerings(self, 'select': select, 'includeHidden': include_hidden, 'limit': limit, - 'offset': offset + 'offset': offset, } if 'headers' in kwargs: @@ -648,16 +585,13 @@ def get_consumption_offerings(self, headers['Accept'] = 'application/json' url = '/offerings' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def list_offerings(self, + def list_offerings( + self, catalog_identifier: str, *, digest: bool = None, @@ -695,18 +629,12 @@ def list_offerings(self, if catalog_identifier is None: raise ValueError('catalog_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_offerings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_offerings' + ) headers.update(sdk_headers) - params = { - 'digest': digest, - 'limit': limit, - 'offset': offset, - 'name': name, - 'sort': sort - } + params = {'digest': digest, 'limit': limit, 'offset': offset, 'name': name, 'sort': sort} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -716,16 +644,13 @@ def list_offerings(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_offering(self, + def create_offering( + self, catalog_identifier: str, *, id: str = None, @@ -853,9 +778,9 @@ def create_offering(self, if media is not None: media = [convert_model(x) for x in media] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_offering' + ) headers.update(sdk_headers) data = { @@ -893,7 +818,7 @@ def create_offering(self, 'provider_info': provider_info, 'repo_info': repo_info, 'support': support, - 'media': media + 'media': media, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -907,16 +832,13 @@ def create_offering(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def import_offering_version(self, + def import_offering_version( + self, catalog_identifier: str, offering_id: str, *, @@ -964,9 +886,9 @@ def import_offering_version(self, if content is not None: content = str(base64.b64encode(content), 'utf-8') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='import_offering_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='import_offering_version' + ) headers.update(sdk_headers) params = { @@ -974,14 +896,10 @@ def import_offering_version(self, 'targetVersion': target_version, 'includeConfig': include_config, 'isVSI': is_vsi, - 'repoType': repo_type + 'repoType': repo_type, } - data = { - 'tags': tags, - 'target_kinds': target_kinds, - 'content': content - } + data = {'tags': tags, 'target_kinds': target_kinds, 'content': content} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -994,17 +912,13 @@ def import_offering_version(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/version'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response - - def import_offering(self, + def import_offering( + self, catalog_identifier: str, *, tags: List[str] = None, @@ -1053,12 +967,10 @@ def import_offering(self, raise ValueError('catalog_identifier must be provided') if content is not None: content = str(base64.b64encode(content), 'utf-8') - headers = { - 'X-Auth-Token': x_auth_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='import_offering') + headers = {'X-Auth-Token': x_auth_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='import_offering' + ) headers.update(sdk_headers) params = { @@ -1067,14 +979,10 @@ def import_offering(self, 'targetVersion': target_version, 'includeConfig': include_config, 'isVSI': is_vsi, - 'repoType': repo_type + 'repoType': repo_type, } - data = { - 'tags': tags, - 'target_kinds': target_kinds, - 'content': content - } + data = {'tags': tags, 'target_kinds': target_kinds, 'content': content} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1087,17 +995,13 @@ def import_offering(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/import/offerings'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response - - def reload_offering(self, + def reload_offering( + self, catalog_identifier: str, offering_id: str, target_version: str, @@ -1140,22 +1044,14 @@ def reload_offering(self, if content is not None: content = str(base64.b64encode(content), 'utf-8') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='reload_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='reload_offering' + ) headers.update(sdk_headers) - params = { - 'targetVersion': target_version, - 'zipurl': zipurl, - 'repoType': repo_type - } + params = {'targetVersion': target_version, 'zipurl': zipurl, 'repoType': repo_type} - data = { - 'tags': tags, - 'target_kinds': target_kinds, - 'content': content - } + data = {'tags': tags, 'target_kinds': target_kinds, 'content': content} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1168,23 +1064,13 @@ def reload_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/reload'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response - - def get_offering(self, - catalog_identifier: str, - offering_id: str, - *, - type: str = None, - digest: bool = None, - **kwargs + def get_offering( + self, catalog_identifier: str, offering_id: str, *, type: str = None, digest: bool = None, **kwargs ) -> DetailedResponse: """ Get offering. @@ -1208,15 +1094,12 @@ def get_offering(self, if offering_id is None: raise ValueError('offering_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering' + ) headers.update(sdk_headers) - params = { - 'type': type, - 'digest': digest - } + params = {'type': type, 'digest': digest} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1226,16 +1109,13 @@ def get_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def replace_offering(self, + def replace_offering( + self, catalog_identifier: str, offering_id: str, *, @@ -1367,9 +1247,9 @@ def replace_offering(self, if media is not None: media = [convert_model(x) for x in media] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_offering' + ) headers.update(sdk_headers) data = { @@ -1407,7 +1287,7 @@ def replace_offering(self, 'provider_info': provider_info, 'repo_info': repo_info, 'support': support, - 'media': media + 'media': media, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1421,16 +1301,13 @@ def replace_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def update_offering(self, + def update_offering( + self, catalog_identifier: str, offering_id: str, if_match: str, @@ -1460,12 +1337,10 @@ def update_offering(self, raise ValueError('if_match must be provided') if updates is not None: updates = [convert_model(x) for x in updates] - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_offering') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_offering' + ) headers.update(sdk_headers) data = json.dumps(updates) @@ -1479,20 +1354,12 @@ def update_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_offering(self, - catalog_identifier: str, - offering_id: str, - **kwargs - ) -> DetailedResponse: + def delete_offering(self, catalog_identifier: str, offering_id: str, **kwargs) -> DetailedResponse: """ Delete offering. @@ -1510,9 +1377,9 @@ def delete_offering(self, if offering_id is None: raise ValueError('offering_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_offering' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1522,19 +1389,12 @@ def delete_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_offering_audit(self, - catalog_identifier: str, - offering_id: str, - **kwargs - ) -> DetailedResponse: + def get_offering_audit(self, catalog_identifier: str, offering_id: str, **kwargs) -> DetailedResponse: """ Get offering audit log. @@ -1552,9 +1412,9 @@ def get_offering_audit(self, if offering_id is None: raise ValueError('offering_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_audit') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_audit' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1565,19 +1425,13 @@ def get_offering_audit(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/audit'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_offering_icon(self, - catalog_identifier: str, - offering_id: str, - file_name: str, - **kwargs + def replace_offering_icon( + self, catalog_identifier: str, offering_id: str, file_name: str, **kwargs ) -> DetailedResponse: """ Upload icon for offering. @@ -1600,9 +1454,9 @@ def replace_offering_icon(self, if file_name is None: raise ValueError('file_name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_offering_icon') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_offering_icon' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1613,20 +1467,13 @@ def replace_offering_icon(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id, file_name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/icon/{file_name}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers) + request = self.prepare_request(method='PUT', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_offering_ibm(self, - catalog_identifier: str, - offering_id: str, - approval_type: str, - approved: str, - **kwargs + def update_offering_ibm( + self, catalog_identifier: str, offering_id: str, approval_type: str, approved: str, **kwargs ) -> DetailedResponse: """ Allow offering to be published. @@ -1662,9 +1509,9 @@ def update_offering_ibm(self, if approved is None: raise ValueError('approved must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_offering_ibm') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_offering_ibm' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1674,16 +1521,16 @@ def update_offering_ibm(self, path_param_keys = ['catalog_identifier', 'offering_id', 'approval_type', 'approved'] path_param_values = self.encode_path_vars(catalog_identifier, offering_id, approval_type, approved) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/publish/{approval_type}/{approved}'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/publish/{approval_type}/{approved}'.format( + **path_param_dict + ) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def deprecate_offering(self, + def deprecate_offering( + self, catalog_identifier: str, offering_id: str, setting: str, @@ -1716,15 +1563,12 @@ def deprecate_offering(self, if setting is None: raise ValueError('setting must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='deprecate_offering') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='deprecate_offering' + ) headers.update(sdk_headers) - data = { - 'description': description, - 'days_until_deprecate': days_until_deprecate - } + data = {'description': description, 'days_until_deprecate': days_until_deprecate} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1736,16 +1580,13 @@ def deprecate_offering(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id, setting) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/deprecate/{setting}'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_offering_updates(self, + def get_offering_updates( + self, catalog_identifier: str, offering_id: str, kind: str, @@ -1805,12 +1646,10 @@ def get_offering_updates(self, raise ValueError('kind must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_updates') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_updates' + ) headers.update(sdk_headers) params = { @@ -1824,7 +1663,7 @@ def get_offering_updates(self, 'sha': sha, 'channel': channel, 'namespaces': convert_list(namespaces), - 'all_namespaces': all_namespaces + 'all_namespaces': all_namespaces, } if 'headers' in kwargs: @@ -1835,16 +1674,13 @@ def get_offering_updates(self, path_param_values = self.encode_path_vars(catalog_identifier, offering_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/offerings/{offering_id}/updates'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_offering_source(self, + def get_offering_source( + self, version: str, *, accept: str = None, @@ -1880,31 +1716,19 @@ def get_offering_source(self, if version is None: raise ValueError('version must be provided') - headers = { - 'Accept': accept - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_source') + headers = {'Accept': accept} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_source' + ) headers.update(sdk_headers) - params = { - 'version': version, - 'catalogID': catalog_id, - 'name': name, - 'id': id, - 'kind': kind, - 'channel': channel - } + params = {'version': version, 'catalogID': catalog_id, 'name': name, 'id': id, 'kind': kind, 'channel': channel} if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/offering/source' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -1913,11 +1737,7 @@ def get_offering_source(self, # Versions ######################### - - def get_offering_about(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def get_offering_about(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Get version about information. @@ -1932,9 +1752,9 @@ def get_offering_about(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_about') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_about' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1945,19 +1765,12 @@ def get_offering_about(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/about'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_offering_license(self, - version_loc_id: str, - license_id: str, - **kwargs - ) -> DetailedResponse: + def get_offering_license(self, version_loc_id: str, license_id: str, **kwargs) -> DetailedResponse: """ Get version license content. @@ -1976,9 +1789,9 @@ def get_offering_license(self, if license_id is None: raise ValueError('license_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_license') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_license' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1989,18 +1802,12 @@ def get_offering_license(self, path_param_values = self.encode_path_vars(version_loc_id, license_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/licenses/{license_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_offering_container_images(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def get_offering_container_images(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Get version's container images. @@ -2017,9 +1824,9 @@ def get_offering_container_images(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_container_images') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_container_images' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2030,18 +1837,12 @@ def get_offering_container_images(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/containerImages'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def deprecate_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def deprecate_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Deprecate version immediately. @@ -2056,9 +1857,9 @@ def deprecate_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='deprecate_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='deprecate_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2068,21 +1869,13 @@ def deprecate_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/deprecate'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def set_deprecate_version(self, - version_loc_id: str, - setting: str, - *, - description: str = None, - days_until_deprecate: int = None, - **kwargs + def set_deprecate_version( + self, version_loc_id: str, setting: str, *, description: str = None, days_until_deprecate: int = None, **kwargs ) -> DetailedResponse: """ Sets version to be deprecated in a certain time period. @@ -2105,15 +1898,12 @@ def set_deprecate_version(self, if setting is None: raise ValueError('setting must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='set_deprecate_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='set_deprecate_version' + ) headers.update(sdk_headers) - data = { - 'description': description, - 'days_until_deprecate': days_until_deprecate - } + data = {'description': description, 'days_until_deprecate': days_until_deprecate} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -2125,19 +1915,12 @@ def set_deprecate_version(self, path_param_values = self.encode_path_vars(version_loc_id, setting) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/deprecate/{setting}'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def account_publish_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def account_publish_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Publish version to account members. @@ -2152,9 +1935,9 @@ def account_publish_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='account_publish_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='account_publish_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2164,18 +1947,12 @@ def account_publish_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/account-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def ibm_publish_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def ibm_publish_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Publish version to IBMers in public catalog. @@ -2191,9 +1968,9 @@ def ibm_publish_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='ibm_publish_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='ibm_publish_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2203,18 +1980,12 @@ def ibm_publish_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/ibm-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def public_publish_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def public_publish_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Publish version to all users in public catalog. @@ -2229,9 +2000,9 @@ def public_publish_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='public_publish_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='public_publish_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2241,18 +2012,12 @@ def public_publish_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/public-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def commit_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def commit_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Commit version. @@ -2267,9 +2032,9 @@ def commit_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='commit_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='commit_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2279,15 +2044,13 @@ def commit_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/commit'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def copy_version(self, + def copy_version( + self, version_loc_id: str, *, tags: List[str] = None, @@ -2316,16 +2079,12 @@ def copy_version(self, if content is not None: content = str(base64.b64encode(content), 'utf-8') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='copy_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='copy_version' + ) headers.update(sdk_headers) - data = { - 'tags': tags, - 'target_kinds': target_kinds, - 'content': content - } + data = {'tags': tags, 'target_kinds': target_kinds, 'content': content} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -2337,19 +2096,12 @@ def copy_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/copy'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_offering_working_copy(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def get_offering_working_copy(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Create working copy of version. @@ -2364,9 +2116,9 @@ def get_offering_working_copy(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_working_copy') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_working_copy' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2377,18 +2129,12 @@ def get_offering_working_copy(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/workingcopy'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def get_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Get offering/kind/version 'branch'. @@ -2403,9 +2149,9 @@ def get_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2416,18 +2162,12 @@ def get_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_version(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def delete_version(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Delete version. @@ -2443,9 +2183,9 @@ def delete_version(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_version') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_version' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -2455,9 +2195,7 @@ def delete_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -2466,13 +2204,7 @@ def delete_version(self, # Deploy ######################### - - def get_cluster(self, - cluster_id: str, - region: str, - x_auth_refresh_token: str, - **kwargs - ) -> DetailedResponse: + def get_cluster(self, cluster_id: str, region: str, x_auth_refresh_token: str, **kwargs) -> DetailedResponse: """ Get kubernetes cluster. @@ -2492,17 +2224,13 @@ def get_cluster(self, raise ValueError('region must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_cluster') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_cluster' + ) headers.update(sdk_headers) - params = { - 'region': region - } + params = {'region': region} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -2512,16 +2240,13 @@ def get_cluster(self, path_param_values = self.encode_path_vars(cluster_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/deploy/kubernetes/clusters/{cluster_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_namespaces(self, + def get_namespaces( + self, cluster_id: str, region: str, x_auth_refresh_token: str, @@ -2552,19 +2277,13 @@ def get_namespaces(self, raise ValueError('region must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_namespaces') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_namespaces' + ) headers.update(sdk_headers) - params = { - 'region': region, - 'limit': limit, - 'offset': offset - } + params = {'region': region, 'limit': limit, 'offset': offset} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -2574,16 +2293,13 @@ def get_namespaces(self, path_param_values = self.encode_path_vars(cluster_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/deploy/kubernetes/clusters/{cluster_id}/namespaces'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def deploy_operators(self, + def deploy_operators( + self, x_auth_refresh_token: str, *, cluster_id: str = None, @@ -2614,12 +2330,10 @@ def deploy_operators(self, if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='deploy_operators') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='deploy_operators' + ) headers.update(sdk_headers) data = { @@ -2627,7 +2341,7 @@ def deploy_operators(self, 'region': region, 'namespaces': namespaces, 'all_namespaces': all_namespaces, - 'version_locator_id': version_locator_id + 'version_locator_id': version_locator_id, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -2638,21 +2352,13 @@ def deploy_operators(self, headers['Accept'] = 'application/json' url = '/deploy/kubernetes/olm/operator' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_operators(self, - x_auth_refresh_token: str, - cluster_id: str, - region: str, - version_locator_id: str, - **kwargs + def list_operators( + self, x_auth_refresh_token: str, cluster_id: str, region: str, version_locator_id: str, **kwargs ) -> DetailedResponse: """ List operators. @@ -2676,35 +2382,26 @@ def list_operators(self, raise ValueError('region must be provided') if version_locator_id is None: raise ValueError('version_locator_id must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_operators') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_operators' + ) headers.update(sdk_headers) - params = { - 'cluster_id': cluster_id, - 'region': region, - 'version_locator_id': version_locator_id - } + params = {'cluster_id': cluster_id, 'region': region, 'version_locator_id': version_locator_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/deploy/kubernetes/olm/operator' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def replace_operators(self, + def replace_operators( + self, x_auth_refresh_token: str, *, cluster_id: str = None, @@ -2735,12 +2432,10 @@ def replace_operators(self, if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_operators') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_operators' + ) headers.update(sdk_headers) data = { @@ -2748,7 +2443,7 @@ def replace_operators(self, 'region': region, 'namespaces': namespaces, 'all_namespaces': all_namespaces, - 'version_locator_id': version_locator_id + 'version_locator_id': version_locator_id, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -2759,21 +2454,13 @@ def replace_operators(self, headers['Accept'] = 'application/json' url = '/deploy/kubernetes/olm/operator' - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_operators(self, - x_auth_refresh_token: str, - cluster_id: str, - region: str, - version_locator_id: str, - **kwargs + def delete_operators( + self, x_auth_refresh_token: str, cluster_id: str, region: str, version_locator_id: str, **kwargs ) -> DetailedResponse: """ Delete operators. @@ -2797,34 +2484,25 @@ def delete_operators(self, raise ValueError('region must be provided') if version_locator_id is None: raise ValueError('version_locator_id must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_operators') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_operators' + ) headers.update(sdk_headers) - params = { - 'cluster_id': cluster_id, - 'region': region, - 'version_locator_id': version_locator_id - } + params = {'cluster_id': cluster_id, 'region': region, 'version_locator_id': version_locator_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) url = '/deploy/kubernetes/olm/operator' - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def install_version(self, + def install_version( + self, version_loc_id: str, x_auth_refresh_token: str, *, @@ -2882,12 +2560,10 @@ def install_version(self, raise ValueError('x_auth_refresh_token must be provided') if schematics is not None: schematics = convert_model(schematics) - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='install_version') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='install_version' + ) headers.update(sdk_headers) data = { @@ -2904,7 +2580,7 @@ def install_version(self, 'vcenter_user': vcenter_user, 'vcenter_password': vcenter_password, 'vcenter_location': vcenter_location, - 'vcenter_datastore': vcenter_datastore + 'vcenter_datastore': vcenter_datastore, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -2917,16 +2593,13 @@ def install_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/install'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def preinstall_version(self, + def preinstall_version( + self, version_loc_id: str, x_auth_refresh_token: str, *, @@ -2984,12 +2657,10 @@ def preinstall_version(self, raise ValueError('x_auth_refresh_token must be provided') if schematics is not None: schematics = convert_model(schematics) - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='preinstall_version') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='preinstall_version' + ) headers.update(sdk_headers) data = { @@ -3006,7 +2677,7 @@ def preinstall_version(self, 'vcenter_user': vcenter_user, 'vcenter_password': vcenter_password, 'vcenter_location': vcenter_location, - 'vcenter_datastore': vcenter_datastore + 'vcenter_datastore': vcenter_datastore, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -3019,16 +2690,13 @@ def preinstall_version(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/preinstall'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_preinstall(self, + def get_preinstall( + self, version_loc_id: str, x_auth_refresh_token: str, *, @@ -3057,19 +2725,13 @@ def get_preinstall(self, raise ValueError('version_loc_id must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_preinstall') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_preinstall' + ) headers.update(sdk_headers) - params = { - 'cluster_id': cluster_id, - 'region': region, - 'namespace': namespace - } + params = {'cluster_id': cluster_id, 'region': region, 'namespace': namespace} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -3079,16 +2741,13 @@ def get_preinstall(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/preinstall'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def validate_install(self, + def validate_install( + self, version_loc_id: str, x_auth_refresh_token: str, *, @@ -3146,12 +2805,10 @@ def validate_install(self, raise ValueError('x_auth_refresh_token must be provided') if schematics is not None: schematics = convert_model(schematics) - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='validate_install') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='validate_install' + ) headers.update(sdk_headers) data = { @@ -3168,7 +2825,7 @@ def validate_install(self, 'vcenter_user': vcenter_user, 'vcenter_password': vcenter_password, 'vcenter_location': vcenter_location, - 'vcenter_datastore': vcenter_datastore + 'vcenter_datastore': vcenter_datastore, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -3181,20 +2838,12 @@ def validate_install(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/validation/install'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_validation_status(self, - version_loc_id: str, - x_auth_refresh_token: str, - **kwargs - ) -> DetailedResponse: + def get_validation_status(self, version_loc_id: str, x_auth_refresh_token: str, **kwargs) -> DetailedResponse: """ Get offering install status. @@ -3211,12 +2860,10 @@ def get_validation_status(self, raise ValueError('version_loc_id must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_validation_status') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_validation_status' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3227,18 +2874,12 @@ def get_validation_status(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/validation/install'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_override_values(self, - version_loc_id: str, - **kwargs - ) -> DetailedResponse: + def get_override_values(self, version_loc_id: str, **kwargs) -> DetailedResponse: """ Get override values. @@ -3254,9 +2895,9 @@ def get_override_values(self, if version_loc_id is None: raise ValueError('version_loc_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_override_values') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_override_values' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3267,9 +2908,7 @@ def get_override_values(self, path_param_values = self.encode_path_vars(version_loc_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/versions/{version_loc_id}/validation/overridevalues'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -3278,15 +2917,8 @@ def get_override_values(self, # Objects ######################### - - def search_objects(self, - query: str, - *, - limit: int = None, - offset: int = None, - collapse: bool = None, - digest: bool = None, - **kwargs + def search_objects( + self, query: str, *, limit: int = None, offset: int = None, collapse: bool = None, digest: bool = None, **kwargs ) -> DetailedResponse: """ List objects across catalogs. @@ -3311,34 +2943,25 @@ def search_objects(self, if query is None: raise ValueError('query must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='search_objects') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='search_objects' + ) headers.update(sdk_headers) - params = { - 'query': query, - 'limit': limit, - 'offset': offset, - 'collapse': collapse, - 'digest': digest - } + params = {'query': query, 'limit': limit, 'offset': offset, 'collapse': collapse, 'digest': digest} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/objects' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def list_objects(self, + def list_objects( + self, catalog_identifier: str, *, limit: int = None, @@ -3371,17 +2994,12 @@ def list_objects(self, if catalog_identifier is None: raise ValueError('catalog_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_objects') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_objects' + ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'offset': offset, - 'name': name, - 'sort': sort - } + params = {'limit': limit, 'offset': offset, 'name': name, 'sort': sort} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -3391,16 +3009,13 @@ def list_objects(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_object(self, + def create_object( + self, catalog_identifier: str, *, id: str = None, @@ -3472,9 +3087,9 @@ def create_object(self, if state is not None: state = convert_model(state) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_object' + ) headers.update(sdk_headers) data = { @@ -3496,7 +3111,7 @@ def create_object(self, 'state': state, 'catalog_id': catalog_id, 'catalog_name': catalog_name, - 'data': data + 'data': data, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -3510,20 +3125,12 @@ def create_object(self, path_param_values = self.encode_path_vars(catalog_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def get_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Get catalog object. @@ -3541,9 +3148,9 @@ def get_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3554,15 +3161,13 @@ def get_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_object(self, + def replace_object( + self, catalog_identifier: str, object_identifier: str, *, @@ -3638,9 +3243,9 @@ def replace_object(self, if state is not None: state = convert_model(state) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_object' + ) headers.update(sdk_headers) data = { @@ -3662,7 +3267,7 @@ def replace_object(self, 'state': state, 'catalog_id': catalog_id, 'catalog_name': catalog_name, - 'data': data + 'data': data, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -3676,20 +3281,12 @@ def replace_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def delete_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Delete catalog object. @@ -3707,9 +3304,9 @@ def delete_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3719,19 +3316,12 @@ def delete_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_object_audit(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def get_object_audit(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Get catalog object audit log. @@ -3749,9 +3339,9 @@ def get_object_audit(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_object_audit') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_object_audit' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3762,19 +3352,12 @@ def get_object_audit(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/audit'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def account_publish_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def account_publish_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Publish object to account. @@ -3792,9 +3375,9 @@ def account_publish_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='account_publish_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='account_publish_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3804,19 +3387,12 @@ def account_publish_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/account-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def shared_publish_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def shared_publish_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Publish object to share with allow list. @@ -3834,9 +3410,9 @@ def shared_publish_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='shared_publish_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='shared_publish_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3846,19 +3422,12 @@ def shared_publish_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/shared-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def ibm_publish_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def ibm_publish_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Publish object to share with IBMers. @@ -3877,9 +3446,9 @@ def ibm_publish_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='ibm_publish_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='ibm_publish_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3889,19 +3458,12 @@ def ibm_publish_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/ibm-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def public_publish_object(self, - catalog_identifier: str, - object_identifier: str, - **kwargs - ) -> DetailedResponse: + def public_publish_object(self, catalog_identifier: str, object_identifier: str, **kwargs) -> DetailedResponse: """ Publish object to share with all users. @@ -3919,9 +3481,9 @@ def public_publish_object(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='public_publish_object') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='public_publish_object' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3931,19 +3493,13 @@ def public_publish_object(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/public-publish'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def create_object_access(self, - catalog_identifier: str, - object_identifier: str, - account_identifier: str, - **kwargs + def create_object_access( + self, catalog_identifier: str, object_identifier: str, account_identifier: str, **kwargs ) -> DetailedResponse: """ Add account ID to object access list. @@ -3965,9 +3521,9 @@ def create_object_access(self, if account_identifier is None: raise ValueError('account_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_object_access') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_object_access' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -3976,20 +3532,16 @@ def create_object_access(self, path_param_keys = ['catalog_identifier', 'object_identifier', 'account_identifier'] path_param_values = self.encode_path_vars(catalog_identifier, object_identifier, account_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format( + **path_param_dict + ) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_object_access(self, - catalog_identifier: str, - object_identifier: str, - account_identifier: str, - **kwargs + def get_object_access( + self, catalog_identifier: str, object_identifier: str, account_identifier: str, **kwargs ) -> DetailedResponse: """ Check for account ID in object access list. @@ -4011,9 +3563,9 @@ def get_object_access(self, if account_identifier is None: raise ValueError('account_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_object_access') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_object_access' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -4023,20 +3575,16 @@ def get_object_access(self, path_param_keys = ['catalog_identifier', 'object_identifier', 'account_identifier'] path_param_values = self.encode_path_vars(catalog_identifier, object_identifier, account_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format( + **path_param_dict + ) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_object_access(self, - catalog_identifier: str, - object_identifier: str, - account_identifier: str, - **kwargs + def delete_object_access( + self, catalog_identifier: str, object_identifier: str, account_identifier: str, **kwargs ) -> DetailedResponse: """ Remove account ID from object access list. @@ -4058,9 +3606,9 @@ def delete_object_access(self, if account_identifier is None: raise ValueError('account_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_object_access') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_object_access' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -4069,22 +3617,16 @@ def delete_object_access(self, path_param_keys = ['catalog_identifier', 'object_identifier', 'account_identifier'] path_param_values = self.encode_path_vars(catalog_identifier, object_identifier, account_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access/{account_identifier}'.format( + **path_param_dict + ) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_object_access_list(self, - catalog_identifier: str, - object_identifier: str, - *, - limit: int = None, - offset: int = None, - **kwargs + def get_object_access_list( + self, catalog_identifier: str, object_identifier: str, *, limit: int = None, offset: int = None, **kwargs ) -> DetailedResponse: """ Get object access list. @@ -4106,15 +3648,12 @@ def get_object_access_list(self, if object_identifier is None: raise ValueError('object_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_object_access_list') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_object_access_list' + ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'offset': offset - } + params = {'limit': limit, 'offset': offset} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -4124,20 +3663,13 @@ def get_object_access_list(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def delete_object_access_list(self, - catalog_identifier: str, - object_identifier: str, - accounts: List[str], - **kwargs + def delete_object_access_list( + self, catalog_identifier: str, object_identifier: str, accounts: List[str], **kwargs ) -> DetailedResponse: """ Delete accounts from object access list. @@ -4160,9 +3692,9 @@ def delete_object_access_list(self, if accounts is None: raise ValueError('accounts must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_object_access_list') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_object_access_list' + ) headers.update(sdk_headers) data = json.dumps(accounts) @@ -4176,20 +3708,13 @@ def delete_object_access_list(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='DELETE', url=url, headers=headers, data=data) response = self.send(request, **kwargs) - return response - - - def add_object_access_list(self, - catalog_identifier: str, - object_identifier: str, - accounts: List[str], - **kwargs + return response + + def add_object_access_list( + self, catalog_identifier: str, object_identifier: str, accounts: List[str], **kwargs ) -> DetailedResponse: """ Add accounts to object access list. @@ -4211,9 +3736,9 @@ def add_object_access_list(self, if accounts is None: raise ValueError('accounts must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='add_object_access_list') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='add_object_access_list' + ) headers.update(sdk_headers) data = json.dumps(accounts) @@ -4227,10 +3752,7 @@ def add_object_access_list(self, path_param_values = self.encode_path_vars(catalog_identifier, object_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/catalogs/{catalog_identifier}/objects/{object_identifier}/access'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -4239,8 +3761,8 @@ def add_object_access_list(self, # Instances ######################### - - def create_offering_instance(self, + def create_offering_instance( + self, x_auth_refresh_token: str, *, id: str = None, @@ -4311,12 +3833,10 @@ def create_offering_instance(self, raise ValueError('x_auth_refresh_token must be provided') if last_operation is not None: last_operation = convert_model(last_operation) - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_offering_instance') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_offering_instance' + ) headers.update(sdk_headers) data = { @@ -4338,7 +3858,7 @@ def create_offering_instance(self, 'install_plan': install_plan, 'channel': channel, 'metadata': metadata, - 'last_operation': last_operation + 'last_operation': last_operation, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -4349,19 +3869,12 @@ def create_offering_instance(self, headers['Accept'] = 'application/json' url = '/instances/offerings' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_offering_instance(self, - instance_identifier: str, - **kwargs - ) -> DetailedResponse: + def get_offering_instance(self, instance_identifier: str, **kwargs) -> DetailedResponse: """ Get Offering Instance. @@ -4376,9 +3889,9 @@ def get_offering_instance(self, if instance_identifier is None: raise ValueError('instance_identifier must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_offering_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_offering_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -4389,15 +3902,13 @@ def get_offering_instance(self, path_param_values = self.encode_path_vars(instance_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/instances/offerings/{instance_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def put_offering_instance(self, + def put_offering_instance( + self, instance_identifier: str, x_auth_refresh_token: str, *, @@ -4472,12 +3983,10 @@ def put_offering_instance(self, raise ValueError('x_auth_refresh_token must be provided') if last_operation is not None: last_operation = convert_model(last_operation) - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='put_offering_instance') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='put_offering_instance' + ) headers.update(sdk_headers) data = { @@ -4499,7 +4008,7 @@ def put_offering_instance(self, 'install_plan': install_plan, 'channel': channel, 'metadata': metadata, - 'last_operation': last_operation + 'last_operation': last_operation, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -4513,19 +4022,13 @@ def put_offering_instance(self, path_param_values = self.encode_path_vars(instance_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/instances/offerings/{instance_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_offering_instance(self, - instance_identifier: str, - x_auth_refresh_token: str, - **kwargs + def delete_offering_instance( + self, instance_identifier: str, x_auth_refresh_token: str, **kwargs ) -> DetailedResponse: """ Delete a version instance. @@ -4543,12 +4046,10 @@ def delete_offering_instance(self, raise ValueError('instance_identifier must be provided') if x_auth_refresh_token is None: raise ValueError('x_auth_refresh_token must be provided') - headers = { - 'X-Auth-Refresh-Token': x_auth_refresh_token - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_offering_instance') + headers = {'X-Auth-Refresh-Token': x_auth_refresh_token} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_offering_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -4558,9 +4059,7 @@ def delete_offering_instance(self, path_param_values = self.encode_path_vars(instance_identifier) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/instances/offerings/{instance_identifier}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -4577,6 +4076,7 @@ class Select(str, Enum): private offerings. 'public' returns only the public offerings and 'private' returns only the private offerings. """ + ALL = 'all' PUBLIC = 'public' PRIVATE = 'private' @@ -4591,14 +4091,17 @@ class ApprovalType(str, Enum): """ Type of approval, ibm or public. """ + PC_MANAGED = 'pc_managed' ALLOW_REQUEST = 'allow_request' IBM = 'ibm' PUBLIC = 'public' + class Approved(str, Enum): """ Approve (true) or disapprove (false). """ + TRUE = 'true' FALSE = 'false' @@ -4612,6 +4115,7 @@ class Setting(str, Enum): """ Set deprecation (true) or cancel deprecation (false). """ + TRUE = 'true' FALSE = 'false' @@ -4626,6 +4130,7 @@ class Accept(str, Enum): The type of the response: application/yaml, application/json, or application/x-gzip. """ + APPLICATION_YAML = 'application/yaml' APPLICATION_JSON = 'application/json' APPLICATION_X_GZIP = 'application/x-gzip' @@ -4640,6 +4145,7 @@ class Setting(str, Enum): """ Set deprecation (true) or cancel deprecation (false). """ + TRUE = 'true' FALSE = 'false' @@ -4649,7 +4155,7 @@ class Setting(str, Enum): ############################################################################## -class AccessListBulkResponse(): +class AccessListBulkResponse: """ Access List Add/Remove result. @@ -4657,9 +4163,7 @@ class AccessListBulkResponse(): account: error. """ - def __init__(self, - *, - errors: dict = None) -> None: + def __init__(self, *, errors: dict = None) -> None: """ Initialize a AccessListBulkResponse object. @@ -4706,7 +4210,8 @@ def __ne__(self, other: 'AccessListBulkResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Account(): + +class Account: """ Account information. @@ -4717,11 +4222,9 @@ class Account(): filters. """ - def __init__(self, - *, - id: str = None, - hide_ibm_cloud_catalog: bool = None, - account_filters: 'Filters' = None) -> None: + def __init__( + self, *, id: str = None, hide_ibm_cloud_catalog: bool = None, account_filters: 'Filters' = None + ) -> None: """ Initialize a Account object. @@ -4781,7 +4284,8 @@ def __ne__(self, other: 'Account') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccumulatedFilters(): + +class AccumulatedFilters: """ The accumulated filters for an account. This will return the account filters plus a filter for each catalog the user has access to. @@ -4792,10 +4296,12 @@ class AccumulatedFilters(): filters for all of the accessible catalogs. """ - def __init__(self, - *, - account_filters: List['Filters'] = None, - catalog_filters: List['AccumulatedFiltersCatalogFiltersItem'] = None) -> None: + def __init__( + self, + *, + account_filters: List['Filters'] = None, + catalog_filters: List['AccumulatedFiltersCatalogFiltersItem'] = None + ) -> None: """ Initialize a AccumulatedFilters object. @@ -4814,7 +4320,9 @@ def from_dict(cls, _dict: Dict) -> 'AccumulatedFilters': if 'account_filters' in _dict: args['account_filters'] = [Filters.from_dict(x) for x in _dict.get('account_filters')] if 'catalog_filters' in _dict: - args['catalog_filters'] = [AccumulatedFiltersCatalogFiltersItem.from_dict(x) for x in _dict.get('catalog_filters')] + args['catalog_filters'] = [ + AccumulatedFiltersCatalogFiltersItem.from_dict(x) for x in _dict.get('catalog_filters') + ] return cls(**args) @classmethod @@ -4849,7 +4357,8 @@ def __ne__(self, other: 'AccumulatedFilters') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccumulatedFiltersCatalogFiltersItem(): + +class AccumulatedFiltersCatalogFiltersItem: """ AccumulatedFiltersCatalogFiltersItem. @@ -4858,10 +4367,9 @@ class AccumulatedFiltersCatalogFiltersItem(): :attr Filters filters: (optional) Filters for account and catalog filters. """ - def __init__(self, - *, - catalog: 'AccumulatedFiltersCatalogFiltersItemCatalog' = None, - filters: 'Filters' = None) -> None: + def __init__( + self, *, catalog: 'AccumulatedFiltersCatalogFiltersItemCatalog' = None, filters: 'Filters' = None + ) -> None: """ Initialize a AccumulatedFiltersCatalogFiltersItem object. @@ -4914,7 +4422,8 @@ def __ne__(self, other: 'AccumulatedFiltersCatalogFiltersItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccumulatedFiltersCatalogFiltersItemCatalog(): + +class AccumulatedFiltersCatalogFiltersItemCatalog: """ Filters for catalog. @@ -4922,10 +4431,7 @@ class AccumulatedFiltersCatalogFiltersItemCatalog(): :attr str name: (optional) The name of the catalog. """ - def __init__(self, - *, - id: str = None, - name: str = None) -> None: + def __init__(self, *, id: str = None, name: str = None) -> None: """ Initialize a AccumulatedFiltersCatalogFiltersItemCatalog object. @@ -4977,7 +4483,8 @@ def __ne__(self, other: 'AccumulatedFiltersCatalogFiltersItemCatalog') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApprovalResult(): + +class ApprovalResult: """ Result of approval. @@ -4987,12 +4494,9 @@ class ApprovalResult(): :attr bool changed: (optional) Denotes whether approval has changed. """ - def __init__(self, - *, - allow_request: bool = None, - ibm: bool = None, - public: bool = None, - changed: bool = None) -> None: + def __init__( + self, *, allow_request: bool = None, ibm: bool = None, public: bool = None, changed: bool = None + ) -> None: """ Initialize a ApprovalResult object. @@ -5056,16 +4560,15 @@ def __ne__(self, other: 'ApprovalResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AuditLog(): + +class AuditLog: """ A collection of audit records. :attr List[AuditRecord] list: (optional) A list of audit records. """ - def __init__(self, - *, - list: List['AuditRecord'] = None) -> None: + def __init__(self, *, list: List['AuditRecord'] = None) -> None: """ Initialize a AuditLog object. @@ -5111,7 +4614,8 @@ def __ne__(self, other: 'AuditLog') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AuditRecord(): + +class AuditRecord: """ An audit record which describes a change made to a catalog or associated resource. @@ -5126,15 +4630,17 @@ class AuditRecord(): :attr str message: (optional) A message which describes the change. """ - def __init__(self, - *, - id: str = None, - created: datetime = None, - change_type: str = None, - target_type: str = None, - target_id: str = None, - who_delegate_email: str = None, - message: str = None) -> None: + def __init__( + self, + *, + id: str = None, + created: datetime = None, + change_type: str = None, + target_type: str = None, + target_id: str = None, + who_delegate_email: str = None, + message: str = None + ) -> None: """ Initialize a AuditRecord object. @@ -5220,7 +4726,8 @@ def __ne__(self, other: 'AuditRecord') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Catalog(): + +class Catalog: """ Catalog information. @@ -5249,26 +4756,28 @@ class Catalog(): vpe. """ - def __init__(self, - *, - id: str = None, - rev: str = None, - label: str = None, - short_description: str = None, - catalog_icon_url: str = None, - tags: List[str] = None, - url: str = None, - crn: str = None, - offerings_url: str = None, - features: List['Feature'] = None, - disabled: bool = None, - created: datetime = None, - updated: datetime = None, - resource_group_id: str = None, - owning_account: str = None, - catalog_filters: 'Filters' = None, - syndication_settings: 'SyndicationResource' = None, - kind: str = None) -> None: + def __init__( + self, + *, + id: str = None, + rev: str = None, + label: str = None, + short_description: str = None, + catalog_icon_url: str = None, + tags: List[str] = None, + url: str = None, + crn: str = None, + offerings_url: str = None, + features: List['Feature'] = None, + disabled: bool = None, + created: datetime = None, + updated: datetime = None, + resource_group_id: str = None, + owning_account: str = None, + catalog_filters: 'Filters' = None, + syndication_settings: 'SyndicationResource' = None, + kind: str = None + ) -> None: """ Initialize a Catalog object. @@ -5419,7 +4928,8 @@ def __ne__(self, other: 'Catalog') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CatalogObject(): + +class CatalogObject: """ object information. @@ -5447,27 +4957,29 @@ class CatalogObject(): :attr dict data: (optional) Map of data values for this object. """ - def __init__(self, - *, - id: str = None, - name: str = None, - rev: str = None, - crn: str = None, - url: str = None, - parent_id: str = None, - label_i18n: str = None, - label: str = None, - tags: List[str] = None, - created: datetime = None, - updated: datetime = None, - short_description: str = None, - short_description_i18n: str = None, - kind: str = None, - publish: 'PublishObject' = None, - state: 'State' = None, - catalog_id: str = None, - catalog_name: str = None, - data: dict = None) -> None: + def __init__( + self, + *, + id: str = None, + name: str = None, + rev: str = None, + crn: str = None, + url: str = None, + parent_id: str = None, + label_i18n: str = None, + label: str = None, + tags: List[str] = None, + created: datetime = None, + updated: datetime = None, + short_description: str = None, + short_description_i18n: str = None, + kind: str = None, + publish: 'PublishObject' = None, + state: 'State' = None, + catalog_id: str = None, + catalog_name: str = None, + data: dict = None + ) -> None: """ Initialize a CatalogObject object. @@ -5628,7 +5140,8 @@ def __ne__(self, other: 'CatalogObject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CatalogSearchResult(): + +class CatalogSearchResult: """ Paginated catalog search result. @@ -5637,10 +5150,7 @@ class CatalogSearchResult(): :attr List[Catalog] resources: (optional) Resulting objects. """ - def __init__(self, - *, - total_count: int = None, - resources: List['Catalog'] = None) -> None: + def __init__(self, *, total_count: int = None, resources: List['Catalog'] = None) -> None: """ Initialize a CatalogSearchResult object. @@ -5693,7 +5203,8 @@ def __ne__(self, other: 'CatalogSearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CategoryFilter(): + +class CategoryFilter: """ Filter on a category. The filter will match against the values of the given category with include or exclude. @@ -5703,10 +5214,7 @@ class CategoryFilter(): :attr FilterTerms filter: (optional) Offering filter terms. """ - def __init__(self, - *, - include: bool = None, - filter: 'FilterTerms' = None) -> None: + def __init__(self, *, include: bool = None, filter: 'FilterTerms' = None) -> None: """ Initialize a CategoryFilter object. @@ -5759,7 +5267,8 @@ def __ne__(self, other: 'CategoryFilter') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ClusterInfo(): + +class ClusterInfo: """ Cluster information. @@ -5770,13 +5279,15 @@ class ClusterInfo(): :attr str region: (optional) Cluster region. """ - def __init__(self, - *, - resource_group_id: str = None, - resource_group_name: str = None, - id: str = None, - name: str = None, - region: str = None) -> None: + def __init__( + self, + *, + resource_group_id: str = None, + resource_group_name: str = None, + id: str = None, + name: str = None, + region: str = None + ) -> None: """ Initialize a ClusterInfo object. @@ -5846,7 +5357,8 @@ def __ne__(self, other: 'ClusterInfo') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Configuration(): + +class Configuration: """ Configuration description. @@ -5863,16 +5375,18 @@ class Configuration(): :attr bool hidden: (optional) Hide values. """ - def __init__(self, - *, - key: str = None, - type: str = None, - default_value: object = None, - value_constraint: str = None, - description: str = None, - required: bool = None, - options: List[object] = None, - hidden: bool = None) -> None: + def __init__( + self, + *, + key: str = None, + type: str = None, + default_value: object = None, + value_constraint: str = None, + description: str = None, + required: bool = None, + options: List[object] = None, + hidden: bool = None + ) -> None: """ Initialize a Configuration object. @@ -5963,7 +5477,8 @@ def __ne__(self, other: 'Configuration') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeployRequestBodySchematics(): + +class DeployRequestBodySchematics: """ Schematics workspace configuration. @@ -5974,12 +5489,9 @@ class DeployRequestBodySchematics(): schematics workspace. """ - def __init__(self, - *, - name: str = None, - description: str = None, - tags: List[str] = None, - resource_group_id: str = None) -> None: + def __init__( + self, *, name: str = None, description: str = None, tags: List[str] = None, resource_group_id: str = None + ) -> None: """ Initialize a DeployRequestBodySchematics object. @@ -6044,7 +5556,8 @@ def __ne__(self, other: 'DeployRequestBodySchematics') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Deployment(): + +class Deployment: """ Deployment for offering. @@ -6061,17 +5574,19 @@ class Deployment(): :attr datetime updated: (optional) the date'time this catalog was last updated. """ - def __init__(self, - *, - id: str = None, - label: str = None, - name: str = None, - short_description: str = None, - long_description: str = None, - metadata: dict = None, - tags: List[str] = None, - created: datetime = None, - updated: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + label: str = None, + name: str = None, + short_description: str = None, + long_description: str = None, + metadata: dict = None, + tags: List[str] = None, + created: datetime = None, + updated: datetime = None + ) -> None: """ Initialize a Deployment object. @@ -6169,7 +5684,8 @@ def __ne__(self, other: 'Deployment') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Feature(): + +class Feature: """ Feature information. @@ -6177,10 +5693,7 @@ class Feature(): :attr str description: (optional) Feature description. """ - def __init__(self, - *, - title: str = None, - description: str = None) -> None: + def __init__(self, *, title: str = None, description: str = None) -> None: """ Initialize a Feature object. @@ -6232,7 +5745,8 @@ def __ne__(self, other: 'Feature') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class FilterTerms(): + +class FilterTerms: """ Offering filter terms. @@ -6242,9 +5756,7 @@ class FilterTerms(): the offering is excluded. """ - def __init__(self, - *, - filter_terms: List[str] = None) -> None: + def __init__(self, *, filter_terms: List[str] = None) -> None: """ Initialize a FilterTerms object. @@ -6293,7 +5805,8 @@ def __ne__(self, other: 'FilterTerms') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Filters(): + +class Filters: """ Filters for account and catalog filters. @@ -6306,11 +5819,9 @@ class Filters(): include filter and an exclule filter. Both can be set. """ - def __init__(self, - *, - include_all: bool = None, - category_filters: dict = None, - id_filters: 'IDFilter' = None) -> None: + def __init__( + self, *, include_all: bool = None, category_filters: dict = None, id_filters: 'IDFilter' = None + ) -> None: """ Initialize a Filters object. @@ -6334,7 +5845,9 @@ def from_dict(cls, _dict: Dict) -> 'Filters': if 'include_all' in _dict: args['include_all'] = _dict.get('include_all') if 'category_filters' in _dict: - args['category_filters'] = {k : CategoryFilter.from_dict(v) for k, v in _dict.get('category_filters').items()} + args['category_filters'] = { + k: CategoryFilter.from_dict(v) for k, v in _dict.get('category_filters').items() + } if 'id_filters' in _dict: args['id_filters'] = IDFilter.from_dict(_dict.get('id_filters')) return cls(**args) @@ -6350,7 +5863,7 @@ def to_dict(self) -> Dict: if hasattr(self, 'include_all') and self.include_all is not None: _dict['include_all'] = self.include_all if hasattr(self, 'category_filters') and self.category_filters is not None: - _dict['category_filters'] = {k : v.to_dict() for k, v in self.category_filters.items()} + _dict['category_filters'] = {k: v.to_dict() for k, v in self.category_filters.items()} if hasattr(self, 'id_filters') and self.id_filters is not None: _dict['id_filters'] = self.id_filters.to_dict() return _dict @@ -6373,7 +5886,8 @@ def __ne__(self, other: 'Filters') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class IDFilter(): + +class IDFilter: """ Filter on offering ID's. There is an include filter and an exclule filter. Both can be set. @@ -6382,10 +5896,7 @@ class IDFilter(): :attr FilterTerms exclude: (optional) Offering filter terms. """ - def __init__(self, - *, - include: 'FilterTerms' = None, - exclude: 'FilterTerms' = None) -> None: + def __init__(self, *, include: 'FilterTerms' = None, exclude: 'FilterTerms' = None) -> None: """ Initialize a IDFilter object. @@ -6437,16 +5948,15 @@ def __ne__(self, other: 'IDFilter') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Image(): + +class Image: """ Image. :attr str image: (optional) Image. """ - def __init__(self, - *, - image: str = None) -> None: + def __init__(self, *, image: str = None) -> None: """ Initialize a Image object. @@ -6492,7 +6002,8 @@ def __ne__(self, other: 'Image') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ImageManifest(): + +class ImageManifest: """ Image Manifest. @@ -6500,10 +6011,7 @@ class ImageManifest(): :attr List[Image] images: (optional) List of images. """ - def __init__(self, - *, - description: str = None, - images: List['Image'] = None) -> None: + def __init__(self, *, description: str = None, images: List['Image'] = None) -> None: """ Initialize a ImageManifest object. @@ -6555,7 +6063,8 @@ def __ne__(self, other: 'ImageManifest') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstallStatus(): + +class InstallStatus: """ Installation status. @@ -6565,11 +6074,13 @@ class InstallStatus(): information. """ - def __init__(self, - *, - metadata: 'InstallStatusMetadata' = None, - release: 'InstallStatusRelease' = None, - content_mgmt: 'InstallStatusContentMgmt' = None) -> None: + def __init__( + self, + *, + metadata: 'InstallStatusMetadata' = None, + release: 'InstallStatusRelease' = None, + content_mgmt: 'InstallStatusContentMgmt' = None + ) -> None: """ Initialize a InstallStatus object. @@ -6629,7 +6140,8 @@ def __ne__(self, other: 'InstallStatus') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstallStatusContentMgmt(): + +class InstallStatusContentMgmt: """ Content management information. @@ -6637,10 +6149,7 @@ class InstallStatusContentMgmt(): :attr List[dict] errors: (optional) Errors. """ - def __init__(self, - *, - pods: List[dict] = None, - errors: List[dict] = None) -> None: + def __init__(self, *, pods: List[dict] = None, errors: List[dict] = None) -> None: """ Initialize a InstallStatusContentMgmt object. @@ -6692,7 +6201,8 @@ def __ne__(self, other: 'InstallStatusContentMgmt') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstallStatusMetadata(): + +class InstallStatusMetadata: """ Installation status metadata. @@ -6703,13 +6213,15 @@ class InstallStatusMetadata(): :attr str workspace_name: (optional) Workspace name. """ - def __init__(self, - *, - cluster_id: str = None, - region: str = None, - namespace: str = None, - workspace_id: str = None, - workspace_name: str = None) -> None: + def __init__( + self, + *, + cluster_id: str = None, + region: str = None, + namespace: str = None, + workspace_id: str = None, + workspace_name: str = None + ) -> None: """ Initialize a InstallStatusMetadata object. @@ -6779,7 +6291,8 @@ def __ne__(self, other: 'InstallStatusMetadata') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstallStatusRelease(): + +class InstallStatusRelease: """ Release information. @@ -6790,13 +6303,15 @@ class InstallStatusRelease(): :attr List[dict] errors: (optional) Kube errors. """ - def __init__(self, - *, - deployments: List[dict] = None, - replicasets: List[dict] = None, - statefulsets: List[dict] = None, - pods: List[dict] = None, - errors: List[dict] = None) -> None: + def __init__( + self, + *, + deployments: List[dict] = None, + replicasets: List[dict] = None, + statefulsets: List[dict] = None, + pods: List[dict] = None, + errors: List[dict] = None + ) -> None: """ Initialize a InstallStatusRelease object. @@ -6866,7 +6381,8 @@ def __ne__(self, other: 'InstallStatusRelease') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class JsonPatchOperation(): + +class JsonPatchOperation: """ This model represents an individual patch operation to be performed on a JSON document, as defined by RFC 6902. @@ -6879,12 +6395,7 @@ class JsonPatchOperation(): :attr object value: (optional) The value to be used within the operation. """ - def __init__(self, - op: str, - path: str, - *, - from_: str = None, - value: object = None) -> None: + def __init__(self, op: str, path: str, *, from_: str = None, value: object = None) -> None: """ Initialize a JsonPatchOperation object. @@ -6958,6 +6469,7 @@ class OpEnum(str, Enum): """ The operation to be performed. """ + ADD = 'add' REMOVE = 'remove' REPLACE = 'replace' @@ -6966,7 +6478,7 @@ class OpEnum(str, Enum): TEST = 'test' -class Kind(): +class Kind: """ Offering kind. @@ -6986,19 +6498,21 @@ class Kind(): :attr List[Plan] plans: (optional) list of plans. """ - def __init__(self, - *, - id: str = None, - format_kind: str = None, - target_kind: str = None, - metadata: dict = None, - install_description: str = None, - tags: List[str] = None, - additional_features: List['Feature'] = None, - created: datetime = None, - updated: datetime = None, - versions: List['Version'] = None, - plans: List['Plan'] = None) -> None: + def __init__( + self, + *, + id: str = None, + format_kind: str = None, + target_kind: str = None, + metadata: dict = None, + install_description: str = None, + tags: List[str] = None, + additional_features: List['Feature'] = None, + created: datetime = None, + updated: datetime = None, + versions: List['Version'] = None, + plans: List['Plan'] = None + ) -> None: """ Initialize a Kind object. @@ -7109,7 +6623,8 @@ def __ne__(self, other: 'Kind') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class License(): + +class License: """ BSS license. @@ -7120,13 +6635,9 @@ class License(): :attr str description: (optional) License description. """ - def __init__(self, - *, - id: str = None, - name: str = None, - type: str = None, - url: str = None, - description: str = None) -> None: + def __init__( + self, *, id: str = None, name: str = None, type: str = None, url: str = None, description: str = None + ) -> None: """ Initialize a License object. @@ -7196,7 +6707,8 @@ def __ne__(self, other: 'License') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class MediaItem(): + +class MediaItem: """ Offering Media information. @@ -7206,12 +6718,7 @@ class MediaItem(): :attr str thumbnail_url: (optional) Thumbnail URL for this media item. """ - def __init__(self, - *, - url: str = None, - caption: str = None, - type: str = None, - thumbnail_url: str = None) -> None: + def __init__(self, *, url: str = None, caption: str = None, type: str = None, thumbnail_url: str = None) -> None: """ Initialize a MediaItem object. @@ -7275,7 +6782,8 @@ def __ne__(self, other: 'MediaItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class NamespaceSearchResult(): + +class NamespaceSearchResult: """ Paginated list of namespace search results. @@ -7296,17 +6804,19 @@ class NamespaceSearchResult(): :attr List[str] resources: (optional) Resulting objects. """ - def __init__(self, - offset: int, - limit: int, - *, - total_count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List[str] = None) -> None: + def __init__( + self, + offset: int, + limit: int, + *, + total_count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List[str] = None + ) -> None: """ Initialize a NamespaceSearchResult object. @@ -7412,7 +6922,8 @@ def __ne__(self, other: 'NamespaceSearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ObjectAccess(): + +class ObjectAccess: """ object access. @@ -7423,13 +6934,15 @@ class ObjectAccess(): :attr datetime create: (optional) date and time create. """ - def __init__(self, - *, - id: str = None, - account: str = None, - catalog_id: str = None, - target_id: str = None, - create: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + account: str = None, + catalog_id: str = None, + target_id: str = None, + create: datetime = None + ) -> None: """ Initialize a ObjectAccess object. @@ -7499,7 +7012,8 @@ def __ne__(self, other: 'ObjectAccess') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ObjectAccessListResult(): + +class ObjectAccessListResult: """ Paginated object search result. @@ -7520,17 +7034,19 @@ class ObjectAccessListResult(): :attr List[ObjectAccess] resources: (optional) Resulting objects. """ - def __init__(self, - offset: int, - limit: int, - *, - total_count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['ObjectAccess'] = None) -> None: + def __init__( + self, + offset: int, + limit: int, + *, + total_count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['ObjectAccess'] = None + ) -> None: """ Initialize a ObjectAccessListResult object. @@ -7636,7 +7152,8 @@ def __ne__(self, other: 'ObjectAccessListResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ObjectListResult(): + +class ObjectListResult: """ Paginated object search result. @@ -7657,17 +7174,19 @@ class ObjectListResult(): :attr List[CatalogObject] resources: (optional) Resulting objects. """ - def __init__(self, - offset: int, - limit: int, - *, - total_count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['CatalogObject'] = None) -> None: + def __init__( + self, + offset: int, + limit: int, + *, + total_count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['CatalogObject'] = None + ) -> None: """ Initialize a ObjectListResult object. @@ -7773,7 +7292,8 @@ def __ne__(self, other: 'ObjectListResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ObjectSearchResult(): + +class ObjectSearchResult: """ Paginated object search result. @@ -7794,17 +7314,19 @@ class ObjectSearchResult(): :attr List[CatalogObject] resources: (optional) Resulting objects. """ - def __init__(self, - offset: int, - limit: int, - *, - total_count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['CatalogObject'] = None) -> None: + def __init__( + self, + offset: int, + limit: int, + *, + total_count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['CatalogObject'] = None + ) -> None: """ Initialize a ObjectSearchResult object. @@ -7910,7 +7432,8 @@ def __ne__(self, other: 'ObjectSearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Offering(): + +class Offering: """ Offering information. @@ -7968,43 +7491,45 @@ class Offering(): offering. """ - def __init__(self, - *, - id: str = None, - rev: str = None, - url: str = None, - crn: str = None, - label: str = None, - name: str = None, - offering_icon_url: str = None, - offering_docs_url: str = None, - offering_support_url: str = None, - tags: List[str] = None, - keywords: List[str] = None, - rating: 'Rating' = None, - created: datetime = None, - updated: datetime = None, - short_description: str = None, - long_description: str = None, - features: List['Feature'] = None, - kinds: List['Kind'] = None, - permit_request_ibm_public_publish: bool = None, - ibm_publish_approved: bool = None, - public_publish_approved: bool = None, - public_original_crn: str = None, - publish_public_crn: str = None, - portal_approval_record: str = None, - portal_ui_url: str = None, - catalog_id: str = None, - catalog_name: str = None, - metadata: dict = None, - disclaimer: str = None, - hidden: bool = None, - provider: str = None, - provider_info: 'ProviderInfo' = None, - repo_info: 'RepoInfo' = None, - support: 'Support' = None, - media: List['MediaItem'] = None) -> None: + def __init__( + self, + *, + id: str = None, + rev: str = None, + url: str = None, + crn: str = None, + label: str = None, + name: str = None, + offering_icon_url: str = None, + offering_docs_url: str = None, + offering_support_url: str = None, + tags: List[str] = None, + keywords: List[str] = None, + rating: 'Rating' = None, + created: datetime = None, + updated: datetime = None, + short_description: str = None, + long_description: str = None, + features: List['Feature'] = None, + kinds: List['Kind'] = None, + permit_request_ibm_public_publish: bool = None, + ibm_publish_approved: bool = None, + public_publish_approved: bool = None, + public_original_crn: str = None, + publish_public_crn: str = None, + portal_approval_record: str = None, + portal_ui_url: str = None, + catalog_id: str = None, + catalog_name: str = None, + metadata: dict = None, + disclaimer: str = None, + hidden: bool = None, + provider: str = None, + provider_info: 'ProviderInfo' = None, + repo_info: 'RepoInfo' = None, + support: 'Support' = None, + media: List['MediaItem'] = None + ) -> None: """ Initialize a Offering object. @@ -8275,7 +7800,8 @@ def __ne__(self, other: 'Offering') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OfferingInstance(): + +class OfferingInstance: """ A offering instance resource (provision instance of a catalog offering). @@ -8311,27 +7837,29 @@ class OfferingInstance(): operation performed and status. """ - def __init__(self, - *, - id: str = None, - rev: str = None, - url: str = None, - crn: str = None, - label: str = None, - catalog_id: str = None, - offering_id: str = None, - kind_format: str = None, - version: str = None, - cluster_id: str = None, - cluster_region: str = None, - cluster_namespaces: List[str] = None, - cluster_all_namespaces: bool = None, - schematics_workspace_id: str = None, - resource_group_id: str = None, - install_plan: str = None, - channel: str = None, - metadata: dict = None, - last_operation: 'OfferingInstanceLastOperation' = None) -> None: + def __init__( + self, + *, + id: str = None, + rev: str = None, + url: str = None, + crn: str = None, + label: str = None, + catalog_id: str = None, + offering_id: str = None, + kind_format: str = None, + version: str = None, + cluster_id: str = None, + cluster_region: str = None, + cluster_namespaces: List[str] = None, + cluster_all_namespaces: bool = None, + schematics_workspace_id: str = None, + resource_group_id: str = None, + install_plan: str = None, + channel: str = None, + metadata: dict = None, + last_operation: 'OfferingInstanceLastOperation' = None + ) -> None: """ Initialize a OfferingInstance object. @@ -8498,7 +8026,8 @@ def __ne__(self, other: 'OfferingInstance') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OfferingInstanceLastOperation(): + +class OfferingInstanceLastOperation: """ the last operation performed and status. @@ -8509,13 +8038,15 @@ class OfferingInstanceLastOperation(): :attr str updated: (optional) Date and time last updated. """ - def __init__(self, - *, - operation: str = None, - state: str = None, - message: str = None, - transaction_id: str = None, - updated: str = None) -> None: + def __init__( + self, + *, + operation: str = None, + state: str = None, + message: str = None, + transaction_id: str = None, + updated: str = None + ) -> None: """ Initialize a OfferingInstanceLastOperation object. @@ -8587,7 +8118,8 @@ def __ne__(self, other: 'OfferingInstanceLastOperation') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OfferingSearchResult(): + +class OfferingSearchResult: """ Paginated offering search result. @@ -8608,17 +8140,19 @@ class OfferingSearchResult(): :attr List[Offering] resources: (optional) Resulting objects. """ - def __init__(self, - offset: int, - limit: int, - *, - total_count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['Offering'] = None) -> None: + def __init__( + self, + offset: int, + limit: int, + *, + total_count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['Offering'] = None + ) -> None: """ Initialize a OfferingSearchResult object. @@ -8724,7 +8258,8 @@ def __ne__(self, other: 'OfferingSearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OperatorDeployResult(): + +class OperatorDeployResult: """ Operator deploy result. @@ -8738,16 +8273,18 @@ class OperatorDeployResult(): :attr str catalog_id: (optional) Catalog identification. """ - def __init__(self, - *, - phase: str = None, - message: str = None, - link: str = None, - name: str = None, - version: str = None, - namespace: str = None, - package_name: str = None, - catalog_id: str = None) -> None: + def __init__( + self, + *, + phase: str = None, + message: str = None, + link: str = None, + name: str = None, + version: str = None, + namespace: str = None, + package_name: str = None, + catalog_id: str = None + ) -> None: """ Initialize a OperatorDeployResult object. @@ -8835,7 +8372,8 @@ def __ne__(self, other: 'OperatorDeployResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Plan(): + +class Plan: """ Offering plan. @@ -8855,19 +8393,21 @@ class Plan(): :attr List[Deployment] deployments: (optional) list of deployments. """ - def __init__(self, - *, - id: str = None, - label: str = None, - name: str = None, - short_description: str = None, - long_description: str = None, - metadata: dict = None, - tags: List[str] = None, - additional_features: List['Feature'] = None, - created: datetime = None, - updated: datetime = None, - deployments: List['Deployment'] = None) -> None: + def __init__( + self, + *, + id: str = None, + label: str = None, + name: str = None, + short_description: str = None, + long_description: str = None, + metadata: dict = None, + tags: List[str] = None, + additional_features: List['Feature'] = None, + created: datetime = None, + updated: datetime = None, + deployments: List['Deployment'] = None + ) -> None: """ Initialize a Plan object. @@ -8978,7 +8518,8 @@ def __ne__(self, other: 'Plan') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProviderInfo(): + +class ProviderInfo: """ Information on the provider for this offering, or omitted if no provider information is given. @@ -8987,10 +8528,7 @@ class ProviderInfo(): :attr str name: (optional) The name of this provider. """ - def __init__(self, - *, - id: str = None, - name: str = None) -> None: + def __init__(self, *, id: str = None, name: str = None) -> None: """ Initialize a ProviderInfo object. @@ -9042,7 +8580,8 @@ def __ne__(self, other: 'ProviderInfo') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PublishObject(): + +class PublishObject: """ Publish information. @@ -9056,13 +8595,15 @@ class PublishObject(): :attr str portal_url: (optional) The portal UI URL. """ - def __init__(self, - *, - permit_ibm_public_publish: bool = None, - ibm_approved: bool = None, - public_approved: bool = None, - portal_approval_record: str = None, - portal_url: str = None) -> None: + def __init__( + self, + *, + permit_ibm_public_publish: bool = None, + ibm_approved: bool = None, + public_approved: bool = None, + portal_approval_record: str = None, + portal_url: str = None + ) -> None: """ Initialize a PublishObject object. @@ -9136,7 +8677,8 @@ def __ne__(self, other: 'PublishObject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Rating(): + +class Rating: """ Repository info for offerings. @@ -9146,12 +8688,14 @@ class Rating(): :attr int four_star_count: (optional) Four start rating. """ - def __init__(self, - *, - one_star_count: int = None, - two_star_count: int = None, - three_star_count: int = None, - four_star_count: int = None) -> None: + def __init__( + self, + *, + one_star_count: int = None, + two_star_count: int = None, + three_star_count: int = None, + four_star_count: int = None + ) -> None: """ Initialize a Rating object. @@ -9215,7 +8759,8 @@ def __ne__(self, other: 'Rating') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RepoInfo(): + +class RepoInfo: """ Repository info for offerings. @@ -9223,10 +8768,7 @@ class RepoInfo(): :attr str type: (optional) Public or enterprise GitHub. """ - def __init__(self, - *, - token: str = None, - type: str = None) -> None: + def __init__(self, *, token: str = None, type: str = None) -> None: """ Initialize a RepoInfo object. @@ -9278,7 +8820,8 @@ def __ne__(self, other: 'RepoInfo') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ Resource requirements. @@ -9287,10 +8830,7 @@ class Resource(): int. targetVersion will be a semver range value. """ - def __init__(self, - *, - type: str = None, - value: object = None) -> None: + def __init__(self, *, type: str = None, value: object = None) -> None: """ Initialize a Resource object. @@ -9347,6 +8887,7 @@ class TypeEnum(str, Enum): """ Type of requirement. """ + MEM = 'mem' DISK = 'disk' CORES = 'cores' @@ -9354,7 +8895,7 @@ class TypeEnum(str, Enum): NODES = 'nodes' -class Script(): +class Script: """ Script information. @@ -9370,13 +8911,15 @@ class Script(): to a namespace or the entire cluster. """ - def __init__(self, - *, - instructions: str = None, - script: str = None, - script_permission: str = None, - delete_script: str = None, - scope: str = None) -> None: + def __init__( + self, + *, + instructions: str = None, + script: str = None, + script_permission: str = None, + delete_script: str = None, + scope: str = None + ) -> None: """ Initialize a Script object. @@ -9452,7 +8995,8 @@ def __ne__(self, other: 'Script') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class State(): + +class State: """ Offering state. @@ -9466,13 +9010,15 @@ class State(): ibm-published, public-published. """ - def __init__(self, - *, - current: str = None, - current_entered: datetime = None, - pending: str = None, - pending_requested: datetime = None, - previous: str = None) -> None: + def __init__( + self, + *, + current: str = None, + current_entered: datetime = None, + pending: str = None, + pending_requested: datetime = None, + previous: str = None + ) -> None: """ Initialize a State object. @@ -9547,7 +9093,8 @@ def __ne__(self, other: 'State') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Support(): + +class Support: """ Offering Support information. @@ -9558,11 +9105,7 @@ class Support(): support is provided. """ - def __init__(self, - *, - url: str = None, - process: str = None, - locations: List[str] = None) -> None: + def __init__(self, *, url: str = None, process: str = None, locations: List[str] = None) -> None: """ Initialize a Support object. @@ -9622,7 +9165,8 @@ def __ne__(self, other: 'Support') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SyndicationAuthorization(): + +class SyndicationAuthorization: """ Feature information. @@ -9630,10 +9174,7 @@ class SyndicationAuthorization(): :attr datetime last_run: (optional) Date and time last updated. """ - def __init__(self, - *, - token: str = None, - last_run: datetime = None) -> None: + def __init__(self, *, token: str = None, last_run: datetime = None) -> None: """ Initialize a SyndicationAuthorization object. @@ -9685,7 +9226,8 @@ def __ne__(self, other: 'SyndicationAuthorization') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SyndicationCluster(): + +class SyndicationCluster: """ Feature information. @@ -9698,15 +9240,17 @@ class SyndicationCluster(): :attr bool all_namespaces: (optional) Syndicated to all namespaces on cluster. """ - def __init__(self, - *, - region: str = None, - id: str = None, - name: str = None, - resource_group_name: str = None, - type: str = None, - namespaces: List[str] = None, - all_namespaces: bool = None) -> None: + def __init__( + self, + *, + region: str = None, + id: str = None, + name: str = None, + resource_group_name: str = None, + type: str = None, + namespaces: List[str] = None, + all_namespaces: bool = None + ) -> None: """ Initialize a SyndicationCluster object. @@ -9789,7 +9333,8 @@ def __ne__(self, other: 'SyndicationCluster') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SyndicationHistory(): + +class SyndicationHistory: """ Feature information. @@ -9799,11 +9344,9 @@ class SyndicationHistory(): :attr datetime last_run: (optional) Date and time last syndicated. """ - def __init__(self, - *, - namespaces: List[str] = None, - clusters: List['SyndicationCluster'] = None, - last_run: datetime = None) -> None: + def __init__( + self, *, namespaces: List[str] = None, clusters: List['SyndicationCluster'] = None, last_run: datetime = None + ) -> None: """ Initialize a SyndicationHistory object. @@ -9862,7 +9405,8 @@ def __ne__(self, other: 'SyndicationHistory') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SyndicationResource(): + +class SyndicationResource: """ Feature information. @@ -9872,12 +9416,14 @@ class SyndicationResource(): :attr SyndicationAuthorization authorization: (optional) Feature information. """ - def __init__(self, - *, - remove_related_components: bool = None, - clusters: List['SyndicationCluster'] = None, - history: 'SyndicationHistory' = None, - authorization: 'SyndicationAuthorization' = None) -> None: + def __init__( + self, + *, + remove_related_components: bool = None, + clusters: List['SyndicationCluster'] = None, + history: 'SyndicationHistory' = None, + authorization: 'SyndicationAuthorization' = None + ) -> None: """ Initialize a SyndicationResource object. @@ -9943,7 +9489,8 @@ def __ne__(self, other: 'SyndicationResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Validation(): + +class Validation: """ Validation response. @@ -9959,13 +9506,15 @@ class Validation(): region, namespace, etc). Values will vary by Content type. """ - def __init__(self, - *, - validated: datetime = None, - requested: datetime = None, - state: str = None, - last_operation: str = None, - target: dict = None) -> None: + def __init__( + self, + *, + validated: datetime = None, + requested: datetime = None, + state: str = None, + last_operation: str = None, + target: dict = None + ) -> None: """ Initialize a Validation object. @@ -10040,7 +9589,8 @@ def __ne__(self, other: 'Validation') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Version(): + +class Version: """ Offering version information. @@ -10086,39 +9636,41 @@ class Version(): version. """ - def __init__(self, - *, - id: str = None, - rev: str = None, - crn: str = None, - version: str = None, - sha: str = None, - created: datetime = None, - updated: datetime = None, - offering_id: str = None, - catalog_id: str = None, - kind_id: str = None, - tags: List[str] = None, - repo_url: str = None, - source_url: str = None, - tgz_url: str = None, - configuration: List['Configuration'] = None, - metadata: dict = None, - validation: 'Validation' = None, - required_resources: List['Resource'] = None, - single_instance: bool = None, - install: 'Script' = None, - pre_install: List['Script'] = None, - entitlement: 'VersionEntitlement' = None, - licenses: List['License'] = None, - image_manifest_url: str = None, - deprecated: bool = None, - package_version: str = None, - state: 'State' = None, - version_locator: str = None, - console_url: str = None, - long_description: str = None, - whitelisted_accounts: List[str] = None) -> None: + def __init__( + self, + *, + id: str = None, + rev: str = None, + crn: str = None, + version: str = None, + sha: str = None, + created: datetime = None, + updated: datetime = None, + offering_id: str = None, + catalog_id: str = None, + kind_id: str = None, + tags: List[str] = None, + repo_url: str = None, + source_url: str = None, + tgz_url: str = None, + configuration: List['Configuration'] = None, + metadata: dict = None, + validation: 'Validation' = None, + required_resources: List['Resource'] = None, + single_instance: bool = None, + install: 'Script' = None, + pre_install: List['Script'] = None, + entitlement: 'VersionEntitlement' = None, + licenses: List['License'] = None, + image_manifest_url: str = None, + deprecated: bool = None, + package_version: str = None, + state: 'State' = None, + version_locator: str = None, + console_url: str = None, + long_description: str = None, + whitelisted_accounts: List[str] = None + ) -> None: """ Initialize a Version object. @@ -10357,7 +9909,8 @@ def __ne__(self, other: 'Version') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class VersionEntitlement(): + +class VersionEntitlement: """ Entitlement license info. @@ -10369,13 +9922,15 @@ class VersionEntitlement(): :attr str image_repo_name: (optional) Image repository name. """ - def __init__(self, - *, - provider_name: str = None, - provider_id: str = None, - product_id: str = None, - part_numbers: List[str] = None, - image_repo_name: str = None) -> None: + def __init__( + self, + *, + provider_name: str = None, + provider_id: str = None, + product_id: str = None, + part_numbers: List[str] = None, + image_repo_name: str = None + ) -> None: """ Initialize a VersionEntitlement object. @@ -10446,7 +10001,8 @@ def __ne__(self, other: 'VersionEntitlement') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class VersionUpdateDescriptor(): + +class VersionUpdateDescriptor: """ Indicates if the current version can be upgraded to the version identified by the descriptor. @@ -10465,16 +10021,18 @@ class VersionUpdateDescriptor(): include nodes, cores, mem, disk, targetVersion, and install-permission-check. """ - def __init__(self, - *, - version_locator: str = None, - version: str = None, - state: 'State' = None, - required_resources: List['Resource'] = None, - package_version: str = None, - sha: str = None, - can_update: bool = None, - messages: dict = None) -> None: + def __init__( + self, + *, + version_locator: str = None, + version: str = None, + state: 'State' = None, + required_resources: List['Resource'] = None, + package_version: str = None, + sha: str = None, + can_update: bool = None, + messages: dict = None + ) -> None: """ Initialize a VersionUpdateDescriptor object. diff --git a/ibm_platform_services/common.py b/ibm_platform_services/common.py index 38827332..ed8e3bdf 100644 --- a/ibm_platform_services/common.py +++ b/ibm_platform_services/common.py @@ -24,15 +24,15 @@ HEADER_NAME_USER_AGENT = 'User-Agent' SDK_NAME = 'platform-services-python-sdk' + def get_system_info(): """ Get information about the system to be inserted into the User-Agent header """ - format_msg='(lang=python; os.name={0}; os.version={1}; python.version={2})' + format_msg = '(lang=python; os.name={0}; os.version={1}; python.version={2})' return format_msg.format( - platform.system(), # OS - platform.release(), # OS version - platform.python_version()) # Python version + platform.system(), platform.release(), platform.python_version() # OS # OS version + ) # Python version def get_user_agent(): diff --git a/ibm_platform_services/context_based_restrictions_v1.py b/ibm_platform_services/context_based_restrictions_v1.py index 5a46e448..f9a110d5 100644 --- a/ibm_platform_services/context_based_restrictions_v1.py +++ b/ibm_platform_services/context_based_restrictions_v1.py @@ -42,6 +42,7 @@ # Service ############################################################################## + class ContextBasedRestrictionsV1(BaseService): """The Context Based Restrictions V1 service.""" @@ -49,23 +50,23 @@ class ContextBasedRestrictionsV1(BaseService): DEFAULT_SERVICE_NAME = 'context_based_restrictions' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'ContextBasedRestrictionsV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'ContextBasedRestrictionsV1': """ Return a new client for the Context Based Restrictions service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Context Based Restrictions service. @@ -73,17 +74,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Zones ######################### - - def create_zone(self, + def create_zone( + self, *, name: str = None, account_id: str = None, @@ -127,13 +125,10 @@ def create_zone(self, addresses = [convert_model(x) for x in addresses] if excluded is not None: excluded = [convert_model(x) for x in excluded] - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_zone') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_zone' + ) headers.update(sdk_headers) data = { @@ -141,7 +136,7 @@ def create_zone(self, 'account_id': account_id, 'addresses': addresses, 'description': description, - 'excluded': excluded + 'excluded': excluded, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -153,16 +148,13 @@ def create_zone(self, headers['Accept'] = 'application/json' url = '/v1/zones' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_zones(self, + def list_zones( + self, account_id: str, *, x_correlation_id: str = None, @@ -199,20 +191,13 @@ def list_zones(self, if account_id is None: raise ValueError('account_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_zones') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_zones' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id, - 'name': name, - 'sort': sort - } + params = {'account_id': account_id, 'name': name, 'sort': sort} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -220,21 +205,13 @@ def list_zones(self, headers['Accept'] = 'application/json' url = '/v1/zones' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_zone(self, - zone_id: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def get_zone( + self, zone_id: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Get a network zone. @@ -260,13 +237,10 @@ def get_zone(self, if zone_id is None: raise ValueError('zone_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_zone') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_zone' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -278,15 +252,13 @@ def get_zone(self, path_param_values = self.encode_path_vars(zone_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/zones/{zone_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_zone(self, + def replace_zone( + self, zone_id: str, if_match: str, *, @@ -341,14 +313,10 @@ def replace_zone(self, addresses = [convert_model(x) for x in addresses] if excluded is not None: excluded = [convert_model(x) for x in excluded] - headers = { - 'If-Match': if_match, - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_zone') + headers = {'If-Match': if_match, 'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_zone' + ) headers.update(sdk_headers) data = { @@ -356,7 +324,7 @@ def replace_zone(self, 'account_id': account_id, 'addresses': addresses, 'description': description, - 'excluded': excluded + 'excluded': excluded, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -371,21 +339,13 @@ def replace_zone(self, path_param_values = self.encode_path_vars(zone_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/zones/{zone_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_zone(self, - zone_id: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def delete_zone( + self, zone_id: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete a network zone. @@ -411,13 +371,10 @@ def delete_zone(self, if zone_id is None: raise ValueError('zone_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_zone') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_zone' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -428,20 +385,13 @@ def delete_zone(self, path_param_values = self.encode_path_vars(zone_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/zones/{zone_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def list_available_serviceref_targets(self, - *, - x_correlation_id: str = None, - transaction_id: str = None, - type: str = None, - **kwargs + def list_available_serviceref_targets( + self, *, x_correlation_id: str = None, transaction_id: str = None, type: str = None, **kwargs ) -> DetailedResponse: """ List available service reference targets. @@ -465,18 +415,15 @@ def list_available_serviceref_targets(self, :rtype: DetailedResponse with `dict` result representing a `ServiceRefTargetList` object """ - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_available_serviceref_targets') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_available_serviceref_targets', + ) headers.update(sdk_headers) - params = { - 'type': type - } + params = {'type': type} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -484,10 +431,7 @@ def list_available_serviceref_targets(self, headers['Accept'] = 'application/json' url = '/v1/zones/serviceref_targets' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -496,8 +440,8 @@ def list_available_serviceref_targets(self, # Rules ######################### - - def create_rule(self, + def create_rule( + self, *, contexts: List['RuleContext'] = None, resources: List['Resource'] = None, @@ -549,13 +493,10 @@ def create_rule(self, resources = [convert_model(x) for x in resources] if operations is not None: operations = convert_model(operations) - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_rule') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_rule' + ) headers.update(sdk_headers) data = { @@ -563,7 +504,7 @@ def create_rule(self, 'resources': resources, 'description': description, 'operations': operations, - 'enforcement_mode': enforcement_mode + 'enforcement_mode': enforcement_mode, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -575,16 +516,13 @@ def create_rule(self, headers['Accept'] = 'application/json' url = '/v1/rules' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_rules(self, + def list_rules( + self, account_id: str, *, x_correlation_id: str = None, @@ -641,13 +579,10 @@ def list_rules(self, if account_id is None: raise ValueError('account_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_rules') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_rules' + ) headers.update(sdk_headers) params = { @@ -661,7 +596,7 @@ def list_rules(self, 'service_group_id': service_group_id, 'zone_id': zone_id, 'sort': sort, - 'enforcement_mode': enforcement_mode + 'enforcement_mode': enforcement_mode, } if 'headers' in kwargs: @@ -670,21 +605,13 @@ def list_rules(self, headers['Accept'] = 'application/json' url = '/v1/rules' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_rule(self, - rule_id: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def get_rule( + self, rule_id: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Get a rule. @@ -710,13 +637,10 @@ def get_rule(self, if rule_id is None: raise ValueError('rule_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_rule') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -728,15 +652,13 @@ def get_rule(self, path_param_values = self.encode_path_vars(rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_rule(self, + def replace_rule( + self, rule_id: str, if_match: str, *, @@ -798,14 +720,10 @@ def replace_rule(self, resources = [convert_model(x) for x in resources] if operations is not None: operations = convert_model(operations) - headers = { - 'If-Match': if_match, - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_rule') + headers = {'If-Match': if_match, 'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_rule' + ) headers.update(sdk_headers) data = { @@ -813,7 +731,7 @@ def replace_rule(self, 'resources': resources, 'description': description, 'operations': operations, - 'enforcement_mode': enforcement_mode + 'enforcement_mode': enforcement_mode, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -828,21 +746,13 @@ def replace_rule(self, path_param_values = self.encode_path_vars(rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_rule(self, - rule_id: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def delete_rule( + self, rule_id: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete a rule. @@ -868,13 +778,10 @@ def delete_rule(self, if rule_id is None: raise ValueError('rule_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_rule') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -885,9 +792,7 @@ def delete_rule(self, path_param_values = self.encode_path_vars(rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -896,13 +801,8 @@ def delete_rule(self, # Account settings ######################### - - def get_account_settings(self, - account_id: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def get_account_settings( + self, account_id: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Get account settings. @@ -928,13 +828,10 @@ def get_account_settings(self, if account_id is None: raise ValueError('account_id must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_account_settings') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_account_settings' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -946,9 +843,7 @@ def get_account_settings(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/account_settings/{account_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -957,13 +852,8 @@ def get_account_settings(self, # operations ######################### - - def list_available_service_operations(self, - service_name: str, - *, - x_correlation_id: str = None, - transaction_id: str = None, - **kwargs + def list_available_service_operations( + self, service_name: str, *, x_correlation_id: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ List available service operations. @@ -989,18 +879,15 @@ def list_available_service_operations(self, if service_name is None: raise ValueError('service_name must be provided') - headers = { - 'X-Correlation-Id': x_correlation_id, - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_available_service_operations') + headers = {'X-Correlation-Id': x_correlation_id, 'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V1', + operation_id='list_available_service_operations', + ) headers.update(sdk_headers) - params = { - 'service_name': service_name - } + params = {'service_name': service_name} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1008,10 +895,7 @@ def list_available_service_operations(self, headers['Accept'] = 'application/json' url = '/v1/operations' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -1026,6 +910,7 @@ class Type(str, Enum): """ Specifies the types of services to retrieve. """ + ALL = 'all' PLATFORM_SERVICE = 'platform_service' @@ -1039,6 +924,7 @@ class EnforcementMode(str, Enum): """ The rule's `enforcement_mode` attribute. """ + ENABLED = 'enabled' DISABLED = 'disabled' REPORT = 'report' @@ -1049,7 +935,7 @@ class EnforcementMode(str, Enum): ############################################################################## -class APIType(): +class APIType: """ Service API Type details. @@ -1059,11 +945,7 @@ class APIType(): :attr List[Action] actions: The actions available for the API type. """ - def __init__(self, - api_type_id: str, - display_name: str, - description: str, - actions: List['Action']) -> None: + def __init__(self, api_type_id: str, display_name: str, description: str, actions: List['Action']) -> None: """ Initialize a APIType object. @@ -1135,7 +1017,8 @@ def __ne__(self, other: 'APIType') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccountSettings(): + +class AccountSettings: """ An output account settings. @@ -1154,18 +1037,20 @@ class AccountSettings(): resource. """ - def __init__(self, - id: str, - crn: str, - rule_count_limit: int, - zone_count_limit: int, - current_rule_count: int, - current_zone_count: int, - href: str, - created_at: datetime, - created_by_id: str, - last_modified_at: datetime, - last_modified_by_id: str) -> None: + def __init__( + self, + id: str, + crn: str, + rule_count_limit: int, + zone_count_limit: int, + current_rule_count: int, + current_zone_count: int, + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, + ) -> None: """ Initialize a AccountSettings object. @@ -1299,7 +1184,8 @@ def __ne__(self, other: 'AccountSettings') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Action(): + +class Action: """ Service API Type actions. @@ -1307,9 +1193,7 @@ class Action(): :attr str description: The description of the action. """ - def __init__(self, - action_id: str, - description: str) -> None: + def __init__(self, action_id: str, description: str) -> None: """ Initialize a Action object. @@ -1365,23 +1249,23 @@ def __ne__(self, other: 'Action') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Address(): + +class Address: """ A zone address. :attr str type: (optional) The type of address. """ - def __init__(self, - *, - type: str = None) -> None: + def __init__(self, *, type: str = None) -> None: """ Initialize a Address object. :param str type: (optional) The type of address. """ msg = "Cannot instantiate base class. Instead, instantiate one of the defined subclasses: {0}".format( - ", ".join(['AddressIPAddress', 'AddressIPAddressRange', 'AddressSubnet', 'AddressVPC', 'AddressServiceRef'])) + ", ".join(['AddressIPAddress', 'AddressIPAddressRange', 'AddressSubnet', 'AddressVPC', 'AddressServiceRef']) + ) raise Exception(msg) @classmethod @@ -1390,9 +1274,12 @@ def from_dict(cls, _dict: Dict) -> 'Address': disc_class = cls._get_class_by_discriminator(_dict) if disc_class != cls: return disc_class.from_dict(_dict) - msg = ("Cannot convert dictionary into an instance of base class 'Address'. " + - "The discriminator value should map to a valid subclass: {1}").format( - ", ".join(['AddressIPAddress', 'AddressIPAddressRange', 'AddressSubnet', 'AddressVPC', 'AddressServiceRef'])) + msg = ( + "Cannot convert dictionary into an instance of base class 'Address'. " + + "The discriminator value should map to a valid subclass: {1}" + ).format( + ", ".join(['AddressIPAddress', 'AddressIPAddressRange', 'AddressSubnet', 'AddressVPC', 'AddressServiceRef']) + ) raise Exception(msg) @classmethod @@ -1424,6 +1311,7 @@ class TypeEnum(str, Enum): """ The type of address. """ + IPADDRESS = 'ipAddress' IPRANGE = 'ipRange' SUBNET = 'subnet' @@ -1431,7 +1319,7 @@ class TypeEnum(str, Enum): SERVICEREF = 'serviceRef' -class NewRuleOperations(): +class NewRuleOperations: """ The operations this rule applies to. @@ -1439,8 +1327,7 @@ class NewRuleOperations(): applies to. """ - def __init__(self, - api_types: List['NewRuleOperationsApiTypesItem']) -> None: + def __init__(self, api_types: List['NewRuleOperationsApiTypesItem']) -> None: """ Initialize a NewRuleOperations object. @@ -1489,15 +1376,15 @@ def __ne__(self, other: 'NewRuleOperations') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class NewRuleOperationsApiTypesItem(): + +class NewRuleOperationsApiTypesItem: """ NewRuleOperationsApiTypesItem. :attr str api_type_id: """ - def __init__(self, - api_type_id: str) -> None: + def __init__(self, api_type_id: str) -> None: """ Initialize a NewRuleOperationsApiTypesItem object. @@ -1545,15 +1432,15 @@ def __ne__(self, other: 'NewRuleOperationsApiTypesItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OperationsList(): + +class OperationsList: """ The response object of the `list_available_service_operations` operation. :attr List[APIType] api_types: The returned API types. """ - def __init__(self, - api_types: List['APIType']) -> None: + def __init__(self, api_types: List['APIType']) -> None: """ Initialize a OperationsList object. @@ -1601,7 +1488,8 @@ def __ne__(self, other: 'OperationsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ An rule resource. @@ -1609,10 +1497,7 @@ class Resource(): :attr List[ResourceTagAttribute] tags: (optional) The optional resource tags. """ - def __init__(self, - attributes: List['ResourceAttribute'], - *, - tags: List['ResourceTagAttribute'] = None) -> None: + def __init__(self, attributes: List['ResourceAttribute'], *, tags: List['ResourceTagAttribute'] = None) -> None: """ Initialize a Resource object. @@ -1667,7 +1552,8 @@ def __ne__(self, other: 'Resource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAttribute(): + +class ResourceAttribute: """ A rule resource attribute. @@ -1676,11 +1562,7 @@ class ResourceAttribute(): :attr str operator: (optional) The attribute operator. """ - def __init__(self, - name: str, - value: str, - *, - operator: str = None) -> None: + def __init__(self, name: str, value: str, *, operator: str = None) -> None: """ Initialize a ResourceAttribute object. @@ -1742,7 +1624,8 @@ def __ne__(self, other: 'ResourceAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceTagAttribute(): + +class ResourceTagAttribute: """ A rule resource tag attribute. @@ -1751,11 +1634,7 @@ class ResourceTagAttribute(): :attr str operator: (optional) The attribute operator. """ - def __init__(self, - name: str, - value: str, - *, - operator: str = None) -> None: + def __init__(self, name: str, value: str, *, operator: str = None) -> None: """ Initialize a ResourceTagAttribute object. @@ -1817,7 +1696,8 @@ def __ne__(self, other: 'ResourceTagAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Rule(): + +class Rule: """ An output rule. @@ -1841,20 +1721,22 @@ class Rule(): resource. """ - def __init__(self, - id: str, - crn: str, - description: str, - contexts: List['RuleContext'], - resources: List['Resource'], - href: str, - created_at: datetime, - created_by_id: str, - last_modified_at: datetime, - last_modified_by_id: str, - *, - operations: 'NewRuleOperations' = None, - enforcement_mode: str = None) -> None: + def __init__( + self, + id: str, + crn: str, + description: str, + contexts: List['RuleContext'], + resources: List['Resource'], + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, + *, + operations: 'NewRuleOperations' = None, + enforcement_mode: str = None + ) -> None: """ Initialize a Rule object. @@ -2002,20 +1884,20 @@ class EnforcementModeEnum(str, Enum): * `disabled` - The restrictions are disabled. Nothing is enforced or reported. * `report` - The restrictions are evaluated and reported, but not enforced. """ + ENABLED = 'enabled' DISABLED = 'disabled' REPORT = 'report' -class RuleContext(): +class RuleContext: """ A rule context. :attr List[RuleContextAttribute] attributes: The attributes. """ - def __init__(self, - attributes: List['RuleContextAttribute']) -> None: + def __init__(self, attributes: List['RuleContextAttribute']) -> None: """ Initialize a RuleContext object. @@ -2063,7 +1945,8 @@ def __ne__(self, other: 'RuleContext') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RuleContextAttribute(): + +class RuleContextAttribute: """ An rule context attribute. @@ -2071,9 +1954,7 @@ class RuleContextAttribute(): :attr str value: The attribute value. """ - def __init__(self, - name: str, - value: str) -> None: + def __init__(self, name: str, value: str) -> None: """ Initialize a RuleContextAttribute object. @@ -2129,7 +2010,8 @@ def __ne__(self, other: 'RuleContextAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RuleList(): + +class RuleList: """ The response object of the ListRules operation. @@ -2137,9 +2019,7 @@ class RuleList(): :attr List[Rule] rules: The returned rules. """ - def __init__(self, - count: int, - rules: List['Rule']) -> None: + def __init__(self, count: int, rules: List['Rule']) -> None: """ Initialize a RuleList object. @@ -2195,7 +2075,8 @@ def __ne__(self, other: 'RuleList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceRefTarget(): + +class ServiceRefTarget: """ Summary information about a service reference target. @@ -2205,11 +2086,9 @@ class ServiceRefTarget(): the service is available. """ - def __init__(self, - service_name: str, - *, - service_type: str = None, - locations: List['ServiceRefTargetLocationsItem'] = None) -> None: + def __init__( + self, service_name: str, *, service_type: str = None, locations: List['ServiceRefTargetLocationsItem'] = None + ) -> None: """ Initialize a ServiceRefTarget object. @@ -2270,7 +2149,8 @@ def __ne__(self, other: 'ServiceRefTarget') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceRefTargetList(): + +class ServiceRefTargetList: """ A list of service reference targets. @@ -2278,9 +2158,7 @@ class ServiceRefTargetList(): :attr List[ServiceRefTarget] targets: The list of service reference targets. """ - def __init__(self, - count: int, - targets: List['ServiceRefTarget']) -> None: + def __init__(self, count: int, targets: List['ServiceRefTarget']) -> None: """ Initialize a ServiceRefTargetList object. @@ -2337,15 +2215,15 @@ def __ne__(self, other: 'ServiceRefTargetList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceRefTargetLocationsItem(): + +class ServiceRefTargetLocationsItem: """ ServiceRefTargetLocationsItem. :attr str name: The location name. """ - def __init__(self, - name: str) -> None: + def __init__(self, name: str) -> None: """ Initialize a ServiceRefTargetLocationsItem object. @@ -2393,7 +2271,8 @@ def __ne__(self, other: 'ServiceRefTargetLocationsItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceRefValue(): + +class ServiceRefValue: """ A service reference value. @@ -2404,13 +2283,15 @@ class ServiceRefValue(): :attr str location: (optional) The location. """ - def __init__(self, - account_id: str, - *, - service_type: str = None, - service_name: str = None, - service_instance: str = None, - location: str = None) -> None: + def __init__( + self, + account_id: str, + *, + service_type: str = None, + service_name: str = None, + service_instance: str = None, + location: str = None + ) -> None: """ Initialize a ServiceRefValue object. @@ -2482,7 +2363,8 @@ def __ne__(self, other: 'ServiceRefValue') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Zone(): + +class Zone: """ An output zone. @@ -2505,21 +2387,23 @@ class Zone(): resource. """ - def __init__(self, - id: str, - crn: str, - address_count: int, - excluded_count: int, - name: str, - account_id: str, - description: str, - addresses: List['Address'], - excluded: List['Address'], - href: str, - created_at: datetime, - created_by_id: str, - last_modified_at: datetime, - last_modified_by_id: str) -> None: + def __init__( + self, + id: str, + crn: str, + address_count: int, + excluded_count: int, + name: str, + account_id: str, + description: str, + addresses: List['Address'], + excluded: List['Address'], + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, + ) -> None: """ Initialize a Zone object. @@ -2675,7 +2559,8 @@ def __ne__(self, other: 'Zone') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ZoneList(): + +class ZoneList: """ The response object of the ListZones operation. @@ -2683,9 +2568,7 @@ class ZoneList(): :attr List[ZoneSummary] zones: The returned zones. """ - def __init__(self, - count: int, - zones: List['ZoneSummary']) -> None: + def __init__(self, count: int, zones: List['ZoneSummary']) -> None: """ Initialize a ZoneList object. @@ -2741,7 +2624,8 @@ def __ne__(self, other: 'ZoneList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ZoneSummary(): + +class ZoneSummary: """ An output zone summary. @@ -2762,20 +2646,22 @@ class ZoneSummary(): resource. """ - def __init__(self, - id: str, - crn: str, - name: str, - addresses_preview: List['Address'], - address_count: int, - excluded_count: int, - href: str, - created_at: datetime, - created_by_id: str, - last_modified_at: datetime, - last_modified_by_id: str, - *, - description: str = None) -> None: + def __init__( + self, + id: str, + crn: str, + name: str, + addresses_preview: List['Address'], + address_count: int, + excluded_count: int, + href: str, + created_at: datetime, + created_by_id: str, + last_modified_at: datetime, + last_modified_by_id: str, + *, + description: str = None + ) -> None: """ Initialize a ZoneSummary object. @@ -2912,6 +2798,7 @@ def __ne__(self, other: 'ZoneSummary') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + class AddressIPAddress(Address): """ A single IP address. @@ -2920,9 +2807,7 @@ class AddressIPAddress(Address): :attr str value: The IP address. """ - def __init__(self, - type: str, - value: str) -> None: + def __init__(self, type: str, value: str) -> None: """ Initialize a AddressIPAddress object. @@ -2983,6 +2868,7 @@ class TypeEnum(str, Enum): """ The type of address. """ + IPADDRESS = 'ipAddress' @@ -2994,9 +2880,7 @@ class AddressIPAddressRange(Address): :attr str value: The ip range in - format. """ - def __init__(self, - type: str, - value: str) -> None: + def __init__(self, type: str, value: str) -> None: """ Initialize a AddressIPAddressRange object. @@ -3057,6 +2941,7 @@ class TypeEnum(str, Enum): """ The type of address. """ + IPRANGE = 'ipRange' @@ -3068,9 +2953,7 @@ class AddressServiceRef(Address): :attr ServiceRefValue ref: A service reference value. """ - def __init__(self, - type: str, - ref: 'ServiceRefValue') -> None: + def __init__(self, type: str, ref: 'ServiceRefValue') -> None: """ Initialize a AddressServiceRef object. @@ -3131,6 +3014,7 @@ class TypeEnum(str, Enum): """ The type of address. """ + SERVICEREF = 'serviceRef' @@ -3142,9 +3026,7 @@ class AddressSubnet(Address): :attr str value: The subnet in CIDR format. """ - def __init__(self, - type: str, - value: str) -> None: + def __init__(self, type: str, value: str) -> None: """ Initialize a AddressSubnet object. @@ -3205,6 +3087,7 @@ class TypeEnum(str, Enum): """ The type of address. """ + SUBNET = 'subnet' @@ -3216,9 +3099,7 @@ class AddressVPC(Address): :attr str value: The VPC CRN. """ - def __init__(self, - type: str, - value: str) -> None: + def __init__(self, type: str, value: str) -> None: """ Initialize a AddressVPC object. @@ -3279,5 +3160,5 @@ class TypeEnum(str, Enum): """ The type of address. """ - VPC = 'vpc' + VPC = 'vpc' diff --git a/ibm_platform_services/enterprise_billing_units_v1.py b/ibm_platform_services/enterprise_billing_units_v1.py index b8ebd491..8f70e576 100644 --- a/ibm_platform_services/enterprise_billing_units_v1.py +++ b/ibm_platform_services/enterprise_billing_units_v1.py @@ -36,6 +36,7 @@ # Service ############################################################################## + class EnterpriseBillingUnitsV1(BaseService): """The Enterprise Billing Units V1 service.""" @@ -43,23 +44,23 @@ class EnterpriseBillingUnitsV1(BaseService): DEFAULT_SERVICE_NAME = 'enterprise_billing_units' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'EnterpriseBillingUnitsV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'EnterpriseBillingUnitsV1': """ Return a new client for the Enterprise Billing Units service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Enterprise Billing Units service. @@ -67,20 +68,13 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Billing Units ######################### - - def get_billing_unit(self, - billing_unit_id: str, - **kwargs - ) -> DetailedResponse: + def get_billing_unit(self, billing_unit_id: str, **kwargs) -> DetailedResponse: """ Get billing unit by ID. @@ -95,9 +89,9 @@ def get_billing_unit(self, if billing_unit_id is None: raise ValueError('billing_unit_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_billing_unit') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_billing_unit' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -108,20 +102,13 @@ def get_billing_unit(self, path_param_values = self.encode_path_vars(billing_unit_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/billing-units/{billing_unit_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request) return response - - def list_billing_units(self, - *, - account_id: str = None, - enterprise_id: str = None, - account_group_id: str = None, - **kwargs + def list_billing_units( + self, *, account_id: str = None, enterprise_id: str = None, account_group_id: str = None, **kwargs ) -> DetailedResponse: """ List billing units. @@ -138,26 +125,19 @@ def list_billing_units(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_billing_units') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_billing_units' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id, - 'enterprise_id': enterprise_id, - 'account_group_id': account_group_id - } + params = {'account_id': account_id, 'enterprise_id': enterprise_id, 'account_group_id': account_group_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/v1/billing-units' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -166,11 +146,7 @@ def list_billing_units(self, # Billing Options ######################### - - def list_billing_options(self, - billing_unit_id: str, - **kwargs - ) -> DetailedResponse: + def list_billing_options(self, billing_unit_id: str, **kwargs) -> DetailedResponse: """ List billing options. @@ -186,24 +162,19 @@ def list_billing_options(self, if billing_unit_id is None: raise ValueError('billing_unit_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_billing_options') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_billing_options' + ) headers.update(sdk_headers) - params = { - 'billing_unit_id': billing_unit_id - } + params = {'billing_unit_id': billing_unit_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/v1/billing-options' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -212,13 +183,8 @@ def list_billing_options(self, # Credit Pools ######################### - - def get_credit_pools(self, - billing_unit_id: str, - *, - date: str = None, - type: str = None, - **kwargs + def get_credit_pools( + self, billing_unit_id: str, *, date: str = None, type: str = None, **kwargs ) -> DetailedResponse: """ Get credit pools. @@ -240,26 +206,19 @@ def get_credit_pools(self, if billing_unit_id is None: raise ValueError('billing_unit_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_credit_pools') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_credit_pools' + ) headers.update(sdk_headers) - params = { - 'billing_unit_id': billing_unit_id, - 'date': date, - 'type': type - } + params = {'billing_unit_id': billing_unit_id, 'date': date, 'type': type} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/v1/credit-pools' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -270,7 +229,7 @@ def get_credit_pools(self, ############################################################################## -class BillingOption(): +class BillingOption: """ Information about a billing option. @@ -297,21 +256,23 @@ class BillingOption(): updated. """ - def __init__(self, - *, - id: str = None, - billing_unit_id: str = None, - start_date: datetime = None, - end_date: datetime = None, - state: str = None, - type: str = None, - category: str = None, - payment_instrument: dict = None, - duration_in_months: int = None, - line_item_id: int = None, - billing_system: dict = None, - renewal_mode_code: str = None, - updated_at: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + billing_unit_id: str = None, + start_date: datetime = None, + end_date: datetime = None, + state: str = None, + type: str = None, + category: str = None, + payment_instrument: dict = None, + duration_in_months: int = None, + line_item_id: int = None, + billing_system: dict = None, + renewal_mode_code: str = None, + updated_at: datetime = None + ) -> None: """ Initialize a BillingOption object. @@ -442,30 +403,31 @@ class StateEnum(str, Enum): The state of the billing option. The valid values include `ACTIVE, `SUSPENDED`, and `CANCELED`. """ + ACTIVE = 'ACTIVE' SUSPENDED = 'SUSPENDED' CANCELED = 'CANCELED' - class TypeEnum(str, Enum): """ The type of billing option. The valid values are `SUBSCRIPTION` and `OFFER`. """ + SUBSCRIPTION = 'SUBSCRIPTION' OFFER = 'OFFER' - class CategoryEnum(str, Enum): """ The category of the billing option. The valid values are `PLATFORM`, `SERVICE`, and `SUPPORT`. """ + PLATFORM = 'PLATFORM' SERVICE = 'SERVICE' SUPPORT = 'SUPPORT' -class BillingOptionsList(): +class BillingOptionsList: """ A search result containing zero or more billing options. @@ -476,11 +438,9 @@ class BillingOptionsList(): :attr List[BillingOption] resources: (optional) A list of billing units found. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['BillingOption'] = None) -> None: + def __init__( + self, *, rows_count: int = None, next_url: str = None, resources: List['BillingOption'] = None + ) -> None: """ Initialize a BillingOptionsList object. @@ -541,7 +501,8 @@ def __ne__(self, other: 'BillingOptionsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class BillingUnit(): + +class BillingUnit: """ Information about a billing unit. @@ -559,16 +520,18 @@ class BillingUnit(): :attr datetime created_at: (optional) The creation date of the billing unit. """ - def __init__(self, - *, - id: str = None, - crn: str = None, - name: str = None, - enterprise_id: str = None, - currency_code: str = None, - country_code: str = None, - master: bool = None, - created_at: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + crn: str = None, + name: str = None, + enterprise_id: str = None, + currency_code: str = None, + country_code: str = None, + master: bool = None, + created_at: datetime = None + ) -> None: """ Initialize a BillingUnit object. @@ -662,7 +625,8 @@ def __ne__(self, other: 'BillingUnit') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class BillingUnitsList(): + +class BillingUnitsList: """ A search result contining zero or more billing units. @@ -673,11 +637,7 @@ class BillingUnitsList(): :attr List[BillingUnit] resources: (optional) A list of billing units found. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['BillingUnit'] = None) -> None: + def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['BillingUnit'] = None) -> None: """ Initialize a BillingUnitsList object. @@ -738,7 +698,8 @@ def __ne__(self, other: 'BillingUnitsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreditPool(): + +class CreditPool: """ The credit pool for a billing unit. @@ -754,13 +715,15 @@ class CreditPool(): credit pool. """ - def __init__(self, - *, - type: str = None, - currency_code: str = None, - billing_unit_id: str = None, - term_credits: List['TermCredits'] = None, - overage: 'CreditPoolOverage' = None) -> None: + def __init__( + self, + *, + type: str = None, + currency_code: str = None, + billing_unit_id: str = None, + term_credits: List['TermCredits'] = None, + overage: 'CreditPoolOverage' = None + ) -> None: """ Initialize a CreditPool object. @@ -840,11 +803,12 @@ class TypeEnum(str, Enum): """ The type of credit, either `PLATFORM` or `SUPPORT`. """ + PLATFORM = 'PLATFORM' SUPPORT = 'SUPPORT' -class CreditPoolOverage(): +class CreditPoolOverage: """ Overage that was generated on the credit pool. @@ -853,10 +817,7 @@ class CreditPoolOverage(): overage. """ - def __init__(self, - *, - cost: float = None, - resources: List[dict] = None) -> None: + def __init__(self, *, cost: float = None, resources: List[dict] = None) -> None: """ Initialize a CreditPoolOverage object. @@ -909,7 +870,8 @@ def __ne__(self, other: 'CreditPoolOverage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreditPoolsList(): + +class CreditPoolsList: """ A search result containing zero or more credit pools. @@ -921,11 +883,7 @@ class CreditPoolsList(): query. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['CreditPool'] = None) -> None: + def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['CreditPool'] = None) -> None: """ Initialize a CreditPoolsList object. @@ -987,7 +945,8 @@ def __ne__(self, other: 'CreditPoolsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TermCredits(): + +class TermCredits: """ The subscription term that is active in the current month. @@ -1009,17 +968,19 @@ class TermCredits(): during the month. """ - def __init__(self, - *, - billing_option_id: str = None, - category: str = None, - start_date: datetime = None, - end_date: datetime = None, - total_credits: float = None, - starting_balance: float = None, - used_credits: float = None, - current_balance: float = None, - resources: List[dict] = None) -> None: + def __init__( + self, + *, + billing_option_id: str = None, + category: str = None, + start_date: datetime = None, + end_date: datetime = None, + total_credits: float = None, + starting_balance: float = None, + used_credits: float = None, + current_balance: float = None, + resources: List[dict] = None + ) -> None: """ Initialize a TermCredits object. @@ -1128,8 +1089,8 @@ class CategoryEnum(str, Enum): The category of the credit pool. The valid values are `PLATFORM`, `OFFER`, or `SERVICE` for platform credit and `SUPPORT` for support credit. """ + PLATFORM = 'PLATFORM' OFFER = 'OFFER' SERVICE = 'SERVICE' SUPPORT = 'SUPPORT' - diff --git a/ibm_platform_services/enterprise_management_v1.py b/ibm_platform_services/enterprise_management_v1.py index 64cc0c7d..1c0db27b 100644 --- a/ibm_platform_services/enterprise_management_v1.py +++ b/ibm_platform_services/enterprise_management_v1.py @@ -38,6 +38,7 @@ # Service ############################################################################## + class EnterpriseManagementV1(BaseService): """The Enterprise Management V1 service.""" @@ -45,23 +46,23 @@ class EnterpriseManagementV1(BaseService): DEFAULT_SERVICE_NAME = 'enterprise_management' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'EnterpriseManagementV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'EnterpriseManagementV1': """ Return a new client for the Enterprise Management service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Enterprise Management service. @@ -69,23 +70,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Enterprise Operations ######################### - - def create_enterprise(self, - source_account_id: str, - name: str, - primary_contact_iam_id: str, - *, - domain: str = None, - **kwargs + def create_enterprise( + self, source_account_id: str, name: str, primary_contact_iam_id: str, *, domain: str = None, **kwargs ) -> DetailedResponse: """ Create an enterprise. @@ -120,16 +112,16 @@ def create_enterprise(self, if primary_contact_iam_id is None: raise ValueError('primary_contact_iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_enterprise') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_enterprise' + ) headers.update(sdk_headers) data = { 'source_account_id': source_account_id, 'name': name, 'primary_contact_iam_id': primary_contact_iam_id, - 'domain': domain + 'domain': domain, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -141,23 +133,20 @@ def create_enterprise(self, headers['Accept'] = 'application/json' url = '/enterprises' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_enterprises(self, + def list_enterprises( + self, *, enterprise_account_id: str = None, account_group_id: str = None, account_id: str = None, next_docid: str = None, limit: int = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ List enterprises. @@ -192,9 +181,9 @@ def list_enterprises(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_enterprises') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_enterprises' + ) headers.update(sdk_headers) params = { @@ -202,7 +191,7 @@ def list_enterprises(self, 'account_group_id': account_group_id, 'account_id': account_id, 'next_docid': next_docid, - 'limit': limit + 'limit': limit, } if 'headers' in kwargs: @@ -211,19 +200,12 @@ def list_enterprises(self, headers['Accept'] = 'application/json' url = '/enterprises' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_enterprise(self, - enterprise_id: str, - **kwargs - ) -> DetailedResponse: + def get_enterprise(self, enterprise_id: str, **kwargs) -> DetailedResponse: """ Get enterprise by ID. @@ -239,9 +221,9 @@ def get_enterprise(self, if not enterprise_id: raise ValueError('enterprise_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_enterprise') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_enterprise' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -253,21 +235,13 @@ def get_enterprise(self, path_param_values = self.encode_path_vars(enterprise_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/enterprises/{enterprise_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_enterprise(self, - enterprise_id: str, - *, - name: str = None, - domain: str = None, - primary_contact_iam_id: str = None, - **kwargs + def update_enterprise( + self, enterprise_id: str, *, name: str = None, domain: str = None, primary_contact_iam_id: str = None, **kwargs ) -> DetailedResponse: """ Update an enterprise. @@ -291,16 +265,12 @@ def update_enterprise(self, if not enterprise_id: raise ValueError('enterprise_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_enterprise') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_enterprise' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'domain': domain, - 'primary_contact_iam_id': primary_contact_iam_id - } + data = {'name': name, 'domain': domain, 'primary_contact_iam_id': primary_contact_iam_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -313,10 +283,7 @@ def update_enterprise(self, path_param_values = self.encode_path_vars(enterprise_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/enterprises/{enterprise_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -325,14 +292,8 @@ def update_enterprise(self, # Account Operations ######################### - - def import_account_to_enterprise(self, - enterprise_id: str, - account_id: str, - *, - parent: str = None, - billing_unit_id: str = None, - **kwargs + def import_account_to_enterprise( + self, enterprise_id: str, account_id: str, *, parent: str = None, billing_unit_id: str = None, **kwargs ) -> DetailedResponse: """ Import an account into an enterprise. @@ -368,15 +329,12 @@ def import_account_to_enterprise(self, if not account_id: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='import_account_to_enterprise') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='import_account_to_enterprise' + ) headers.update(sdk_headers) - data = { - 'parent': parent, - 'billing_unit_id': billing_unit_id - } + data = {'parent': parent, 'billing_unit_id': billing_unit_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -389,21 +347,12 @@ def import_account_to_enterprise(self, path_param_values = self.encode_path_vars(enterprise_id, account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/enterprises/{enterprise_id}/import/accounts/{account_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def create_account(self, - parent: str, - name: str, - owner_iam_id: str, - **kwargs - ) -> DetailedResponse: + def create_account(self, parent: str, name: str, owner_iam_id: str, **kwargs) -> DetailedResponse: """ Create a new account in an enterprise. @@ -432,16 +381,12 @@ def create_account(self, if owner_iam_id is None: raise ValueError('owner_iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_account') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_account' + ) headers.update(sdk_headers) - data = { - 'parent': parent, - 'name': name, - 'owner_iam_id': owner_iam_id - } + data = {'parent': parent, 'name': name, 'owner_iam_id': owner_iam_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -452,23 +397,20 @@ def create_account(self, headers['Accept'] = 'application/json' url = '/accounts' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_accounts(self, + def list_accounts( + self, *, enterprise_id: str = None, account_group_id: str = None, next_docid: str = None, parent: str = None, limit: int = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ List accounts. @@ -506,9 +448,9 @@ def list_accounts(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_accounts') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_accounts' + ) headers.update(sdk_headers) params = { @@ -516,7 +458,7 @@ def list_accounts(self, 'account_group_id': account_group_id, 'next_docid': next_docid, 'parent': parent, - 'limit': limit + 'limit': limit, } if 'headers' in kwargs: @@ -525,19 +467,12 @@ def list_accounts(self, headers['Accept'] = 'application/json' url = '/accounts' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_account(self, - account_id: str, - **kwargs - ) -> DetailedResponse: + def get_account(self, account_id: str, **kwargs) -> DetailedResponse: """ Get account by ID. @@ -553,9 +488,9 @@ def get_account(self, if not account_id: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_account') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_account' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -567,19 +502,12 @@ def get_account(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/accounts/{account_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_account(self, - account_id: str, - parent: str, - **kwargs - ) -> DetailedResponse: + def update_account(self, account_id: str, parent: str, **kwargs) -> DetailedResponse: """ Move an account within the enterprise. @@ -597,14 +525,12 @@ def update_account(self, if parent is None: raise ValueError('parent must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_account') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_account' + ) headers.update(sdk_headers) - data = { - 'parent': parent - } + data = {'parent': parent} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -617,10 +543,7 @@ def update_account(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/accounts/{account_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -629,13 +552,7 @@ def update_account(self, # Account Group Operations ######################### - - def create_account_group(self, - parent: str, - name: str, - primary_contact_iam_id: str, - **kwargs - ) -> DetailedResponse: + def create_account_group(self, parent: str, name: str, primary_contact_iam_id: str, **kwargs) -> DetailedResponse: """ Create an account group. @@ -664,16 +581,12 @@ def create_account_group(self, if primary_contact_iam_id is None: raise ValueError('primary_contact_iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_account_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_account_group' + ) headers.update(sdk_headers) - data = { - 'parent': parent, - 'name': name, - 'primary_contact_iam_id': primary_contact_iam_id - } + data = {'parent': parent, 'name': name, 'primary_contact_iam_id': primary_contact_iam_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -684,23 +597,20 @@ def create_account_group(self, headers['Accept'] = 'application/json' url = '/account-groups' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_account_groups(self, + def list_account_groups( + self, *, enterprise_id: str = None, parent_account_group_id: str = None, next_docid: str = None, parent: str = None, limit: int = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ List account groups. @@ -740,9 +650,9 @@ def list_account_groups(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_account_groups') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_account_groups' + ) headers.update(sdk_headers) params = { @@ -750,7 +660,7 @@ def list_account_groups(self, 'parent_account_group_id': parent_account_group_id, 'next_docid': next_docid, 'parent': parent, - 'limit': limit + 'limit': limit, } if 'headers' in kwargs: @@ -759,19 +669,12 @@ def list_account_groups(self, headers['Accept'] = 'application/json' url = '/account-groups' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_account_group(self, - account_group_id: str, - **kwargs - ) -> DetailedResponse: + def get_account_group(self, account_group_id: str, **kwargs) -> DetailedResponse: """ Get account group by ID. @@ -788,9 +691,9 @@ def get_account_group(self, if not account_group_id: raise ValueError('account_group_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_account_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_account_group' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -802,20 +705,13 @@ def get_account_group(self, path_param_values = self.encode_path_vars(account_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/account-groups/{account_group_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_account_group(self, - account_group_id: str, - *, - name: str = None, - primary_contact_iam_id: str = None, - **kwargs + def update_account_group( + self, account_group_id: str, *, name: str = None, primary_contact_iam_id: str = None, **kwargs ) -> DetailedResponse: """ Update an account group. @@ -836,15 +732,12 @@ def update_account_group(self, if not account_group_id: raise ValueError('account_group_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_account_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_account_group' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'primary_contact_iam_id': primary_contact_iam_id - } + data = {'name': name, 'primary_contact_iam_id': primary_contact_iam_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -857,10 +750,7 @@ def update_account_group(self, path_param_values = self.encode_path_vars(account_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/account-groups/{account_group_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -871,7 +761,7 @@ def update_account_group(self, ############################################################################## -class Account(): +class Account: """ An account resource. @@ -901,25 +791,27 @@ class Account(): the account. """ - def __init__(self, - *, - url: str = None, - id: str = None, - crn: str = None, - parent: str = None, - enterprise_account_id: str = None, - enterprise_id: str = None, - enterprise_path: str = None, - name: str = None, - state: str = None, - owner_iam_id: str = None, - paid: bool = None, - owner_email: str = None, - is_enterprise_account: bool = None, - created_at: datetime = None, - created_by: str = None, - updated_at: datetime = None, - updated_by: str = None) -> None: + def __init__( + self, + *, + url: str = None, + id: str = None, + crn: str = None, + parent: str = None, + enterprise_account_id: str = None, + enterprise_id: str = None, + enterprise_path: str = None, + name: str = None, + state: str = None, + owner_iam_id: str = None, + paid: bool = None, + owner_email: str = None, + is_enterprise_account: bool = None, + created_at: datetime = None, + created_by: str = None, + updated_at: datetime = None, + updated_by: str = None, + ) -> None: """ Initialize a Account object. @@ -1070,7 +962,8 @@ def __ne__(self, other: 'Account') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccountGroup(): + +class AccountGroup: """ An account group resource. @@ -1099,23 +992,25 @@ class AccountGroup(): the account group. """ - def __init__(self, - *, - url: str = None, - id: str = None, - crn: str = None, - parent: str = None, - enterprise_account_id: str = None, - enterprise_id: str = None, - enterprise_path: str = None, - name: str = None, - state: str = None, - primary_contact_iam_id: str = None, - primary_contact_email: str = None, - created_at: datetime = None, - created_by: str = None, - updated_at: datetime = None, - updated_by: str = None) -> None: + def __init__( + self, + *, + url: str = None, + id: str = None, + crn: str = None, + parent: str = None, + enterprise_account_id: str = None, + enterprise_id: str = None, + enterprise_path: str = None, + name: str = None, + state: str = None, + primary_contact_iam_id: str = None, + primary_contact_email: str = None, + created_at: datetime = None, + created_by: str = None, + updated_at: datetime = None, + updated_by: str = None, + ) -> None: """ Initialize a AccountGroup object. @@ -1254,7 +1149,8 @@ def __ne__(self, other: 'AccountGroup') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreateAccountGroupResponse(): + +class CreateAccountGroupResponse: """ A newly-created account group. @@ -1262,9 +1158,7 @@ class CreateAccountGroupResponse(): was created. """ - def __init__(self, - *, - account_group_id: str = None) -> None: + def __init__(self, *, account_group_id: str = None) -> None: """ Initialize a CreateAccountGroupResponse object. @@ -1311,16 +1205,15 @@ def __ne__(self, other: 'CreateAccountGroupResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreateAccountResponse(): + +class CreateAccountResponse: """ A newly-created account. :attr str account_id: (optional) The ID of the account entity that was created. """ - def __init__(self, - *, - account_id: str = None) -> None: + def __init__(self, *, account_id: str = None) -> None: """ Initialize a CreateAccountResponse object. @@ -1367,7 +1260,8 @@ def __ne__(self, other: 'CreateAccountResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreateEnterpriseResponse(): + +class CreateEnterpriseResponse: """ The response from calling create enterprise. @@ -1378,10 +1272,7 @@ class CreateEnterpriseResponse(): the enterprise management. """ - def __init__(self, - *, - enterprise_id: str = None, - enterprise_account_id: str = None) -> None: + def __init__(self, *, enterprise_id: str = None, enterprise_account_id: str = None) -> None: """ Initialize a CreateEnterpriseResponse object. @@ -1436,7 +1327,8 @@ def __ne__(self, other: 'CreateEnterpriseResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Enterprise(): + +class Enterprise: """ An enterprise resource. @@ -1461,21 +1353,23 @@ class Enterprise(): the enterprise. """ - def __init__(self, - *, - url: str = None, - id: str = None, - enterprise_account_id: str = None, - crn: str = None, - name: str = None, - domain: str = None, - state: str = None, - primary_contact_iam_id: str = None, - primary_contact_email: str = None, - created_at: datetime = None, - created_by: str = None, - updated_at: datetime = None, - updated_by: str = None) -> None: + def __init__( + self, + *, + url: str = None, + id: str = None, + enterprise_account_id: str = None, + crn: str = None, + name: str = None, + domain: str = None, + state: str = None, + primary_contact_iam_id: str = None, + primary_contact_email: str = None, + created_at: datetime = None, + created_by: str = None, + updated_at: datetime = None, + updated_by: str = None, + ) -> None: """ Initialize a Enterprise object. @@ -1599,7 +1493,8 @@ def __ne__(self, other: 'Enterprise') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ListAccountGroupsResponse(): + +class ListAccountGroupsResponse: """ The list_account_groups operation response. @@ -1610,11 +1505,7 @@ class ListAccountGroupsResponse(): :attr List[AccountGroup] resources: (optional) A list of account groups. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['AccountGroup'] = None) -> None: + def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['AccountGroup'] = None) -> None: """ Initialize a ListAccountGroupsResponse object. @@ -1680,7 +1571,8 @@ def __ne__(self, other: 'ListAccountGroupsResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ListAccountsResponse(): + +class ListAccountsResponse: """ The list_accounts operation response. @@ -1691,11 +1583,7 @@ class ListAccountsResponse(): :attr List[Account] resources: (optional) A list of accounts. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['Account'] = None) -> None: + def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['Account'] = None) -> None: """ Initialize a ListAccountsResponse object. @@ -1761,7 +1649,8 @@ def __ne__(self, other: 'ListAccountsResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ListEnterprisesResponse(): + +class ListEnterprisesResponse: """ The response from calling list enterprises. @@ -1772,11 +1661,7 @@ class ListEnterprisesResponse(): :attr List[Enterprise] resources: (optional) A list of enterprise objects. """ - def __init__(self, - *, - rows_count: int = None, - next_url: str = None, - resources: List['Enterprise'] = None) -> None: + def __init__(self, *, rows_count: int = None, next_url: str = None, resources: List['Enterprise'] = None) -> None: """ Initialize a ListEnterprisesResponse object. @@ -1842,22 +1727,25 @@ def __ne__(self, other: 'ListEnterprisesResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + ############################################################################## # Pagers ############################################################################## -class EnterprisesPager(): + +class EnterprisesPager: """ EnterprisesPager can be used to simplify the use of the "list_enterprises" method. """ - def __init__(self, - *, - client: EnterpriseManagementV1, - enterprise_account_id: str = None, - account_group_id: str = None, - account_id: str = None, - limit: int = None, + def __init__( + self, + *, + client: EnterpriseManagementV1, + enterprise_account_id: str = None, + account_group_id: str = None, + account_id: str = None, + limit: int = None, ) -> None: """ Initialize a EnterprisesPager object. @@ -1871,7 +1759,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._enterprise_account_id = enterprise_account_id self._account_group_id = account_group_id self._account_id = account_id @@ -1923,18 +1811,20 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class AccountsPager(): + +class AccountsPager: """ AccountsPager can be used to simplify the use of the "list_accounts" method. """ - def __init__(self, - *, - client: EnterpriseManagementV1, - enterprise_id: str = None, - account_group_id: str = None, - parent: str = None, - limit: int = None, + def __init__( + self, + *, + client: EnterpriseManagementV1, + enterprise_id: str = None, + account_group_id: str = None, + parent: str = None, + limit: int = None, ) -> None: """ Initialize a AccountsPager object. @@ -1950,7 +1840,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._enterprise_id = enterprise_id self._account_group_id = account_group_id self._parent = parent @@ -2002,18 +1892,20 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class AccountGroupsPager(): + +class AccountGroupsPager: """ AccountGroupsPager can be used to simplify the use of the "list_account_groups" method. """ - def __init__(self, - *, - client: EnterpriseManagementV1, - enterprise_id: str = None, - parent_account_group_id: str = None, - parent: str = None, - limit: int = None, + def __init__( + self, + *, + client: EnterpriseManagementV1, + enterprise_id: str = None, + parent_account_group_id: str = None, + parent: str = None, + limit: int = None, ) -> None: """ Initialize a AccountGroupsPager object. @@ -2030,7 +1922,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._enterprise_id = enterprise_id self._parent_account_group_id = parent_account_group_id self._parent = parent diff --git a/ibm_platform_services/enterprise_usage_reports_v1.py b/ibm_platform_services/enterprise_usage_reports_v1.py index 46b6c586..38daf5ac 100644 --- a/ibm_platform_services/enterprise_usage_reports_v1.py +++ b/ibm_platform_services/enterprise_usage_reports_v1.py @@ -36,6 +36,7 @@ # Service ############################################################################## + class EnterpriseUsageReportsV1(BaseService): """The Enterprise Usage Reports V1 service.""" @@ -43,23 +44,23 @@ class EnterpriseUsageReportsV1(BaseService): DEFAULT_SERVICE_NAME = 'enterprise_usage_reports' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'EnterpriseUsageReportsV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'EnterpriseUsageReportsV1': """ Return a new client for the Enterprise Usage Reports service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Enterprise Usage Reports service. @@ -67,17 +68,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Enterprise Usage Reports ######################### - - def get_resource_usage_report(self, + def get_resource_usage_report( + self, *, enterprise_id: str = None, account_group_id: str = None, @@ -87,7 +85,7 @@ def get_resource_usage_report(self, billing_unit_id: str = None, limit: int = None, offset: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get usage reports for enterprise entities. @@ -125,9 +123,9 @@ def get_resource_usage_report(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_resource_usage_report') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_resource_usage_report' + ) headers.update(sdk_headers) params = { @@ -138,7 +136,7 @@ def get_resource_usage_report(self, 'month': month, 'billing_unit_id': billing_unit_id, 'limit': limit, - 'offset': offset + 'offset': offset, } if 'headers' in kwargs: @@ -147,10 +145,7 @@ def get_resource_usage_report(self, headers['Accept'] = 'application/json' url = '/v1/resource-usage-reports' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -161,16 +156,14 @@ def get_resource_usage_report(self, ############################################################################## -class Link(): +class Link: """ An object that contains a link to a page of search results. :attr str href: (optional) A link to a page of search results. """ - def __init__(self, - *, - href: str = None) -> None: + def __init__(self, *, href: str = None) -> None: """ Initialize a Link object. @@ -216,7 +209,8 @@ def __ne__(self, other: 'Link') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class MetricUsage(): + +class MetricUsage: """ An object that represents a metric. @@ -230,15 +224,17 @@ class MetricUsage(): :attr List[dict] price: (optional) The price with which cost was calculated. """ - def __init__(self, - metric: str, - unit: str, - quantity: float, - rateable_quantity: float, - cost: float, - rated_cost: float, - *, - price: List[dict] = None) -> None: + def __init__( + self, + metric: str, + unit: str, + quantity: float, + rateable_quantity: float, + cost: float, + rated_cost: float, + *, + price: List[dict] = None, + ) -> None: """ Initialize a MetricUsage object. @@ -335,7 +331,8 @@ def __ne__(self, other: 'MetricUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PlanUsage(): + +class PlanUsage: """ Aggregated values for the plan. @@ -350,15 +347,17 @@ class PlanUsage(): :attr List[MetricUsage] usage: All of the metrics in the plan. """ - def __init__(self, - plan_id: str, - billable: bool, - cost: float, - rated_cost: float, - usage: List['MetricUsage'], - *, - pricing_region: str = None, - pricing_plan_id: str = None) -> None: + def __init__( + self, + plan_id: str, + billable: bool, + cost: float, + rated_cost: float, + usage: List['MetricUsage'], + *, + pricing_region: str = None, + pricing_plan_id: str = None, + ) -> None: """ Initialize a PlanUsage object. @@ -452,7 +451,8 @@ def __ne__(self, other: 'PlanUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Reports(): + +class Reports: """ Resource Usage Reports API response. @@ -464,12 +464,14 @@ class Reports(): :attr List[ResourceUsageReport] reports: (optional) The list of usage reports. """ - def __init__(self, - *, - limit: int = None, - first: 'Link' = None, - next: 'Link' = None, - reports: List['ResourceUsageReport'] = None) -> None: + def __init__( + self, + *, + limit: int = None, + first: 'Link' = None, + next: 'Link' = None, + reports: List['ResourceUsageReport'] = None, + ) -> None: """ Initialize a Reports object. @@ -536,7 +538,8 @@ def __ne__(self, other: 'Reports') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceUsage(): + +class ResourceUsage: """ A container for all the plans in the resource. @@ -550,13 +553,15 @@ class ResourceUsage(): :attr List[PlanUsage] plans: All of the plans in the resource. """ - def __init__(self, - resource_id: str, - billable_cost: float, - billable_rated_cost: float, - non_billable_cost: float, - non_billable_rated_cost: float, - plans: List['PlanUsage']) -> None: + def __init__( + self, + resource_id: str, + billable_cost: float, + billable_rated_cost: float, + non_billable_cost: float, + non_billable_rated_cost: float, + plans: List['PlanUsage'], + ) -> None: """ Initialize a ResourceUsage object. @@ -646,7 +651,8 @@ def __ne__(self, other: 'ResourceUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceUsageReport(): + +class ResourceUsageReport: """ An object that represents a usage report. @@ -673,22 +679,24 @@ class ResourceUsageReport(): included in the aggregated charges. """ - def __init__(self, - entity_id: str, - entity_type: str, - entity_crn: str, - entity_name: str, - billing_unit_id: str, - billing_unit_crn: str, - billing_unit_name: str, - country_code: str, - currency_code: str, - month: str, - billable_cost: float, - non_billable_cost: float, - billable_rated_cost: float, - non_billable_rated_cost: float, - resources: List['ResourceUsage']) -> None: + def __init__( + self, + entity_id: str, + entity_type: str, + entity_crn: str, + entity_name: str, + billing_unit_id: str, + billing_unit_crn: str, + billing_unit_name: str, + country_code: str, + currency_code: str, + month: str, + billable_cost: float, + non_billable_cost: float, + billable_rated_cost: float, + non_billable_rated_cost: float, + resources: List['ResourceUsage'], + ) -> None: """ Initialize a ResourceUsageReport object. @@ -859,6 +867,7 @@ class EntityTypeEnum(str, Enum): """ The entity type. """ + ENTERPRISE = 'enterprise' ACCOUNT_GROUP = 'account-group' ACCOUNT = 'account' @@ -868,21 +877,23 @@ class EntityTypeEnum(str, Enum): # Pagers ############################################################################## -class GetResourceUsageReportPager(): + +class GetResourceUsageReportPager: """ GetResourceUsageReportPager can be used to simplify the use of the "get_resource_usage_report" method. """ - def __init__(self, - *, - client: EnterpriseUsageReportsV1, - enterprise_id: str = None, - account_group_id: str = None, - account_id: str = None, - children: bool = None, - month: str = None, - billing_unit_id: str = None, - limit: int = None, + def __init__( + self, + *, + client: EnterpriseUsageReportsV1, + enterprise_id: str = None, + account_group_id: str = None, + account_id: str = None, + children: bool = None, + month: str = None, + billing_unit_id: str = None, + limit: int = None, ) -> None: """ Initialize a GetResourceUsageReportPager object. @@ -908,7 +919,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._enterprise_id = enterprise_id self._account_group_id = account_group_id self._account_id = account_id diff --git a/ibm_platform_services/global_catalog_v1.py b/ibm_platform_services/global_catalog_v1.py index af905ce3..a4b2bbe4 100644 --- a/ibm_platform_services/global_catalog_v1.py +++ b/ibm_platform_services/global_catalog_v1.py @@ -42,6 +42,7 @@ # Service ############################################################################## + class GlobalCatalogV1(BaseService): """The Global Catalog V1 service.""" @@ -49,23 +50,23 @@ class GlobalCatalogV1(BaseService): DEFAULT_SERVICE_NAME = 'global_catalog' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'GlobalCatalogV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'GlobalCatalogV1': """ Return a new client for the Global Catalog service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Global Catalog service. @@ -73,17 +74,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Object ######################### - - def list_catalog_entries(self, + def list_catalog_entries( + self, *, account: str = None, include: str = None, @@ -150,9 +148,9 @@ def list_catalog_entries(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_catalog_entries') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_catalog_entries' + ) headers.update(sdk_headers) params = { @@ -165,7 +163,7 @@ def list_catalog_entries(self, 'catalog': catalog, 'complete': complete, '_offset': offset, - '_limit': limit + '_limit': limit, } if 'headers' in kwargs: @@ -173,16 +171,13 @@ def list_catalog_entries(self, headers['Accept'] = 'application/json' url = '/' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def create_catalog_entry(self, + def create_catalog_entry( + self, name: str, kind: str, overview_ui: dict, @@ -262,14 +257,12 @@ def create_catalog_entry(self, if metadata is not None: metadata = convert_model(metadata) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_catalog_entry') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_catalog_entry' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} data = { 'name': name, @@ -283,7 +276,7 @@ def create_catalog_entry(self, 'parent_id': parent_id, 'group': group, 'active': active, - 'metadata': metadata + 'metadata': metadata, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -294,17 +287,13 @@ def create_catalog_entry(self, headers['Accept'] = 'application/json' url = '/' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def get_catalog_entry(self, + def get_catalog_entry( + self, id: str, *, account: str = None, @@ -354,18 +343,12 @@ def get_catalog_entry(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_catalog_entry') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_catalog_entry' + ) headers.update(sdk_headers) - params = { - 'account': account, - 'include': include, - 'languages': languages, - 'complete': complete, - 'depth': depth - } + params = {'account': account, 'include': include, 'languages': languages, 'complete': complete, 'depth': depth} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -375,16 +358,13 @@ def get_catalog_entry(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def update_catalog_entry(self, + def update_catalog_entry( + self, id: str, name: str, kind: str, @@ -470,15 +450,12 @@ def update_catalog_entry(self, if metadata is not None: metadata = convert_model(metadata) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_catalog_entry') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_catalog_entry' + ) headers.update(sdk_headers) - params = { - 'account': account, - 'move': move - } + params = {'account': account, 'move': move} data = { 'name': name, @@ -491,7 +468,7 @@ def update_catalog_entry(self, 'parent_id': parent_id, 'group': group, 'active': active, - 'metadata': metadata + 'metadata': metadata, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -505,23 +482,12 @@ def update_catalog_entry(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def delete_catalog_entry(self, - id: str, - *, - account: str = None, - force: bool = None, - **kwargs - ) -> DetailedResponse: + def delete_catalog_entry(self, id: str, *, account: str = None, force: bool = None, **kwargs) -> DetailedResponse: """ Delete a catalog entry. @@ -546,15 +512,12 @@ def delete_catalog_entry(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_catalog_entry') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_catalog_entry' + ) headers.update(sdk_headers) - params = { - 'account': account, - 'force': force - } + params = {'account': account, 'force': force} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -563,16 +526,13 @@ def delete_catalog_entry(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response - - def get_child_objects(self, + def get_child_objects( + self, id: str, kind: str, *, @@ -634,9 +594,9 @@ def get_child_objects(self, if kind is None: raise ValueError('kind must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_child_objects') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_child_objects' + ) headers.update(sdk_headers) params = { @@ -648,7 +608,7 @@ def get_child_objects(self, 'languages': languages, 'complete': complete, '_offset': offset, - '_limit': limit + '_limit': limit, } if 'headers' in kwargs: @@ -659,21 +619,12 @@ def get_child_objects(self, path_param_values = self.encode_path_vars(id, kind) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/{kind}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def restore_catalog_entry(self, - id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def restore_catalog_entry(self, id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Restore archived catalog entry. @@ -693,14 +644,12 @@ def restore_catalog_entry(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='restore_catalog_entry') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='restore_catalog_entry' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -709,10 +658,7 @@ def restore_catalog_entry(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/restore'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params) response = self.send(request) return response @@ -721,13 +667,7 @@ def restore_catalog_entry(self, # Visibility ######################### - - def get_visibility(self, - id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def get_visibility(self, id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Get the visibility constraints for an object. @@ -749,14 +689,12 @@ def get_visibility(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_visibility') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_visibility' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -766,16 +704,13 @@ def get_visibility(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/visibility'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def update_visibility(self, + def update_visibility( + self, id: str, *, extendable: bool = None, @@ -812,20 +747,14 @@ def update_visibility(self, if exclude is not None: exclude = convert_model(exclude) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_visibility') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_visibility' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} - data = { - 'extendable': extendable, - 'include': include, - 'exclude': exclude - } + data = {'extendable': extendable, 'include': include, 'exclude': exclude} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -837,11 +766,7 @@ def update_visibility(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/visibility'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request) return response @@ -850,13 +775,7 @@ def update_visibility(self, # Pricing ######################### - - def get_pricing(self, - id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def get_pricing(self, id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Get the pricing for an object. @@ -877,14 +796,12 @@ def get_pricing(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_pricing') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_pricing' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -894,10 +811,7 @@ def get_pricing(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/pricing'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -906,8 +820,8 @@ def get_pricing(self, # Audit ######################### - - def get_audit_logs(self, + def get_audit_logs( + self, id: str, *, account: str = None, @@ -948,18 +862,12 @@ def get_audit_logs(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_audit_logs') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_audit_logs' + ) headers.update(sdk_headers) - params = { - 'account': account, - 'ascending': ascending, - 'startat': startat, - '_offset': offset, - '_limit': limit - } + params = {'account': account, 'ascending': ascending, 'startat': startat, '_offset': offset, '_limit': limit} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -969,10 +877,7 @@ def get_audit_logs(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{id}/logs'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -981,13 +886,7 @@ def get_audit_logs(self, # Artifact ######################### - - def list_artifacts(self, - object_id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def list_artifacts(self, object_id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Get artifacts. @@ -1006,14 +905,12 @@ def list_artifacts(self, if object_id is None: raise ValueError('object_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_artifacts') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_artifacts' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1023,22 +920,12 @@ def list_artifacts(self, path_param_values = self.encode_path_vars(object_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{object_id}/artifacts'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def get_artifact(self, - object_id: str, - artifact_id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def get_artifact(self, object_id: str, artifact_id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Get artifact. @@ -1060,14 +947,12 @@ def get_artifact(self, if artifact_id is None: raise ValueError('artifact_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_artifact') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_artifact' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1077,16 +962,13 @@ def get_artifact(self, path_param_values = self.encode_path_vars(object_id, artifact_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{object_id}/artifacts/{artifact_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def upload_artifact(self, + def upload_artifact( + self, object_id: str, artifact_id: str, *, @@ -1118,17 +1000,13 @@ def upload_artifact(self, raise ValueError('object_id must be provided') if artifact_id is None: raise ValueError('artifact_id must be provided') - headers = { - 'Content-Type': content_type - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='upload_artifact') + headers = {'Content-Type': content_type} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='upload_artifact' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} data = artifact @@ -1139,23 +1017,12 @@ def upload_artifact(self, path_param_values = self.encode_path_vars(object_id, artifact_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{object_id}/artifacts/{artifact_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def delete_artifact(self, - object_id: str, - artifact_id: str, - *, - account: str = None, - **kwargs - ) -> DetailedResponse: + def delete_artifact(self, object_id: str, artifact_id: str, *, account: str = None, **kwargs) -> DetailedResponse: """ Delete artifact. @@ -1178,14 +1045,12 @@ def delete_artifact(self, if artifact_id is None: raise ValueError('artifact_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_artifact') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_artifact' + ) headers.update(sdk_headers) - params = { - 'account': account - } + params = {'account': account} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1194,10 +1059,7 @@ def delete_artifact(self, path_param_values = self.encode_path_vars(object_id, artifact_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/{object_id}/artifacts/{artifact_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response @@ -1208,7 +1070,7 @@ def delete_artifact(self, ############################################################################## -class AliasMetaData(): +class AliasMetaData: """ Alias-related metadata. @@ -1217,10 +1079,7 @@ class AliasMetaData(): for. """ - def __init__(self, - *, - type: str = None, - plan_id: str = None) -> None: + def __init__(self, *, type: str = None, plan_id: str = None) -> None: """ Initialize a AliasMetaData object. @@ -1273,7 +1132,8 @@ def __ne__(self, other: 'AliasMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Amount(): + +class Amount: """ Country-specific pricing information. @@ -1282,11 +1142,7 @@ class Amount(): :attr List[Price] prices: (optional) See Price for nested fields. """ - def __init__(self, - *, - country: str = None, - currency: str = None, - prices: List['Price'] = None) -> None: + def __init__(self, *, country: str = None, currency: str = None, prices: List['Price'] = None) -> None: """ Initialize a Amount object. @@ -1344,7 +1200,8 @@ def __ne__(self, other: 'Amount') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Artifact(): + +class Artifact: """ Artifact Details. @@ -1356,13 +1213,9 @@ class Artifact(): :attr int size: (optional) The content length of the artifact. """ - def __init__(self, - *, - name: str = None, - updated: datetime = None, - url: str = None, - etag: str = None, - size: int = None) -> None: + def __init__( + self, *, name: str = None, updated: datetime = None, url: str = None, etag: str = None, size: int = None + ) -> None: """ Initialize a Artifact object. @@ -1433,7 +1286,8 @@ def __ne__(self, other: 'Artifact') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Artifacts(): + +class Artifacts: """ Artifacts List. @@ -1441,10 +1295,7 @@ class Artifacts(): :attr List[Artifact] resources: (optional) The list of artifacts. """ - def __init__(self, - *, - count: int = None, - resources: List['Artifact'] = None) -> None: + def __init__(self, *, count: int = None, resources: List['Artifact'] = None) -> None: """ Initialize a Artifacts object. @@ -1496,7 +1347,8 @@ def __ne__(self, other: 'Artifacts') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AuditSearchResult(): + +class AuditSearchResult: """ A paginated search result containing audit logs. @@ -1518,17 +1370,19 @@ class AuditSearchResult(): contained in this page of search results. """ - def __init__(self, - *, - offset: int = None, - limit: int = None, - count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['Message'] = None) -> None: + def __init__( + self, + *, + offset: int = None, + limit: int = None, + count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['Message'] = None + ) -> None: """ Initialize a AuditSearchResult object. @@ -1631,7 +1485,8 @@ def __ne__(self, other: 'AuditSearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Broker(): + +class Broker: """ The broker associated with a catalog entry. @@ -1639,10 +1494,7 @@ class Broker(): :attr str guid: (optional) Broker guid. """ - def __init__(self, - *, - name: str = None, - guid: str = None) -> None: + def __init__(self, *, name: str = None, guid: str = None) -> None: """ Initialize a Broker object. @@ -1694,7 +1546,8 @@ def __ne__(self, other: 'Broker') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Bullets(): + +class Bullets: """ Information related to list delimiters. @@ -1704,12 +1557,7 @@ class Bullets(): :attr int quantity: (optional) The bullet quantity. """ - def __init__(self, - *, - title: str = None, - description: str = None, - icon: str = None, - quantity: int = None) -> None: + def __init__(self, *, title: str = None, description: str = None, icon: str = None, quantity: int = None) -> None: """ Initialize a Bullets object. @@ -1773,7 +1621,8 @@ def __ne__(self, other: 'Bullets') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CFMetaData(): + +class CFMetaData: """ Service-related metadata. @@ -1806,22 +1655,24 @@ class CFMetaData(): `us-south=123`. """ - def __init__(self, - *, - type: str = None, - iam_compatible: bool = None, - unique_api_key: bool = None, - provisionable: bool = None, - bindable: bool = None, - async_provisioning_supported: bool = None, - async_unprovisioning_supported: bool = None, - requires: List[str] = None, - plan_updateable: bool = None, - state: str = None, - service_check_enabled: bool = None, - test_check_interval: int = None, - service_key_supported: bool = None, - cf_guid: dict = None) -> None: + def __init__( + self, + *, + type: str = None, + iam_compatible: bool = None, + unique_api_key: bool = None, + provisionable: bool = None, + bindable: bool = None, + async_provisioning_supported: bool = None, + async_unprovisioning_supported: bool = None, + requires: List[str] = None, + plan_updateable: bool = None, + state: str = None, + service_check_enabled: bool = None, + test_check_interval: int = None, + service_key_supported: bool = None, + cf_guid: dict = None + ) -> None: """ Initialize a CFMetaData object. @@ -1958,7 +1809,8 @@ def __ne__(self, other: 'CFMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Callbacks(): + +class Callbacks: """ Callback-related information associated with a catalog entry. @@ -1977,18 +1829,20 @@ class Callbacks(): :attr dict api_endpoint: (optional) API endpoint. """ - def __init__(self, - *, - controller_url: str = None, - broker_url: str = None, - broker_proxy_url: str = None, - dashboard_url: str = None, - dashboard_data_url: str = None, - dashboard_detail_tab_url: str = None, - dashboard_detail_tab_ext_url: str = None, - service_monitor_api: str = None, - service_monitor_app: str = None, - api_endpoint: dict = None) -> None: + def __init__( + self, + *, + controller_url: str = None, + broker_url: str = None, + broker_proxy_url: str = None, + dashboard_url: str = None, + dashboard_data_url: str = None, + dashboard_detail_tab_url: str = None, + dashboard_detail_tab_ext_url: str = None, + service_monitor_api: str = None, + service_monitor_app: str = None, + api_endpoint: dict = None + ) -> None: """ Initialize a Callbacks object. @@ -2091,7 +1945,8 @@ def __ne__(self, other: 'Callbacks') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CatalogEntry(): + +class CatalogEntry: """ An entry in the global catalog. @@ -2130,27 +1985,29 @@ class CatalogEntry(): :attr datetime updated: (optional) Date last updated. """ - def __init__(self, - name: str, - kind: str, - overview_ui: dict, - images: 'Image', - disabled: bool, - tags: List[str], - provider: 'Provider', - *, - parent_id: str = None, - group: bool = None, - active: bool = None, - metadata: 'CatalogEntryMetadata' = None, - id: str = None, - catalog_crn: str = None, - url: str = None, - children_url: str = None, - geo_tags: List[str] = None, - pricing_tags: List[str] = None, - created: datetime = None, - updated: datetime = None) -> None: + def __init__( + self, + name: str, + kind: str, + overview_ui: dict, + images: 'Image', + disabled: bool, + tags: List[str], + provider: 'Provider', + *, + parent_id: str = None, + group: bool = None, + active: bool = None, + metadata: 'CatalogEntryMetadata' = None, + id: str = None, + catalog_crn: str = None, + url: str = None, + children_url: str = None, + geo_tags: List[str] = None, + pricing_tags: List[str] = None, + created: datetime = None, + updated: datetime = None + ) -> None: """ Initialize a CatalogEntry object. @@ -2212,7 +2069,7 @@ def from_dict(cls, _dict: Dict) -> 'CatalogEntry': else: raise ValueError('Required property \'kind\' not present in CatalogEntry JSON') if 'overview_ui' in _dict: - args['overview_ui'] = {k : Overview.from_dict(v) for k, v in _dict.get('overview_ui').items()} + args['overview_ui'] = {k: Overview.from_dict(v) for k, v in _dict.get('overview_ui').items()} else: raise ValueError('Required property \'overview_ui\' not present in CatalogEntry JSON') if 'images' in _dict: @@ -2270,7 +2127,7 @@ def to_dict(self) -> Dict: if hasattr(self, 'kind') and self.kind is not None: _dict['kind'] = self.kind if hasattr(self, 'overview_ui') and self.overview_ui is not None: - _dict['overview_ui'] = {k : v.to_dict() for k, v in self.overview_ui.items()} + _dict['overview_ui'] = {k: v.to_dict() for k, v in self.overview_ui.items()} if hasattr(self, 'images') and self.images is not None: _dict['images'] = self.images.to_dict() if hasattr(self, 'parent_id') and self.parent_id is not None: @@ -2328,12 +2185,13 @@ class KindEnum(str, Enum): The type of catalog entry, **service**, **template**, **dashboard**, which determines the type and shape of the object. """ + SERVICE = 'service' TEMPLATE = 'template' DASHBOARD = 'dashboard' -class CatalogEntryMetadata(): +class CatalogEntryMetadata: """ Model used to describe metadata object returned. @@ -2358,22 +2216,24 @@ class CatalogEntryMetadata(): metadata. """ - def __init__(self, - *, - rc_compatible: bool = None, - service: 'CFMetaData' = None, - plan: 'PlanMetaData' = None, - alias: 'AliasMetaData' = None, - template: 'TemplateMetaData' = None, - ui: 'UIMetaData' = None, - compliance: List[str] = None, - sla: 'SLAMetaData' = None, - callbacks: 'Callbacks' = None, - original_name: str = None, - version: str = None, - other: dict = None, - pricing: 'CatalogEntryMetadataPricing' = None, - deployment: 'CatalogEntryMetadataDeployment' = None) -> None: + def __init__( + self, + *, + rc_compatible: bool = None, + service: 'CFMetaData' = None, + plan: 'PlanMetaData' = None, + alias: 'AliasMetaData' = None, + template: 'TemplateMetaData' = None, + ui: 'UIMetaData' = None, + compliance: List[str] = None, + sla: 'SLAMetaData' = None, + callbacks: 'Callbacks' = None, + original_name: str = None, + version: str = None, + other: dict = None, + pricing: 'CatalogEntryMetadataPricing' = None, + deployment: 'CatalogEntryMetadataDeployment' = None + ) -> None: """ Initialize a CatalogEntryMetadata object. @@ -2504,7 +2364,8 @@ def __ne__(self, other: 'CatalogEntryMetadata') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CatalogEntryMetadataDeployment(): + +class CatalogEntryMetadataDeployment: """ Deployment-related metadata. @@ -2523,17 +2384,19 @@ class CatalogEntryMetadataDeployment(): :attr str target_network: (optional) network to use during deployment. """ - def __init__(self, - *, - location: str = None, - location_url: str = None, - original_location: str = None, - target_crn: str = None, - service_crn: str = None, - mccp_id: str = None, - broker: 'Broker' = None, - supports_rc_migration: bool = None, - target_network: str = None) -> None: + def __init__( + self, + *, + location: str = None, + location_url: str = None, + original_location: str = None, + target_crn: str = None, + service_crn: str = None, + mccp_id: str = None, + broker: 'Broker' = None, + supports_rc_migration: bool = None, + target_network: str = None + ) -> None: """ Initialize a CatalogEntryMetadataDeployment object. @@ -2631,7 +2494,8 @@ def __ne__(self, other: 'CatalogEntryMetadataDeployment') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CatalogEntryMetadataPricing(): + +class CatalogEntryMetadataPricing: """ Pricing-related information. @@ -2643,12 +2507,14 @@ class CatalogEntryMetadataPricing(): :attr List[Metrics] metrics: (optional) Plan-specific cost metric structure. """ - def __init__(self, - *, - type: str = None, - origin: str = None, - starting_price: 'StartingPrice' = None, - metrics: List['Metrics'] = None) -> None: + def __init__( + self, + *, + type: str = None, + origin: str = None, + starting_price: 'StartingPrice' = None, + metrics: List['Metrics'] = None + ) -> None: """ Initialize a CatalogEntryMetadataPricing object. @@ -2715,7 +2581,8 @@ def __ne__(self, other: 'CatalogEntryMetadataPricing') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DRMetaData(): + +class DRMetaData: """ SLA Disaster Recovery-related metadata. @@ -2725,10 +2592,7 @@ class DRMetaData(): implementation. """ - def __init__(self, - *, - dr: bool = None, - description: str = None) -> None: + def __init__(self, *, dr: bool = None, description: str = None) -> None: """ Initialize a DRMetaData object. @@ -2782,7 +2646,8 @@ def __ne__(self, other: 'DRMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeploymentBase(): + +class DeploymentBase: """ Deployment-related metadata. @@ -2800,17 +2665,19 @@ class DeploymentBase(): :attr str target_network: (optional) network to use during deployment. """ - def __init__(self, - *, - location: str = None, - location_url: str = None, - original_location: str = None, - target_crn: str = None, - service_crn: str = None, - mccp_id: str = None, - broker: 'Broker' = None, - supports_rc_migration: bool = None, - target_network: str = None) -> None: + def __init__( + self, + *, + location: str = None, + location_url: str = None, + original_location: str = None, + target_crn: str = None, + service_crn: str = None, + mccp_id: str = None, + broker: 'Broker' = None, + supports_rc_migration: bool = None, + target_network: str = None + ) -> None: """ Initialize a DeploymentBase object. @@ -2909,7 +2776,8 @@ def __ne__(self, other: 'DeploymentBase') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EntrySearchResult(): + +class EntrySearchResult: """ A paginated search result containing catalog entries. @@ -2931,17 +2799,19 @@ class EntrySearchResult(): contained in this page of search results. """ - def __init__(self, - *, - offset: int = None, - limit: int = None, - count: int = None, - resource_count: int = None, - first: str = None, - last: str = None, - prev: str = None, - next: str = None, - resources: List['CatalogEntry'] = None) -> None: + def __init__( + self, + *, + offset: int = None, + limit: int = None, + count: int = None, + resource_count: int = None, + first: str = None, + last: str = None, + prev: str = None, + next: str = None, + resources: List['CatalogEntry'] = None + ) -> None: """ Initialize a EntrySearchResult object. @@ -3044,7 +2914,8 @@ def __ne__(self, other: 'EntrySearchResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Image(): + +class Image: """ Image annotation for this catalog entry. The image is a URL. @@ -3054,12 +2925,9 @@ class Image(): :attr str feature_image: (optional) URL for a featured image. """ - def __init__(self, - image: str, - *, - small_image: str = None, - medium_image: str = None, - feature_image: str = None) -> None: + def __init__( + self, image: str, *, small_image: str = None, medium_image: str = None, feature_image: str = None + ) -> None: """ Initialize a Image object. @@ -3125,7 +2993,8 @@ def __ne__(self, other: 'Image') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Message(): + +class Message: """ log object describing who did what. @@ -3144,19 +3013,21 @@ class Message(): object data. """ - def __init__(self, - *, - id: str = None, - effective: 'Visibility' = None, - time: datetime = None, - who_id: str = None, - who_name: str = None, - who_email: str = None, - instance: str = None, - gid: str = None, - type: str = None, - message: str = None, - data: dict = None) -> None: + def __init__( + self, + *, + id: str = None, + effective: 'Visibility' = None, + time: datetime = None, + who_id: str = None, + who_name: str = None, + who_email: str = None, + instance: str = None, + gid: str = None, + type: str = None, + message: str = None, + data: dict = None + ) -> None: """ Initialize a Message object. @@ -3264,7 +3135,8 @@ def __ne__(self, other: 'Message') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Metrics(): + +class Metrics: """ Plan-specific cost metrics information. @@ -3284,21 +3156,23 @@ class Metrics(): currency. """ - def __init__(self, - *, - part_ref: str = None, - metric_id: str = None, - tier_model: str = None, - charge_unit: str = None, - charge_unit_name: str = None, - charge_unit_quantity: str = None, - resource_display_name: str = None, - charge_unit_display_name: str = None, - usage_cap_qty: int = None, - display_cap: int = None, - effective_from: datetime = None, - effective_until: datetime = None, - amounts: List['Amount'] = None) -> None: + def __init__( + self, + *, + part_ref: str = None, + metric_id: str = None, + tier_model: str = None, + charge_unit: str = None, + charge_unit_name: str = None, + charge_unit_quantity: str = None, + resource_display_name: str = None, + charge_unit_display_name: str = None, + usage_cap_qty: int = None, + display_cap: int = None, + effective_from: datetime = None, + effective_until: datetime = None, + amounts: List['Amount'] = None + ) -> None: """ Initialize a Metrics object. @@ -3418,7 +3292,8 @@ def __ne__(self, other: 'Metrics') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ObjectMetadataSet(): + +class ObjectMetadataSet: """ Model used to describe metadata object that can be set. @@ -3441,22 +3316,24 @@ class ObjectMetadataSet(): :attr DeploymentBase deployment: (optional) Deployment-related metadata. """ - def __init__(self, - *, - rc_compatible: bool = None, - service: 'CFMetaData' = None, - plan: 'PlanMetaData' = None, - alias: 'AliasMetaData' = None, - template: 'TemplateMetaData' = None, - ui: 'UIMetaData' = None, - compliance: List[str] = None, - sla: 'SLAMetaData' = None, - callbacks: 'Callbacks' = None, - original_name: str = None, - version: str = None, - other: dict = None, - pricing: 'PricingSet' = None, - deployment: 'DeploymentBase' = None) -> None: + def __init__( + self, + *, + rc_compatible: bool = None, + service: 'CFMetaData' = None, + plan: 'PlanMetaData' = None, + alias: 'AliasMetaData' = None, + template: 'TemplateMetaData' = None, + ui: 'UIMetaData' = None, + compliance: List[str] = None, + sla: 'SLAMetaData' = None, + callbacks: 'Callbacks' = None, + original_name: str = None, + version: str = None, + other: dict = None, + pricing: 'PricingSet' = None, + deployment: 'DeploymentBase' = None + ) -> None: """ Initialize a ObjectMetadataSet object. @@ -3585,7 +3462,8 @@ def __ne__(self, other: 'ObjectMetadataSet') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Overview(): + +class Overview: """ Overview is nested in the top level. The key value pair is `[_language_]overview_ui`. @@ -3596,12 +3474,9 @@ class Overview(): be featured. """ - def __init__(self, - display_name: str, - long_description: str, - description: str, - *, - featured_description: str = None) -> None: + def __init__( + self, display_name: str, long_description: str, description: str, *, featured_description: str = None + ) -> None: """ Initialize a Overview object. @@ -3672,7 +3547,8 @@ def __ne__(self, other: 'Overview') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PlanMetaData(): + +class PlanMetaData: """ Plan-related metadata. @@ -3695,17 +3571,19 @@ class PlanMetaData(): `us-south=123`. """ - def __init__(self, - *, - bindable: bool = None, - reservable: bool = None, - allow_internal_users: bool = None, - async_provisioning_supported: bool = None, - async_unprovisioning_supported: bool = None, - test_check_interval: int = None, - single_scope_instance: str = None, - service_check_enabled: bool = None, - cf_guid: dict = None) -> None: + def __init__( + self, + *, + bindable: bool = None, + reservable: bool = None, + allow_internal_users: bool = None, + async_provisioning_supported: bool = None, + async_unprovisioning_supported: bool = None, + test_check_interval: int = None, + single_scope_instance: str = None, + service_check_enabled: bool = None, + cf_guid: dict = None + ) -> None: """ Initialize a PlanMetaData object. @@ -3807,7 +3685,8 @@ def __ne__(self, other: 'PlanMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Price(): + +class Price: """ Pricing-related information. @@ -3815,10 +3694,7 @@ class Price(): :attr float price: (optional) Price in the selected currency. """ - def __init__(self, - *, - quantity_tier: int = None, - price: float = None) -> None: + def __init__(self, *, quantity_tier: int = None, price: float = None) -> None: """ Initialize a Price object. @@ -3870,7 +3746,8 @@ def __ne__(self, other: 'Price') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PricingGet(): + +class PricingGet: """ Pricing-related information. @@ -3882,12 +3759,14 @@ class PricingGet(): :attr List[Metrics] metrics: (optional) Plan-specific cost metric structure. """ - def __init__(self, - *, - type: str = None, - origin: str = None, - starting_price: 'StartingPrice' = None, - metrics: List['Metrics'] = None) -> None: + def __init__( + self, + *, + type: str = None, + origin: str = None, + starting_price: 'StartingPrice' = None, + metrics: List['Metrics'] = None + ) -> None: """ Initialize a PricingGet object. @@ -3954,7 +3833,8 @@ def __ne__(self, other: 'PricingGet') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PricingSet(): + +class PricingSet: """ Pricing-related information. @@ -3965,11 +3845,7 @@ class PricingSet(): information. """ - def __init__(self, - *, - type: str = None, - origin: str = None, - starting_price: 'StartingPrice' = None) -> None: + def __init__(self, *, type: str = None, origin: str = None, starting_price: 'StartingPrice' = None) -> None: """ Initialize a PricingSet object. @@ -4029,7 +3905,8 @@ def __ne__(self, other: 'PricingSet') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Provider(): + +class Provider: """ Information related to the provider associated with a catalog entry. @@ -4040,13 +3917,9 @@ class Provider(): :attr str phone: (optional) Provider's contact phone. """ - def __init__(self, - email: str, - name: str, - *, - contact: str = None, - support_email: str = None, - phone: str = None) -> None: + def __init__( + self, email: str, name: str, *, contact: str = None, support_email: str = None, phone: str = None + ) -> None: """ Initialize a Provider object. @@ -4120,7 +3993,8 @@ def __ne__(self, other: 'Provider') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SLAMetaData(): + +class SLAMetaData: """ Service Level Agreement related metadata. @@ -4134,13 +4008,15 @@ class SLAMetaData(): :attr DRMetaData dr: (optional) SLA Disaster Recovery-related metadata. """ - def __init__(self, - *, - terms: str = None, - tenancy: str = None, - provisioning: str = None, - responsiveness: str = None, - dr: 'DRMetaData' = None) -> None: + def __init__( + self, + *, + terms: str = None, + tenancy: str = None, + provisioning: str = None, + responsiveness: str = None, + dr: 'DRMetaData' = None + ) -> None: """ Initialize a SLAMetaData object. @@ -4215,7 +4091,8 @@ def __ne__(self, other: 'SLAMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SourceMetaData(): + +class SourceMetaData: """ Location of your applications source files. @@ -4224,11 +4101,7 @@ class SourceMetaData(): :attr str url: (optional) URL to source. """ - def __init__(self, - *, - path: str = None, - type: str = None, - url: str = None) -> None: + def __init__(self, *, path: str = None, type: str = None, url: str = None) -> None: """ Initialize a SourceMetaData object. @@ -4286,7 +4159,8 @@ def __ne__(self, other: 'SourceMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class StartingPrice(): + +class StartingPrice: """ Plan-specific starting price information. @@ -4298,12 +4172,9 @@ class StartingPrice(): currency. """ - def __init__(self, - *, - plan_id: str = None, - deployment_id: str = None, - unit: str = None, - amount: List['Amount'] = None) -> None: + def __init__( + self, *, plan_id: str = None, deployment_id: str = None, unit: str = None, amount: List['Amount'] = None + ) -> None: """ Initialize a StartingPrice object. @@ -4370,7 +4241,8 @@ def __ne__(self, other: 'StartingPrice') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Strings(): + +class Strings: """ Information related to a translated text message. @@ -4385,15 +4257,17 @@ class Strings(): :attr str instruction: (optional) Instructions for UI strings. """ - def __init__(self, - *, - bullets: List['Bullets'] = None, - media: List['UIMetaMedia'] = None, - not_creatable_msg: str = None, - not_creatable_robot_msg: str = None, - deprecation_warning: str = None, - popup_warning_message: str = None, - instruction: str = None) -> None: + def __init__( + self, + *, + bullets: List['Bullets'] = None, + media: List['UIMetaMedia'] = None, + not_creatable_msg: str = None, + not_creatable_robot_msg: str = None, + deprecation_warning: str = None, + popup_warning_message: str = None, + instruction: str = None + ) -> None: """ Initialize a Strings object. @@ -4478,7 +4352,8 @@ def __ne__(self, other: 'Strings') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TemplateMetaData(): + +class TemplateMetaData: """ Template-related metadata. @@ -4497,18 +4372,20 @@ class TemplateMetaData(): pairs) for the template. """ - def __init__(self, - *, - services: List[str] = None, - default_memory: int = None, - start_cmd: str = None, - source: 'SourceMetaData' = None, - runtime_catalog_id: str = None, - cf_runtime_id: str = None, - template_id: str = None, - executable_file: str = None, - buildpack: str = None, - environment_variables: dict = None) -> None: + def __init__( + self, + *, + services: List[str] = None, + default_memory: int = None, + start_cmd: str = None, + source: 'SourceMetaData' = None, + runtime_catalog_id: str = None, + cf_runtime_id: str = None, + template_id: str = None, + executable_file: str = None, + buildpack: str = None, + environment_variables: dict = None + ) -> None: """ Initialize a TemplateMetaData object. @@ -4612,7 +4489,8 @@ def __ne__(self, other: 'TemplateMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UIMetaData(): + +class UIMetaData: """ Information related to the UI presentation associated with a catalog entry. @@ -4642,21 +4520,23 @@ class UIMetaData(): occurr. """ - def __init__(self, - *, - strings: dict = None, - urls: 'URLS' = None, - embeddable_dashboard: str = None, - embeddable_dashboard_full_width: bool = None, - navigation_order: List[str] = None, - not_creatable: bool = None, - primary_offering_id: str = None, - accessible_during_provision: bool = None, - side_by_side_index: int = None, - end_of_service_time: datetime = None, - hidden: bool = None, - hide_lite_metering: bool = None, - no_upgrade_next_step: bool = None) -> None: + def __init__( + self, + *, + strings: dict = None, + urls: 'URLS' = None, + embeddable_dashboard: str = None, + embeddable_dashboard_full_width: bool = None, + navigation_order: List[str] = None, + not_creatable: bool = None, + primary_offering_id: str = None, + accessible_during_provision: bool = None, + side_by_side_index: int = None, + end_of_service_time: datetime = None, + hidden: bool = None, + hide_lite_metering: bool = None, + no_upgrade_next_step: bool = None + ) -> None: """ Initialize a UIMetaData object. @@ -4705,7 +4585,7 @@ def from_dict(cls, _dict: Dict) -> 'UIMetaData': """Initialize a UIMetaData object from a json dictionary.""" args = {} if 'strings' in _dict: - args['strings'] = {k : Strings.from_dict(v) for k, v in _dict.get('strings').items()} + args['strings'] = {k: Strings.from_dict(v) for k, v in _dict.get('strings').items()} if 'urls' in _dict: args['urls'] = URLS.from_dict(_dict.get('urls')) if 'embeddable_dashboard' in _dict: @@ -4741,7 +4621,7 @@ def to_dict(self) -> Dict: """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'strings') and self.strings is not None: - _dict['strings'] = {k : v.to_dict() for k, v in self.strings.items()} + _dict['strings'] = {k: v.to_dict() for k, v in self.strings.items()} if hasattr(self, 'urls') and self.urls is not None: _dict['urls'] = self.urls.to_dict() if hasattr(self, 'embeddable_dashboard') and self.embeddable_dashboard is not None: @@ -4786,7 +4666,8 @@ def __ne__(self, other: 'UIMetaData') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UIMetaMedia(): + +class UIMetaMedia: """ Media-related metadata. @@ -4797,13 +4678,15 @@ class UIMetaMedia(): :attr Bullets source: (optional) Information related to list delimiters. """ - def __init__(self, - *, - caption: str = None, - thumbnail_url: str = None, - type: str = None, - url: str = None, - source: 'Bullets' = None) -> None: + def __init__( + self, + *, + caption: str = None, + thumbnail_url: str = None, + type: str = None, + url: str = None, + source: 'Bullets' = None + ) -> None: """ Initialize a UIMetaMedia object. @@ -4873,7 +4756,8 @@ def __ne__(self, other: 'UIMetaMedia') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class URLS(): + +class URLS: """ UI based URLs. @@ -4893,20 +4777,22 @@ class URLS(): :attr str apidocsurl: (optional) URL for API documentation. """ - def __init__(self, - *, - doc_url: str = None, - instructions_url: str = None, - api_url: str = None, - create_url: str = None, - sdk_download_url: str = None, - terms_url: str = None, - custom_create_page_url: str = None, - catalog_details_url: str = None, - deprecation_doc_url: str = None, - dashboard_url: str = None, - registration_url: str = None, - apidocsurl: str = None) -> None: + def __init__( + self, + *, + doc_url: str = None, + instructions_url: str = None, + api_url: str = None, + create_url: str = None, + sdk_download_url: str = None, + terms_url: str = None, + custom_create_page_url: str = None, + catalog_details_url: str = None, + deprecation_doc_url: str = None, + dashboard_url: str = None, + registration_url: str = None, + apidocsurl: str = None + ) -> None: """ Initialize a URLS object. @@ -5021,7 +4907,8 @@ def __ne__(self, other: 'URLS') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Visibility(): + +class Visibility: """ Information related to the visibility of a catalog entry. @@ -5041,14 +4928,16 @@ class Visibility(): whitelist and making entries `private`, `ibm_only` or `public`. """ - def __init__(self, - *, - restrictions: str = None, - owner: str = None, - extendable: bool = None, - include: 'VisibilityDetail' = None, - exclude: 'VisibilityDetail' = None, - approved: bool = None) -> None: + def __init__( + self, + *, + restrictions: str = None, + owner: str = None, + extendable: bool = None, + include: 'VisibilityDetail' = None, + exclude: 'VisibilityDetail' = None, + approved: bool = None + ) -> None: """ Initialize a Visibility object. @@ -5123,7 +5012,8 @@ def __ne__(self, other: 'Visibility') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class VisibilityDetail(): + +class VisibilityDetail: """ Visibility details related to a catalog entry. @@ -5131,8 +5021,7 @@ class VisibilityDetail(): which a catalog entry is visible. """ - def __init__(self, - accounts: 'VisibilityDetailAccounts') -> None: + def __init__(self, accounts: 'VisibilityDetailAccounts') -> None: """ Initialize a VisibilityDetail object. @@ -5181,7 +5070,8 @@ def __ne__(self, other: 'VisibilityDetail') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class VisibilityDetailAccounts(): + +class VisibilityDetailAccounts: """ Information related to the accounts for which a catalog entry is visible. @@ -5190,9 +5080,7 @@ class VisibilityDetailAccounts(): is replaced with the owner scope when saved. """ - def __init__(self, - *, - accountid: str = None) -> None: + def __init__(self, *, accountid: str = None) -> None: """ Initialize a VisibilityDetailAccounts object. diff --git a/ibm_platform_services/global_search_v2.py b/ibm_platform_services/global_search_v2.py index 47419328..75c5f2ba 100644 --- a/ibm_platform_services/global_search_v2.py +++ b/ibm_platform_services/global_search_v2.py @@ -41,6 +41,7 @@ # Service ############################################################################## + class GlobalSearchV2(BaseService): """The global_search V2 service.""" @@ -48,23 +49,23 @@ class GlobalSearchV2(BaseService): DEFAULT_SERVICE_NAME = 'global_search' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'GlobalSearchV2': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'GlobalSearchV2': """ Return a new client for the global_search service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the global_search service. @@ -72,17 +73,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Search ######################### - - def search(self, + def search( + self, *, query: str = None, fields: List[str] = None, @@ -137,26 +135,15 @@ def search(self, :rtype: DetailedResponse with `dict` result representing a `ScanResult` object """ - headers = { - 'transaction-id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='search') + headers = {'transaction-id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='search' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id, - 'limit': limit, - 'timeout': timeout, - 'sort': convert_list(sort) - } - - data = { - 'query': query, - 'fields': fields, - 'search_cursor': search_cursor - } + params = {'account_id': account_id, 'limit': limit, 'timeout': timeout, 'sort': convert_list(sort)} + + data = {'query': query, 'fields': fields, 'search_cursor': search_cursor} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -166,11 +153,7 @@ def search(self, headers['Accept'] = 'application/json' url = '/v3/resources/search' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response @@ -179,10 +162,7 @@ def search(self, # Resource Types ######################### - - def get_supported_types(self, - **kwargs - ) -> DetailedResponse: + def get_supported_types(self, **kwargs) -> DetailedResponse: """ DEPRECATED. Get all GhoST indices. @@ -194,9 +174,9 @@ def get_supported_types(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_supported_types') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_supported_types' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -204,9 +184,7 @@ def get_supported_types(self, headers['Accept'] = 'application/json' url = '/v2/resources/supported_types' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request) return response @@ -217,7 +195,7 @@ def get_supported_types(self, ############################################################################## -class ResultItem(): +class ResultItem: """ A resource returned in a search result. @@ -227,10 +205,7 @@ class ResultItem(): # The set of defined properties for the class _properties = frozenset(['crn']) - def __init__(self, - *, - crn: str = None, - **kwargs) -> None: + def __init__(self, *, crn: str = None, **kwargs) -> None: """ Initialize a ResultItem object. @@ -247,7 +222,7 @@ def from_dict(cls, _dict: Dict) -> 'ResultItem': args = {} if 'crn' in _dict: args['crn'] = _dict.get('crn') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -283,7 +258,8 @@ def __ne__(self, other: 'ResultItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ScanResult(): + +class ScanResult: """ The search scan response. @@ -295,11 +271,7 @@ class ScanResult(): hits to fetch. """ - def __init__(self, - search_cursor: str, - items: List['ResultItem'], - *, - limit: int = None) -> None: + def __init__(self, search_cursor: str, items: List['ResultItem'], *, limit: int = None) -> None: """ Initialize a ScanResult object. @@ -365,16 +337,15 @@ def __ne__(self, other: 'ScanResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SupportedTypesList(): + +class SupportedTypesList: """ A list of all GhoST indices. :attr List[str] supported_types: (optional) A list of all GhoST indices. """ - def __init__(self, - *, - supported_types: List[str] = None) -> None: + def __init__(self, *, supported_types: List[str] = None) -> None: """ Initialize a SupportedTypesList object. diff --git a/ibm_platform_services/global_tagging_v1.py b/ibm_platform_services/global_tagging_v1.py index 492e51a0..3245116a 100644 --- a/ibm_platform_services/global_tagging_v1.py +++ b/ibm_platform_services/global_tagging_v1.py @@ -42,6 +42,7 @@ # Service ############################################################################## + class GlobalTaggingV1(BaseService): """The global_tagging V1 service.""" @@ -49,23 +50,23 @@ class GlobalTaggingV1(BaseService): DEFAULT_SERVICE_NAME = 'global_tagging' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'GlobalTaggingV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'GlobalTaggingV1': """ Return a new client for the global_tagging service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the global_tagging service. @@ -73,17 +74,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # tags ######################### - - def list_tags(self, + def list_tags( + self, *, impersonate_user: str = None, account_id: str = None, @@ -141,9 +139,9 @@ def list_tags(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_tags') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_tags' + ) headers.update(sdk_headers) params = { @@ -157,7 +155,7 @@ def list_tags(self, 'limit': limit, 'timeout': timeout, 'order_by_name': order_by_name, - 'attached_only': attached_only + 'attached_only': attached_only, } if 'headers' in kwargs: @@ -165,16 +163,13 @@ def list_tags(self, headers['Accept'] = 'application/json' url = '/v3/tags' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response - - def create_tag(self, + def create_tag( + self, tag_names: List[str], *, impersonate_user: str = None, @@ -207,20 +202,14 @@ def create_tag(self, if tag_names is None: raise ValueError('tag_names must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_tag') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_tag' + ) headers.update(sdk_headers) - params = { - 'impersonate_user': impersonate_user, - 'account_id': account_id, - 'tag_type': tag_type - } + params = {'impersonate_user': impersonate_user, 'account_id': account_id, 'tag_type': tag_type} - data = { - 'tag_names': tag_names - } + data = {'tag_names': tag_names} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -230,17 +219,13 @@ def create_tag(self, headers['Accept'] = 'application/json' url = '/v3/tags' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def delete_tag_all(self, + def delete_tag_all( + self, *, providers: str = None, impersonate_user: str = None, @@ -269,16 +254,16 @@ def delete_tag_all(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_tag_all') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_tag_all' + ) headers.update(sdk_headers) params = { 'providers': providers, 'impersonate_user': impersonate_user, 'account_id': account_id, - 'tag_type': tag_type + 'tag_type': tag_type, } if 'headers' in kwargs: @@ -286,16 +271,13 @@ def delete_tag_all(self, headers['Accept'] = 'application/json' url = '/v3/tags' - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response - - def delete_tag(self, + def delete_tag( + self, tag_name: str, *, providers: List[str] = None, @@ -330,16 +312,16 @@ def delete_tag(self, if tag_name is None: raise ValueError('tag_name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_tag') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_tag' + ) headers.update(sdk_headers) params = { 'providers': convert_list(providers), 'impersonate_user': impersonate_user, 'account_id': account_id, - 'tag_type': tag_type + 'tag_type': tag_type, } if 'headers' in kwargs: @@ -350,16 +332,13 @@ def delete_tag(self, path_param_values = self.encode_path_vars(tag_name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v3/tags/{tag_name}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response - - def attach_tag(self, + def attach_tag( + self, resources: List['Resource'], *, tag_name: str = None, @@ -396,22 +375,14 @@ def attach_tag(self, raise ValueError('resources must be provided') resources = [convert_model(x) for x in resources] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='attach_tag') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='attach_tag' + ) headers.update(sdk_headers) - params = { - 'impersonate_user': impersonate_user, - 'account_id': account_id, - 'tag_type': tag_type - } + params = {'impersonate_user': impersonate_user, 'account_id': account_id, 'tag_type': tag_type} - data = { - 'resources': resources, - 'tag_name': tag_name, - 'tag_names': tag_names - } + data = {'resources': resources, 'tag_name': tag_name, 'tag_names': tag_names} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -421,17 +392,13 @@ def attach_tag(self, headers['Accept'] = 'application/json' url = '/v3/tags/attach' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def detach_tag(self, + def detach_tag( + self, resources: List['Resource'], *, tag_name: str = None, @@ -468,22 +435,14 @@ def detach_tag(self, raise ValueError('resources must be provided') resources = [convert_model(x) for x in resources] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='detach_tag') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='detach_tag' + ) headers.update(sdk_headers) - params = { - 'impersonate_user': impersonate_user, - 'account_id': account_id, - 'tag_type': tag_type - } + params = {'impersonate_user': impersonate_user, 'account_id': account_id, 'tag_type': tag_type} - data = { - 'resources': resources, - 'tag_name': tag_name, - 'tag_names': tag_names - } + data = {'resources': resources, 'tag_name': tag_name, 'tag_names': tag_names} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -493,11 +452,7 @@ def detach_tag(self, headers['Accept'] = 'application/json' url = '/v3/tags/detach' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request) return response @@ -513,9 +468,11 @@ class TagType(str, Enum): The type of the tag you want to list. Supported values are `user`, `service` and `access`. """ + USER = 'user' SERVICE = 'service' ACCESS = 'access' + class Providers(str, Enum): """ Select a provider. Supported values are `ghost` and `ims`. To list both Global @@ -523,12 +480,15 @@ class Providers(str, Enum): `access` tags can only be attached to resources that are onboarded to Global Search and Tagging, so you should not set this parameter when listing them. """ + GHOST = 'ghost' IMS = 'ims' + class OrderByName(str, Enum): """ Order the output by tag name. """ + ASC = 'asc' DESC = 'desc' @@ -542,6 +502,7 @@ class TagType(str, Enum): """ The type of the tags you want to create. The only allowed value is `access`. """ + ACCESS = 'access' @@ -554,14 +515,17 @@ class Providers(str, Enum): """ Select a provider. Supported values are `ghost` and `ims`. """ + GHOST = 'ghost' IMS = 'ims' + class TagType(str, Enum): """ The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported for IMS resources (`providers` parameter set to `ims`). """ + USER = 'user' SERVICE = 'service' ACCESS = 'access' @@ -577,14 +541,17 @@ class Providers(str, Enum): Select a provider. Supported values are `ghost` and `ims`. To delete tags both in Global Search and Tagging and in IMS, use `ghost,ims`. """ + GHOST = 'ghost' IMS = 'ims' + class TagType(str, Enum): """ The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported for IMS resources (`providers` parameter set to `ims`). """ + USER = 'user' SERVICE = 'service' ACCESS = 'access' @@ -600,6 +567,7 @@ class TagType(str, Enum): The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported for IMS resources. """ + USER = 'user' SERVICE = 'service' ACCESS = 'access' @@ -615,6 +583,7 @@ class TagType(str, Enum): The type of the tag. Supported values are `user`, `service` and `access`. `service` and `access` are not supported for IMS resources. """ + USER = 'user' SERVICE = 'service' ACCESS = 'access' @@ -625,7 +594,7 @@ class TagType(str, Enum): ############################################################################## -class CreateTagResults(): +class CreateTagResults: """ Results of a create tag(s) request. @@ -633,9 +602,7 @@ class CreateTagResults(): an set_tags request. """ - def __init__(self, - *, - results: List['CreateTagResultsResultsItem'] = None) -> None: + def __init__(self, *, results: List['CreateTagResultsResultsItem'] = None) -> None: """ Initialize a CreateTagResults object. @@ -682,7 +649,8 @@ def __ne__(self, other: 'CreateTagResults') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreateTagResultsResultsItem(): + +class CreateTagResultsResultsItem: """ CreateTagResultsResultsItem. @@ -690,10 +658,7 @@ class CreateTagResultsResultsItem(): :attr bool is_error: (optional) true if the tag was not created. """ - def __init__(self, - *, - tag_name: str = None, - is_error: bool = None) -> None: + def __init__(self, *, tag_name: str = None, is_error: bool = None) -> None: """ Initialize a CreateTagResultsResultsItem object. @@ -745,7 +710,8 @@ def __ne__(self, other: 'CreateTagResultsResultsItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteTagResults(): + +class DeleteTagResults: """ Results of a delete_tag request. @@ -753,9 +719,7 @@ class DeleteTagResults(): delete_tag request. """ - def __init__(self, - *, - results: List['DeleteTagResultsItem'] = None) -> None: + def __init__(self, *, results: List['DeleteTagResultsItem'] = None) -> None: """ Initialize a DeleteTagResults object. @@ -802,7 +766,8 @@ def __ne__(self, other: 'DeleteTagResults') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteTagResultsItem(): + +class DeleteTagResultsItem: """ Result of a delete_tag request. @@ -814,11 +779,7 @@ class DeleteTagResultsItem(): # The set of defined properties for the class _properties = frozenset(['provider', 'is_error']) - def __init__(self, - *, - provider: str = None, - is_error: bool = None, - **kwargs) -> None: + def __init__(self, *, provider: str = None, is_error: bool = None, **kwargs) -> None: """ Initialize a DeleteTagResultsItem object. @@ -840,7 +801,7 @@ def from_dict(cls, _dict: Dict) -> 'DeleteTagResultsItem': args['provider'] = _dict.get('provider') if 'is_error' in _dict: args['is_error'] = _dict.get('is_error') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -882,11 +843,12 @@ class ProviderEnum(str, Enum): """ The provider of the tag. """ + GHOST = 'ghost' IMS = 'ims' -class DeleteTagsResult(): +class DeleteTagsResult: """ Results of a deleting unattatched tags. @@ -897,11 +859,9 @@ class DeleteTagsResult(): results. """ - def __init__(self, - *, - total_count: int = None, - errors: bool = None, - items: List['DeleteTagsResultItem'] = None) -> None: + def __init__( + self, *, total_count: int = None, errors: bool = None, items: List['DeleteTagsResultItem'] = None + ) -> None: """ Initialize a DeleteTagsResult object. @@ -962,7 +922,8 @@ def __ne__(self, other: 'DeleteTagsResult') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteTagsResultItem(): + +class DeleteTagsResultItem: """ Result of a delete_tags request. @@ -970,10 +931,7 @@ class DeleteTagsResultItem(): :attr bool is_error: (optional) true if the tag was not deleted. """ - def __init__(self, - *, - tag_name: str = None, - is_error: bool = None) -> None: + def __init__(self, *, tag_name: str = None, is_error: bool = None) -> None: """ Initialize a DeleteTagsResultItem object. @@ -1025,7 +983,8 @@ def __ne__(self, other: 'DeleteTagsResultItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ A resource that may have attached tags. @@ -1033,10 +992,7 @@ class Resource(): :attr str resource_type: (optional) The IMS resource type of the resource. """ - def __init__(self, - resource_id: str, - *, - resource_type: str = None) -> None: + def __init__(self, resource_id: str, *, resource_type: str = None) -> None: """ Initialize a Resource object. @@ -1090,15 +1046,15 @@ def __ne__(self, other: 'Resource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Tag(): + +class Tag: """ A tag. :attr str name: This is the name of the tag. """ - def __init__(self, - name: str) -> None: + def __init__(self, name: str) -> None: """ Initialize a Tag object. @@ -1146,7 +1102,8 @@ def __ne__(self, other: 'Tag') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TagList(): + +class TagList: """ A list of tags. @@ -1157,12 +1114,9 @@ class TagList(): :attr List[Tag] items: (optional) Array of output results. """ - def __init__(self, - *, - total_count: int = None, - offset: int = None, - limit: int = None, - items: List['Tag'] = None) -> None: + def __init__( + self, *, total_count: int = None, offset: int = None, limit: int = None, items: List['Tag'] = None + ) -> None: """ Initialize a TagList object. @@ -1227,7 +1181,8 @@ def __ne__(self, other: 'TagList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TagResults(): + +class TagResults: """ Results of an attach_tag or detach_tag request. @@ -1235,9 +1190,7 @@ class TagResults(): or detach_tag request. """ - def __init__(self, - *, - results: List['TagResultsItem'] = None) -> None: + def __init__(self, *, results: List['TagResultsItem'] = None) -> None: """ Initialize a TagResults object. @@ -1284,7 +1237,8 @@ def __ne__(self, other: 'TagResults') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TagResultsItem(): + +class TagResultsItem: """ Result of an attach_tag or detach_tag request for a tagged resource. @@ -1293,10 +1247,7 @@ class TagResultsItem(): error. """ - def __init__(self, - resource_id: str, - *, - is_error: bool = None) -> None: + def __init__(self, resource_id: str, *, is_error: bool = None) -> None: """ Initialize a TagResultsItem object. diff --git a/ibm_platform_services/iam_access_groups_v2.py b/ibm_platform_services/iam_access_groups_v2.py index 1f05ea6f..10a3527e 100644 --- a/ibm_platform_services/iam_access_groups_v2.py +++ b/ibm_platform_services/iam_access_groups_v2.py @@ -40,6 +40,7 @@ # Service ############################################################################## + class IamAccessGroupsV2(BaseService): """The iam-access-groups V2 service.""" @@ -47,23 +48,23 @@ class IamAccessGroupsV2(BaseService): DEFAULT_SERVICE_NAME = 'iam_access_groups' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'IamAccessGroupsV2': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'IamAccessGroupsV2': """ Return a new client for the iam-access-groups service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the iam-access-groups service. @@ -71,23 +72,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Access group operations ######################### - - def create_access_group(self, - account_id: str, - name: str, - *, - description: str = None, - transaction_id: str = None, - **kwargs + def create_access_group( + self, account_id: str, name: str, *, description: str = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Create an access group. @@ -121,22 +113,15 @@ def create_access_group(self, raise ValueError('account_id must be provided') if name is None: raise ValueError('name 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_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_access_group' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id - } + params = {'account_id': account_id} - data = { - 'name': name, - 'description': description - } + data = {'name': name, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -147,17 +132,13 @@ def create_access_group(self, headers['Accept'] = 'application/json' url = '/v2/groups' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response - - def list_access_groups(self, + def list_access_groups( + self, account_id: str, *, transaction_id: str = None, @@ -168,7 +149,7 @@ def list_access_groups(self, sort: str = None, show_federated: bool = None, hide_public_access: bool = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ List access groups. @@ -215,12 +196,10 @@ def list_access_groups(self, 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_access_groups') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_access_groups' + ) headers.update(sdk_headers) params = { @@ -231,7 +210,7 @@ def list_access_groups(self, 'offset': offset, 'sort': sort, 'show_federated': show_federated, - 'hide_public_access': hide_public_access + 'hide_public_access': hide_public_access, } if 'headers' in kwargs: @@ -240,21 +219,13 @@ def list_access_groups(self, headers['Accept'] = 'application/json' url = '/v2/groups' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_access_group(self, - access_group_id: str, - *, - transaction_id: str = None, - show_federated: bool = None, - **kwargs + def get_access_group( + self, access_group_id: str, *, transaction_id: str = None, show_federated: bool = None, **kwargs ) -> DetailedResponse: """ Get an access group. @@ -280,17 +251,13 @@ def get_access_group(self, if not access_group_id: raise ValueError('access_group_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_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_access_group' + ) headers.update(sdk_headers) - params = { - 'show_federated': show_federated - } + params = {'show_federated': show_federated} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -301,23 +268,20 @@ def get_access_group(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_access_group(self, + def update_access_group( + self, access_group_id: str, if_match: str, *, name: str = None, description: str = None, transaction_id: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Update an access group. @@ -349,19 +313,13 @@ def update_access_group(self, raise ValueError('access_group_id 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='update_access_group') + 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_access_group' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'description': description - } + data = {'name': name, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -375,21 +333,13 @@ def update_access_group(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_access_group(self, - access_group_id: str, - *, - transaction_id: str = None, - force: bool = None, - **kwargs + def delete_access_group( + self, access_group_id: str, *, transaction_id: str = None, force: bool = None, **kwargs ) -> DetailedResponse: """ Delete an access group. @@ -414,17 +364,13 @@ def delete_access_group(self, if not access_group_id: raise ValueError('access_group_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_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_access_group' + ) headers.update(sdk_headers) - params = { - 'force': force - } + params = {'force': force} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -434,10 +380,7 @@ def delete_access_group(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -446,13 +389,8 @@ def delete_access_group(self, # Membership operations ######################### - - def is_member_of_access_group(self, - access_group_id: str, - iam_id: str, - *, - transaction_id: str = None, - **kwargs + def is_member_of_access_group( + self, access_group_id: str, iam_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Check membership in an access group. @@ -479,12 +417,10 @@ def is_member_of_access_group(self, raise ValueError('access_group_id must be provided') if not iam_id: raise ValueError('iam_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='is_member_of_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='is_member_of_access_group' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -495,20 +431,18 @@ def is_member_of_access_group(self, path_param_values = self.encode_path_vars(access_group_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/members/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='HEAD', - url=url, - headers=headers) + request = self.prepare_request(method='HEAD', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def add_members_to_access_group(self, + def add_members_to_access_group( + self, access_group_id: str, *, members: List['AddGroupMembersRequestMembersItem'] = None, transaction_id: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Add members to an access group. @@ -537,17 +471,13 @@ def add_members_to_access_group(self, raise ValueError('access_group_id must be provided') if members is not None: members = [convert_model(x) for x in members] - headers = { - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='add_members_to_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='add_members_to_access_group' + ) headers.update(sdk_headers) - data = { - 'members': members - } + data = {'members': members} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -561,16 +491,13 @@ def add_members_to_access_group(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/members'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_access_group_members(self, + def list_access_group_members( + self, access_group_id: str, *, transaction_id: str = None, @@ -580,7 +507,7 @@ def list_access_group_members(self, type: str = None, verbose: bool = None, sort: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ List access group members. @@ -618,12 +545,10 @@ def list_access_group_members(self, if not access_group_id: raise ValueError('access_group_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_access_group_members') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_access_group_members' + ) headers.update(sdk_headers) params = { @@ -632,7 +557,7 @@ def list_access_group_members(self, 'offset': offset, 'type': type, 'verbose': verbose, - 'sort': sort + 'sort': sort, } if 'headers' in kwargs: @@ -644,21 +569,13 @@ def list_access_group_members(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/members'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def remove_member_from_access_group(self, - access_group_id: str, - iam_id: str, - *, - transaction_id: str = None, - **kwargs + def remove_member_from_access_group( + self, access_group_id: str, iam_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete member from an access group. @@ -685,12 +602,10 @@ def remove_member_from_access_group(self, raise ValueError('access_group_id must be provided') if not iam_id: raise ValueError('iam_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='remove_member_from_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='remove_member_from_access_group' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -701,20 +616,13 @@ def remove_member_from_access_group(self, path_param_values = self.encode_path_vars(access_group_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/members/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def remove_members_from_access_group(self, - access_group_id: str, - *, - members: List[str] = None, - transaction_id: str = None, - **kwargs + def remove_members_from_access_group( + self, access_group_id: str, *, members: List[str] = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete members from an access group. @@ -740,17 +648,15 @@ def remove_members_from_access_group(self, if not access_group_id: raise ValueError('access_group_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='remove_members_from_access_group') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='remove_members_from_access_group', + ) headers.update(sdk_headers) - data = { - 'members': members - } + data = {'members': members} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -764,21 +670,13 @@ def remove_members_from_access_group(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/members/delete'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def remove_member_from_all_access_groups(self, - account_id: str, - iam_id: str, - *, - transaction_id: str = None, - **kwargs + def remove_member_from_all_access_groups( + self, account_id: str, iam_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete member from all access groups. @@ -807,17 +705,15 @@ def remove_member_from_all_access_groups(self, raise ValueError('account_id must be provided') if not iam_id: raise ValueError('iam_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='remove_member_from_all_access_groups') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='remove_member_from_all_access_groups', + ) headers.update(sdk_headers) - params = { - 'account_id': account_id - } + params = {'account_id': account_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -828,23 +724,20 @@ def remove_member_from_all_access_groups(self, path_param_values = self.encode_path_vars(iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/_allgroups/members/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def add_member_to_multiple_access_groups(self, + def add_member_to_multiple_access_groups( + self, account_id: str, iam_id: str, *, type: str = None, groups: List[str] = None, transaction_id: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Add member to multiple access groups. @@ -876,22 +769,17 @@ def add_member_to_multiple_access_groups(self, raise ValueError('account_id must be provided') if not iam_id: raise ValueError('iam_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='add_member_to_multiple_access_groups') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='add_member_to_multiple_access_groups', + ) headers.update(sdk_headers) - params = { - 'account_id': account_id - } + params = {'account_id': account_id} - data = { - 'type': type, - 'groups': groups - } + data = {'type': type, 'groups': groups} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -905,11 +793,7 @@ def add_member_to_multiple_access_groups(self, path_param_values = self.encode_path_vars(iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/_allgroups/members/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response @@ -918,8 +802,8 @@ def add_member_to_multiple_access_groups(self, # Rule operations ######################### - - def add_access_group_rule(self, + def add_access_group_rule( + self, access_group_id: str, expiration: int, realm_name: str, @@ -927,7 +811,7 @@ def add_access_group_rule(self, *, name: str = None, transaction_id: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Create rule for an access group. @@ -965,20 +849,13 @@ def add_access_group_rule(self, if conditions is None: raise ValueError('conditions must be provided') conditions = [convert_model(x) for x in conditions] - headers = { - 'Transaction-Id': transaction_id - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='add_access_group_rule') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='add_access_group_rule' + ) headers.update(sdk_headers) - data = { - 'expiration': expiration, - 'realm_name': realm_name, - 'conditions': conditions, - 'name': name - } + data = {'expiration': expiration, 'realm_name': realm_name, 'conditions': conditions, 'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -992,20 +869,13 @@ def add_access_group_rule(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/rules'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_access_group_rules(self, - access_group_id: str, - *, - transaction_id: str = None, - **kwargs + def list_access_group_rules( + self, access_group_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ List access group rules. @@ -1026,12 +896,10 @@ def list_access_group_rules(self, if not access_group_id: raise ValueError('access_group_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_access_group_rules') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_access_group_rules' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1043,20 +911,13 @@ def list_access_group_rules(self, path_param_values = self.encode_path_vars(access_group_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/rules'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_access_group_rule(self, - access_group_id: str, - rule_id: str, - *, - transaction_id: str = None, - **kwargs + def get_access_group_rule( + self, access_group_id: str, rule_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Get an access group rule. @@ -1080,12 +941,10 @@ def get_access_group_rule(self, raise ValueError('access_group_id must be provided') if not rule_id: raise ValueError('rule_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_access_group_rule') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_access_group_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1097,15 +956,13 @@ def get_access_group_rule(self, path_param_values = self.encode_path_vars(access_group_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def replace_access_group_rule(self, + def replace_access_group_rule( + self, access_group_id: str, rule_id: str, if_match: str, @@ -1115,7 +972,7 @@ def replace_access_group_rule(self, *, name: str = None, transaction_id: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Replace an access group rule. @@ -1156,21 +1013,13 @@ def replace_access_group_rule(self, if conditions is None: raise ValueError('conditions must be provided') conditions = [convert_model(x) for x in conditions] - 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='replace_access_group_rule') + 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='replace_access_group_rule' + ) headers.update(sdk_headers) - data = { - 'expiration': expiration, - 'realm_name': realm_name, - 'conditions': conditions, - 'name': name - } + data = {'expiration': expiration, 'realm_name': realm_name, 'conditions': conditions, 'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1184,21 +1033,13 @@ def replace_access_group_rule(self, path_param_values = self.encode_path_vars(access_group_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def remove_access_group_rule(self, - access_group_id: str, - rule_id: str, - *, - transaction_id: str = None, - **kwargs + def remove_access_group_rule( + self, access_group_id: str, rule_id: str, *, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Delete an access group rule. @@ -1223,12 +1064,10 @@ def remove_access_group_rule(self, raise ValueError('access_group_id must be provided') if not rule_id: raise ValueError('rule_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='remove_access_group_rule') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='remove_access_group_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1239,9 +1078,7 @@ def remove_access_group_rule(self, path_param_values = self.encode_path_vars(access_group_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/groups/{access_group_id}/rules/{rule_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -1250,13 +1087,7 @@ def remove_access_group_rule(self, # Account settings ######################### - - def get_account_settings(self, - account_id: str, - *, - transaction_id: str = None, - **kwargs - ) -> DetailedResponse: + def get_account_settings(self, account_id: str, *, transaction_id: str = None, **kwargs) -> DetailedResponse: """ Get account settings. @@ -1278,17 +1109,13 @@ def get_account_settings(self, 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='get_account_settings') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_account_settings' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id - } + params = {'account_id': account_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1296,21 +1123,13 @@ def get_account_settings(self, headers['Accept'] = 'application/json' url = '/v2/groups/settings' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_account_settings(self, - account_id: str, - *, - public_access_enabled: bool = None, - transaction_id: str = None, - **kwargs + def update_account_settings( + self, account_id: str, *, public_access_enabled: bool = None, transaction_id: str = None, **kwargs ) -> DetailedResponse: """ Update account settings. @@ -1341,21 +1160,15 @@ def update_account_settings(self, 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='update_account_settings') + headers = {'Transaction-Id': transaction_id} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_account_settings' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id - } + params = {'account_id': account_id} - data = { - 'public_access_enabled': public_access_enabled - } + data = {'public_access_enabled': public_access_enabled} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1366,11 +1179,7 @@ def update_account_settings(self, headers['Accept'] = 'application/json' url = '/v2/groups/settings' - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response @@ -1381,7 +1190,7 @@ def update_account_settings(self, ############################################################################## -class AccountSettings(): +class AccountSettings: """ The access groups settings for a specific account. @@ -1396,12 +1205,14 @@ class AccountSettings(): 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: + 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. @@ -1471,7 +1282,8 @@ def __ne__(self, other: 'AccountSettings') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddGroupMembersRequestMembersItem(): + +class AddGroupMembersRequestMembersItem: """ AddGroupMembersRequestMembersItem. @@ -1480,9 +1292,7 @@ class AddGroupMembersRequestMembersItem(): "profile". """ - def __init__(self, - iam_id: str, - type: str) -> None: + def __init__(self, iam_id: str, type: str) -> None: """ Initialize a AddGroupMembersRequestMembersItem object. @@ -1540,7 +1350,8 @@ def __ne__(self, other: 'AddGroupMembersRequestMembersItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddGroupMembersResponse(): + +class AddGroupMembersResponse: """ The members added to an access group. @@ -1548,9 +1359,7 @@ class AddGroupMembersResponse(): added to an access group. """ - def __init__(self, - *, - members: List['AddGroupMembersResponseMembersItem'] = None) -> None: + def __init__(self, *, members: List['AddGroupMembersResponseMembersItem'] = None) -> None: """ Initialize a AddGroupMembersResponse object. @@ -1597,7 +1406,8 @@ def __ne__(self, other: 'AddGroupMembersResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddGroupMembersResponseMembersItem(): + +class AddGroupMembersResponseMembersItem: """ AddGroupMembersResponseMembersItem. @@ -1615,15 +1425,17 @@ class AddGroupMembersResponseMembersItem(): 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: + 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. @@ -1711,7 +1523,8 @@ def __ne__(self, other: 'AddGroupMembersResponseMembersItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddMembershipMultipleGroupsResponse(): + +class AddMembershipMultipleGroupsResponse: """ The response from the add member to multiple access groups request. @@ -1720,10 +1533,9 @@ class AddMembershipMultipleGroupsResponse(): list of access groups a member was added to. """ - def __init__(self, - *, - iam_id: str = None, - groups: List['AddMembershipMultipleGroupsResponseGroupsItem'] = None) -> None: + def __init__( + self, *, iam_id: str = None, groups: List['AddMembershipMultipleGroupsResponseGroupsItem'] = None + ) -> None: """ Initialize a AddMembershipMultipleGroupsResponse object. @@ -1776,7 +1588,8 @@ def __ne__(self, other: 'AddMembershipMultipleGroupsResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AddMembershipMultipleGroupsResponseGroupsItem(): + +class AddMembershipMultipleGroupsResponseGroupsItem: """ AddMembershipMultipleGroupsResponseGroupsItem. @@ -1790,12 +1603,9 @@ class AddMembershipMultipleGroupsResponseGroupsItem(): member to access group. """ - def __init__(self, - *, - access_group_id: str = None, - status_code: int = None, - trace: str = None, - errors: List['Error'] = None) -> None: + def __init__( + self, *, access_group_id: str = None, status_code: int = None, trace: str = None, errors: List['Error'] = None + ) -> None: """ Initialize a AddMembershipMultipleGroupsResponseGroupsItem object. @@ -1863,7 +1673,8 @@ def __ne__(self, other: 'AddMembershipMultipleGroupsResponseGroupsItem') -> bool """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteFromAllGroupsResponse(): + +class DeleteFromAllGroupsResponse: """ The response from the delete member from access groups request. @@ -1872,10 +1683,7 @@ class DeleteFromAllGroupsResponse(): the member was removed from. """ - def __init__(self, - *, - iam_id: str = None, - groups: List['DeleteFromAllGroupsResponseGroupsItem'] = None) -> None: + def __init__(self, *, iam_id: str = None, groups: List['DeleteFromAllGroupsResponseGroupsItem'] = None) -> None: """ Initialize a DeleteFromAllGroupsResponse object. @@ -1929,7 +1737,8 @@ def __ne__(self, other: 'DeleteFromAllGroupsResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteFromAllGroupsResponseGroupsItem(): + +class DeleteFromAllGroupsResponseGroupsItem: """ DeleteFromAllGroupsResponseGroupsItem. @@ -1943,12 +1752,9 @@ class DeleteFromAllGroupsResponseGroupsItem(): 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: + def __init__( + self, *, access_group_id: str = None, status_code: int = None, trace: str = None, errors: List['Error'] = None + ) -> None: """ Initialize a DeleteFromAllGroupsResponseGroupsItem object. @@ -2016,7 +1822,8 @@ def __ne__(self, other: 'DeleteFromAllGroupsResponseGroupsItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteGroupBulkMembersResponse(): + +class DeleteGroupBulkMembersResponse: """ The access group id and the members removed from it. @@ -2025,10 +1832,9 @@ class DeleteGroupBulkMembersResponse(): `iam_id`s removed from the access group. """ - def __init__(self, - *, - access_group_id: str = None, - members: List['DeleteGroupBulkMembersResponseMembersItem'] = None) -> None: + def __init__( + self, *, access_group_id: str = None, members: List['DeleteGroupBulkMembersResponseMembersItem'] = None + ) -> None: """ Initialize a DeleteGroupBulkMembersResponse object. @@ -2081,7 +1887,8 @@ def __ne__(self, other: 'DeleteGroupBulkMembersResponse') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class DeleteGroupBulkMembersResponseMembersItem(): + +class DeleteGroupBulkMembersResponseMembersItem: """ DeleteGroupBulkMembersResponseMembersItem. @@ -2094,12 +1901,9 @@ class DeleteGroupBulkMembersResponseMembersItem(): 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: + def __init__( + self, *, iam_id: str = None, trace: str = None, status_code: int = None, errors: List['Error'] = None + ) -> None: """ Initialize a DeleteGroupBulkMembersResponseMembersItem object. @@ -2166,7 +1970,8 @@ def __ne__(self, other: 'DeleteGroupBulkMembersResponseMembersItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Error(): + +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 @@ -2178,10 +1983,7 @@ class Error(): an action to take. """ - def __init__(self, - *, - code: str = None, - message: str = None) -> None: + def __init__(self, *, code: str = None, message: str = None) -> None: """ Initialize a Error object. @@ -2235,7 +2037,8 @@ def __ne__(self, other: 'Error') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Group(): + +class Group: """ An IAM access group. @@ -2255,18 +2058,20 @@ class Group(): 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: + 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. @@ -2364,7 +2169,8 @@ def __ne__(self, other: 'Group') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GroupMembersList(): + +class GroupMembersList: """ The members of a group. @@ -2379,16 +2185,18 @@ class GroupMembersList(): 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: + 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. @@ -2483,7 +2291,8 @@ def __ne__(self, other: 'GroupMembersList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class GroupsList(): + +class GroupsList: """ The list of access groups returned as part of a response. @@ -2497,16 +2306,18 @@ class GroupsList(): :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: + 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. @@ -2600,16 +2411,15 @@ def __ne__(self, other: 'GroupsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class HrefStruct(): + +class HrefStruct: """ A link object. :attr str href: (optional) A string containing the link’s URL. """ - def __init__(self, - *, - href: str = None) -> None: + def __init__(self, *, href: str = None) -> None: """ Initialize a HrefStruct object. @@ -2655,7 +2465,8 @@ def __ne__(self, other: 'HrefStruct') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ListGroupMembersResponseMember(): + +class ListGroupMembersResponseMember: """ A single member of an access group in a list. @@ -2676,17 +2487,19 @@ class ListGroupMembersResponseMember(): membership. """ - 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) -> None: + 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, + ) -> None: """ Initialize a ListGroupMembersResponseMember object. @@ -2786,7 +2599,8 @@ def __ne__(self, other: 'ListGroupMembersResponseMember') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Rule(): + +class Rule: """ A rule of an access group. @@ -2808,19 +2622,21 @@ class Rule(): rule. """ - def __init__(self, - *, - 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) -> None: + def __init__( + self, + *, + 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, + ) -> None: """ Initialize a Rule object. @@ -2933,7 +2749,8 @@ def __ne__(self, other: 'Rule') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RuleConditions(): + +class RuleConditions: """ The conditions of a rule. @@ -2944,10 +2761,7 @@ class RuleConditions(): the operator. """ - def __init__(self, - claim: str, - operator: str, - value: str) -> None: + def __init__(self, claim: str, operator: str, value: str) -> None: """ Initialize a RuleConditions object. @@ -3017,6 +2831,7 @@ class OperatorEnum(str, Enum): """ The operation to perform on the claim. """ + EQUALS = 'EQUALS' EQUALS_IGNORE_CASE = 'EQUALS_IGNORE_CASE' IN = 'IN' @@ -3025,16 +2840,14 @@ class OperatorEnum(str, Enum): CONTAINS = 'CONTAINS' -class RulesList(): +class RulesList: """ A list of rules attached to the access group. :attr List[Rule] rules: (optional) A list of rules. """ - def __init__(self, - *, - rules: List['Rule'] = None) -> None: + def __init__(self, *, rules: List['Rule'] = None) -> None: """ Initialize a RulesList object. @@ -3080,26 +2893,29 @@ def __ne__(self, other: 'RulesList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + ############################################################################## # Pagers ############################################################################## -class AccessGroupsPager(): + +class AccessGroupsPager: """ AccessGroupsPager can be used to simplify the use of the "list_access_groups" method. """ - def __init__(self, - *, - client: IamAccessGroupsV2, - account_id: str, - transaction_id: str = None, - iam_id: str = None, - membership_type: str = None, - limit: int = None, - sort: str = None, - show_federated: bool = None, - hide_public_access: bool = None, + def __init__( + self, + *, + client: IamAccessGroupsV2, + account_id: str, + transaction_id: str = None, + iam_id: str = None, + membership_type: str = None, + limit: int = None, + sort: str = None, + show_federated: bool = None, + hide_public_access: bool = None, ) -> None: """ Initialize a AccessGroupsPager object. @@ -3132,7 +2948,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._account_id = account_id self._transaction_id = transaction_id self._iam_id = iam_id @@ -3192,21 +3008,23 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class AccessGroupMembersPager(): + +class AccessGroupMembersPager: """ AccessGroupMembersPager can be used to simplify the use of the "list_access_group_members" method. """ - def __init__(self, - *, - client: IamAccessGroupsV2, - access_group_id: str, - transaction_id: str = None, - membership_type: str = None, - limit: int = None, - type: str = None, - verbose: bool = None, - sort: str = None, + def __init__( + self, + *, + client: IamAccessGroupsV2, + access_group_id: str, + transaction_id: str = None, + membership_type: str = None, + limit: int = None, + type: str = None, + verbose: bool = None, + sort: str = None, ) -> None: """ Initialize a AccessGroupMembersPager object. @@ -3231,7 +3049,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._access_group_id = access_group_id self._transaction_id = transaction_id self._membership_type = membership_type diff --git a/ibm_platform_services/iam_identity_v1.py b/ibm_platform_services/iam_identity_v1.py index b37a2d4e..76422e37 100644 --- a/ibm_platform_services/iam_identity_v1.py +++ b/ibm_platform_services/iam_identity_v1.py @@ -39,6 +39,7 @@ # Service ############################################################################## + class IamIdentityV1(BaseService): """The iam_identity V1 service.""" @@ -46,23 +47,23 @@ class IamIdentityV1(BaseService): DEFAULT_SERVICE_NAME = 'iam_identity' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'IamIdentityV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'IamIdentityV1': """ Return a new client for the iam_identity service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the iam_identity service. @@ -70,17 +71,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # API key Operations ######################### - - def list_api_keys(self, + def list_api_keys( + self, *, account_id: str = None, iam_id: str = None, @@ -131,9 +129,9 @@ def list_api_keys(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_api_keys') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_api_keys' + ) headers.update(sdk_headers) params = { @@ -145,7 +143,7 @@ def list_api_keys(self, 'type': type, 'sort': sort, 'order': order, - 'include_history': include_history + 'include_history': include_history, } if 'headers' in kwargs: @@ -153,16 +151,13 @@ def list_api_keys(self, headers['Accept'] = 'application/json' url = '/v1/apikeys' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_api_key(self, + def create_api_key( + self, name: str, iam_id: str, *, @@ -209,12 +204,10 @@ def create_api_key(self, raise ValueError('name must be provided') if iam_id is None: raise ValueError('iam_id must be provided') - headers = { - 'Entity-Lock': entity_lock - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_api_key') + headers = {'Entity-Lock': entity_lock} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_api_key' + ) headers.update(sdk_headers) data = { @@ -223,7 +216,7 @@ def create_api_key(self, 'description': description, 'account_id': account_id, 'apikey': apikey, - 'store_value': store_value + 'store_value': store_value, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -234,20 +227,13 @@ def create_api_key(self, headers['Accept'] = 'application/json' url = '/v1/apikeys' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_api_keys_details(self, - *, - iam_api_key: str = None, - include_history: bool = None, - **kwargs + def get_api_keys_details( + self, *, iam_api_key: str = None, include_history: bool = None, **kwargs ) -> DetailedResponse: """ Get details of an API key by its value. @@ -264,38 +250,26 @@ def get_api_keys_details(self, :rtype: DetailedResponse with `dict` result representing a `ApiKey` object """ - headers = { - 'IAM-ApiKey': iam_api_key - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_api_keys_details') + headers = {'IAM-ApiKey': iam_api_key} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_api_keys_details' + ) headers.update(sdk_headers) - params = { - 'include_history': include_history - } + params = {'include_history': include_history} if 'headers' in kwargs: headers.update(kwargs.get('headers')) headers['Accept'] = 'application/json' url = '/v1/apikeys/details' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_api_key(self, - id: str, - *, - include_history: bool = None, - include_activity: bool = None, - **kwargs + def get_api_key( + self, id: str, *, include_history: bool = None, include_activity: bool = None, **kwargs ) -> DetailedResponse: """ Get details of an API key. @@ -320,15 +294,12 @@ def get_api_key(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_api_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_api_key' + ) headers.update(sdk_headers) - params = { - 'include_history': include_history, - 'include_activity': include_activity - } + params = {'include_history': include_history, 'include_activity': include_activity} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -338,22 +309,13 @@ def get_api_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/apikeys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_api_key(self, - id: str, - if_match: str, - *, - name: str = None, - description: str = None, - **kwargs + def update_api_key( + self, id: str, if_match: str, *, name: str = None, description: str = None, **kwargs ) -> DetailedResponse: """ Updates an API key. @@ -385,18 +347,13 @@ def update_api_key(self, raise ValueError('id must be provided') if if_match is None: raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_api_key') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_api_key' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'description': description - } + data = {'name': name, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -409,19 +366,12 @@ def update_api_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/apikeys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_api_key(self, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_api_key(self, id: str, **kwargs) -> DetailedResponse: """ Deletes an API key. @@ -438,9 +388,9 @@ def delete_api_key(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_api_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_api_key' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -450,18 +400,12 @@ def delete_api_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/apikeys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def lock_api_key(self, - id: str, - **kwargs - ) -> DetailedResponse: + def lock_api_key(self, id: str, **kwargs) -> DetailedResponse: """ Lock the API key. @@ -480,9 +424,9 @@ def lock_api_key(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='lock_api_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='lock_api_key' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -492,18 +436,12 @@ def lock_api_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/apikeys/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def unlock_api_key(self, - id: str, - **kwargs - ) -> DetailedResponse: + def unlock_api_key(self, id: str, **kwargs) -> DetailedResponse: """ Unlock the API key. @@ -522,9 +460,9 @@ def unlock_api_key(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='unlock_api_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='unlock_api_key' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -534,9 +472,7 @@ def unlock_api_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/apikeys/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -545,8 +481,8 @@ def unlock_api_key(self, # Service ID Operations ######################### - - def list_service_ids(self, + def list_service_ids( + self, *, account_id: str = None, name: str = None, @@ -586,9 +522,9 @@ def list_service_ids(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_service_ids') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_service_ids' + ) headers.update(sdk_headers) params = { @@ -598,7 +534,7 @@ def list_service_ids(self, 'pagetoken': pagetoken, 'sort': sort, 'order': order, - 'include_history': include_history + 'include_history': include_history, } if 'headers' in kwargs: @@ -606,16 +542,13 @@ def list_service_ids(self, headers['Accept'] = 'application/json' url = '/v1/serviceids/' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_service_id(self, + def create_service_id( + self, account_id: str, name: str, *, @@ -656,12 +589,10 @@ def create_service_id(self, raise ValueError('name must be provided') if apikey is not None: apikey = convert_model(apikey) - headers = { - 'Entity-Lock': entity_lock - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_service_id') + headers = {'Entity-Lock': entity_lock} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_service_id' + ) headers.update(sdk_headers) data = { @@ -669,7 +600,7 @@ def create_service_id(self, 'name': name, 'description': description, 'unique_instance_crns': unique_instance_crns, - 'apikey': apikey + 'apikey': apikey, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -680,21 +611,13 @@ def create_service_id(self, headers['Accept'] = 'application/json' url = '/v1/serviceids/' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_service_id(self, - id: str, - *, - include_history: bool = None, - include_activity: bool = None, - **kwargs + def get_service_id( + self, id: str, *, include_history: bool = None, include_activity: bool = None, **kwargs ) -> DetailedResponse: """ Get details of a service ID. @@ -718,15 +641,12 @@ def get_service_id(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_service_id') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_service_id' + ) headers.update(sdk_headers) - params = { - 'include_history': include_history, - 'include_activity': include_activity - } + params = {'include_history': include_history, 'include_activity': include_activity} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -736,16 +656,13 @@ def get_service_id(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/serviceids/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_service_id(self, + def update_service_id( + self, id: str, if_match: str, *, @@ -790,19 +707,13 @@ def update_service_id(self, raise ValueError('id must be provided') if if_match is None: raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_service_id') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_service_id' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'description': description, - 'unique_instance_crns': unique_instance_crns - } + data = {'name': name, 'description': description, 'unique_instance_crns': unique_instance_crns} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -815,19 +726,12 @@ def update_service_id(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/serviceids/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_service_id(self, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_service_id(self, id: str, **kwargs) -> DetailedResponse: """ Deletes a service ID and associated API keys. @@ -847,9 +751,9 @@ def delete_service_id(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_service_id') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_service_id' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -859,18 +763,12 @@ def delete_service_id(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/serviceids/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def lock_service_id(self, - id: str, - **kwargs - ) -> DetailedResponse: + def lock_service_id(self, id: str, **kwargs) -> DetailedResponse: """ Lock the service ID. @@ -889,9 +787,9 @@ def lock_service_id(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='lock_service_id') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='lock_service_id' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -901,18 +799,12 @@ def lock_service_id(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/serviceids/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def unlock_service_id(self, - id: str, - **kwargs - ) -> DetailedResponse: + def unlock_service_id(self, id: str, **kwargs) -> DetailedResponse: """ Unlock the service ID. @@ -931,9 +823,9 @@ def unlock_service_id(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='unlock_service_id') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='unlock_service_id' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -943,9 +835,7 @@ def unlock_service_id(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/serviceids/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -954,14 +844,7 @@ def unlock_service_id(self, # Trusted Profiles Operations ######################### - - def create_profile(self, - name: str, - account_id: str, - *, - description: str = None, - **kwargs - ) -> DetailedResponse: + def create_profile(self, name: str, account_id: str, *, description: str = None, **kwargs) -> DetailedResponse: """ Create a trusted profile. @@ -984,16 +867,12 @@ def create_profile(self, if account_id is None: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_profile') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_profile' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'account_id': account_id, - 'description': description - } + data = {'name': name, 'account_id': account_id, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1003,16 +882,13 @@ def create_profile(self, headers['Accept'] = 'application/json' url = '/v1/profiles' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_profiles(self, + def list_profiles( + self, account_id: str, *, name: str = None, @@ -1050,9 +926,9 @@ def list_profiles(self, if account_id is None: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_profiles') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_profiles' + ) headers.update(sdk_headers) params = { @@ -1062,7 +938,7 @@ def list_profiles(self, 'sort': sort, 'order': order, 'include_history': include_history, - 'pagetoken': pagetoken + 'pagetoken': pagetoken, } if 'headers' in kwargs: @@ -1070,21 +946,12 @@ def list_profiles(self, headers['Accept'] = 'application/json' url = '/v1/profiles' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_profile(self, - profile_id: str, - *, - include_activity: bool = None, - **kwargs - ) -> DetailedResponse: + def get_profile(self, profile_id: str, *, include_activity: bool = None, **kwargs) -> DetailedResponse: """ Get a trusted profile. @@ -1104,14 +971,12 @@ def get_profile(self, if profile_id is None: raise ValueError('profile_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_profile') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_profile' + ) headers.update(sdk_headers) - params = { - 'include_activity': include_activity - } + params = {'include_activity': include_activity} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1121,22 +986,13 @@ def get_profile(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_profile(self, - profile_id: str, - if_match: str, - *, - name: str = None, - description: str = None, - **kwargs + def update_profile( + self, profile_id: str, if_match: str, *, name: str = None, description: str = None, **kwargs ) -> DetailedResponse: """ Update a trusted profile. @@ -1165,18 +1021,13 @@ def update_profile(self, raise ValueError('profile_id must be provided') if if_match is None: raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_profile') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_profile' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'description': description - } + data = {'name': name, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1189,19 +1040,12 @@ def update_profile(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_profile(self, - profile_id: str, - **kwargs - ) -> DetailedResponse: + def delete_profile(self, profile_id: str, **kwargs) -> DetailedResponse: """ Delete a trusted profile. @@ -1218,9 +1062,9 @@ def delete_profile(self, if profile_id is None: raise ValueError('profile_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_profile') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_profile' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1230,15 +1074,13 @@ def delete_profile(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def create_claim_rule(self, + def create_claim_rule( + self, profile_id: str, type: str, conditions: List['ProfileClaimRuleConditions'], @@ -1288,9 +1130,9 @@ def create_claim_rule(self, if context is not None: context = convert_model(context) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_claim_rule') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_claim_rule' + ) headers.update(sdk_headers) data = { @@ -1300,7 +1142,7 @@ def create_claim_rule(self, 'name': name, 'realm_name': realm_name, 'cr_type': cr_type, - 'expiration': expiration + 'expiration': expiration, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1314,19 +1156,12 @@ def create_claim_rule(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/rules'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_claim_rules(self, - profile_id: str, - **kwargs - ) -> DetailedResponse: + def list_claim_rules(self, profile_id: str, **kwargs) -> DetailedResponse: """ List claim rules for a trusted profile. @@ -1342,9 +1177,9 @@ def list_claim_rules(self, if profile_id is None: raise ValueError('profile_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_claim_rules') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_claim_rules' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1355,19 +1190,12 @@ def list_claim_rules(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/rules'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_claim_rule(self, - profile_id: str, - rule_id: str, - **kwargs - ) -> DetailedResponse: + def get_claim_rule(self, profile_id: str, rule_id: str, **kwargs) -> DetailedResponse: """ Get a claim rule for a trusted profile. @@ -1385,9 +1213,9 @@ def get_claim_rule(self, if rule_id is None: raise ValueError('rule_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_claim_rule') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_claim_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1398,15 +1226,13 @@ def get_claim_rule(self, path_param_values = self.encode_path_vars(profile_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/rules/{rule-id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_claim_rule(self, + def update_claim_rule( + self, profile_id: str, rule_id: str, if_match: str, @@ -1465,12 +1291,10 @@ def update_claim_rule(self, conditions = [convert_model(x) for x in conditions] if context is not None: context = convert_model(context) - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_claim_rule') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_claim_rule' + ) headers.update(sdk_headers) data = { @@ -1480,7 +1304,7 @@ def update_claim_rule(self, 'name': name, 'realm_name': realm_name, 'cr_type': cr_type, - 'expiration': expiration + 'expiration': expiration, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1494,20 +1318,12 @@ def update_claim_rule(self, path_param_values = self.encode_path_vars(profile_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/rules/{rule-id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_claim_rule(self, - profile_id: str, - rule_id: str, - **kwargs - ) -> DetailedResponse: + def delete_claim_rule(self, profile_id: str, rule_id: str, **kwargs) -> DetailedResponse: """ Delete a claim rule. @@ -1527,9 +1343,9 @@ def delete_claim_rule(self, if rule_id is None: raise ValueError('rule_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_claim_rule') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_claim_rule' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1539,21 +1355,13 @@ def delete_claim_rule(self, path_param_values = self.encode_path_vars(profile_id, rule_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/rules/{rule-id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def create_link(self, - profile_id: str, - cr_type: str, - link: 'CreateProfileLinkRequestLink', - *, - name: str = None, - **kwargs + def create_link( + self, profile_id: str, cr_type: str, link: 'CreateProfileLinkRequestLink', *, name: str = None, **kwargs ) -> DetailedResponse: """ Create link to a trusted profile. @@ -1580,16 +1388,12 @@ def create_link(self, raise ValueError('link must be provided') link = convert_model(link) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_link') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_link' + ) headers.update(sdk_headers) - data = { - 'cr_type': cr_type, - 'link': link, - 'name': name - } + data = {'cr_type': cr_type, 'link': link, 'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1602,19 +1406,12 @@ def create_link(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/links'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_links(self, - profile_id: str, - **kwargs - ) -> DetailedResponse: + def list_links(self, profile_id: str, **kwargs) -> DetailedResponse: """ List links to a trusted profile. @@ -1629,9 +1426,9 @@ def list_links(self, if profile_id is None: raise ValueError('profile_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_links') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_links' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1642,19 +1439,12 @@ def list_links(self, path_param_values = self.encode_path_vars(profile_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/links'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_link(self, - profile_id: str, - link_id: str, - **kwargs - ) -> DetailedResponse: + def get_link(self, profile_id: str, link_id: str, **kwargs) -> DetailedResponse: """ Get link to a trusted profile. @@ -1672,9 +1462,9 @@ def get_link(self, if link_id is None: raise ValueError('link_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_link') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_link' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1685,19 +1475,12 @@ def get_link(self, path_param_values = self.encode_path_vars(profile_id, link_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/links/{link-id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_link(self, - profile_id: str, - link_id: str, - **kwargs - ) -> DetailedResponse: + def delete_link(self, profile_id: str, link_id: str, **kwargs) -> DetailedResponse: """ Delete link to a trusted profile. @@ -1715,9 +1498,9 @@ def delete_link(self, if link_id is None: raise ValueError('link_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_link') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_link' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1727,9 +1510,7 @@ def delete_link(self, path_param_values = self.encode_path_vars(profile_id, link_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/profiles/{profile-id}/links/{link-id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -1738,13 +1519,7 @@ def delete_link(self, # Account Settings ######################### - - def get_account_settings(self, - account_id: str, - *, - include_history: bool = None, - **kwargs - ) -> DetailedResponse: + def get_account_settings(self, account_id: str, *, include_history: bool = None, **kwargs) -> DetailedResponse: """ Get account configurations. @@ -1761,14 +1536,12 @@ def get_account_settings(self, if account_id is None: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_account_settings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_account_settings' + ) headers.update(sdk_headers) - params = { - 'include_history': include_history - } + params = {'include_history': include_history} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1778,16 +1551,13 @@ def get_account_settings(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/accounts/{account_id}/settings/identity'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_account_settings(self, + def update_account_settings( + self, if_match: str, account_id: str, *, @@ -1855,12 +1625,10 @@ def update_account_settings(self, raise ValueError('if_match must be provided') if account_id is None: raise ValueError('account_id must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_account_settings') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_account_settings' + ) headers.update(sdk_headers) data = { @@ -1870,7 +1638,7 @@ def update_account_settings(self, 'mfa': mfa, 'session_expiration_in_seconds': session_expiration_in_seconds, 'session_invalidation_in_seconds': session_invalidation_in_seconds, - 'max_sessions_per_identity': max_sessions_per_identity + 'max_sessions_per_identity': max_sessions_per_identity, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -1884,10 +1652,7 @@ def update_account_settings(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/accounts/{account_id}/settings/identity'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -1896,14 +1661,7 @@ def update_account_settings(self, # activityOperations ######################### - - def create_report(self, - account_id: str, - *, - type: str = None, - duration: str = None, - **kwargs - ) -> DetailedResponse: + def create_report(self, account_id: str, *, type: str = None, duration: str = None, **kwargs) -> DetailedResponse: """ Trigger activity report across on account scope. @@ -1923,15 +1681,12 @@ def create_report(self, if account_id is None: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_report') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_report' + ) headers.update(sdk_headers) - params = { - 'type': type, - 'duration': duration - } + params = {'type': type, 'duration': duration} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1941,20 +1696,12 @@ def create_report(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/activity/accounts/{account_id}/report'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='POST', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_report(self, - account_id: str, - reference: str, - **kwargs - ) -> DetailedResponse: + def get_report(self, account_id: str, reference: str, **kwargs) -> DetailedResponse: """ Get activity report across on account scope. @@ -1973,9 +1720,9 @@ def get_report(self, if reference is None: raise ValueError('reference must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_report') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_report' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1986,9 +1733,7 @@ def get_report(self, path_param_values = self.encode_path_vars(account_id, reference) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/activity/accounts/{account_id}/report/{reference}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -2004,19 +1749,24 @@ class Scope(str, Enum): Optional parameter to define the scope of the queried API keys. Can be 'entity' (default) or 'account'. """ + ENTITY = 'entity' ACCOUNT = 'account' + class Type(str, Enum): """ Optional parameter to filter the type of the queried API keys. Can be 'user' or 'serviceid'. """ + USER = 'user' SERVICEID = 'serviceid' + class Order(str, Enum): """ Optional sort order, valid values are asc and desc. Default: asc. """ + ASC = 'asc' DESC = 'desc' @@ -2030,6 +1780,7 @@ class Order(str, Enum): """ Optional sort order, valid values are asc and desc. Default: asc. """ + ASC = 'asc' DESC = 'desc' @@ -2043,6 +1794,7 @@ class Order(str, Enum): """ Optional sort order, valid values are asc and desc. Default: asc. """ + ASC = 'asc' DESC = 'desc' @@ -2052,7 +1804,7 @@ class Order(str, Enum): ############################################################################## -class AccountSettingsResponse(): +class AccountSettingsResponse: """ Response body format for Account Settings REST requests. @@ -2095,19 +1847,21 @@ class AccountSettingsResponse(): * NOT_SET - To unset account setting and use service default. """ - def __init__(self, - account_id: str, - restrict_create_service_id: str, - restrict_create_platform_apikey: str, - allowed_ip_addresses: str, - entity_tag: str, - mfa: str, - session_expiration_in_seconds: str, - session_invalidation_in_seconds: str, - max_sessions_per_identity: str, - *, - context: 'ResponseContext' = None, - history: List['EnityHistoryRecord'] = None) -> None: + def __init__( + self, + account_id: str, + restrict_create_service_id: str, + restrict_create_platform_apikey: str, + allowed_ip_addresses: str, + entity_tag: str, + mfa: str, + session_expiration_in_seconds: str, + session_invalidation_in_seconds: str, + max_sessions_per_identity: str, + *, + context: 'ResponseContext' = None, + history: List['EnityHistoryRecord'] = None + ) -> None: """ Initialize a AccountSettingsResponse object. @@ -2175,11 +1929,15 @@ def from_dict(cls, _dict: Dict) -> 'AccountSettingsResponse': if 'restrict_create_service_id' in _dict: args['restrict_create_service_id'] = _dict.get('restrict_create_service_id') else: - raise ValueError('Required property \'restrict_create_service_id\' not present in AccountSettingsResponse JSON') + raise ValueError( + 'Required property \'restrict_create_service_id\' not present in AccountSettingsResponse JSON' + ) if 'restrict_create_platform_apikey' in _dict: args['restrict_create_platform_apikey'] = _dict.get('restrict_create_platform_apikey') else: - raise ValueError('Required property \'restrict_create_platform_apikey\' not present in AccountSettingsResponse JSON') + raise ValueError( + 'Required property \'restrict_create_platform_apikey\' not present in AccountSettingsResponse JSON' + ) if 'allowed_ip_addresses' in _dict: args['allowed_ip_addresses'] = _dict.get('allowed_ip_addresses') else: @@ -2197,15 +1955,21 @@ def from_dict(cls, _dict: Dict) -> 'AccountSettingsResponse': if 'session_expiration_in_seconds' in _dict: args['session_expiration_in_seconds'] = _dict.get('session_expiration_in_seconds') else: - raise ValueError('Required property \'session_expiration_in_seconds\' not present in AccountSettingsResponse JSON') + raise ValueError( + 'Required property \'session_expiration_in_seconds\' not present in AccountSettingsResponse JSON' + ) if 'session_invalidation_in_seconds' in _dict: args['session_invalidation_in_seconds'] = _dict.get('session_invalidation_in_seconds') else: - raise ValueError('Required property \'session_invalidation_in_seconds\' not present in AccountSettingsResponse JSON') + raise ValueError( + 'Required property \'session_invalidation_in_seconds\' not present in AccountSettingsResponse JSON' + ) if 'max_sessions_per_identity' in _dict: args['max_sessions_per_identity'] = _dict.get('max_sessions_per_identity') else: - raise ValueError('Required property \'max_sessions_per_identity\' not present in AccountSettingsResponse JSON') + raise ValueError( + 'Required property \'max_sessions_per_identity\' not present in AccountSettingsResponse JSON' + ) return cls(**args) @classmethod @@ -2265,11 +2029,11 @@ class RestrictCreateServiceIdEnum(str, Enum): * NOT_RESTRICTED - to remove access control * NOT_SET - to 'unset' a previous set value. """ + RESTRICTED = 'RESTRICTED' NOT_RESTRICTED = 'NOT_RESTRICTED' NOT_SET = 'NOT_SET' - class RestrictCreatePlatformApikeyEnum(str, Enum): """ Defines whether or not creating platform API keys is access controlled. Valid @@ -2278,11 +2042,11 @@ class RestrictCreatePlatformApikeyEnum(str, Enum): * NOT_RESTRICTED - to remove access control * NOT_SET - to 'unset' a previous set value. """ + RESTRICTED = 'RESTRICTED' NOT_RESTRICTED = 'NOT_RESTRICTED' NOT_SET = 'NOT_SET' - class MfaEnum(str, Enum): """ Defines the MFA trait for the account. Valid values: @@ -2293,6 +2057,7 @@ class MfaEnum(str, Enum): * LEVEL2 - TOTP-based MFA for all users * LEVEL3 - U2F MFA for all users. """ + NONE = 'NONE' TOTP = 'TOTP' TOTP4ALL = 'TOTP4ALL' @@ -2301,7 +2066,7 @@ class MfaEnum(str, Enum): LEVEL3 = 'LEVEL3' -class Activity(): +class Activity: """ Activity. @@ -2310,10 +2075,7 @@ class Activity(): authenticated. """ - def __init__(self, - authn_count: int, - *, - last_authn: str = None) -> None: + def __init__(self, authn_count: int, *, last_authn: str = None) -> None: """ Initialize a Activity object. @@ -2369,7 +2131,8 @@ def __ne__(self, other: 'Activity') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApiKey(): + +class ApiKey: """ Response body format for API key V1 REST requests. @@ -2404,23 +2167,25 @@ class ApiKey(): :attr Activity activity: (optional) """ - def __init__(self, - id: str, - crn: str, - locked: bool, - created_by: str, - name: str, - iam_id: str, - account_id: str, - apikey: str, - *, - context: 'ResponseContext' = None, - entity_tag: str = None, - created_at: datetime = None, - modified_at: datetime = None, - description: str = None, - history: List['EnityHistoryRecord'] = None, - activity: 'Activity' = None) -> None: + def __init__( + self, + id: str, + crn: str, + locked: bool, + created_by: str, + name: str, + iam_id: str, + account_id: str, + apikey: str, + *, + context: 'ResponseContext' = None, + entity_tag: str = None, + created_at: datetime = None, + modified_at: datetime = None, + description: str = None, + history: List['EnityHistoryRecord'] = None, + activity: 'Activity' = None + ) -> None: """ Initialize a ApiKey object. @@ -2584,7 +2349,8 @@ def __ne__(self, other: 'ApiKey') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApiKeyInsideCreateServiceIdRequest(): + +class ApiKeyInsideCreateServiceIdRequest: """ Parameters for the API key in the Create service Id V1 REST request. @@ -2605,12 +2371,7 @@ class ApiKeyInsideCreateServiceIdRequest(): the value. We don't allow storing of API keys for users. """ - def __init__(self, - name: str, - *, - description: str = None, - apikey: str = None, - store_value: bool = None) -> None: + def __init__(self, name: str, *, description: str = None, apikey: str = None, store_value: bool = None) -> None: """ Initialize a ApiKeyInsideCreateServiceIdRequest object. @@ -2688,7 +2449,8 @@ def __ne__(self, other: 'ApiKeyInsideCreateServiceIdRequest') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApiKeyList(): + +class ApiKeyList: """ Response body format for the List API keys V1 REST request. @@ -2707,15 +2469,17 @@ class ApiKeyList(): empty depending on the query parameters values provided. """ - def __init__(self, - apikeys: List['ApiKey'], - *, - context: 'ResponseContext' = None, - offset: int = None, - limit: int = None, - first: str = None, - previous: str = None, - next: str = None) -> None: + def __init__( + self, + apikeys: List['ApiKey'], + *, + context: 'ResponseContext' = None, + offset: int = None, + limit: int = None, + first: str = None, + previous: str = None, + next: str = None + ) -> None: """ Initialize a ApiKeyList object. @@ -2806,7 +2570,8 @@ def __ne__(self, other: 'ApiKeyList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApikeyActivity(): + +class ApikeyActivity: """ Apikeys activity details. @@ -2820,14 +2585,16 @@ class ApikeyActivity(): :attr str last_authn: (optional) Time when the apikey was last authenticated. """ - def __init__(self, - id: str, - type: str, - *, - name: str = None, - serviceid: 'ApikeyActivityServiceid' = None, - user: 'ApikeyActivityUser' = None, - last_authn: str = None) -> None: + def __init__( + self, + id: str, + type: str, + *, + name: str = None, + serviceid: 'ApikeyActivityServiceid' = None, + user: 'ApikeyActivityUser' = None, + last_authn: str = None + ) -> None: """ Initialize a ApikeyActivity object. @@ -2911,7 +2678,8 @@ def __ne__(self, other: 'ApikeyActivity') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApikeyActivityServiceid(): + +class ApikeyActivityServiceid: """ serviceid details will be present if type is `serviceid`. @@ -2919,10 +2687,7 @@ class ApikeyActivityServiceid(): :attr str name: (optional) Name provided during creation of the serviceid. """ - def __init__(self, - *, - id: str = None, - name: str = None) -> None: + def __init__(self, *, id: str = None, name: str = None) -> None: """ Initialize a ApikeyActivityServiceid object. @@ -2974,7 +2739,8 @@ def __ne__(self, other: 'ApikeyActivityServiceid') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ApikeyActivityUser(): + +class ApikeyActivityUser: """ user details will be present if type is `user`. @@ -2984,12 +2750,7 @@ class ApikeyActivityUser(): :attr str email: (optional) Email of the user. """ - def __init__(self, - *, - iam_id: str = None, - name: str = None, - username: str = None, - email: str = None) -> None: + def __init__(self, *, iam_id: str = None, name: str = None, username: str = None, email: str = None) -> None: """ Initialize a ApikeyActivityUser object. @@ -3053,7 +2814,8 @@ def __ne__(self, other: 'ApikeyActivityUser') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class CreateProfileLinkRequestLink(): + +class CreateProfileLinkRequestLink: """ Link details. @@ -3064,11 +2826,7 @@ class CreateProfileLinkRequestLink(): cr_type is IKS_SA or ROKS_SA. """ - def __init__(self, - crn: str, - namespace: str, - *, - name: str = None) -> None: + def __init__(self, crn: str, namespace: str, *, name: str = None) -> None: """ Initialize a CreateProfileLinkRequestLink object. @@ -3132,7 +2890,8 @@ def __ne__(self, other: 'CreateProfileLinkRequestLink') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EnityHistoryRecord(): + +class EnityHistoryRecord: """ Response body format for an entity history record. @@ -3144,13 +2903,9 @@ class EnityHistoryRecord(): :attr str message: Message which summarizes the executed action. """ - def __init__(self, - timestamp: str, - iam_id: str, - iam_id_account: str, - action: str, - params: List[str], - message: str) -> None: + def __init__( + self, timestamp: str, iam_id: str, iam_id_account: str, action: str, params: List[str], message: str + ) -> None: """ Initialize a EnityHistoryRecord object. @@ -3239,7 +2994,8 @@ def __ne__(self, other: 'EnityHistoryRecord') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class EntityActivity(): + +class EntityActivity: """ EntityActivity. @@ -3248,11 +3004,7 @@ class EntityActivity(): :attr str last_authn: (optional) Time when the entity was last authenticated. """ - def __init__(self, - id: str, - *, - name: str = None, - last_authn: str = None) -> None: + def __init__(self, id: str, *, name: str = None, last_authn: str = None) -> None: """ Initialize a EntityActivity object. @@ -3313,7 +3065,8 @@ def __ne__(self, other: 'EntityActivity') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileClaimRule(): + +class ProfileClaimRule: """ ProfileClaimRule. @@ -3334,18 +3087,20 @@ class ProfileClaimRule(): rule. """ - def __init__(self, - id: str, - entity_tag: str, - created_at: datetime, - type: str, - expiration: int, - conditions: List['ProfileClaimRuleConditions'], - *, - modified_at: datetime = None, - name: str = None, - realm_name: str = None, - cr_type: str = None) -> None: + def __init__( + self, + id: str, + entity_tag: str, + created_at: datetime, + type: str, + expiration: int, + conditions: List['ProfileClaimRuleConditions'], + *, + modified_at: datetime = None, + name: str = None, + realm_name: str = None, + cr_type: str = None + ) -> None: """ Initialize a ProfileClaimRule object. @@ -3463,7 +3218,8 @@ def __ne__(self, other: 'ProfileClaimRule') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileClaimRuleConditions(): + +class ProfileClaimRuleConditions: """ ProfileClaimRuleConditions. @@ -3474,10 +3230,7 @@ class ProfileClaimRuleConditions(): the operator. """ - def __init__(self, - claim: str, - operator: str, - value: str) -> None: + def __init__(self, claim: str, operator: str, value: str) -> None: """ Initialize a ProfileClaimRuleConditions object. @@ -3544,7 +3297,8 @@ def __ne__(self, other: 'ProfileClaimRuleConditions') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileClaimRuleList(): + +class ProfileClaimRuleList: """ ProfileClaimRuleList. @@ -3553,10 +3307,7 @@ class ProfileClaimRuleList(): :attr List[ProfileClaimRule] rules: List of claim rules. """ - def __init__(self, - rules: List['ProfileClaimRule'], - *, - context: 'ResponseContext' = None) -> None: + def __init__(self, rules: List['ProfileClaimRule'], *, context: 'ResponseContext' = None) -> None: """ Initialize a ProfileClaimRuleList object. @@ -3611,7 +3362,8 @@ def __ne__(self, other: 'ProfileClaimRuleList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileLink(): + +class ProfileLink: """ Link details. @@ -3627,15 +3379,17 @@ class ProfileLink(): :attr ProfileLinkLink link: """ - def __init__(self, - id: str, - entity_tag: str, - created_at: datetime, - modified_at: datetime, - cr_type: str, - link: 'ProfileLinkLink', - *, - name: str = None) -> None: + def __init__( + self, + id: str, + entity_tag: str, + created_at: datetime, + modified_at: datetime, + cr_type: str, + link: 'ProfileLinkLink', + *, + name: str = None + ) -> None: """ Initialize a ProfileLink object. @@ -3732,7 +3486,8 @@ def __ne__(self, other: 'ProfileLink') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileLinkLink(): + +class ProfileLinkLink: """ ProfileLinkLink. @@ -3743,11 +3498,7 @@ class ProfileLinkLink(): cr_type is IKS_SA or ROKS_SA. """ - def __init__(self, - *, - crn: str = None, - namespace: str = None, - name: str = None) -> None: + def __init__(self, *, crn: str = None, namespace: str = None, name: str = None) -> None: """ Initialize a ProfileLinkLink object. @@ -3807,15 +3558,15 @@ def __ne__(self, other: 'ProfileLinkLink') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ProfileLinkList(): + +class ProfileLinkList: """ ProfileLinkList. :attr List[ProfileLink] links: List of links to a trusted profile. """ - def __init__(self, - links: List['ProfileLink']) -> None: + def __init__(self, links: List['ProfileLink']) -> None: """ Initialize a ProfileLinkList object. @@ -3863,7 +3614,8 @@ def __ne__(self, other: 'ProfileLinkList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Report(): + +class Report: """ Report. @@ -3878,17 +3630,19 @@ class Report(): :attr List[EntityActivity] profiles: (optional) List of profiles. """ - def __init__(self, - created_by: str, - reference: str, - report_duration: str, - report_start_time: str, - report_end_time: str, - *, - users: List['UserActivity'] = None, - apikeys: List['ApikeyActivity'] = None, - serviceids: List['EntityActivity'] = None, - profiles: List['EntityActivity'] = None) -> None: + def __init__( + self, + created_by: str, + reference: str, + report_duration: str, + report_start_time: str, + report_end_time: str, + *, + users: List['UserActivity'] = None, + apikeys: List['ApikeyActivity'] = None, + serviceids: List['EntityActivity'] = None, + profiles: List['EntityActivity'] = None + ) -> None: """ Initialize a Report object. @@ -3993,15 +3747,15 @@ def __ne__(self, other: 'Report') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ReportReference(): + +class ReportReference: """ ReportReference. :attr str reference: Reference for the report to be generated. """ - def __init__(self, - reference: str) -> None: + def __init__(self, reference: str) -> None: """ Initialize a ReportReference object. @@ -4049,7 +3803,8 @@ def __ne__(self, other: 'ReportReference') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResponseContext(): + +class ResponseContext: """ Context with key properties for problem determination. @@ -4070,19 +3825,21 @@ class ResponseContext(): :attr str cluster_name: (optional) The cluster name. """ - def __init__(self, - *, - transaction_id: str = None, - operation: str = None, - user_agent: str = None, - url: str = None, - instance_id: str = None, - thread_id: str = None, - host: str = None, - start_time: str = None, - end_time: str = None, - elapsed_time: str = None, - cluster_name: str = None) -> None: + def __init__( + self, + *, + transaction_id: str = None, + operation: str = None, + user_agent: str = None, + url: str = None, + instance_id: str = None, + thread_id: str = None, + host: str = None, + start_time: str = None, + end_time: str = None, + elapsed_time: str = None, + cluster_name: str = None + ) -> None: """ Initialize a ResponseContext object. @@ -4193,7 +3950,8 @@ def __ne__(self, other: 'ResponseContext') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceId(): + +class ServiceId: """ Response body format for service ID V1 REST requests. @@ -4225,23 +3983,25 @@ class ServiceId(): :attr Activity activity: (optional) """ - def __init__(self, - id: str, - iam_id: str, - entity_tag: str, - crn: str, - locked: bool, - created_at: datetime, - modified_at: datetime, - account_id: str, - name: str, - *, - context: 'ResponseContext' = None, - description: str = None, - unique_instance_crns: List[str] = None, - history: List['EnityHistoryRecord'] = None, - apikey: 'ApiKey' = None, - activity: 'Activity' = None) -> None: + def __init__( + self, + id: str, + iam_id: str, + entity_tag: str, + crn: str, + locked: bool, + created_at: datetime, + modified_at: datetime, + account_id: str, + name: str, + *, + context: 'ResponseContext' = None, + description: str = None, + unique_instance_crns: List[str] = None, + history: List['EnityHistoryRecord'] = None, + apikey: 'ApiKey' = None, + activity: 'Activity' = None + ) -> None: """ Initialize a ServiceId object. @@ -4402,7 +4162,8 @@ def __ne__(self, other: 'ServiceId') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ServiceIdList(): + +class ServiceIdList: """ Response body format for the list service ID V1 REST request. @@ -4421,15 +4182,17 @@ class ServiceIdList(): response but might be empty depending on the query parameter values provided. """ - def __init__(self, - serviceids: List['ServiceId'], - *, - context: 'ResponseContext' = None, - offset: int = None, - limit: int = None, - first: str = None, - previous: str = None, - next: str = None) -> None: + def __init__( + self, + serviceids: List['ServiceId'], + *, + context: 'ResponseContext' = None, + offset: int = None, + limit: int = None, + first: str = None, + previous: str = None, + next: str = None + ) -> None: """ Initialize a ServiceIdList object. @@ -4521,7 +4284,8 @@ def __ne__(self, other: 'ServiceIdList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TrustedProfile(): + +class TrustedProfile: """ Response body format for trusted profile V1 REST requests. @@ -4552,22 +4316,24 @@ class TrustedProfile(): :attr Activity activity: (optional) """ - def __init__(self, - id: str, - entity_tag: str, - crn: str, - name: str, - iam_id: str, - account_id: str, - *, - context: 'ResponseContext' = None, - description: str = None, - created_at: datetime = None, - modified_at: datetime = None, - ims_account_id: int = None, - ims_user_id: int = None, - history: List['EnityHistoryRecord'] = None, - activity: 'Activity' = None) -> None: + def __init__( + self, + id: str, + entity_tag: str, + crn: str, + name: str, + iam_id: str, + account_id: str, + *, + context: 'ResponseContext' = None, + description: str = None, + created_at: datetime = None, + modified_at: datetime = None, + ims_account_id: int = None, + ims_user_id: int = None, + history: List['EnityHistoryRecord'] = None, + activity: 'Activity' = None + ) -> None: """ Initialize a TrustedProfile object. @@ -4717,7 +4483,8 @@ def __ne__(self, other: 'TrustedProfile') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class TrustedProfilesList(): + +class TrustedProfilesList: """ Response body format for the List trusted profiles V1 REST request. @@ -4734,15 +4501,17 @@ class TrustedProfilesList(): :attr List[TrustedProfile] profiles: List of trusted profiles. """ - def __init__(self, - profiles: List['TrustedProfile'], - *, - context: 'ResponseContext' = None, - offset: int = None, - limit: int = None, - first: str = None, - previous: str = None, - next: str = None) -> None: + def __init__( + self, + profiles: List['TrustedProfile'], + *, + context: 'ResponseContext' = None, + offset: int = None, + limit: int = None, + first: str = None, + previous: str = None, + next: str = None + ) -> None: """ Initialize a TrustedProfilesList object. @@ -4831,7 +4600,8 @@ def __ne__(self, other: 'TrustedProfilesList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UserActivity(): + +class UserActivity: """ UserActivity. @@ -4842,13 +4612,9 @@ class UserActivity(): :attr str last_authn: (optional) Time when the user was last authenticated. """ - def __init__(self, - iam_id: str, - username: str, - *, - name: str = None, - email: str = None, - last_authn: str = None) -> None: + def __init__( + self, iam_id: str, username: str, *, name: str = None, email: str = None, last_authn: str = None + ) -> None: """ Initialize a UserActivity object. diff --git a/ibm_platform_services/iam_policy_management_v1.py b/ibm_platform_services/iam_policy_management_v1.py index 4d461e17..b0dccc5d 100644 --- a/ibm_platform_services/iam_policy_management_v1.py +++ b/ibm_platform_services/iam_policy_management_v1.py @@ -38,6 +38,7 @@ # Service ############################################################################## + class IamPolicyManagementV1(BaseService): """The iam_policy_management V1 service.""" @@ -45,23 +46,23 @@ class IamPolicyManagementV1(BaseService): DEFAULT_SERVICE_NAME = 'iam_policy_management' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'IamPolicyManagementV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'IamPolicyManagementV1': """ Return a new client for the iam_policy_management service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the iam_policy_management service. @@ -69,17 +70,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Policies ######################### - - def list_policies(self, + def list_policies( + self, account_id: str, *, accept_language: str = None, @@ -144,12 +142,10 @@ def list_policies(self, if account_id is None: raise ValueError('account_id must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_policies') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_policies' + ) headers.update(sdk_headers) params = { @@ -162,7 +158,7 @@ def list_policies(self, 'tag_value': tag_value, 'sort': sort, 'format': format, - 'state': state + 'state': state, } if 'headers' in kwargs: @@ -170,16 +166,13 @@ def list_policies(self, headers['Accept'] = 'application/json' url = '/v1/policies' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_policy(self, + def create_policy( + self, type: str, subjects: List['PolicySubject'], roles: List['PolicyRole'], @@ -268,21 +261,13 @@ def create_policy(self, subjects = [convert_model(x) for x in subjects] roles = [convert_model(x) for x in roles] resources = [convert_model(x) for x in resources] - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_policy') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_policy' + ) headers.update(sdk_headers) - data = { - 'type': type, - 'subjects': subjects, - 'roles': roles, - 'resources': resources, - 'description': description - } + data = {'type': type, 'subjects': subjects, 'roles': roles, 'resources': resources, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -292,16 +277,13 @@ def create_policy(self, headers['Accept'] = 'application/json' url = '/v1/policies' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def update_policy(self, + def update_policy( + self, policy_id: str, if_match: str, type: str, @@ -384,21 +366,13 @@ def update_policy(self, subjects = [convert_model(x) for x in subjects] roles = [convert_model(x) for x in roles] resources = [convert_model(x) for x in resources] - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_policy') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_policy' + ) headers.update(sdk_headers) - data = { - 'type': type, - 'subjects': subjects, - 'roles': roles, - 'resources': resources, - 'description': description - } + data = {'type': type, 'subjects': subjects, 'roles': roles, 'resources': resources, 'description': description} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -411,19 +385,12 @@ def update_policy(self, path_param_values = self.encode_path_vars(policy_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/policies/{policy_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_policy(self, - policy_id: str, - **kwargs - ) -> DetailedResponse: + def get_policy(self, policy_id: str, **kwargs) -> DetailedResponse: """ Retrieve a policy by ID. @@ -438,9 +405,9 @@ def get_policy(self, if policy_id is None: raise ValueError('policy_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_policy') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_policy' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -451,18 +418,12 @@ def get_policy(self, path_param_values = self.encode_path_vars(policy_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/policies/{policy_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_policy(self, - policy_id: str, - **kwargs - ) -> DetailedResponse: + def delete_policy(self, policy_id: str, **kwargs) -> DetailedResponse: """ Delete a policy by ID. @@ -479,9 +440,9 @@ def delete_policy(self, if policy_id is None: raise ValueError('policy_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_policy') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_policy' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -491,21 +452,12 @@ def delete_policy(self, path_param_values = self.encode_path_vars(policy_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/policies/{policy_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def patch_policy(self, - policy_id: str, - if_match: str, - *, - state: str = None, - **kwargs - ) -> DetailedResponse: + def patch_policy(self, policy_id: str, if_match: str, *, state: str = None, **kwargs) -> DetailedResponse: """ Restore a deleted policy by ID. @@ -528,17 +480,13 @@ def patch_policy(self, raise ValueError('policy_id must be provided') if if_match is None: raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='patch_policy') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='patch_policy' + ) headers.update(sdk_headers) - data = { - 'state': state - } + data = {'state': state} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -551,10 +499,7 @@ def patch_policy(self, path_param_values = self.encode_path_vars(policy_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/policies/{policy_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -563,8 +508,8 @@ def patch_policy(self, # Roles ######################### - - def list_roles(self, + def list_roles( + self, *, accept_language: str = None, account_id: str = None, @@ -606,19 +551,17 @@ def list_roles(self, :rtype: DetailedResponse with `dict` result representing a `RoleList` object """ - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_roles') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_roles' + ) headers.update(sdk_headers) params = { 'account_id': account_id, 'service_name': service_name, 'source_service_name': source_service_name, - 'policy_type': policy_type + 'policy_type': policy_type, } if 'headers' in kwargs: @@ -626,16 +569,13 @@ def list_roles(self, headers['Accept'] = 'application/json' url = '/v2/roles' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_role(self, + def create_role( + self, display_name: str, actions: List[str], name: str, @@ -692,12 +632,10 @@ def create_role(self, raise ValueError('account_id must be provided') if service_name is None: raise ValueError('service_name must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='create_role') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='create_role' + ) headers.update(sdk_headers) data = { @@ -706,7 +644,7 @@ def create_role(self, 'name': name, 'account_id': account_id, 'service_name': service_name, - 'description': description + 'description': description, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -717,16 +655,13 @@ def create_role(self, headers['Accept'] = 'application/json' url = '/v2/roles' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def update_role(self, + def update_role( + self, role_id: str, if_match: str, *, @@ -761,19 +696,13 @@ def update_role(self, raise ValueError('role_id must be provided') if if_match is None: raise ValueError('if_match must be provided') - headers = { - 'If-Match': if_match - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_role') + headers = {'If-Match': if_match} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_role' + ) headers.update(sdk_headers) - data = { - 'display_name': display_name, - 'description': description, - 'actions': actions - } + data = {'display_name': display_name, 'description': description, 'actions': actions} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -786,19 +715,12 @@ def update_role(self, path_param_values = self.encode_path_vars(role_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/roles/{role_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_role(self, - role_id: str, - **kwargs - ) -> DetailedResponse: + def get_role(self, role_id: str, **kwargs) -> DetailedResponse: """ Retrieve a role by ID. @@ -813,9 +735,9 @@ def get_role(self, if role_id is None: raise ValueError('role_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_role') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_role' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -826,18 +748,12 @@ def get_role(self, path_param_values = self.encode_path_vars(role_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/roles/{role_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_role(self, - role_id: str, - **kwargs - ) -> DetailedResponse: + def delete_role(self, role_id: str, **kwargs) -> DetailedResponse: """ Delete a role by ID. @@ -852,9 +768,9 @@ def delete_role(self, if role_id is None: raise ValueError('role_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_role') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_role' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -864,9 +780,7 @@ def delete_role(self, path_param_values = self.encode_path_vars(role_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/roles/{role_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -881,19 +795,24 @@ class Type(str, Enum): """ Optional type of policy. """ + ACCESS = 'access' AUTHORIZATION = 'authorization' + class ServiceType(str, Enum): """ Optional type of service. """ + SERVICE = 'service' PLATFORM_SERVICE = 'platform_service' + class Sort(str, Enum): """ Optional top level policy field to sort results. Ascending sort is default. Descending sort available by prepending '-' to field. Example '-last_modified_at'. """ + ID = 'id' TYPE = 'type' HREF = 'href' @@ -902,6 +821,7 @@ class Sort(str, Enum): LAST_MODIFIED_AT = 'last_modified_at' LAST_MODIFIED_BY_ID = 'last_modified_by_id' STATE = 'state' + class Format(str, Enum): """ Include additional data per policy returned @@ -910,14 +830,17 @@ class Format(str, Enum): * `display` - returns the list of all actions included in each of the policy roles. """ + INCLUDE_LAST_PERMIT = 'include_last_permit' DISPLAY = 'display' + class State(str, Enum): """ The state of the policy. * `active` - returns active policies * `deleted` - returns non-active policies. """ + ACTIVE = 'active' DELETED = 'deleted' @@ -927,7 +850,7 @@ class State(str, Enum): ############################################################################## -class CustomRole(): +class CustomRole: """ An additional set of properties associated with a role. @@ -955,21 +878,23 @@ class CustomRole(): :attr str href: (optional) The href link back to the role. """ - def __init__(self, - *, - id: str = None, - display_name: str = None, - description: str = None, - actions: List[str] = None, - crn: str = None, - name: str = None, - account_id: str = None, - service_name: 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) -> None: + def __init__( + self, + *, + id: str = None, + display_name: str = None, + description: str = None, + actions: List[str] = None, + crn: str = None, + name: str = None, + account_id: str = None, + service_name: 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 + ) -> None: """ Initialize a CustomRole object. @@ -1084,7 +1009,8 @@ def __ne__(self, other: 'CustomRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Policy(): + +class Policy: """ The core set of properties associated with a policy. @@ -1109,20 +1035,22 @@ class Policy(): :attr str state: (optional) The policy state. """ - def __init__(self, - *, - id: str = None, - type: str = None, - description: str = None, - subjects: List['PolicySubject'] = None, - roles: List['PolicyRole'] = None, - resources: List['PolicyResource'] = None, - href: str = None, - created_at: datetime = None, - created_by_id: str = None, - last_modified_at: datetime = None, - last_modified_by_id: str = None, - state: str = None) -> None: + def __init__( + self, + *, + id: str = None, + type: str = None, + description: str = None, + subjects: List['PolicySubject'] = None, + roles: List['PolicyRole'] = None, + resources: List['PolicyResource'] = None, + href: str = None, + created_at: datetime = None, + created_by_id: str = None, + last_modified_at: datetime = None, + last_modified_by_id: str = None, + state: str = None + ) -> None: """ Initialize a Policy object. @@ -1236,20 +1164,19 @@ class StateEnum(str, Enum): """ The policy state. """ + ACTIVE = 'active' DELETED = 'deleted' -class PolicyList(): +class PolicyList: """ A collection of policies. :attr List[Policy] policies: (optional) List of policies. """ - def __init__(self, - *, - policies: List['Policy'] = None) -> None: + def __init__(self, *, policies: List['Policy'] = None) -> None: """ Initialize a PolicyList object. @@ -1295,7 +1222,8 @@ def __ne__(self, other: 'PolicyList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyResource(): + +class PolicyResource: """ The attributes of the resource. Note that only one resource is allowed in a policy. @@ -1304,10 +1232,7 @@ class PolicyResource(): :attr List[ResourceTag] tags: (optional) List of access management tags. """ - def __init__(self, - *, - attributes: List['ResourceAttribute'] = None, - tags: List['ResourceTag'] = None) -> None: + def __init__(self, *, attributes: List['ResourceAttribute'] = None, tags: List['ResourceTag'] = None) -> None: """ Initialize a PolicyResource object. @@ -1360,7 +1285,8 @@ def __ne__(self, other: 'PolicyResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicyRole(): + +class PolicyRole: """ A role associated with a policy. @@ -1370,11 +1296,7 @@ class PolicyRole(): :attr str description: (optional) The description of the role. """ - def __init__(self, - role_id: str, - *, - display_name: str = None, - description: str = None) -> None: + def __init__(self, role_id: str, *, display_name: str = None, description: str = None) -> None: """ Initialize a PolicyRole object. @@ -1433,7 +1355,8 @@ def __ne__(self, other: 'PolicyRole') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class PolicySubject(): + +class PolicySubject: """ The subject attribute values that must match in order for this policy to apply in a permission decision. @@ -1441,9 +1364,7 @@ class PolicySubject(): :attr List[SubjectAttribute] attributes: (optional) List of subject attributes. """ - def __init__(self, - *, - attributes: List['SubjectAttribute'] = None) -> None: + def __init__(self, *, attributes: List['SubjectAttribute'] = None) -> None: """ Initialize a PolicySubject object. @@ -1490,7 +1411,8 @@ def __ne__(self, other: 'PolicySubject') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAttribute(): + +class ResourceAttribute: """ An attribute associated with a resource. @@ -1499,11 +1421,7 @@ class ResourceAttribute(): :attr str operator: (optional) The operator of an attribute. """ - def __init__(self, - name: str, - value: str, - *, - operator: str = None) -> None: + def __init__(self, name: str, value: str, *, operator: str = None) -> None: """ Initialize a ResourceAttribute object. @@ -1565,7 +1483,8 @@ def __ne__(self, other: 'ResourceAttribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceTag(): + +class ResourceTag: """ A tag associated with a resource. @@ -1574,11 +1493,7 @@ class ResourceTag(): :attr str operator: (optional) The operator of an access management tag. """ - def __init__(self, - name: str, - value: str, - *, - operator: str = None) -> None: + def __init__(self, name: str, value: str, *, operator: str = None) -> None: """ Initialize a ResourceTag object. @@ -1640,7 +1555,8 @@ def __ne__(self, other: 'ResourceTag') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Role(): + +class Role: """ A role resource. @@ -1654,12 +1570,9 @@ class Role(): 'crn:v1:ibmcloud:public:iam-access-management::a/exampleAccountId::customRole:ExampleRoleName'. """ - def __init__(self, - *, - display_name: str = None, - description: str = None, - actions: List[str] = None, - crn: str = None) -> None: + def __init__( + self, *, display_name: str = None, description: str = None, actions: List[str] = None, crn: str = None + ) -> None: """ Initialize a Role object. @@ -1725,7 +1638,8 @@ def __ne__(self, other: 'Role') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RoleList(): + +class RoleList: """ A collection of roles returned by the 'list roles' operation. @@ -1734,11 +1648,13 @@ class RoleList(): :attr List[Role] system_roles: (optional) List of system roles. """ - def __init__(self, - *, - custom_roles: List['CustomRole'] = None, - service_roles: List['Role'] = None, - system_roles: List['Role'] = None) -> None: + def __init__( + self, + *, + custom_roles: List['CustomRole'] = None, + service_roles: List['Role'] = None, + system_roles: List['Role'] = None + ) -> None: """ Initialize a RoleList object. @@ -1796,7 +1712,8 @@ def __ne__(self, other: 'RoleList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SubjectAttribute(): + +class SubjectAttribute: """ An attribute associated with a subject. @@ -1804,9 +1721,7 @@ class SubjectAttribute(): :attr str value: The value of an attribute. """ - def __init__(self, - name: str, - value: str) -> None: + def __init__(self, name: str, value: str) -> None: """ Initialize a SubjectAttribute object. diff --git a/ibm_platform_services/ibm_cloud_shell_v1.py b/ibm_platform_services/ibm_cloud_shell_v1.py index f6db65a0..727c520d 100644 --- a/ibm_platform_services/ibm_cloud_shell_v1.py +++ b/ibm_platform_services/ibm_cloud_shell_v1.py @@ -34,6 +34,7 @@ # Service ############################################################################## + class IbmCloudShellV1(BaseService): """The IBM Cloud Shell V1 service.""" @@ -41,23 +42,23 @@ class IbmCloudShellV1(BaseService): DEFAULT_SERVICE_NAME = 'ibm_cloud_shell' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'IbmCloudShellV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'IbmCloudShellV1': """ Return a new client for the IBM Cloud Shell service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the IBM Cloud Shell service. @@ -65,20 +66,13 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # account_settings ######################### - - def get_account_settings(self, - account_id: str, - **kwargs - ) -> DetailedResponse: + def get_account_settings(self, account_id: str, **kwargs) -> DetailedResponse: """ Get account settings. @@ -98,9 +92,9 @@ def get_account_settings(self, if account_id is None: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_account_settings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_account_settings' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -111,15 +105,13 @@ def get_account_settings(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/api/v1/user/accounts/{account_id}/settings'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request) return response - - def update_account_settings(self, + def update_account_settings( + self, account_id: str, *, rev: str = None, @@ -167,9 +159,9 @@ def update_account_settings(self, if regions is not None: regions = [convert_model(x) for x in regions] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_account_settings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_account_settings' + ) headers.update(sdk_headers) data = { @@ -178,7 +170,7 @@ def update_account_settings(self, 'default_enable_new_regions': default_enable_new_regions, 'enabled': enabled, 'features': features, - 'regions': regions + 'regions': regions, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -192,10 +184,7 @@ def update_account_settings(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/api/v1/user/accounts/{account_id}/settings'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response @@ -206,7 +195,7 @@ def update_account_settings(self, ############################################################################## -class AccountSettings(): +class AccountSettings: """ Definition of Cloud Shell account settings. @@ -233,21 +222,23 @@ class AccountSettings(): :attr str updated_by: (optional) IAM ID of last updater. """ - def __init__(self, - *, - id: str = None, - rev: str = None, - account_id: str = None, - created_at: int = None, - created_by: str = None, - default_enable_new_features: bool = None, - default_enable_new_regions: bool = None, - enabled: bool = None, - features: List['Feature'] = None, - regions: List['RegionSetting'] = None, - type: str = None, - updated_at: int = None, - updated_by: str = None) -> None: + def __init__( + self, + *, + id: str = None, + rev: str = None, + account_id: str = None, + created_at: int = None, + created_by: str = None, + default_enable_new_features: bool = None, + default_enable_new_regions: bool = None, + enabled: bool = None, + features: List['Feature'] = None, + regions: List['RegionSetting'] = None, + type: str = None, + updated_at: int = None, + updated_by: str = None + ) -> None: """ Initialize a AccountSettings object. @@ -366,7 +357,8 @@ def __ne__(self, other: 'AccountSettings') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Feature(): + +class Feature: """ Describes a Cloud Shell feature. @@ -374,10 +366,7 @@ class Feature(): :attr str key: (optional) Name of the feature. """ - def __init__(self, - *, - enabled: bool = None, - key: str = None) -> None: + def __init__(self, *, enabled: bool = None, key: str = None) -> None: """ Initialize a Feature object. @@ -429,7 +418,8 @@ def __ne__(self, other: 'Feature') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class RegionSetting(): + +class RegionSetting: """ Describes a Cloud Shell region setting. @@ -437,10 +427,7 @@ class RegionSetting(): :attr str key: (optional) Name of the region. """ - def __init__(self, - *, - enabled: bool = None, - key: str = None) -> None: + def __init__(self, *, enabled: bool = None, key: str = None) -> None: """ Initialize a RegionSetting object. diff --git a/ibm_platform_services/open_service_broker_v1.py b/ibm_platform_services/open_service_broker_v1.py index 30395c3b..38ccbc95 100644 --- a/ibm_platform_services/open_service_broker_v1.py +++ b/ibm_platform_services/open_service_broker_v1.py @@ -38,6 +38,7 @@ # Service ############################################################################## + class OpenServiceBrokerV1(BaseService): """The Open Service Broker V1 service.""" @@ -45,23 +46,23 @@ class OpenServiceBrokerV1(BaseService): DEFAULT_SERVICE_NAME = 'open_service_broker' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'OpenServiceBrokerV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'OpenServiceBrokerV1': """ Return a new client for the Open Service Broker service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Open Service Broker service. @@ -69,20 +70,13 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Enable and Disable Instances ######################### - - def get_service_instance_state(self, - instance_id: str, - **kwargs - ) -> DetailedResponse: + def get_service_instance_state(self, instance_id: str, **kwargs) -> DetailedResponse: """ Get the current state of the service instance. @@ -107,9 +101,9 @@ def get_service_instance_state(self, if instance_id is None: raise ValueError('instance_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_service_instance_state') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_service_instance_state' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -120,21 +114,13 @@ def get_service_instance_state(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/bluemix_v1/service_instances/{instance_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request) return response - - def replace_service_instance_state(self, - instance_id: str, - *, - enabled: bool = None, - initiator_id: str = None, - reason_code: str = None, - **kwargs + def replace_service_instance_state( + self, instance_id: str, *, enabled: bool = None, initiator_id: str = None, reason_code: str = None, **kwargs ) -> DetailedResponse: """ Update the state of a provisioned service instance. @@ -177,16 +163,12 @@ def replace_service_instance_state(self, if instance_id is None: raise ValueError('instance_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_service_instance_state') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_service_instance_state' + ) headers.update(sdk_headers) - data = { - 'enabled': enabled, - 'initiator_id': initiator_id, - 'reason_code': reason_code - } + data = {'enabled': enabled, 'initiator_id': initiator_id, 'reason_code': reason_code} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -199,10 +181,7 @@ def replace_service_instance_state(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/bluemix_v1/service_instances/{instance_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response @@ -211,8 +190,8 @@ def replace_service_instance_state(self, # Resource Instances ######################### - - def replace_service_instance(self, + def replace_service_instance( + self, instance_id: str, *, organization_guid: str = None, @@ -286,14 +265,12 @@ def replace_service_instance(self, if context is not None: context = convert_model(context) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_service_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_service_instance' + ) headers.update(sdk_headers) - params = { - 'accepts_incomplete': accepts_incomplete - } + params = {'accepts_incomplete': accepts_incomplete} data = { 'organization_guid': organization_guid, @@ -301,7 +278,7 @@ def replace_service_instance(self, 'service_id': service_id, 'space_guid': space_guid, 'context': context, - 'parameters': parameters + 'parameters': parameters, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -315,17 +292,13 @@ def replace_service_instance(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def update_service_instance(self, + def update_service_instance( + self, instance_id: str, *, service_id: str = None, @@ -384,21 +357,19 @@ def update_service_instance(self, if context is not None: context = convert_model(context) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_service_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_service_instance' + ) headers.update(sdk_headers) - params = { - 'accepts_incomplete': accepts_incomplete - } + params = {'accepts_incomplete': accepts_incomplete} data = { 'service_id': service_id, 'context': context, 'parameters': parameters, 'plan_id': plan_id, - 'previous_values': previous_values + 'previous_values': previous_values, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -412,23 +383,13 @@ def update_service_instance(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, data=data) response = self.send(request) return response - - def delete_service_instance(self, - service_id: str, - plan_id: str, - instance_id: str, - *, - accepts_incomplete: bool = None, - **kwargs + def delete_service_instance( + self, service_id: str, plan_id: str, instance_id: str, *, accepts_incomplete: bool = None, **kwargs ) -> DetailedResponse: """ Delete (deprovision) a service instance. @@ -463,16 +424,12 @@ def delete_service_instance(self, if instance_id is None: raise ValueError('instance_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_service_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_service_instance' + ) headers.update(sdk_headers) - params = { - 'service_id': service_id, - 'plan_id': plan_id, - 'accepts_incomplete': accepts_incomplete - } + params = {'service_id': service_id, 'plan_id': plan_id, 'accepts_incomplete': accepts_incomplete} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -482,10 +439,7 @@ def delete_service_instance(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response @@ -494,10 +448,7 @@ def delete_service_instance(self, # Catalog ######################### - - def list_catalog(self, - **kwargs - ) -> DetailedResponse: + def list_catalog(self, **kwargs) -> DetailedResponse: """ Get the catalog metadata stored within the broker. @@ -519,9 +470,9 @@ def list_catalog(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_catalog') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_catalog' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -529,9 +480,7 @@ def list_catalog(self, headers['Accept'] = 'application/json' url = '/v2/catalog' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request) return response @@ -540,14 +489,8 @@ def list_catalog(self, # Last Operation (Async) ######################### - - def get_last_operation(self, - instance_id: str, - *, - operation: str = None, - plan_id: str = None, - service_id: str = None, - **kwargs + def get_last_operation( + self, instance_id: str, *, operation: str = None, plan_id: str = None, service_id: str = None, **kwargs ) -> DetailedResponse: """ Get the current status of a provision in-progress for a service instance. @@ -583,16 +526,12 @@ def get_last_operation(self, if instance_id is None: raise ValueError('instance_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_last_operation') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_last_operation' + ) headers.update(sdk_headers) - params = { - 'operation': operation, - 'plan_id': plan_id, - 'service_id': service_id - } + params = {'operation': operation, 'plan_id': plan_id, 'service_id': service_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -602,10 +541,7 @@ def get_last_operation(self, path_param_values = self.encode_path_vars(instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}/last_operation'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request) return response @@ -614,8 +550,8 @@ def get_last_operation(self, # Bindings and Credentials ######################### - - def replace_service_binding(self, + def replace_service_binding( + self, binding_id: str, instance_id: str, *, @@ -666,17 +602,12 @@ def replace_service_binding(self, if bind_resource is not None: bind_resource = convert_model(bind_resource) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='replace_service_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='replace_service_binding' + ) headers.update(sdk_headers) - data = { - 'plan_id': plan_id, - 'service_id': service_id, - 'bind_resource': bind_resource, - 'parameters': parameters - } + data = {'plan_id': plan_id, 'service_id': service_id, 'bind_resource': bind_resource, 'parameters': parameters} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -689,21 +620,13 @@ def replace_service_binding(self, path_param_values = self.encode_path_vars(binding_id, instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}/service_bindings/{binding_id}'.format(**path_param_dict) - request = self.prepare_request(method='PUT', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PUT', url=url, headers=headers, data=data) response = self.send(request) return response - - def delete_service_binding(self, - binding_id: str, - instance_id: str, - plan_id: str, - service_id: str, - **kwargs + def delete_service_binding( + self, binding_id: str, instance_id: str, plan_id: str, service_id: str, **kwargs ) -> DetailedResponse: """ Delete (unbind) the credentials bound to a resource. @@ -738,15 +661,12 @@ def delete_service_binding(self, if service_id is None: raise ValueError('service_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='delete_service_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='delete_service_binding' + ) headers.update(sdk_headers) - params = { - 'plan_id': plan_id, - 'service_id': service_id - } + params = {'plan_id': plan_id, 'service_id': service_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -756,10 +676,7 @@ def delete_service_binding(self, path_param_values = self.encode_path_vars(binding_id, instance_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/service_instances/{instance_id}/service_bindings/{binding_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request) return response @@ -770,7 +687,7 @@ def delete_service_binding(self, ############################################################################## -class Resp1874644Root(): +class Resp1874644Root: """ Check the active status of an enabled service. @@ -785,11 +702,7 @@ class Resp1874644Root(): accurate to the second/hour. """ - def __init__(self, - *, - active: bool = None, - enabled: bool = None, - last_active: float = None) -> None: + def __init__(self, *, active: bool = None, enabled: bool = None, last_active: float = None) -> None: """ Initialize a Resp1874644Root object. @@ -853,16 +766,15 @@ def __ne__(self, other: 'Resp1874644Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp1874650Root(): + +class Resp1874650Root: """ Resp1874650Root. :attr List[Services] services: (optional) List of services. """ - def __init__(self, - *, - services: List['Services'] = None) -> None: + def __init__(self, *, services: List['Services'] = None) -> None: """ Initialize a Resp1874650Root object. @@ -908,7 +820,8 @@ def __ne__(self, other: 'Resp1874650Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp2079872Root(): + +class Resp2079872Root: """ OK - MUST be returned if the service instance already exists, is fully provisioned, and the requested parameters are identical to the existing service instance. @@ -926,10 +839,7 @@ class Resp2079872Root(): encoded query parameter. If present, MUST be a non-empty string. """ - def __init__(self, - *, - dashboard_url: str = None, - operation: str = None) -> None: + def __init__(self, *, dashboard_url: str = None, operation: str = None) -> None: """ Initialize a Resp2079872Root object. @@ -991,7 +901,8 @@ def __ne__(self, other: 'Resp2079872Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp2079874Root(): + +class Resp2079874Root: """ Accepted - MUST be returned if the service instance provisioning is in progress. This triggers the IBM Cloud platform to poll the Service Instance `last_operation` Endpoint @@ -1004,9 +915,7 @@ class Resp2079874Root(): encoded query parameter. If present, MUST be a non-empty string. """ - def __init__(self, - *, - operation: str = None) -> None: + def __init__(self, *, operation: str = None) -> None: """ Initialize a Resp2079874Root object. @@ -1056,7 +965,8 @@ def __ne__(self, other: 'Resp2079874Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp2079876Root(): + +class Resp2079876Root: """ Resp2079876Root. @@ -1075,12 +985,14 @@ class Resp2079876Root(): platform can consider the response invalid. """ - def __init__(self, - *, - credentials: object = None, - syslog_drain_url: str = None, - route_service_url: str = None, - volume_mounts: List['VolumeMount'] = None) -> None: + def __init__( + self, + *, + credentials: object = None, + syslog_drain_url: str = None, + route_service_url: str = None, + volume_mounts: List['VolumeMount'] = None + ) -> None: """ Initialize a Resp2079876Root object. @@ -1153,7 +1065,8 @@ def __ne__(self, other: 'Resp2079876Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp2079894Root(): + +class Resp2079894Root: """ OK - MUST be returned upon successful processing of this request. @@ -1166,10 +1079,7 @@ class Resp2079894Root(): the platform to cease polling. """ - def __init__(self, - state: str, - *, - description: str = None) -> None: + def __init__(self, state: str, *, description: str = None) -> None: """ Initialize a Resp2079894Root object. @@ -1228,7 +1138,8 @@ def __ne__(self, other: 'Resp2079894Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resp2448145Root(): + +class Resp2448145Root: """ Check the enabled status of active service. @@ -1242,11 +1153,7 @@ class Resp2448145Root(): accurate to the second/hour. """ - def __init__(self, - enabled: bool, - *, - active: bool = None, - last_active: int = None) -> None: + def __init__(self, enabled: bool, *, active: bool = None, last_active: int = None) -> None: """ Initialize a Resp2448145Root object. @@ -1311,7 +1218,8 @@ def __ne__(self, other: 'Resp2448145Root') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class BindResource(): + +class BindResource: """ A JSON object that contains data for platform resources associated with the binding to be created. @@ -1325,13 +1233,15 @@ class BindResource(): route services bindings. """ - def __init__(self, - *, - account_id: str = None, - serviceid_crn: str = None, - target_crn: str = None, - app_guid: str = None, - route: str = None) -> None: + def __init__( + self, + *, + account_id: str = None, + serviceid_crn: str = None, + target_crn: str = None, + app_guid: str = None, + route: str = None + ) -> None: """ Initialize a BindResource object. @@ -1403,7 +1313,8 @@ def __ne__(self, other: 'BindResource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Context(): + +class Context: """ Platform specific contextual information under which the service instance is to be provisioned. @@ -1422,11 +1333,7 @@ class Context(): :attr str platform: (optional) Identifies the platform as "ibmcloud". """ - def __init__(self, - *, - account_id: str = None, - crn: str = None, - platform: str = None) -> None: + def __init__(self, *, account_id: str = None, crn: str = None, platform: str = None) -> None: """ Initialize a Context object. @@ -1493,7 +1400,8 @@ def __ne__(self, other: 'Context') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Plans(): + +class Plans: """ Where is this in the source?. @@ -1514,12 +1422,7 @@ class Plans(): displayed in the IBM Cloud catalog or IBM Cloud CLI. """ - def __init__(self, - description: str, - id: str, - name: str, - *, - free: bool = None) -> None: + def __init__(self, description: str, id: str, name: str, *, free: bool = None) -> None: """ Initialize a Plans object. @@ -1600,7 +1503,8 @@ def __ne__(self, other: 'Plans') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Services(): + +class Services: """ The service object that describes the properties of your service. @@ -1640,14 +1544,16 @@ class Services(): least one plan. """ - def __init__(self, - bindable: bool, - description: str, - id: str, - name: str, - plans: List['Plans'], - *, - plan_updateable: bool = None) -> None: + def __init__( + self, + bindable: bool, + description: str, + id: str, + name: str, + plans: List['Plans'], + *, + plan_updateable: bool = None + ) -> None: """ Initialize a Services object. @@ -1762,7 +1668,8 @@ def __ne__(self, other: 'Services') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class VolumeMount(): + +class VolumeMount: """ VolumeMount. @@ -1779,12 +1686,7 @@ class VolumeMount(): Currently only shared devices are supported. """ - def __init__(self, - driver: str, - container_dir: str, - mode: str, - device_type: str, - device: str) -> None: + def __init__(self, driver: str, container_dir: str, mode: str, device_type: str, device: str) -> None: """ Initialize a VolumeMount object. diff --git a/ibm_platform_services/resource_controller_v2.py b/ibm_platform_services/resource_controller_v2.py index be9271df..3bec4f4b 100644 --- a/ibm_platform_services/resource_controller_v2.py +++ b/ibm_platform_services/resource_controller_v2.py @@ -40,6 +40,7 @@ # Service ############################################################################## + class ResourceControllerV2(BaseService): """The resource_controller V2 service.""" @@ -47,23 +48,23 @@ class ResourceControllerV2(BaseService): DEFAULT_SERVICE_NAME = 'resource_controller' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'ResourceControllerV2': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'ResourceControllerV2': """ Return a new client for the resource_controller service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the resource_controller service. @@ -71,17 +72,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Resource Instances ######################### - - def list_resource_instances(self, + def list_resource_instances( + self, *, guid: str = None, name: str = None, @@ -95,7 +93,7 @@ def list_resource_instances(self, state: str = None, updated_from: str = None, updated_to: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get a list of all resource instances. @@ -132,9 +130,9 @@ def list_resource_instances(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_instances') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_instances' + ) headers.update(sdk_headers) params = { @@ -149,7 +147,7 @@ def list_resource_instances(self, 'start': start, 'state': state, 'updated_from': updated_from, - 'updated_to': updated_to + 'updated_to': updated_to, } if 'headers' in kwargs: @@ -158,16 +156,13 @@ def list_resource_instances(self, headers['Accept'] = 'application/json' url = '/v2/resource_instances' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_resource_instance(self, + def create_resource_instance( + self, name: str, target: str, resource_group: str, @@ -177,7 +172,7 @@ def create_resource_instance(self, allow_cleanup: bool = None, parameters: dict = None, entity_lock: bool = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Create (provision) a new resource instance. @@ -218,12 +213,10 @@ def create_resource_instance(self, raise ValueError('resource_group must be provided') if resource_plan_id is None: raise ValueError('resource_plan_id must be provided') - headers = { - 'Entity-Lock': entity_lock - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='create_resource_instance') + headers = {'Entity-Lock': entity_lock} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_resource_instance' + ) headers.update(sdk_headers) data = { @@ -233,7 +226,7 @@ def create_resource_instance(self, 'resource_plan_id': resource_plan_id, 'tags': tags, 'allow_cleanup': allow_cleanup, - 'parameters': parameters + 'parameters': parameters, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -245,19 +238,12 @@ def create_resource_instance(self, headers['Accept'] = 'application/json' url = '/v2/resource_instances' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_resource_instance(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_resource_instance(self, id: str, **kwargs) -> DetailedResponse: """ Get a resource instance. @@ -273,9 +259,9 @@ def get_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_resource_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -287,20 +273,12 @@ def get_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_resource_instance(self, - id: str, - *, - recursive: bool = None, - **kwargs - ) -> DetailedResponse: + def delete_resource_instance(self, id: str, *, recursive: bool = None, **kwargs) -> DetailedResponse: """ Delete a resource instance. @@ -319,14 +297,12 @@ def delete_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='delete_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_resource_instance' + ) headers.update(sdk_headers) - params = { - 'recursive': recursive - } + params = {'recursive': recursive} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -336,23 +312,20 @@ def delete_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_resource_instance(self, + def update_resource_instance( + self, id: str, *, name: str = None, parameters: dict = None, resource_plan_id: str = None, allow_cleanup: bool = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Update a resource instance. @@ -380,16 +353,16 @@ def update_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='update_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_resource_instance' + ) headers.update(sdk_headers) data = { 'name': name, 'parameters': parameters, 'resource_plan_id': resource_plan_id, - 'allow_cleanup': allow_cleanup + 'allow_cleanup': allow_cleanup, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -404,21 +377,13 @@ def update_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_resource_aliases_for_instance(self, - id: str, - *, - limit: int = None, - start: str = None, - **kwargs + def list_resource_aliases_for_instance( + self, id: str, *, limit: int = None, start: str = None, **kwargs ) -> DetailedResponse: """ Get a list of all resource aliases for the instance. @@ -441,15 +406,14 @@ def list_resource_aliases_for_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_aliases_for_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_resource_aliases_for_instance', + ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'start': start - } + params = {'limit': limit, 'start': start} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -460,21 +424,13 @@ def list_resource_aliases_for_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}/resource_aliases'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def list_resource_keys_for_instance(self, - id: str, - *, - limit: int = None, - start: str = None, - **kwargs + def list_resource_keys_for_instance( + self, id: str, *, limit: int = None, start: str = None, **kwargs ) -> DetailedResponse: """ Get a list of all the resource keys for the instance. @@ -497,15 +453,12 @@ def list_resource_keys_for_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_keys_for_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_keys_for_instance' + ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'start': start - } + params = {'limit': limit, 'start': start} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -516,19 +469,12 @@ def list_resource_keys_for_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}/resource_keys'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def lock_resource_instance(self, - id: str, - **kwargs - ) -> DetailedResponse: + def lock_resource_instance(self, id: str, **kwargs) -> DetailedResponse: """ Lock a resource instance. @@ -545,9 +491,9 @@ def lock_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='lock_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='lock_resource_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -559,18 +505,12 @@ def lock_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers) + request = self.prepare_request(method='POST', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def unlock_resource_instance(self, - id: str, - **kwargs - ) -> DetailedResponse: + def unlock_resource_instance(self, id: str, **kwargs) -> DetailedResponse: """ Unlock a resource instance. @@ -586,9 +526,9 @@ def unlock_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='unlock_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='unlock_resource_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -600,18 +540,12 @@ def unlock_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}/lock'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def cancel_lastop_resource_instance(self, - id: str, - **kwargs - ) -> DetailedResponse: + def cancel_lastop_resource_instance(self, id: str, **kwargs) -> DetailedResponse: """ Cancel the in progress last operation of the resource instance. @@ -627,9 +561,9 @@ def cancel_lastop_resource_instance(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='cancel_lastop_resource_instance') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='cancel_lastop_resource_instance' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -641,9 +575,7 @@ def cancel_lastop_resource_instance(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_instances/{id}/last_operation'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -652,8 +584,8 @@ def cancel_lastop_resource_instance(self, # Resource Keys ######################### - - def list_resource_keys(self, + def list_resource_keys( + self, *, guid: str = None, name: str = None, @@ -663,7 +595,7 @@ def list_resource_keys(self, start: str = None, updated_from: str = None, updated_to: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get a list of all of the resource keys. @@ -689,9 +621,9 @@ def list_resource_keys(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_keys') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_keys' + ) headers.update(sdk_headers) params = { @@ -702,7 +634,7 @@ def list_resource_keys(self, 'limit': limit, 'start': start, 'updated_from': updated_from, - 'updated_to': updated_to + 'updated_to': updated_to, } if 'headers' in kwargs: @@ -711,22 +643,13 @@ def list_resource_keys(self, headers['Accept'] = 'application/json' url = '/v2/resource_keys' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_resource_key(self, - name: str, - source: str, - *, - parameters: 'ResourceKeyPostParameters' = None, - role: str = None, - **kwargs + def create_resource_key( + self, name: str, source: str, *, parameters: 'ResourceKeyPostParameters' = None, role: str = None, **kwargs ) -> DetailedResponse: """ Create a new resource key. @@ -755,17 +678,12 @@ def create_resource_key(self, if parameters is not None: parameters = convert_model(parameters) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='create_resource_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_resource_key' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'source': source, - 'parameters': parameters, - 'role': role - } + data = {'name': name, 'source': source, 'parameters': parameters, 'role': role} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -776,19 +694,12 @@ def create_resource_key(self, headers['Accept'] = 'application/json' url = '/v2/resource_keys' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_resource_key(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_resource_key(self, id: str, **kwargs) -> DetailedResponse: """ Get resource key. @@ -804,9 +715,9 @@ def get_resource_key(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_resource_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_resource_key' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -818,18 +729,12 @@ def get_resource_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_keys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_resource_key(self, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_resource_key(self, id: str, **kwargs) -> DetailedResponse: """ Delete a resource key. @@ -845,9 +750,9 @@ def delete_resource_key(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='delete_resource_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_resource_key' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -858,19 +763,12 @@ def delete_resource_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_keys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_resource_key(self, - id: str, - name: str, - **kwargs - ) -> DetailedResponse: + def update_resource_key(self, id: str, name: str, **kwargs) -> DetailedResponse: """ Update a resource key. @@ -889,14 +787,12 @@ def update_resource_key(self, if name is None: raise ValueError('name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='update_resource_key') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_resource_key' + ) headers.update(sdk_headers) - data = { - 'name': name - } + data = {'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -910,10 +806,7 @@ def update_resource_key(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_keys/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -922,8 +815,8 @@ def update_resource_key(self, # Resource Bindings ######################### - - def list_resource_bindings(self, + def list_resource_bindings( + self, *, guid: str = None, name: str = None, @@ -934,7 +827,7 @@ def list_resource_bindings(self, start: str = None, updated_from: str = None, updated_to: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get a list of all resource bindings. @@ -963,9 +856,9 @@ def list_resource_bindings(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_bindings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_bindings' + ) headers.update(sdk_headers) params = { @@ -977,7 +870,7 @@ def list_resource_bindings(self, 'limit': limit, 'start': start, 'updated_from': updated_from, - 'updated_to': updated_to + 'updated_to': updated_to, } if 'headers' in kwargs: @@ -986,23 +879,20 @@ def list_resource_bindings(self, headers['Accept'] = 'application/json' url = '/v2/resource_bindings' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_resource_binding(self, + def create_resource_binding( + self, source: str, target: str, *, name: str = None, parameters: 'ResourceBindingPostParameters' = None, role: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Create a new resource binding. @@ -1035,18 +925,12 @@ def create_resource_binding(self, if parameters is not None: parameters = convert_model(parameters) headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='create_resource_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_resource_binding' + ) headers.update(sdk_headers) - data = { - 'source': source, - 'target': target, - 'name': name, - 'parameters': parameters, - 'role': role - } + data = {'source': source, 'target': target, 'name': name, 'parameters': parameters, 'role': role} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1057,19 +941,12 @@ def create_resource_binding(self, headers['Accept'] = 'application/json' url = '/v2/resource_bindings' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_resource_binding(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_resource_binding(self, id: str, **kwargs) -> DetailedResponse: """ Get a resource binding. @@ -1085,9 +962,9 @@ def get_resource_binding(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_resource_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_resource_binding' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1099,18 +976,12 @@ def get_resource_binding(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_bindings/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_resource_binding(self, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_resource_binding(self, id: str, **kwargs) -> DetailedResponse: """ Delete a resource binding. @@ -1126,9 +997,9 @@ def delete_resource_binding(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='delete_resource_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_resource_binding' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1139,19 +1010,12 @@ def delete_resource_binding(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_bindings/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_resource_binding(self, - id: str, - name: str, - **kwargs - ) -> DetailedResponse: + def update_resource_binding(self, id: str, name: str, **kwargs) -> DetailedResponse: """ Update a resource binding. @@ -1171,14 +1035,12 @@ def update_resource_binding(self, if name is None: raise ValueError('name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='update_resource_binding') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_resource_binding' + ) headers.update(sdk_headers) - data = { - 'name': name - } + data = {'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1192,10 +1054,7 @@ def update_resource_binding(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_bindings/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -1204,8 +1063,8 @@ def update_resource_binding(self, # Resource Aliases ######################### - - def list_resource_aliases(self, + def list_resource_aliases( + self, *, guid: str = None, name: str = None, @@ -1217,7 +1076,7 @@ def list_resource_aliases(self, start: str = None, updated_from: str = None, updated_to: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Get a list of all resource aliases. @@ -1248,9 +1107,9 @@ def list_resource_aliases(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_aliases') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_aliases' + ) headers.update(sdk_headers) params = { @@ -1263,7 +1122,7 @@ def list_resource_aliases(self, 'limit': limit, 'start': start, 'updated_from': updated_from, - 'updated_to': updated_to + 'updated_to': updated_to, } if 'headers' in kwargs: @@ -1272,21 +1131,12 @@ def list_resource_aliases(self, headers['Accept'] = 'application/json' url = '/v2/resource_aliases' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_resource_alias(self, - name: str, - source: str, - target: str, - **kwargs - ) -> DetailedResponse: + def create_resource_alias(self, name: str, source: str, target: str, **kwargs) -> DetailedResponse: """ Create a new resource alias. @@ -1309,16 +1159,12 @@ def create_resource_alias(self, if target is None: raise ValueError('target must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='create_resource_alias') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_resource_alias' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'source': source, - 'target': target - } + data = {'name': name, 'source': source, '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' @@ -1329,19 +1175,12 @@ def create_resource_alias(self, headers['Accept'] = 'application/json' url = '/v2/resource_aliases' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_resource_alias(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_resource_alias(self, id: str, **kwargs) -> DetailedResponse: """ Get a resource alias. @@ -1357,9 +1196,9 @@ def get_resource_alias(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_resource_alias') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_resource_alias' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -1371,20 +1210,12 @@ def get_resource_alias(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_aliases/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def delete_resource_alias(self, - id: str, - *, - recursive: bool = None, - **kwargs - ) -> DetailedResponse: + def delete_resource_alias(self, id: str, *, recursive: bool = None, **kwargs) -> DetailedResponse: """ Delete a resource alias. @@ -1403,14 +1234,12 @@ def delete_resource_alias(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='delete_resource_alias') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_resource_alias' + ) headers.update(sdk_headers) - params = { - 'recursive': recursive - } + params = {'recursive': recursive} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1420,20 +1249,12 @@ def delete_resource_alias(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_aliases/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_resource_alias(self, - id: str, - name: str, - **kwargs - ) -> DetailedResponse: + def update_resource_alias(self, id: str, name: str, **kwargs) -> DetailedResponse: """ Update a resource alias. @@ -1452,14 +1273,12 @@ def update_resource_alias(self, if name is None: raise ValueError('name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='update_resource_alias') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_resource_alias' + ) headers.update(sdk_headers) - data = { - 'name': name - } + data = {'name': name} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1473,21 +1292,13 @@ def update_resource_alias(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_aliases/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def list_resource_bindings_for_alias(self, - id: str, - *, - limit: int = None, - start: str = None, - **kwargs + def list_resource_bindings_for_alias( + self, id: str, *, limit: int = None, start: str = None, **kwargs ) -> DetailedResponse: """ Get a list of all resource bindings for the alias. @@ -1509,15 +1320,14 @@ def list_resource_bindings_for_alias(self, if not id: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_bindings_for_alias') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V2', + operation_id='list_resource_bindings_for_alias', + ) headers.update(sdk_headers) - params = { - 'limit': limit, - 'start': start - } + params = {'limit': limit, 'start': start} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1528,10 +1338,7 @@ def list_resource_bindings_for_alias(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_aliases/{id}/resource_bindings'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -1540,12 +1347,8 @@ def list_resource_bindings_for_alias(self, # Resource Reclamations ######################### - - def list_reclamations(self, - *, - account_id: str = None, - resource_instance_id: str = None, - **kwargs + def list_reclamations( + self, *, account_id: str = None, resource_instance_id: str = None, **kwargs ) -> DetailedResponse: """ Get a list of all reclamations. @@ -1562,15 +1365,12 @@ def list_reclamations(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_reclamations') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_reclamations' + ) headers.update(sdk_headers) - params = { - 'account_id': account_id, - 'resource_instance_id': resource_instance_id - } + params = {'account_id': account_id, 'resource_instance_id': resource_instance_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -1578,22 +1378,13 @@ def list_reclamations(self, headers['Accept'] = 'application/json' url = '/v1/reclamations' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def run_reclamation_action(self, - id: str, - action_name: str, - *, - request_by: str = None, - comment: str = None, - **kwargs + def run_reclamation_action( + self, id: str, action_name: str, *, request_by: str = None, comment: str = None, **kwargs ) -> DetailedResponse: """ Perform a reclamation action. @@ -1617,15 +1408,12 @@ def run_reclamation_action(self, if not action_name: raise ValueError('action_name must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='run_reclamation_action') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='run_reclamation_action' + ) headers.update(sdk_headers) - data = { - 'request_by': request_by, - 'comment': comment - } + data = {'request_by': request_by, 'comment': comment} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -1639,10 +1427,7 @@ def run_reclamation_action(self, path_param_values = self.encode_path_vars(id, action_name) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v1/reclamations/{id}/actions/{action_name}'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -1658,6 +1443,7 @@ class State(str, Enum): The state of the instance. If not specified, instances in state `active` and `provisioning` are returned. """ + ACTIVE = 'active' INACTIVE = 'inactive' FAILED = 'failed' @@ -1672,7 +1458,7 @@ class State(str, Enum): ############################################################################## -class Credentials(): +class Credentials: """ The credentials for a resource. @@ -1692,17 +1478,29 @@ class Credentials(): """ # The set of defined properties for the class - _properties = frozenset(['redacted', 'REDACTED', 'apikey', 'iam_apikey_description', 'iam_apikey_name', 'iam_role_crn', 'iam_serviceid_crn']) - - def __init__(self, - *, - redacted: str = None, - apikey: str = None, - iam_apikey_description: str = None, - iam_apikey_name: str = None, - iam_role_crn: str = None, - iam_serviceid_crn: str = None, - **kwargs) -> None: + _properties = frozenset( + [ + 'redacted', + 'REDACTED', + 'apikey', + 'iam_apikey_description', + 'iam_apikey_name', + 'iam_role_crn', + 'iam_serviceid_crn', + ] + ) + + def __init__( + self, + *, + redacted: str = None, + apikey: str = None, + iam_apikey_description: str = None, + iam_apikey_name: str = None, + iam_role_crn: str = None, + iam_serviceid_crn: str = None, + **kwargs, + ) -> None: """ Initialize a Credentials object. @@ -1746,7 +1544,7 @@ def from_dict(cls, _dict: Dict) -> 'Credentials': args['iam_role_crn'] = _dict.get('iam_role_crn') if 'iam_serviceid_crn' in _dict: args['iam_serviceid_crn'] = _dict.get('iam_serviceid_crn') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -1815,11 +1613,12 @@ class RedactedEnum(str, Enum): required to view the credential. For additional information, see [viewing a credential](https://cloud.ibm.com/docs/account?topic=account-service_credentials&interface=ui#viewing-credentials-ui). """ + REDACTED = 'REDACTED' REDACTED_EXPLICIT = 'REDACTED_EXPLICIT' -class PlanHistoryItem(): +class PlanHistoryItem: """ An element of the plan history of the instance. @@ -1829,11 +1628,7 @@ class PlanHistoryItem(): :attr str requestor_id: (optional) The subject who made the plan change. """ - def __init__(self, - resource_plan_id: str, - start_date: datetime, - *, - requestor_id: str = None) -> None: + def __init__(self, resource_plan_id: str, start_date: datetime, *, requestor_id: str = None) -> None: """ Initialize a PlanHistoryItem object. @@ -1896,7 +1691,8 @@ def __ne__(self, other: 'PlanHistoryItem') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Reclamation(): + +class Reclamation: """ A reclamation. @@ -1924,23 +1720,25 @@ class Reclamation(): :attr str updated_by: (optional) The subject who updated the reclamation. """ - def __init__(self, - *, - id: str = None, - entity_id: str = None, - entity_type_id: str = None, - entity_crn: str = None, - resource_instance_id: str = None, - resource_group_id: str = None, - account_id: str = None, - policy_id: str = None, - state: str = None, - target_time: str = None, - custom_properties: dict = None, - created_at: datetime = None, - created_by: str = None, - updated_at: datetime = None, - updated_by: str = None) -> None: + def __init__( + self, + *, + id: str = None, + entity_id: str = None, + entity_type_id: str = None, + entity_crn: str = None, + resource_instance_id: str = None, + resource_group_id: str = None, + account_id: str = None, + policy_id: str = None, + state: str = None, + target_time: str = None, + custom_properties: dict = None, + created_at: datetime = None, + created_by: str = None, + updated_at: datetime = None, + updated_by: str = None, + ) -> None: """ Initialize a Reclamation object. @@ -2080,16 +1878,15 @@ def __ne__(self, other: 'Reclamation') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ReclamationsList(): + +class ReclamationsList: """ A list of reclamations. :attr List[Reclamation] resources: (optional) A list of reclamations. """ - def __init__(self, - *, - resources: List['Reclamation'] = None) -> None: + def __init__(self, *, resources: List['Reclamation'] = None) -> None: """ Initialize a ReclamationsList object. @@ -2141,7 +1938,8 @@ def __ne__(self, other: 'ReclamationsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAlias(): + +class ResourceAlias: """ A resource alias. @@ -2184,31 +1982,33 @@ class ResourceAlias(): for the alias. """ - def __init__(self, - *, - id: str = None, - guid: str = None, - url: str = None, - created_at: datetime = None, - updated_at: datetime = None, - deleted_at: datetime = None, - created_by: str = None, - updated_by: str = None, - deleted_by: str = None, - name: str = None, - resource_instance_id: str = None, - target_crn: str = None, - account_id: str = None, - resource_id: str = None, - resource_group_id: str = None, - crn: str = None, - region_instance_id: str = None, - region_instance_crn: str = None, - state: str = None, - migrated: bool = None, - resource_instance_url: str = None, - resource_bindings_url: str = None, - resource_keys_url: str = None) -> None: + def __init__( + self, + *, + id: str = None, + guid: str = None, + url: str = None, + created_at: datetime = None, + updated_at: datetime = None, + deleted_at: datetime = None, + created_by: str = None, + updated_by: str = None, + deleted_by: str = None, + name: str = None, + resource_instance_id: str = None, + target_crn: str = None, + account_id: str = None, + resource_id: str = None, + resource_group_id: str = None, + crn: str = None, + region_instance_id: str = None, + region_instance_crn: str = None, + state: str = None, + migrated: bool = None, + resource_instance_url: str = None, + resource_bindings_url: str = None, + resource_keys_url: str = None, + ) -> None: """ Initialize a ResourceAlias object. @@ -2401,7 +2201,8 @@ def __ne__(self, other: 'ResourceAlias') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceAliasesList(): + +class ResourceAliasesList: """ A list of resource aliases. @@ -2410,10 +2211,7 @@ class ResourceAliasesList(): :attr List[ResourceAlias] resources: A list of resource aliases. """ - def __init__(self, - rows_count: int, - next_url: str, - resources: List['ResourceAlias']) -> None: + def __init__(self, rows_count: int, next_url: str, resources: List['ResourceAlias']) -> None: """ Initialize a ResourceAliasesList object. @@ -2483,7 +2281,8 @@ def __ne__(self, other: 'ResourceAliasesList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceBinding(): + +class ResourceBinding: """ A resource binding. @@ -2532,31 +2331,33 @@ class ResourceBinding(): that this binding is associated with. """ - def __init__(self, - *, - id: str = None, - guid: str = None, - url: str = None, - created_at: datetime = None, - updated_at: datetime = None, - deleted_at: datetime = None, - created_by: str = None, - updated_by: str = None, - deleted_by: str = None, - source_crn: str = None, - target_crn: str = None, - crn: str = None, - region_binding_id: str = None, - region_binding_crn: str = None, - name: str = None, - account_id: str = None, - resource_group_id: str = None, - state: str = None, - credentials: 'Credentials' = None, - iam_compatible: bool = None, - resource_id: str = None, - migrated: bool = None, - resource_alias_url: str = None) -> None: + def __init__( + self, + *, + id: str = None, + guid: str = None, + url: str = None, + created_at: datetime = None, + updated_at: datetime = None, + deleted_at: datetime = None, + created_by: str = None, + updated_by: str = None, + deleted_by: str = None, + source_crn: str = None, + target_crn: str = None, + crn: str = None, + region_binding_id: str = None, + region_binding_crn: str = None, + name: str = None, + account_id: str = None, + resource_group_id: str = None, + state: str = None, + credentials: 'Credentials' = None, + iam_compatible: bool = None, + resource_id: str = None, + migrated: bool = None, + resource_alias_url: str = None, + ) -> None: """ Initialize a ResourceBinding object. @@ -2760,7 +2561,8 @@ def __ne__(self, other: 'ResourceBinding') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceBindingPostParameters(): + +class ResourceBindingPostParameters: """ Configuration options represented as key-value pairs. Service defined options are passed through to the target resource brokers, whereas platform defined options are @@ -2773,10 +2575,7 @@ class ResourceBindingPostParameters(): # The set of defined properties for the class _properties = frozenset(['serviceid_crn']) - def __init__(self, - *, - serviceid_crn: str = None, - **kwargs) -> None: + def __init__(self, *, serviceid_crn: str = None, **kwargs) -> None: """ Initialize a ResourceBindingPostParameters object. @@ -2794,7 +2593,7 @@ def from_dict(cls, _dict: Dict) -> 'ResourceBindingPostParameters': args = {} if 'serviceid_crn' in _dict: args['serviceid_crn'] = _dict.get('serviceid_crn') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -2846,7 +2645,8 @@ def __ne__(self, other: 'ResourceBindingPostParameters') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceBindingsList(): + +class ResourceBindingsList: """ A list of resource bindings. @@ -2855,10 +2655,7 @@ class ResourceBindingsList(): :attr List[ResourceBinding] resources: A list of resource bindings. """ - def __init__(self, - rows_count: int, - next_url: str, - resources: List['ResourceBinding']) -> None: + def __init__(self, rows_count: int, next_url: str, resources: List['ResourceBinding']) -> None: """ Initialize a ResourceBindingsList object. @@ -2928,7 +2725,8 @@ def __ne__(self, other: 'ResourceBindingsList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceInstance(): + +class ResourceInstance: """ A resource instance. @@ -3002,46 +2800,48 @@ class ResourceInstance(): is locked or not. """ - def __init__(self, - *, - id: str = None, - guid: str = None, - url: str = None, - created_at: datetime = None, - updated_at: datetime = None, - deleted_at: datetime = None, - created_by: str = None, - updated_by: str = None, - deleted_by: str = None, - scheduled_reclaim_at: datetime = None, - restored_at: datetime = None, - restored_by: str = None, - scheduled_reclaim_by: str = None, - name: str = None, - region_id: str = None, - account_id: str = None, - reseller_channel_id: str = None, - resource_plan_id: str = None, - resource_group_id: str = None, - resource_group_crn: str = None, - target_crn: str = None, - parameters: dict = None, - allow_cleanup: bool = None, - crn: str = None, - state: str = None, - type: str = None, - sub_type: str = None, - resource_id: str = None, - dashboard_url: str = None, - last_operation: 'ResourceInstanceLastOperation' = None, - resource_aliases_url: str = None, - resource_bindings_url: str = None, - resource_keys_url: str = None, - plan_history: List['PlanHistoryItem'] = None, - migrated: bool = None, - extensions: dict = None, - controlled_by: str = None, - locked: bool = None) -> None: + def __init__( + self, + *, + id: str = None, + guid: str = None, + url: str = None, + created_at: datetime = None, + updated_at: datetime = None, + deleted_at: datetime = None, + created_by: str = None, + updated_by: str = None, + deleted_by: str = None, + scheduled_reclaim_at: datetime = None, + restored_at: datetime = None, + restored_by: str = None, + scheduled_reclaim_by: str = None, + name: str = None, + region_id: str = None, + account_id: str = None, + reseller_channel_id: str = None, + resource_plan_id: str = None, + resource_group_id: str = None, + resource_group_crn: str = None, + target_crn: str = None, + parameters: dict = None, + allow_cleanup: bool = None, + crn: str = None, + state: str = None, + type: str = None, + sub_type: str = None, + resource_id: str = None, + dashboard_url: str = None, + last_operation: 'ResourceInstanceLastOperation' = None, + resource_aliases_url: str = None, + resource_bindings_url: str = None, + resource_keys_url: str = None, + plan_history: List['PlanHistoryItem'] = None, + migrated: bool = None, + extensions: dict = None, + controlled_by: str = None, + locked: bool = None, + ) -> None: """ Initialize a ResourceInstance object. @@ -3358,6 +3158,7 @@ class StateEnum(str, Enum): The current state of the instance. For example, if the instance is deleted, it will return removed. """ + ACTIVE = 'active' INACTIVE = 'inactive' REMOVED = 'removed' @@ -3368,7 +3169,7 @@ class StateEnum(str, Enum): PRE_PROVISIONING = 'pre_provisioning' -class ResourceInstanceLastOperation(): +class ResourceInstanceLastOperation: """ The status of the last operation requested on the instance. @@ -3391,20 +3192,35 @@ class ResourceInstanceLastOperation(): """ # The set of defined properties for the class - _properties = frozenset(['type', 'state', 'sub_type', 'async_', 'async', 'description', 'reason_code', 'poll_after', 'cancelable', 'poll']) - - def __init__(self, - type: str, - state: str, - async_: bool, - description: str, - cancelable: bool, - poll: bool, - *, - sub_type: str = None, - reason_code: str = None, - poll_after: float = None, - **kwargs) -> None: + _properties = frozenset( + [ + 'type', + 'state', + 'sub_type', + 'async_', + 'async', + 'description', + 'reason_code', + 'poll_after', + 'cancelable', + 'poll', + ] + ) + + def __init__( + self, + type: str, + state: str, + async_: bool, + description: str, + cancelable: bool, + poll: bool, + *, + sub_type: str = None, + reason_code: str = None, + poll_after: float = None, + **kwargs, + ) -> None: """ Initialize a ResourceInstanceLastOperation object. @@ -3473,7 +3289,7 @@ def from_dict(cls, _dict: Dict) -> 'ResourceInstanceLastOperation': args['poll'] = _dict.get('poll') else: raise ValueError('Required property \'poll\' not present in ResourceInstanceLastOperation JSON') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -3546,12 +3362,13 @@ class StateEnum(str, Enum): The last operation state of the resoure instance. This indicates if the resource's last operation is in progress, succeeded or failed. """ + IN_PROGRESS = 'in progress' SUCCEEDED = 'succeeded' FAILED = 'failed' -class ResourceInstancesList(): +class ResourceInstancesList: """ A list of resource instances. @@ -3560,10 +3377,7 @@ class ResourceInstancesList(): :attr List[ResourceInstance] resources: A list of resource instances. """ - def __init__(self, - rows_count: int, - next_url: str, - resources: List['ResourceInstance']) -> None: + def __init__(self, rows_count: int, next_url: str, resources: List['ResourceInstance']) -> None: """ Initialize a ResourceInstancesList object. @@ -3633,7 +3447,8 @@ def __ne__(self, other: 'ResourceInstancesList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceKey(): + +class ResourceKey: """ A resource key. @@ -3676,29 +3491,31 @@ class ResourceKey(): that this binding is associated with. """ - def __init__(self, - *, - id: str = None, - guid: str = None, - url: str = None, - created_at: datetime = None, - updated_at: datetime = None, - deleted_at: datetime = None, - created_by: str = None, - updated_by: str = None, - deleted_by: str = None, - source_crn: str = None, - name: str = None, - crn: str = None, - state: str = None, - account_id: str = None, - resource_group_id: str = None, - resource_id: str = None, - credentials: 'Credentials' = None, - iam_compatible: bool = None, - migrated: bool = None, - resource_instance_url: str = None, - resource_alias_url: str = None) -> None: + def __init__( + self, + *, + id: str = None, + guid: str = None, + url: str = None, + created_at: datetime = None, + updated_at: datetime = None, + deleted_at: datetime = None, + created_by: str = None, + updated_by: str = None, + deleted_by: str = None, + source_crn: str = None, + name: str = None, + crn: str = None, + state: str = None, + account_id: str = None, + resource_group_id: str = None, + resource_id: str = None, + credentials: 'Credentials' = None, + iam_compatible: bool = None, + migrated: bool = None, + resource_instance_url: str = None, + resource_alias_url: str = None, + ) -> None: """ Initialize a ResourceKey object. @@ -3885,7 +3702,8 @@ def __ne__(self, other: 'ResourceKey') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceKeyPostParameters(): + +class ResourceKeyPostParameters: """ Configuration options represented as key-value pairs. Service defined options are passed through to the target resource brokers, whereas platform defined options are @@ -3898,10 +3716,7 @@ class ResourceKeyPostParameters(): # The set of defined properties for the class _properties = frozenset(['serviceid_crn']) - def __init__(self, - *, - serviceid_crn: str = None, - **kwargs) -> None: + def __init__(self, *, serviceid_crn: str = None, **kwargs) -> None: """ Initialize a ResourceKeyPostParameters object. @@ -3919,7 +3734,7 @@ def from_dict(cls, _dict: Dict) -> 'ResourceKeyPostParameters': args = {} if 'serviceid_crn' in _dict: args['serviceid_crn'] = _dict.get('serviceid_crn') - args.update({k:v for (k, v) in _dict.items() if k not in cls._properties}) + args.update({k: v for (k, v) in _dict.items() if k not in cls._properties}) return cls(**args) @classmethod @@ -3971,7 +3786,8 @@ def __ne__(self, other: 'ResourceKeyPostParameters') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceKeysList(): + +class ResourceKeysList: """ A list of resource keys. @@ -3980,10 +3796,7 @@ class ResourceKeysList(): :attr List[ResourceKey] resources: A list of resource keys. """ - def __init__(self, - rows_count: int, - next_url: str, - resources: List['ResourceKey']) -> None: + def __init__(self, rows_count: int, next_url: str, resources: List['ResourceKey']) -> None: """ Initialize a ResourceKeysList object. @@ -4053,29 +3866,32 @@ def __ne__(self, other: 'ResourceKeysList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + ############################################################################## # Pagers ############################################################################## -class ResourceInstancesPager(): + +class ResourceInstancesPager: """ ResourceInstancesPager can be used to simplify the use of the "list_resource_instances" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - guid: str = None, - name: str = None, - resource_group_id: str = None, - resource_id: str = None, - resource_plan_id: str = None, - type: str = None, - sub_type: str = None, - limit: int = None, - state: str = None, - updated_from: str = None, - updated_to: str = None, + def __init__( + self, + *, + client: ResourceControllerV2, + guid: str = None, + name: str = None, + resource_group_id: str = None, + resource_id: str = None, + resource_plan_id: str = None, + type: str = None, + sub_type: str = None, + limit: int = None, + state: str = None, + updated_from: str = None, + updated_to: str = None, ) -> None: """ Initialize a ResourceInstancesPager object. @@ -4099,7 +3915,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._guid = guid self._name = name self._resource_group_id = resource_group_id @@ -4165,16 +3981,18 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceAliasesForInstancePager(): + +class ResourceAliasesForInstancePager: """ ResourceAliasesForInstancePager can be used to simplify the use of the "list_resource_aliases_for_instance" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - id: str, - limit: int = None, + def __init__( + self, + *, + client: ResourceControllerV2, + id: str, + limit: int = None, ) -> None: """ Initialize a ResourceAliasesForInstancePager object. @@ -4183,7 +4001,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._id = id self._limit = limit @@ -4231,16 +4049,18 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceKeysForInstancePager(): + +class ResourceKeysForInstancePager: """ ResourceKeysForInstancePager can be used to simplify the use of the "list_resource_keys_for_instance" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - id: str, - limit: int = None, + def __init__( + self, + *, + client: ResourceControllerV2, + id: str, + limit: int = None, ) -> None: """ Initialize a ResourceKeysForInstancePager object. @@ -4249,7 +4069,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._id = id self._limit = limit @@ -4297,21 +4117,23 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceKeysPager(): + +class ResourceKeysPager: """ ResourceKeysPager can be used to simplify the use of the "list_resource_keys" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - guid: str = None, - name: str = None, - resource_group_id: str = None, - resource_id: str = None, - limit: int = None, - updated_from: str = None, - updated_to: str = None, + def __init__( + self, + *, + client: ResourceControllerV2, + guid: str = None, + name: str = None, + resource_group_id: str = None, + resource_id: str = None, + limit: int = None, + updated_from: str = None, + updated_to: str = None, ) -> None: """ Initialize a ResourceKeysPager object. @@ -4326,7 +4148,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._guid = guid self._name = name self._resource_group_id = resource_group_id @@ -4384,22 +4206,24 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceBindingsPager(): + +class ResourceBindingsPager: """ ResourceBindingsPager can be used to simplify the use of the "list_resource_bindings" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - guid: str = None, - name: str = None, - resource_group_id: str = None, - resource_id: str = None, - region_binding_id: str = None, - limit: int = None, - updated_from: str = None, - updated_to: str = None, + def __init__( + self, + *, + client: ResourceControllerV2, + guid: str = None, + name: str = None, + resource_group_id: str = None, + resource_id: str = None, + region_binding_id: str = None, + limit: int = None, + updated_from: str = None, + updated_to: str = None, ) -> None: """ Initialize a ResourceBindingsPager object. @@ -4417,7 +4241,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._guid = guid self._name = name self._resource_group_id = resource_group_id @@ -4477,23 +4301,25 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceAliasesPager(): + +class ResourceAliasesPager: """ ResourceAliasesPager can be used to simplify the use of the "list_resource_aliases" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - guid: str = None, - name: str = None, - resource_instance_id: str = None, - region_instance_id: str = None, - resource_id: str = None, - resource_group_id: str = None, - limit: int = None, - updated_from: str = None, - updated_to: str = None, + def __init__( + self, + *, + client: ResourceControllerV2, + guid: str = None, + name: str = None, + resource_instance_id: str = None, + region_instance_id: str = None, + resource_id: str = None, + resource_group_id: str = None, + limit: int = None, + updated_from: str = None, + updated_to: str = None, ) -> None: """ Initialize a ResourceAliasesPager object. @@ -4513,7 +4339,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._guid = guid self._name = name self._resource_instance_id = resource_instance_id @@ -4575,16 +4401,18 @@ def get_all(self) -> List[dict]: results.extend(next_page) return results -class ResourceBindingsForAliasPager(): + +class ResourceBindingsForAliasPager: """ ResourceBindingsForAliasPager can be used to simplify the use of the "list_resource_bindings_for_alias" method. """ - def __init__(self, - *, - client: ResourceControllerV2, - id: str, - limit: int = None, + def __init__( + self, + *, + client: ResourceControllerV2, + id: str, + limit: int = None, ) -> None: """ Initialize a ResourceBindingsForAliasPager object. @@ -4593,7 +4421,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._id = id self._limit = limit diff --git a/ibm_platform_services/resource_manager_v2.py b/ibm_platform_services/resource_manager_v2.py index 528d1bd0..ec016d05 100644 --- a/ibm_platform_services/resource_manager_v2.py +++ b/ibm_platform_services/resource_manager_v2.py @@ -37,6 +37,7 @@ # Service ############################################################################## + class ResourceManagerV2(BaseService): """The Resource Manager V2 service.""" @@ -44,23 +45,23 @@ class ResourceManagerV2(BaseService): DEFAULT_SERVICE_NAME = 'resource_manager' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'ResourceManagerV2': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'ResourceManagerV2': """ Return a new client for the Resource Manager service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Resource Manager service. @@ -68,17 +69,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Resource Group ######################### - - def list_resource_groups(self, + def list_resource_groups( + self, *, account_id: str = None, date: str = None, @@ -114,9 +112,9 @@ def list_resource_groups(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_resource_groups') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_resource_groups' + ) headers.update(sdk_headers) params = { @@ -124,7 +122,7 @@ def list_resource_groups(self, 'date': date, 'name': name, 'default': default, - 'include_deleted': include_deleted + 'include_deleted': include_deleted, } if 'headers' in kwargs: @@ -132,21 +130,12 @@ def list_resource_groups(self, headers['Accept'] = 'application/json' url = '/v2/resource_groups' - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def create_resource_group(self, - *, - name: str = None, - account_id: str = None, - **kwargs - ) -> DetailedResponse: + def create_resource_group(self, *, name: str = None, account_id: str = None, **kwargs) -> DetailedResponse: """ Create a resource group. @@ -170,15 +159,12 @@ def create_resource_group(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='create_resource_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='create_resource_group' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'account_id': account_id - } + data = {'name': name, 'account_id': account_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -188,19 +174,12 @@ def create_resource_group(self, headers['Accept'] = 'application/json' url = '/v2/resource_groups' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_resource_group(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_resource_group(self, id: str, **kwargs) -> DetailedResponse: """ Get a resource group. @@ -221,9 +200,9 @@ def get_resource_group(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_resource_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_resource_group' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -234,21 +213,12 @@ def get_resource_group(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_groups/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_resource_group(self, - id: str, - *, - name: str = None, - state: str = None, - **kwargs - ) -> DetailedResponse: + def update_resource_group(self, id: str, *, name: str = None, state: str = None, **kwargs) -> DetailedResponse: """ Update a resource group. @@ -268,15 +238,12 @@ def update_resource_group(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='update_resource_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='update_resource_group' + ) headers.update(sdk_headers) - data = { - 'name': name, - 'state': state - } + data = {'name': name, 'state': state} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -289,19 +256,12 @@ def update_resource_group(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_groups/{id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def delete_resource_group(self, - id: str, - **kwargs - ) -> DetailedResponse: + def delete_resource_group(self, id: str, **kwargs) -> DetailedResponse: """ Delete a resource group. @@ -324,9 +284,9 @@ def delete_resource_group(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='delete_resource_group') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='delete_resource_group' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -336,9 +296,7 @@ def delete_resource_group(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/resource_groups/{id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -347,10 +305,7 @@ def delete_resource_group(self, # Quota Definition ######################### - - def list_quota_definitions(self, - **kwargs - ) -> DetailedResponse: + def list_quota_definitions(self, **kwargs) -> DetailedResponse: """ List quota definitions. @@ -368,9 +323,9 @@ def list_quota_definitions(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='list_quota_definitions') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='list_quota_definitions' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -378,18 +333,12 @@ def list_quota_definitions(self, headers['Accept'] = 'application/json' url = '/v2/quota_definitions' - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_quota_definition(self, - id: str, - **kwargs - ) -> DetailedResponse: + def get_quota_definition(self, id: str, **kwargs) -> DetailedResponse: """ Get a quota definition. @@ -412,9 +361,9 @@ def get_quota_definition(self, if id is None: raise ValueError('id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V2', - operation_id='get_quota_definition') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V2', operation_id='get_quota_definition' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -425,9 +374,7 @@ def get_quota_definition(self, path_param_values = self.encode_path_vars(id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/quota_definitions/{id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -438,7 +385,7 @@ def get_quota_definition(self, ############################################################################## -class QuotaDefinition(): +class QuotaDefinition: """ A returned quota definition. @@ -461,21 +408,23 @@ class QuotaDefinition(): :attr datetime updated_at: (optional) The date when the quota was last updated. """ - def __init__(self, - *, - id: str = None, - name: str = None, - type: str = None, - number_of_apps: float = None, - number_of_service_instances: float = None, - default_number_of_instances_per_lite_plan: float = None, - instances_per_app: float = None, - instance_memory: str = None, - total_app_memory: str = None, - vsi_limit: float = None, - resource_quotas: List['ResourceQuota'] = None, - created_at: datetime = None, - updated_at: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + name: str = None, + type: str = None, + number_of_apps: float = None, + number_of_service_instances: float = None, + default_number_of_instances_per_lite_plan: float = None, + instances_per_app: float = None, + instance_memory: str = None, + total_app_memory: str = None, + vsi_limit: float = None, + resource_quotas: List['ResourceQuota'] = None, + created_at: datetime = None, + updated_at: datetime = None + ) -> None: """ Initialize a QuotaDefinition object. @@ -563,7 +512,10 @@ def to_dict(self) -> Dict: _dict['number_of_apps'] = self.number_of_apps if hasattr(self, 'number_of_service_instances') and self.number_of_service_instances is not None: _dict['number_of_service_instances'] = self.number_of_service_instances - if hasattr(self, 'default_number_of_instances_per_lite_plan') and self.default_number_of_instances_per_lite_plan is not None: + if ( + hasattr(self, 'default_number_of_instances_per_lite_plan') + and self.default_number_of_instances_per_lite_plan is not None + ): _dict['default_number_of_instances_per_lite_plan'] = self.default_number_of_instances_per_lite_plan if hasattr(self, 'instances_per_app') and self.instances_per_app is not None: _dict['instances_per_app'] = self.instances_per_app @@ -599,15 +551,15 @@ def __ne__(self, other: 'QuotaDefinition') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class QuotaDefinitionList(): + +class QuotaDefinitionList: """ A list of quota definitions. :attr List[QuotaDefinition] resources: The list of quota definitions. """ - def __init__(self, - resources: List['QuotaDefinition']) -> None: + def __init__(self, resources: List['QuotaDefinition']) -> None: """ Initialize a QuotaDefinitionList object. @@ -655,7 +607,8 @@ def __ne__(self, other: 'QuotaDefinitionList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResCreateResourceGroup(): + +class ResCreateResourceGroup: """ A newly-created resource group. @@ -665,10 +618,7 @@ class ResCreateResourceGroup(): Names](https://cloud.ibm.com/docs/account?topic=account-crn). """ - def __init__(self, - *, - id: str = None, - crn: str = None) -> None: + def __init__(self, *, id: str = None, crn: str = None) -> None: """ Initialize a ResCreateResourceGroup object. @@ -723,7 +673,8 @@ def __ne__(self, other: 'ResCreateResourceGroup') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceGroup(): + +class ResourceGroup: """ A resource group. @@ -753,21 +704,23 @@ class ResourceGroup(): updated. """ - def __init__(self, - *, - id: str = None, - crn: str = None, - account_id: str = None, - name: str = None, - state: str = None, - default: bool = None, - quota_id: str = None, - quota_url: str = None, - payment_methods_url: str = None, - resource_linkages: List[object] = None, - teams_url: str = None, - created_at: datetime = None, - updated_at: datetime = None) -> None: + def __init__( + self, + *, + id: str = None, + crn: str = None, + account_id: str = None, + name: str = None, + state: str = None, + default: bool = None, + quota_id: str = None, + quota_url: str = None, + payment_methods_url: str = None, + resource_linkages: List[object] = None, + teams_url: str = None, + created_at: datetime = None, + updated_at: datetime = None + ) -> None: """ Initialize a ResourceGroup object. @@ -897,15 +850,15 @@ def __ne__(self, other: 'ResourceGroup') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceGroupList(): + +class ResourceGroupList: """ A list of resource groups. :attr List[ResourceGroup] resources: The list of resource groups. """ - def __init__(self, - resources: List['ResourceGroup']) -> None: + def __init__(self, resources: List['ResourceGroup']) -> None: """ Initialize a ResourceGroupList object. @@ -953,7 +906,8 @@ def __ne__(self, other: 'ResourceGroupList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceQuota(): + +class ResourceQuota: """ A resource quota. @@ -965,12 +919,7 @@ class ResourceQuota(): :attr float limit: (optional) The limit number of this resource. """ - def __init__(self, - *, - id: str = None, - resource_id: str = None, - crn: str = None, - limit: float = None) -> None: + def __init__(self, *, id: str = None, resource_id: str = None, crn: str = None, limit: float = None) -> None: """ Initialize a ResourceQuota object. diff --git a/ibm_platform_services/usage_metering_v4.py b/ibm_platform_services/usage_metering_v4.py index 3f3e9831..b344e2b7 100644 --- a/ibm_platform_services/usage_metering_v4.py +++ b/ibm_platform_services/usage_metering_v4.py @@ -39,6 +39,7 @@ # Service ############################################################################## + class UsageMeteringV4(BaseService): """The usage_metering V4 service.""" @@ -46,23 +47,23 @@ class UsageMeteringV4(BaseService): DEFAULT_SERVICE_NAME = 'usage_metering' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'UsageMeteringV4': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'UsageMeteringV4': """ Return a new client for the usage_metering service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the usage_metering service. @@ -70,20 +71,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Resource Usage ######################### - - def report_resource_usage(self, - resource_id: str, - resource_usage: List['ResourceInstanceUsage'], - **kwargs + def report_resource_usage( + self, resource_id: str, resource_usage: List['ResourceInstanceUsage'], **kwargs ) -> DetailedResponse: """ Report Resource Controller resource usage. @@ -104,9 +99,9 @@ def report_resource_usage(self, raise ValueError('resource_usage must be provided') resource_usage = [convert_model(x) for x in resource_usage] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='report_resource_usage') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='report_resource_usage' + ) headers.update(sdk_headers) data = json.dumps(resource_usage) @@ -120,10 +115,7 @@ def report_resource_usage(self, path_param_values = self.encode_path_vars(resource_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v4/metering/resources/{resource_id}/usage'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request) return response @@ -134,7 +126,7 @@ def report_resource_usage(self, ############################################################################## -class MeasureAndQuantity(): +class MeasureAndQuantity: """ A usage measurement. @@ -145,9 +137,7 @@ class MeasureAndQuantity(): "current": 2 }`. """ - def __init__(self, - measure: str, - quantity: object) -> None: + def __init__(self, measure: str, quantity: object) -> None: """ Initialize a MeasureAndQuantity object. @@ -206,7 +196,8 @@ def __ne__(self, other: 'MeasureAndQuantity') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceInstanceUsage(): + +class ResourceInstanceUsage: """ Usage information for a resource instance. @@ -228,15 +219,17 @@ class ResourceInstanceUsage(): instance-consumer combination. """ - def __init__(self, - resource_instance_id: str, - plan_id: str, - start: int, - end: int, - measured_usage: List['MeasureAndQuantity'], - *, - region: str = None, - consumer_id: str = None) -> None: + def __init__( + self, + resource_instance_id: str, + plan_id: str, + start: int, + end: int, + measured_usage: List['MeasureAndQuantity'], + *, + region: str = None, + consumer_id: str = None + ) -> None: """ Initialize a ResourceInstanceUsage object. @@ -339,7 +332,8 @@ def __ne__(self, other: 'ResourceInstanceUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceUsageDetails(): + +class ResourceUsageDetails: """ Resource usage details. @@ -349,12 +343,7 @@ class ResourceUsageDetails(): :attr str message: (optional) A description of the error. """ - def __init__(self, - status: int, - location: str, - *, - code: str = None, - message: str = None) -> None: + def __init__(self, status: int, location: str, *, code: str = None, message: str = None) -> None: """ Initialize a ResourceUsageDetails object. @@ -422,7 +411,8 @@ def __ne__(self, other: 'ResourceUsageDetails') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResponseAccepted(): + +class ResponseAccepted: """ Response when usage submitted is accepted. @@ -430,8 +420,7 @@ class ResponseAccepted(): status of each submitted usage record. """ - def __init__(self, - resources: List['ResourceUsageDetails']) -> None: + def __init__(self, resources: List['ResourceUsageDetails']) -> None: """ Initialize a ResponseAccepted object. diff --git a/ibm_platform_services/usage_reports_v4.py b/ibm_platform_services/usage_reports_v4.py index 12b1e04d..c3f417d4 100644 --- a/ibm_platform_services/usage_reports_v4.py +++ b/ibm_platform_services/usage_reports_v4.py @@ -35,6 +35,7 @@ # Service ############################################################################## + class UsageReportsV4(BaseService): """The Usage Reports V4 service.""" @@ -42,23 +43,23 @@ class UsageReportsV4(BaseService): DEFAULT_SERVICE_NAME = 'usage_reports' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'UsageReportsV4': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'UsageReportsV4': """ Return a new client for the Usage Reports service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the Usage Reports service. @@ -66,21 +67,13 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/master/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Account operations ######################### - - def get_account_summary(self, - account_id: str, - billingmonth: str, - **kwargs - ) -> DetailedResponse: + def get_account_summary(self, account_id: str, billingmonth: str, **kwargs) -> DetailedResponse: """ Get account summary. @@ -100,9 +93,9 @@ def get_account_summary(self, if billingmonth is None: raise ValueError('billingmonth must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_account_summary') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_account_summary' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -113,21 +106,13 @@ def get_account_summary(self, path_param_values = self.encode_path_vars(account_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v4/accounts/{account_id}/summary/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def get_account_usage(self, - account_id: str, - billingmonth: str, - *, - names: bool = None, - accept_language: str = None, - **kwargs + def get_account_usage( + self, account_id: str, billingmonth: str, *, names: bool = None, accept_language: str = None, **kwargs ) -> DetailedResponse: """ Get account usage. @@ -151,17 +136,13 @@ def get_account_usage(self, raise ValueError('account_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_account_usage') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_account_usage' + ) headers.update(sdk_headers) - params = { - '_names': names - } + params = {'_names': names} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -171,10 +152,7 @@ def get_account_usage(self, path_param_values = self.encode_path_vars(account_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v4/accounts/{account_id}/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -183,8 +161,8 @@ def get_account_usage(self, # Resource operations ######################### - - def get_resource_group_usage(self, + def get_resource_group_usage( + self, account_id: str, resource_group_id: str, billingmonth: str, @@ -220,17 +198,13 @@ def get_resource_group_usage(self, raise ValueError('resource_group_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_resource_group_usage') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_group_usage' + ) headers.update(sdk_headers) - params = { - '_names': names - } + params = {'_names': names} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -239,17 +213,16 @@ def get_resource_group_usage(self, path_param_keys = ['account_id', 'resource_group_id', 'billingmonth'] path_param_values = self.encode_path_vars(account_id, resource_group_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/usage/{billingmonth}'.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_resource_usage_account(self, + def get_resource_usage_account( + self, account_id: str, billingmonth: str, *, @@ -298,12 +271,10 @@ def get_resource_usage_account(self, raise ValueError('account_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_resource_usage_account') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_usage_account' + ) headers.update(sdk_headers) params = { @@ -315,7 +286,7 @@ def get_resource_usage_account(self, 'resource_instance_id': resource_instance_id, 'resource_id': resource_id, 'plan_id': plan_id, - 'region': region + 'region': region, } if 'headers' in kwargs: @@ -326,16 +297,13 @@ def get_resource_usage_account(self, path_param_values = self.encode_path_vars(account_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v4/accounts/{account_id}/resource_instances/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def get_resource_usage_resource_group(self, + def get_resource_usage_resource_group( + self, account_id: str, resource_group_id: str, billingmonth: str, @@ -386,12 +354,12 @@ def get_resource_usage_resource_group(self, raise ValueError('resource_group_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_resource_usage_resource_group') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, + service_version='V4', + operation_id='get_resource_usage_resource_group', + ) headers.update(sdk_headers) params = { @@ -401,7 +369,7 @@ def get_resource_usage_resource_group(self, 'resource_instance_id': resource_instance_id, 'resource_id': resource_id, 'plan_id': plan_id, - 'region': region + 'region': region, } if 'headers' in kwargs: @@ -411,17 +379,16 @@ def get_resource_usage_resource_group(self, path_param_keys = ['account_id', 'resource_group_id', 'billingmonth'] path_param_values = self.encode_path_vars(account_id, resource_group_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/resource_instances/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + url = '/v4/accounts/{account_id}/resource_groups/{resource_group_id}/resource_instances/usage/{billingmonth}'.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_resource_usage_org(self, + def get_resource_usage_org( + self, account_id: str, organization_id: str, billingmonth: str, @@ -471,12 +438,10 @@ def get_resource_usage_org(self, raise ValueError('organization_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_resource_usage_org') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_resource_usage_org' + ) headers.update(sdk_headers) params = { @@ -486,7 +451,7 @@ def get_resource_usage_org(self, 'resource_instance_id': resource_instance_id, 'resource_id': resource_id, 'plan_id': plan_id, - 'region': region + 'region': region, } if 'headers' in kwargs: @@ -496,11 +461,12 @@ def get_resource_usage_org(self, path_param_keys = ['account_id', 'organization_id', 'billingmonth'] path_param_values = self.encode_path_vars(account_id, organization_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) - url = '/v4/accounts/{account_id}/organizations/{organization_id}/resource_instances/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + url = ( + '/v4/accounts/{account_id}/organizations/{organization_id}/resource_instances/usage/{billingmonth}'.format( + **path_param_dict + ) + ) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -509,8 +475,8 @@ def get_resource_usage_org(self, # Organization operations ######################### - - def get_org_usage(self, + def get_org_usage( + self, account_id: str, organization_id: str, billingmonth: str, @@ -545,17 +511,13 @@ def get_org_usage(self, raise ValueError('organization_id must be provided') if billingmonth is None: raise ValueError('billingmonth must be provided') - headers = { - 'Accept-Language': accept_language - } - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V4', - operation_id='get_org_usage') + headers = {'Accept-Language': accept_language} + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V4', operation_id='get_org_usage' + ) headers.update(sdk_headers) - params = { - '_names': names - } + params = {'_names': names} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -565,10 +527,7 @@ def get_org_usage(self, path_param_values = self.encode_path_vars(account_id, organization_id, billingmonth) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v4/accounts/{account_id}/organizations/{organization_id}/usage/{billingmonth}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response @@ -579,7 +538,7 @@ def get_org_usage(self, ############################################################################## -class AccountSummary(): +class AccountSummary: """ A summary of charges and credits for an account. @@ -596,15 +555,17 @@ class AccountSummary(): to a subscription. """ - def __init__(self, - account_id: str, - billing_month: str, - billing_country_code: str, - billing_currency_code: str, - resources: 'ResourcesSummary', - offers: List['Offer'], - support: List['SupportSummary'], - subscription: 'SubscriptionSummary') -> None: + def __init__( + self, + account_id: str, + billing_month: str, + billing_country_code: str, + billing_currency_code: str, + resources: 'ResourcesSummary', + offers: List['Offer'], + support: List['SupportSummary'], + subscription: 'SubscriptionSummary', + ) -> None: """ Initialize a AccountSummary object. @@ -712,7 +673,8 @@ def __ne__(self, other: 'AccountSummary') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class AccountUsage(): + +class AccountUsage: """ The aggregated usage and charges for all the plans in the account. @@ -724,12 +686,9 @@ class AccountUsage(): :attr List[Resource] resources: All the resource used in the account. """ - def __init__(self, - account_id: str, - pricing_country: str, - currency_code: str, - month: str, - resources: List['Resource']) -> None: + def __init__( + self, account_id: str, pricing_country: str, currency_code: str, month: str, resources: List['Resource'] + ) -> None: """ Initialize a AccountUsage object. @@ -810,7 +769,8 @@ def __ne__(self, other: 'AccountUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Discount(): + +class Discount: """ Information about a discount that is associated with a metric. @@ -820,12 +780,7 @@ class Discount(): :attr float discount: The discount percentage. """ - def __init__(self, - ref: str, - discount: float, - *, - name: str = None, - display_name: str = None) -> None: + def __init__(self, ref: str, discount: float, *, name: str = None, display_name: str = None) -> None: """ Initialize a Discount object. @@ -893,7 +848,8 @@ def __ne__(self, other: 'Discount') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstanceUsage(): + +class InstanceUsage: """ The aggregated usage and charges for an instance. @@ -924,29 +880,31 @@ class InstanceUsage(): :attr List[Metric] usage: All the resource used in the account. """ - def __init__(self, - account_id: str, - resource_instance_id: str, - resource_id: str, - pricing_country: str, - currency_code: str, - billable: bool, - plan_id: str, - month: str, - usage: List['Metric'], - *, - resource_instance_name: str = None, - resource_name: str = None, - resource_group_id: str = None, - resource_group_name: str = None, - organization_id: str = None, - organization_name: str = None, - space_id: str = None, - space_name: str = None, - consumer_id: str = None, - region: str = None, - pricing_region: str = None, - plan_name: str = None) -> None: + def __init__( + self, + account_id: str, + resource_instance_id: str, + resource_id: str, + pricing_country: str, + currency_code: str, + billable: bool, + plan_id: str, + month: str, + usage: List['Metric'], + *, + resource_instance_name: str = None, + resource_name: str = None, + resource_group_id: str = None, + resource_group_name: str = None, + organization_id: str = None, + organization_name: str = None, + space_id: str = None, + space_name: str = None, + consumer_id: str = None, + region: str = None, + pricing_region: str = None, + plan_name: str = None + ) -> None: """ Initialize a InstanceUsage object. @@ -1135,16 +1093,15 @@ def __ne__(self, other: 'InstanceUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstancesUsageFirst(): + +class InstancesUsageFirst: """ The link to the first page of the search query. :attr str href: (optional) A link to a page of query results. """ - def __init__(self, - *, - href: str = None) -> None: + def __init__(self, *, href: str = None) -> None: """ Initialize a InstancesUsageFirst object. @@ -1190,7 +1147,8 @@ def __ne__(self, other: 'InstancesUsageFirst') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstancesUsageNext(): + +class InstancesUsageNext: """ The link to the next page of the search query. @@ -1199,10 +1157,7 @@ class InstancesUsageNext(): the next page. """ - def __init__(self, - *, - href: str = None, - offset: str = None) -> None: + def __init__(self, *, href: str = None, offset: str = None) -> None: """ Initialize a InstancesUsageNext object. @@ -1255,7 +1210,8 @@ def __ne__(self, other: 'InstancesUsageNext') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InstancesUsage(): + +class InstancesUsage: """ The list of instance usage reports. @@ -1269,13 +1225,15 @@ class InstancesUsage(): reports. """ - def __init__(self, - *, - limit: int = None, - count: int = None, - first: 'InstancesUsageFirst' = None, - next: 'InstancesUsageNext' = None, - resources: List['InstanceUsage'] = None) -> None: + def __init__( + self, + *, + limit: int = None, + count: int = None, + first: 'InstancesUsageFirst' = None, + next: 'InstancesUsageNext' = None, + resources: List['InstanceUsage'] = None + ) -> None: """ Initialize a InstancesUsage object. @@ -1348,7 +1306,8 @@ def __ne__(self, other: 'InstancesUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Metric(): + +class Metric: """ Information about a metric. @@ -1368,19 +1327,21 @@ class Metric(): :attr List[Discount] discounts: All the discounts applicable to the metric. """ - def __init__(self, - metric: str, - quantity: float, - cost: float, - rated_cost: float, - discounts: List['Discount'], - *, - metric_name: str = None, - rateable_quantity: float = None, - price: List[object] = None, - unit: str = None, - unit_name: str = None, - non_chargeable: bool = None) -> None: + def __init__( + self, + metric: str, + quantity: float, + cost: float, + rated_cost: float, + discounts: List['Discount'], + *, + metric_name: str = None, + rateable_quantity: float = None, + price: List[object] = None, + unit: str = None, + unit_name: str = None, + non_chargeable: bool = None + ) -> None: """ Initialize a Metric object. @@ -1501,7 +1462,8 @@ def __ne__(self, other: 'Metric') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Offer(): + +class Offer: """ Information about an individual offer. @@ -1513,13 +1475,15 @@ class Offer(): :attr OfferCredits credits: Credit information related to an offer. """ - def __init__(self, - offer_id: str, - credits_total: float, - offer_template: str, - valid_from: datetime, - expires_on: datetime, - credits: 'OfferCredits') -> None: + def __init__( + self, + offer_id: str, + credits_total: float, + offer_template: str, + valid_from: datetime, + expires_on: datetime, + credits: 'OfferCredits', + ) -> None: """ Initialize a Offer object. @@ -1607,7 +1571,8 @@ def __ne__(self, other: 'Offer') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OfferCredits(): + +class OfferCredits: """ Credit information related to an offer. @@ -1617,10 +1582,7 @@ class OfferCredits(): :attr float balance: The remaining credits in the offer. """ - def __init__(self, - starting_balance: float, - used: float, - balance: float) -> None: + def __init__(self, starting_balance: float, used: float, balance: float) -> None: """ Initialize a OfferCredits object. @@ -1685,7 +1647,8 @@ def __ne__(self, other: 'OfferCredits') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class OrgUsage(): + +class OrgUsage: """ The aggregated usage and charges for all the plans in the org. @@ -1699,15 +1662,17 @@ class OrgUsage(): :attr List[Resource] resources: All the resource used in the account. """ - def __init__(self, - account_id: str, - organization_id: str, - pricing_country: str, - currency_code: str, - month: str, - resources: List['Resource'], - *, - organization_name: str = None) -> None: + def __init__( + self, + account_id: str, + organization_id: str, + pricing_country: str, + currency_code: str, + month: str, + resources: List['Resource'], + *, + organization_name: str = None + ) -> None: """ Initialize a OrgUsage object. @@ -1802,7 +1767,8 @@ def __ne__(self, other: 'OrgUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Plan(): + +class Plan: """ The aggregated values for the plan. @@ -1816,16 +1782,18 @@ class Plan(): :attr List[Discount] discounts: All the discounts applicable to the plan. """ - def __init__(self, - plan_id: str, - billable: bool, - cost: float, - rated_cost: float, - usage: List['Metric'], - discounts: List['Discount'], - *, - plan_name: str = None, - pricing_region: str = None) -> None: + def __init__( + self, + plan_id: str, + billable: bool, + cost: float, + rated_cost: float, + usage: List['Metric'], + discounts: List['Discount'], + *, + plan_name: str = None, + pricing_region: str = None + ) -> None: """ Initialize a Plan object. @@ -1926,7 +1894,8 @@ def __ne__(self, other: 'Plan') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ The container for all the plans in the resource. @@ -1942,16 +1911,18 @@ class Resource(): :attr List[Discount] discounts: All the discounts applicable to the resource. """ - def __init__(self, - resource_id: str, - billable_cost: float, - billable_rated_cost: float, - non_billable_cost: float, - non_billable_rated_cost: float, - plans: List['Plan'], - discounts: List['Discount'], - *, - resource_name: str = None) -> None: + def __init__( + self, + resource_id: str, + billable_cost: float, + billable_rated_cost: float, + non_billable_cost: float, + non_billable_rated_cost: float, + plans: List['Plan'], + discounts: List['Discount'], + *, + resource_name: str = None + ) -> None: """ Initialize a Resource object. @@ -2056,7 +2027,8 @@ def __ne__(self, other: 'Resource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourceGroupUsage(): + +class ResourceGroupUsage: """ The aggregated usage and charges for all the plans in the resource group. @@ -2070,15 +2042,17 @@ class ResourceGroupUsage(): :attr List[Resource] resources: All the resource used in the account. """ - def __init__(self, - account_id: str, - resource_group_id: str, - pricing_country: str, - currency_code: str, - month: str, - resources: List['Resource'], - *, - resource_group_name: str = None) -> None: + def __init__( + self, + account_id: str, + resource_group_id: str, + pricing_country: str, + currency_code: str, + month: str, + resources: List['Resource'], + *, + resource_group_name: str = None + ) -> None: """ Initialize a ResourceGroupUsage object. @@ -2173,7 +2147,8 @@ def __ne__(self, other: 'ResourceGroupUsage') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class ResourcesSummary(): + +class ResourcesSummary: """ Charges related to cloud resources. @@ -2183,9 +2158,7 @@ class ResourcesSummary(): in the account. """ - def __init__(self, - billable_cost: float, - non_billable_cost: float) -> None: + def __init__(self, billable_cost: float, non_billable_cost: float) -> None: """ Initialize a ResourcesSummary object. @@ -2243,7 +2216,8 @@ def __ne__(self, other: 'ResourcesSummary') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Subscription(): + +class Subscription: """ Subscription. @@ -2261,16 +2235,18 @@ class Subscription(): split into. """ - def __init__(self, - subscription_id: str, - charge_agreement_number: str, - type: str, - subscription_amount: float, - start: datetime, - credits_total: float, - terms: List['SubscriptionTerm'], - *, - end: datetime = None) -> None: + def __init__( + self, + subscription_id: str, + charge_agreement_number: str, + type: str, + subscription_amount: float, + start: datetime, + credits_total: float, + terms: List['SubscriptionTerm'], + *, + end: datetime = None + ) -> None: """ Initialize a Subscription object. @@ -2377,7 +2353,8 @@ def __ne__(self, other: 'Subscription') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SubscriptionSummary(): + +class SubscriptionSummary: """ A summary of charges and credits related to a subscription. @@ -2387,10 +2364,7 @@ class SubscriptionSummary(): applicable for the month. """ - def __init__(self, - *, - overage: float = None, - subscriptions: List['Subscription'] = None) -> None: + def __init__(self, *, overage: float = None, subscriptions: List['Subscription'] = None) -> None: """ Initialize a SubscriptionSummary object. @@ -2444,7 +2418,8 @@ def __ne__(self, other: 'SubscriptionSummary') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SubscriptionTerm(): + +class SubscriptionTerm: """ SubscriptionTerm. @@ -2454,10 +2429,7 @@ class SubscriptionTerm(): subscription. """ - def __init__(self, - start: datetime, - end: datetime, - credits: 'SubscriptionTermCredits') -> None: + def __init__(self, start: datetime, end: datetime, credits: 'SubscriptionTermCredits') -> None: """ Initialize a SubscriptionTerm object. @@ -2522,7 +2494,8 @@ def __ne__(self, other: 'SubscriptionTerm') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SubscriptionTermCredits(): + +class SubscriptionTermCredits: """ Information about credits related to a subscription. @@ -2533,11 +2506,7 @@ class SubscriptionTermCredits(): :attr float balance: The remaining credits in this term. """ - def __init__(self, - total: float, - starting_balance: float, - used: float, - balance: float) -> None: + def __init__(self, total: float, starting_balance: float, used: float, balance: float) -> None: """ Initialize a SubscriptionTermCredits object. @@ -2610,7 +2579,8 @@ def __ne__(self, other: 'SubscriptionTermCredits') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class SupportSummary(): + +class SupportSummary: """ SupportSummary. @@ -2619,10 +2589,7 @@ class SupportSummary(): :attr float overage: Additional support cost for the month. """ - def __init__(self, - cost: float, - type: str, - overage: float) -> None: + def __init__(self, cost: float, type: str, overage: float) -> None: """ Initialize a SupportSummary object. diff --git a/ibm_platform_services/user_management_v1.py b/ibm_platform_services/user_management_v1.py index 3318fe81..031dd0e4 100644 --- a/ibm_platform_services/user_management_v1.py +++ b/ibm_platform_services/user_management_v1.py @@ -36,6 +36,7 @@ # Service ############################################################################## + class UserManagementV1(BaseService): """The User Management V1 service.""" @@ -43,23 +44,23 @@ class UserManagementV1(BaseService): DEFAULT_SERVICE_NAME = 'user_management' @classmethod - def new_instance(cls, - service_name: str = DEFAULT_SERVICE_NAME, - ) -> 'UserManagementV1': + def new_instance( + cls, + service_name: str = DEFAULT_SERVICE_NAME, + ) -> 'UserManagementV1': """ Return a new client for the User Management service using the specified parameters and external configuration. """ authenticator = get_authenticator_from_environment(service_name) - service = cls( - authenticator - ) + service = cls(authenticator) service.configure_service(service_name) return service - def __init__(self, - authenticator: Authenticator = None, - ) -> None: + def __init__( + self, + authenticator: Authenticator = None, + ) -> None: """ Construct a new client for the User Management service. @@ -67,23 +68,14 @@ def __init__(self, Get up to date information from https://github.com/IBM/python-sdk-core/blob/main/README.md about initializing the authenticator of your choice. """ - BaseService.__init__(self, - service_url=self.DEFAULT_SERVICE_URL, - authenticator=authenticator) - + BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator) ######################### # Users ######################### - - def list_users(self, - account_id: str, - *, - limit: int = None, - start: str = None, - user_id: str = None, - **kwargs + def list_users( + self, account_id: str, *, limit: int = None, start: str = None, user_id: str = None, **kwargs ) -> DetailedResponse: """ List users. @@ -114,16 +106,12 @@ def list_users(self, if not account_id: raise ValueError('account_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='list_users') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='list_users' + ) headers.update(sdk_headers) - params = { - 'limit': limit, - '_start': start, - 'user_id': user_id - } + params = {'limit': limit, '_start': start, 'user_id': user_id} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -134,22 +122,19 @@ def list_users(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def invite_users(self, + def invite_users( + self, account_id: str, *, users: List['InviteUser'] = None, iam_policy: List['InviteUserIamPolicy'] = None, access_groups: List[str] = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Invite users to an account. @@ -185,16 +170,12 @@ def invite_users(self, if iam_policy is not None: iam_policy = [convert_model(x) for x in iam_policy] headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='invite_users') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='invite_users' + ) headers.update(sdk_headers) - data = { - 'users': users, - 'iam_policy': iam_policy, - 'access_groups': access_groups - } + data = {'users': users, 'iam_policy': iam_policy, 'access_groups': access_groups} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -208,21 +189,13 @@ def invite_users(self, path_param_values = self.encode_path_vars(account_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users'.format(**path_param_dict) - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def get_user_profile(self, - account_id: str, - iam_id: str, - *, - include_activity: str = None, - **kwargs + def get_user_profile( + self, account_id: str, iam_id: str, *, include_activity: str = None, **kwargs ) -> DetailedResponse: """ Get user profile. @@ -246,14 +219,12 @@ def get_user_profile(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_user_profile') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_user_profile' + ) headers.update(sdk_headers) - params = { - 'include_activity': include_activity - } + params = {'include_activity': include_activity} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -264,16 +235,13 @@ def get_user_profile(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='GET', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def update_user_profile(self, + def update_user_profile( + self, account_id: str, iam_id: str, *, @@ -285,7 +253,7 @@ def update_user_profile(self, altphonenumber: str = None, photo: str = None, include_activity: str = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Partially update user profile. @@ -323,14 +291,12 @@ def update_user_profile(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_user_profile') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_user_profile' + ) headers.update(sdk_headers) - params = { - 'include_activity': include_activity - } + params = {'include_activity': include_activity} data = { 'firstname': firstname, @@ -339,7 +305,7 @@ def update_user_profile(self, 'email': email, 'phonenumber': phonenumber, 'altphonenumber': altphonenumber, - 'photo': photo + 'photo': photo, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -353,23 +319,12 @@ def update_user_profile(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - params=params, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, params=params, data=data) response = self.send(request, **kwargs) return response - - def remove_user(self, - account_id: str, - iam_id: str, - *, - include_activity: str = None, - **kwargs - ) -> DetailedResponse: + def remove_user(self, account_id: str, iam_id: str, *, include_activity: str = None, **kwargs) -> DetailedResponse: """ Remove user from account. @@ -393,14 +348,12 @@ def remove_user(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='remove_user') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='remove_user' + ) headers.update(sdk_headers) - params = { - 'include_activity': include_activity - } + params = {'include_activity': include_activity} if 'headers' in kwargs: headers.update(kwargs.get('headers')) @@ -410,20 +363,12 @@ def remove_user(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers, - params=params) + request = self.prepare_request(method='DELETE', url=url, headers=headers, params=params) response = self.send(request, **kwargs) return response - - def accept(self, - *, - account_id: str = None, - **kwargs - ) -> DetailedResponse: + def accept(self, *, account_id: str = None, **kwargs) -> DetailedResponse: """ Accept an invitation. @@ -439,14 +384,12 @@ def accept(self, """ headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='accept') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='accept' + ) headers.update(sdk_headers) - data = { - 'account_id': account_id - } + data = {'account_id': account_id} data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) headers['content-type'] = 'application/json' @@ -456,20 +399,12 @@ def accept(self, del kwargs['headers'] url = '/v2/users/accept' - request = self.prepare_request(method='POST', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='POST', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response - - def v3_remove_user(self, - account_id: str, - iam_id: str, - **kwargs - ) -> DetailedResponse: + def v3_remove_user(self, account_id: str, iam_id: str, **kwargs) -> DetailedResponse: """ Remove user from account (Asynchronous). @@ -492,9 +427,9 @@ def v3_remove_user(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='v3_remove_user') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='v3_remove_user' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -505,9 +440,7 @@ def v3_remove_user(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v3/accounts/{account_id}/users/{iam_id}'.format(**path_param_dict) - request = self.prepare_request(method='DELETE', - url=url, - headers=headers) + request = self.prepare_request(method='DELETE', url=url, headers=headers) response = self.send(request, **kwargs) return response @@ -516,12 +449,7 @@ def v3_remove_user(self, # User Settings ######################### - - def get_user_settings(self, - account_id: str, - iam_id: str, - **kwargs - ) -> DetailedResponse: + def get_user_settings(self, account_id: str, iam_id: str, **kwargs) -> DetailedResponse: """ Get user settings. @@ -550,9 +478,9 @@ def get_user_settings(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='get_user_settings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='get_user_settings' + ) headers.update(sdk_headers) if 'headers' in kwargs: @@ -564,15 +492,13 @@ def get_user_settings(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict) - request = self.prepare_request(method='GET', - url=url, - headers=headers) + request = self.prepare_request(method='GET', url=url, headers=headers) response = self.send(request, **kwargs) return response - - def update_user_settings(self, + def update_user_settings( + self, account_id: str, iam_id: str, *, @@ -580,7 +506,7 @@ def update_user_settings(self, notification_language: str = None, allowed_ip_addresses: str = None, self_manage: bool = None, - **kwargs + **kwargs, ) -> DetailedResponse: """ Partially update user settings. @@ -612,16 +538,16 @@ def update_user_settings(self, if not iam_id: raise ValueError('iam_id must be provided') headers = {} - sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, - service_version='V1', - operation_id='update_user_settings') + sdk_headers = get_sdk_headers( + service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='update_user_settings' + ) headers.update(sdk_headers) data = { 'language': language, 'notification_language': notification_language, 'allowed_ip_addresses': allowed_ip_addresses, - 'self_manage': self_manage + 'self_manage': self_manage, } data = {k: v for (k, v) in data.items() if v is not None} data = json.dumps(data) @@ -635,10 +561,7 @@ def update_user_settings(self, path_param_values = self.encode_path_vars(account_id, iam_id) path_param_dict = dict(zip(path_param_keys, path_param_values)) url = '/v2/accounts/{account_id}/users/{iam_id}/settings'.format(**path_param_dict) - request = self.prepare_request(method='PATCH', - url=url, - headers=headers, - data=data) + request = self.prepare_request(method='PATCH', url=url, headers=headers, data=data) response = self.send(request, **kwargs) return response @@ -649,7 +572,7 @@ def update_user_settings(self, ############################################################################## -class InvitedUser(): +class InvitedUser: """ Information about a user that has been invited to join an account. @@ -658,11 +581,7 @@ class InvitedUser(): :attr str state: (optional) The state of the invitation for the user. """ - def __init__(self, - *, - email: str = None, - id: str = None, - state: str = None) -> None: + def __init__(self, *, email: str = None, id: str = None, state: str = None) -> None: """ Initialize a InvitedUser object. @@ -721,7 +640,8 @@ def __ne__(self, other: 'InvitedUser') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InvitedUserList(): + +class InvitedUserList: """ A collection of invited users. This is the response returned by the invite_users operation. @@ -730,9 +650,7 @@ class InvitedUserList(): invited to join the account. """ - def __init__(self, - *, - resources: List['InvitedUser'] = None) -> None: + def __init__(self, *, resources: List['InvitedUser'] = None) -> None: """ Initialize a InvitedUserList object. @@ -785,7 +703,8 @@ def __ne__(self, other: 'InvitedUserList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UserList(): + +class UserList: """ The users returned. @@ -796,13 +715,15 @@ class UserList(): :attr List[UserProfile] resources: (optional) A list of users in the account. """ - def __init__(self, - total_results: int, - limit: int, - *, - first_url: str = None, - next_url: str = None, - resources: List['UserProfile'] = None) -> None: + def __init__( + self, + total_results: int, + limit: int, + *, + first_url: str = None, + next_url: str = None, + resources: List['UserProfile'] = None, + ) -> None: """ Initialize a UserList object. @@ -883,7 +804,8 @@ def __ne__(self, other: 'UserList') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UserProfile(): + +class UserProfile: """ Returned the user profile. @@ -908,21 +830,23 @@ class UserProfile(): account. """ - def __init__(self, - *, - id: str = None, - iam_id: str = None, - realm: str = None, - user_id: str = None, - firstname: str = None, - lastname: str = None, - state: str = None, - email: str = None, - phonenumber: str = None, - altphonenumber: str = None, - photo: str = None, - account_id: str = None, - added_on: str = None) -> None: + def __init__( + self, + *, + id: str = None, + iam_id: str = None, + realm: str = None, + user_id: str = None, + firstname: str = None, + lastname: str = None, + state: str = None, + email: str = None, + phonenumber: str = None, + altphonenumber: str = None, + photo: str = None, + account_id: str = None, + added_on: str = None, + ) -> None: """ Initialize a UserProfile object. @@ -1048,7 +972,8 @@ def __ne__(self, other: 'UserProfile') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class UserSettings(): + +class UserSettings: """ The user settings returned. @@ -1062,12 +987,14 @@ class UserSettings(): default value is `false`. """ - def __init__(self, - *, - language: str = None, - notification_language: str = None, - allowed_ip_addresses: str = None, - self_manage: bool = None) -> None: + def __init__( + self, + *, + language: str = None, + notification_language: str = None, + allowed_ip_addresses: str = None, + self_manage: bool = None, + ) -> None: """ Initialize a UserSettings object. @@ -1135,7 +1062,8 @@ def __ne__(self, other: 'UserSettings') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Attribute(): + +class Attribute: """ An attribute/value pair. @@ -1143,10 +1071,7 @@ class Attribute(): :attr str value: (optional) The value of the attribute. """ - def __init__(self, - *, - name: str = None, - value: str = None) -> None: + def __init__(self, *, name: str = None, value: str = None) -> None: """ Initialize a Attribute object. @@ -1198,7 +1123,8 @@ def __ne__(self, other: 'Attribute') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InviteUser(): + +class InviteUser: """ Invite a user. @@ -1206,10 +1132,7 @@ class InviteUser(): :attr str account_role: (optional) The account role of the user to be invited. """ - def __init__(self, - *, - email: str = None, - account_role: str = None) -> None: + def __init__(self, *, email: str = None, account_role: str = None) -> None: """ Initialize a InviteUser object. @@ -1262,7 +1185,8 @@ def __ne__(self, other: 'InviteUser') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class InviteUserIamPolicy(): + +class InviteUserIamPolicy: """ Invite a user to an IAM policy. @@ -1271,11 +1195,7 @@ class InviteUserIamPolicy(): :attr List[Resource] resources: (optional) A list of resources. """ - def __init__(self, - type: str, - *, - roles: List['Role'] = None, - resources: List['Resource'] = None) -> None: + def __init__(self, type: str, *, roles: List['Role'] = None, resources: List['Resource'] = None) -> None: """ Initialize a InviteUserIamPolicy object. @@ -1348,16 +1268,15 @@ def __ne__(self, other: 'InviteUserIamPolicy') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Resource(): + +class Resource: """ A collection of attribute value pairs. :attr List[Attribute] attributes: (optional) A list of IAM attributes. """ - def __init__(self, - *, - attributes: List['Attribute'] = None) -> None: + def __init__(self, *, attributes: List['Attribute'] = None) -> None: """ Initialize a Resource object. @@ -1409,16 +1328,15 @@ def __ne__(self, other: 'Resource') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other -class Role(): + +class Role: """ The role of an IAM policy. :attr str role_id: (optional) An alphanumeric value identifying the origin. """ - def __init__(self, - *, - role_id: str = None) -> None: + def __init__(self, *, role_id: str = None) -> None: """ Initialize a Role object. @@ -1465,21 +1383,24 @@ def __ne__(self, other: 'Role') -> bool: """Return `true` when self and other are not equal, false otherwise.""" return not self == other + ############################################################################## # Pagers ############################################################################## -class UsersPager(): + +class UsersPager: """ UsersPager can be used to simplify the use of the "list_users" method. """ - def __init__(self, - *, - client: UserManagementV1, - account_id: str, - limit: int = None, - user_id: str = None, + def __init__( + self, + *, + client: UserManagementV1, + account_id: str, + limit: int = None, + user_id: str = None, ) -> None: """ Initialize a UsersPager object. @@ -1489,7 +1410,7 @@ def __init__(self, """ self._has_next = True self._client = client - self._page_context = { 'next': None } + self._page_context = {'next': None} self._account_id = account_id self._limit = limit self._user_id = user_id diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..6ae249d0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true diff --git a/requirements-dev.txt b/requirements-dev.txt index e7b73e4c..2ba33dd5 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -6,3 +6,4 @@ pytest>=7.0.1,<8.0.0 pytest-cov>=2.2.1,<3.0.0 responses>=0.12.1,<1.0.0 tox>=3.2.0,<4.0.0 +black>=22.10 diff --git a/setup.py b/setup.py index 2323a7d7..d9ca70dc 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,7 @@ PACKAGE_DESC = 'Python client library for IBM Cloud Platform Services' with open('requirements.txt') as f: - install_requires = [ - str(req) for req in pkg_resources.parse_requirements(f) - ] + install_requires = [str(req) for req in pkg_resources.parse_requirements(f)] with open('requirements-dev.txt') as f: tests_require = [str(req) for req in pkg_resources.parse_requirements(f)] @@ -72,4 +70,5 @@ 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Software Development :: Libraries :: Application Frameworks', ], - zip_safe=True) + zip_safe=True, +) diff --git a/test/integration/__init__.py b/test/integration/__init__.py index 7ad8a3bd..f71ea093 100644 --- a/test/integration/__init__.py +++ b/test/integration/__init__.py @@ -2,4 +2,4 @@ """Integration Tests""" -# this file is present so that pylint will lint-check the files in this directory \ No newline at end of file +# this file is present so that pylint will lint-check the files in this directory diff --git a/test/integration/test_case_management_v1.py b/test/integration/test_case_management_v1.py index 12e7e807..b664e9f4 100644 --- a/test/integration/test_case_management_v1.py +++ b/test/integration/test_case_management_v1.py @@ -48,8 +48,7 @@ def setUpClass(cls): if os.path.exists(configFile): os.environ['IBM_CREDENTIALS_FILE'] = configFile else: - raise unittest.SkipTest( - 'External configuration not available, skipping...') + raise unittest.SkipTest('External configuration not available, skipping...') cls.service = CaseManagementV1.new_instance() assert cls.service is not None @@ -62,8 +61,7 @@ def test_01_create_case(self): offering_payload_type_model = {} offering_payload_type_model['group'] = 'crn_service_name' offering_payload_type_model['key'] = 'cloud-object-storage' - offering_payload_type_model[ - 'id'] = 'dff97f5c-bc5e-4455-b470-411c3edbe49c' + offering_payload_type_model['id'] = 'dff97f5c-bc5e-4455-b470-411c3edbe49c' offering_payload_model = {} offering_payload_model['name'] = 'Cloud Object Storage' @@ -75,16 +73,12 @@ def test_01_create_case(self): severity = 4 offering = offering_payload_model - response = self.service.create_case(type, - subject, - description, - severity=severity, - offering=offering, - headers={}) + response = self.service.create_case( + type, subject, description, severity=severity, offering=offering, headers={} + ) assert response.get_status_code() == 200 assert response.result is not None - print('create_case() response:\n{}'.format( - json.dumps(response.result, indent=2))) + print('create_case() response:\n{}'.format(json.dumps(response.result, indent=2))) # Storing the new case number for subsequent test cases TestCaseManagementV1.new_case_number = response.result['number'] @@ -100,11 +94,7 @@ def test_02_create_case_with_empty_offering(self): severity = 4 with pytest.raises(ApiException) as e: - self.service.create_case(type, - subject, - description, - severity=severity, - headers={}) + self.service.create_case(type, subject, description, severity=severity, headers={}) assert e.value.code == 400 def test_03_create_case_with_empty_subject_and_description(self): @@ -113,8 +103,7 @@ def test_03_create_case_with_empty_subject_and_description(self): offering_payload_type_model = {} offering_payload_type_model['group'] = 'crn_service_name' offering_payload_type_model['key'] = 'cloud-object-storage' - offering_payload_type_model[ - 'id'] = 'dff97f5c-bc5e-4455-b470-411c3edbe49c' + offering_payload_type_model['id'] = 'dff97f5c-bc5e-4455-b470-411c3edbe49c' offering_payload_model = {} offering_payload_model['name'] = 'Cloud Object Storage' @@ -128,12 +117,7 @@ def test_03_create_case_with_empty_subject_and_description(self): # Subject and description are required with pytest.raises(ApiException) as e: - self.service.create_case(type, - subject, - description, - severity=severity, - offering=offering, - headers={}) + self.service.create_case(type, subject, description, severity=severity, offering=offering, headers={}) assert e.value.code == 400 def test_04_get_cases(self): @@ -197,12 +181,9 @@ def test_05_get_case(self): fields = ['number', 'short_description'] case_number = TestCaseManagementV1.new_case_number - response = self.service.get_case(self.new_case_number, - fields=fields, - headers={}) + response = self.service.get_case(self.new_case_number, fields=fields, headers={}) - assert TestCaseManagementV1.new_case_number == response.result[ - 'number'] + assert TestCaseManagementV1.new_case_number == response.result['number'] assert response.result['short_description'] != '' def test_06_get_case_with_invalid_field(self): @@ -211,9 +192,7 @@ def test_06_get_case_with_invalid_field(self): case_number = TestCaseManagementV1.new_case_number with pytest.raises(ApiException) as e: - self.service.get_case(self.new_case_number, - fields=fields, - headers={}) + self.service.get_case(self.new_case_number, fields=fields, headers={}) assert e.value.code == 400 def test_07_add_comment(self): @@ -244,10 +223,7 @@ def test_09_add_watch_list_member(self): watchlist = [user_id_and_realm_model] - response = self.service.add_watchlist( - TestCaseManagementV1.new_case_number, - watchlist=watchlist, - headers={}) + response = self.service.add_watchlist(TestCaseManagementV1.new_case_number, watchlist=watchlist, headers={}) # Non-account member cannot be added to the watch-list, # therefore the response will include a "failed" list @@ -255,8 +231,7 @@ def test_09_add_watch_list_member(self): # Loop over all returned users and find the matching one by user id found_users = [ - user for user in response.result['failed'] - if user['user_id'] == user_id_and_realm_model['user_id'] + user for user in response.result['failed'] if user['user_id'] == user_id_and_realm_model['user_id'] ] assert len(found_users) == 1 @@ -265,14 +240,12 @@ def test_10_file_upload(self): fileName = "test_file.txt" file_with_metadata_model = {} - file_with_metadata_model['data'] = io.BytesIO( - b'This is a mock file.').getvalue() + file_with_metadata_model['data'] = io.BytesIO(b'This is a mock file.').getvalue() file_with_metadata_model['filename'] = fileName file = [file_with_metadata_model] - response = self.service.upload_file( - TestCaseManagementV1.new_case_number, file, headers={}) + response = self.service.upload_file(TestCaseManagementV1.new_case_number, file, headers={}) TestCaseManagementV1.file_attachment_id = response.result['id'] @@ -282,9 +255,8 @@ def test_10_file_upload(self): def test_11_download_file(self): response = self.service.download_file( - TestCaseManagementV1.new_case_number, - TestCaseManagementV1.file_attachment_id, - headers={}) + TestCaseManagementV1.new_case_number, TestCaseManagementV1.file_attachment_id, headers={} + ) assert response.status_code == 200 assert 'content-type' in response.headers @@ -292,9 +264,8 @@ def test_11_download_file(self): def test_12_delete_file(self): response = self.service.delete_file( - TestCaseManagementV1.new_case_number, - TestCaseManagementV1.file_attachment_id, - headers={}) + TestCaseManagementV1.new_case_number, TestCaseManagementV1.file_attachment_id, headers={} + ) assert response.status_code == 200 # Assert the file attachment list is empty @@ -303,9 +274,8 @@ def test_12_delete_file(self): def test_13_add_resource(self): response = self.service.add_resource( - TestCaseManagementV1.new_case_number, - crn=TestCaseManagementV1.resource_crn, - note='Test resource') + TestCaseManagementV1.new_case_number, crn=TestCaseManagementV1.resource_crn, note='Test resource' + ) assert response.status_code == 200 assert response is not None @@ -316,9 +286,7 @@ def test_14_resolve_case(self): status_payload['comment'] = 'testString' status_payload['resolution_code'] = 1 - response = self.service.update_case_status( - TestCaseManagementV1.new_case_number, status_payload, headers={}) + response = self.service.update_case_status(TestCaseManagementV1.new_case_number, status_payload, headers={}) assert response.status_code == 200 - assert TestCaseManagementV1.new_case_number == response.result[ - "number"] + assert TestCaseManagementV1.new_case_number == response.result["number"] diff --git a/test/integration/test_catalog_management_v1.py b/test/integration/test_catalog_management_v1.py index d2152d03..93f5f309 100644 --- a/test/integration/test_catalog_management_v1.py +++ b/test/integration/test_catalog_management_v1.py @@ -44,8 +44,10 @@ object_crn = 'crn:v1:bluemix:public:iam-global-endpoint:global:::endpoint:private.iam.cloud.ibm.com' region_us_south = 'us-south' namespace_python_sdk = 'python-sdk' -import_offering_zip_url = 'https://github.com/rhm-samples/node-red-operator/blob/master/node-red-operator/bundle/0.0' \ - '.2/node-red-operator.v0.0.2.clusterserviceversion.yaml' +import_offering_zip_url = ( + 'https://github.com/rhm-samples/node-red-operator/blob/master/node-red-operator/bundle/0.0' + '.2/node-red-operator.v0.0.2.clusterserviceversion.yaml' +) label_python_sdk = 'python-sdk' @@ -53,7 +55,7 @@ bogus_version_locator_id = 'bogus-version-locator-id' -class TestCatalogManagementV1(): +class TestCatalogManagementV1: """ Integration Test Class for CatalogManagementV1 """ @@ -63,17 +65,13 @@ def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.catalog_management_service_authorized = CatalogManagementV1.new_instance( - ) + cls.catalog_management_service_authorized = CatalogManagementV1.new_instance() assert cls.catalog_management_service_authorized is not None - cls.catalog_management_service_not_authorized = CatalogManagementV1.new_instance( - 'NOT_AUTHORIZED' - ) + cls.catalog_management_service_not_authorized = CatalogManagementV1.new_instance('NOT_AUTHORIZED') assert cls.catalog_management_service_not_authorized is not None - cls.config = read_external_sources( - CatalogManagementV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(CatalogManagementV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.account_id = cls.config.get('ACCOUNT_ID') @@ -158,7 +156,7 @@ def test_get_catalog_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.get_catalog( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 @@ -212,7 +210,7 @@ def test_replace_catalog_returns_400_when_backend_input_validation_fails(self): try: self.catalog_management_service_authorized.replace_catalog( catalog_identifier=catalog_id, - id='invalid-'+catalog_id, + id='invalid-' + catalog_id, owning_account=self.account_id, kind=kind_vpe, ) @@ -225,8 +223,8 @@ def test_replace_catalog_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.replace_catalog( - catalog_identifier='invalid-'+catalog_id, - id='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, + id='invalid-' + catalog_id, owning_account=self.account_id, kind=kind_vpe, ) @@ -265,9 +263,10 @@ def test_list_catalogs(self): catalog_search_result = list_catalogs_response.get_result() assert catalog_search_result is not None - assert next((catalog for catalog in catalog_search_result['resources'] - if catalog['id'] == catalog_id), - None) is not None + assert ( + next((catalog for catalog in catalog_search_result['resources'] if catalog['id'] == catalog_id), None) + is not None + ) #### # Create Offering @@ -279,7 +278,7 @@ def test_create_offering_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.create_offering( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 @@ -320,7 +319,7 @@ def test_create_offering(self): create_offering_response = self.catalog_management_service_authorized.create_offering( catalog_identifier=catalog_id, label=label_python_sdk, - name='offering-created-by-python-sdk-'+str(i), + name='offering-created-by-python-sdk-' + str(i), ) assert create_offering_response.get_status_code() == 201 @@ -328,7 +327,7 @@ def test_create_offering(self): assert offering is not None assert offering['id'] is not None - print('offering id: '+offering['id']) + print('offering id: ' + offering['id']) if offering_id is None: offering_id = offering['id'] @@ -346,7 +345,7 @@ def test_get_offering_returns_404_when_no_such_offering(self): try: self.catalog_management_service_authorized.get_offering( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, ) except ApiException as e: assert e.code == 404 @@ -392,8 +391,8 @@ def test_replace_offering_returns_404_when_no_such_offering(self): try: self.catalog_management_service_authorized.replace_offering( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, - id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, + id='invalid-' + offering_id, name='updated-offering-name-by-python-sdk', ) except ApiException as e: @@ -493,12 +492,8 @@ def test_update_offering(self): update_offering_response = self.catalog_management_service_authorized.update_offering( catalog_identifier=catalog_id, offering_id=offering_id, - if_match='"'+offering['_rev']+'"', - updates=[JsonPatchOperation( - op="replace", - path="/name", - value="updated-offering-name-by-python-sdk-patch" - )] + if_match='"' + offering['_rev'] + '"', + updates=[JsonPatchOperation(op="replace", path="/name", value="updated-offering-name-by-python-sdk-patch")], ) assert update_offering_response.get_status_code() == 200 @@ -518,11 +513,9 @@ def test_update_offering_returns_412_on_bad_request(self): catalog_identifier=catalog_id, offering_id=offering_id, if_match='"bogus_rev"', - updates=[JsonPatchOperation( - op="replace", - path="/name", - value="updated-offering-name-by-python-sdk-patch" - )] + updates=[ + JsonPatchOperation(op="replace", path="/name", value="updated-offering-name-by-python-sdk-patch") + ], ) except ApiException as e: assert e.code == 412 @@ -548,9 +541,7 @@ def test_list_offerings_returns_400_when_backend_input_validation_fails(self): try: self.catalog_management_service_authorized.list_offerings( - catalog_identifier=catalog_id, - digest=True, - sort='bogus-sort-value' + catalog_identifier=catalog_id, digest=True, sort='bogus-sort-value' ) except ApiException as e: assert e.code == 400 @@ -561,7 +552,7 @@ def test_list_offerings_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.list_offerings( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 @@ -586,14 +577,14 @@ def test_list_offerings(self): assert offering_search_result is not None offset_value = get_query_param(offering_search_result.next, 'offset') - print('offset value: '+offset_value) + print('offset value: ' + offset_value) if offset_value is None: offset = offset_value else: offset = 0 - print('Amount of offerings is: '+str(amount_of_offerings)) + print('Amount of offerings is: ' + str(amount_of_offerings)) #### # Import Offering @@ -644,7 +635,7 @@ def test_import_offering_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.import_offering( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, tags=['python', 'sdk'], target_kinds=[kind_roks], zipurl=import_offering_zip_url, @@ -711,7 +702,7 @@ def test_reload_offering_returns_404_when_no_such_offering(self): try: self.catalog_management_service_authorized.reload_offering( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, target_version='0.0.2', target_kinds=kind_roks, zipurl=import_offering_zip_url, @@ -834,8 +825,8 @@ def test_create_object_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.create_object( - catalog_identifier='invalid-'+catalog_id, - catalog_id='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, + catalog_id='invalid-' + catalog_id, name=object_name, crn=object_crn, parent_id=region_us_south, @@ -862,7 +853,7 @@ def test_create_object(self): 'current': 'new', } - name = object_name+'_'+str(i) + name = object_name + '_' + str(i) create_object_response = self.catalog_management_service_authorized.create_object( catalog_identifier=catalog_id, catalog_id=catalog_id, @@ -895,7 +886,7 @@ def test_get_offering_audit_returns_200_when_no_such_offerings(self): get_offering_audit_response = self.catalog_management_service_authorized.get_offering_audit( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, ) assert get_offering_audit_response.get_status_code() == 200 @@ -949,7 +940,7 @@ def test_update_catalog_account_returns_400_when_no_such_account(self): try: self.catalog_management_service_authorized.update_catalog_account( - id='invalid-'+self.account_id, + id='invalid-' + self.account_id, ) except ApiException as e: assert e.code == 400 @@ -1031,7 +1022,7 @@ def test_get_catalog_account_filters_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.get_catalog_account_filters( - catalog='invalid-'+catalog_id, + catalog='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 @@ -1056,7 +1047,7 @@ def test_get_catalog_audit_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.get_catalog_audit( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 @@ -1106,7 +1097,7 @@ def test_get_consumption_offerings_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.get_consumption_offerings( - catalog='invalid-'+catalog_id, + catalog='invalid-' + catalog_id, select='all', ) except ApiException as e: @@ -1154,7 +1145,7 @@ def test_import_offering_version_returns_404_when_no_such_offerings(self): try: self.catalog_management_service_authorized.import_offering_version( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, target_kinds=[kind_roks], zipurl=import_offering_zip_url, target_version='0.0.3', @@ -1213,7 +1204,7 @@ def test_replace_offering_icon_returns_404_when_no_such_offerings(self): try: self.catalog_management_service_authorized.replace_offering_icon( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, file_name='filename.jpg', ) except ApiException as e: @@ -1287,7 +1278,7 @@ def test_update_offering_ibm_returns_404_when_no_such_offerings(self): try: self.catalog_management_service_authorized.update_offering_ibm( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, approval_type='allow_request', approved='true', ) @@ -1362,7 +1353,7 @@ def test_get_offering_updates_returns_404_when_no_such_offerings(self): try: self.catalog_management_service_authorized.get_offering_updates( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, version='0.0.2', kind=kind_vpe, cluster_id=self.cluster_id, @@ -1435,7 +1426,7 @@ def test_get_offering_about_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_offering_about( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: @@ -1488,7 +1479,7 @@ def test_get_offering_license_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_offering_license( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, license_id='license-id-is-needed', ) @@ -1543,7 +1534,7 @@ def test_get_offering_container_images_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_offering_container_images( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1563,8 +1554,10 @@ def test_get_offering_container_images_returns_403_when_user_is_not_authorized(s def test_get_offering_container_images(self): assert version_locator_id is not None - get_offering_container_images_response = self.catalog_management_service_authorized.get_offering_container_images( - version_loc_id=version_locator_id, + get_offering_container_images_response = ( + self.catalog_management_service_authorized.get_offering_container_images( + version_loc_id=version_locator_id, + ) ) assert get_offering_container_images_response.get_status_code() == 200 @@ -1581,7 +1574,7 @@ def test_deprecate_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.deprecate_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1641,7 +1634,7 @@ def test_account_publish_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.account_publish_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1691,7 +1684,7 @@ def test_ibm_publish_version_404_when_no_such_version(self): try: self.catalog_management_service_authorized.ibm_publish_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1740,7 +1733,7 @@ def test_public_publish_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.public_publish_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1789,7 +1782,7 @@ def test_commit_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.commit_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1841,7 +1834,7 @@ def test_copy_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.copy_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, target_kinds=[kind_roks], ) except ApiException as e: @@ -1903,7 +1896,7 @@ def test_get_offering_working_copy_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_offering_working_copy( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1945,7 +1938,7 @@ def test_get_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -1997,7 +1990,7 @@ def test_get_cluster_returns_404_when_no_such_cluster(self): try: self.catalog_management_service_authorized.get_cluster( - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, x_auth_refresh_token=self.refresh_token_authorized, ) @@ -2030,7 +2023,7 @@ def test_get_cluster(self): def test_get_namespaces_returns_404_when_no_such_cluster(self): try: self.catalog_management_service_authorized.get_namespaces( - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, x_auth_refresh_token=self.refresh_token_authorized, ) @@ -2100,7 +2093,7 @@ def test_deploy_operators_returns_404_when_no_such_cluster(self): try: self.catalog_management_service_authorized.deploy_operators( x_auth_refresh_token=self.refresh_token_authorized, - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, all_namespaces=True, version_locator_id=version_locator_id, @@ -2182,7 +2175,7 @@ def test_list_operators_returns_404_when_no_such_cluster(self): try: self.catalog_management_service_authorized.list_operators( x_auth_refresh_token=self.refresh_token_authorized, - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, version_locator_id=version_locator_id, ) @@ -2236,7 +2229,7 @@ def test_replace_operators_returns_404_when_no_such_cluster(self): try: self.catalog_management_service_authorized.replace_operators( x_auth_refresh_token=self.refresh_token_authorized, - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, all_namespaces=True, version_locator_id=version_locator_id, @@ -2307,7 +2300,7 @@ def test_install_version_returns_404_when_no_such_cluster(self): self.catalog_management_service_authorized.install_version( version_loc_id=version_locator_id, x_auth_refresh_token=self.refresh_token_authorized, - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, version_locator_id=version_locator_id, ) @@ -2381,7 +2374,7 @@ def test_preinstall_version_returns_404_when_no_such_cluster(self): self.catalog_management_service_authorized.preinstall_version( version_loc_id=version_locator_id, x_auth_refresh_token=self.refresh_token_authorized, - cluster_id='invalid-'+self.cluster_id, + cluster_id='invalid-' + self.cluster_id, region=region_us_south, version_locator_id=version_locator_id, ) @@ -2443,7 +2436,7 @@ def test_get_preinstall_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_preinstall( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, x_auth_refresh_token=self.refresh_token_authorized, cluster_id=self.cluster_id, region=region_us_south, @@ -2507,11 +2500,11 @@ def test_validate_install_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.validate_install( - version_loc_id='invalid'+version_locator_id, + version_loc_id='invalid' + version_locator_id, x_auth_refresh_token=self.refresh_token_authorized, cluster_id=self.cluster_id, region=region_us_south, - version_locator_id='invalid-'+version_locator_id, + version_locator_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -2572,7 +2565,7 @@ def test_get_validation_status_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_validation_status( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, x_auth_refresh_token=self.refresh_token_authorized, ) except ApiException as e: @@ -2623,7 +2616,7 @@ def test_get_override_values_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.get_override_values( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -2674,7 +2667,7 @@ def test_search_objects_returns_400_when_backend_input_validation_fails(self): def test_search_objects_returns_200_when_user_is_not_authorized(self): search_objects_response = self.catalog_management_service_not_authorized.search_objects( - query='name: '+object_name, + query='name: ' + object_name, collapse=True, digest=True, ) @@ -2716,11 +2709,7 @@ def test_list_objects_returns_400_when_backend_input_validation_fails(self): assert catalog_id is not None try: - self.catalog_management_service_authorized.list_objects( - catalog_identifier=catalog_id, - name=' ', - sort=' ' - ) + self.catalog_management_service_authorized.list_objects(catalog_identifier=catalog_id, name=' ', sort=' ') except ApiException as e: assert e.code == 400 @@ -2752,7 +2741,7 @@ def test_list_objects(self): assert list_objects_response.get_status_code() == 200 object_list_result = list_objects_response.get_result() assert object_list_result is not None - offset_value = get_query_param(object_list_result.next, 'offset'); + offset_value = get_query_param(object_list_result.next, 'offset') if offset_value is not None: offset = offset_value else: @@ -2789,8 +2778,8 @@ def test_replace_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.replace_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, - id='invalid-'+object_id, + object_identifier='invalid-' + object_id, + id='invalid-' + object_id, name='updated-object-name-created-by-python-sdk', parent_id=region_us_south, kind=kind_vpe, @@ -2868,7 +2857,7 @@ def test_get_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.get_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) except ApiException as e: assert e.code == 404 @@ -2911,7 +2900,7 @@ def test_get_object_audit_returns_200_when_no_such_object(self): get_object_audit_response = self.catalog_management_service_authorized.get_object_audit( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) assert get_object_audit_response.get_status_code() == 200 @@ -2957,7 +2946,7 @@ def test_account_publish_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.account_publish_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) except ApiException as e: assert e.code == 404 @@ -2999,7 +2988,7 @@ def test_shared_publish_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.shared_publish_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) except ApiException as e: assert e.code == 404 @@ -3044,7 +3033,7 @@ def test_ibm_publish_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.ibm_publish_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) except ApiException as e: assert e.code == 404 @@ -3089,7 +3078,7 @@ def test_public_publish_object_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.public_publish_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) except ApiException as e: assert e.code == 404 @@ -3135,7 +3124,7 @@ def test_create_object_access_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.create_object_access( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, account_identifier=self.account_id, ) except ApiException as e: @@ -3178,7 +3167,7 @@ def test_get_object_access_list_returns_200_when_no_such_object(self): get_object_access_list_response = self.catalog_management_service_authorized.get_object_access_list( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) assert get_object_access_list_response.get_status_code() == 200 @@ -3226,7 +3215,7 @@ def test_get_object_access_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.get_object_access( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, account_identifier=self.account_id, ) except ApiException as e: @@ -3277,7 +3266,7 @@ def test_add_object_access_list_returns_404_when_no_such_object(self): try: self.catalog_management_service_authorized.add_object_access_list( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, accounts=[self.account_id], ) except ApiException as e: @@ -3314,7 +3303,7 @@ def test_create_offering_instance_returns_404_when_no_such_catalog(self): self.catalog_management_service_authorized.create_offering_instance( x_auth_refresh_token=self.refresh_token_authorized, id=offering_id, - catalog_id='invalid-'+catalog_id, + catalog_id='invalid-' + catalog_id, offering_id=offering_id, kind_format=kind_vpe, version='0.0.2', @@ -3417,7 +3406,7 @@ def test_get_offering_instance_returns_404_when_no_such_offering_instance(self): try: self.catalog_management_service_authorized.get_offering_instance( - instance_identifier='invalid-'+offering_instance_id + instance_identifier='invalid-' + offering_instance_id ) except ApiException as e: assert e.code == 404 @@ -3474,7 +3463,7 @@ def test_put_offering_instance_returns_404_when_no_such_catalog(self): instance_identifier=offering_instance_id, x_auth_refresh_token=self.refresh_token_authorized, id=offering_instance_id, - catalog_id='invalid-'+catalog_id, + catalog_id='invalid-' + catalog_id, offering_id=offering_id, kind_format=kind_vpe, version='0.0.3', @@ -3552,7 +3541,7 @@ def test_delete_version_returns_404_when_no_such_version(self): try: self.catalog_management_service_authorized.delete_version( - version_loc_id='invalid-'+version_locator_id, + version_loc_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -3605,7 +3594,7 @@ def test_delete_operators_returns_404_when_no_such_version(self): x_auth_refresh_token=self.refresh_token_authorized, cluster_id=self.cluster_id, region=region_us_south, - version_locator_id='invalid-'+version_locator_id, + version_locator_id='invalid-' + version_locator_id, ) except ApiException as e: assert e.code == 404 @@ -3665,7 +3654,7 @@ def test_delete_offering_instance_returns_404_when_no_such_offering_instance(sel try: self.catalog_management_service_authorized.delete_offering_instance( - instance_identifier='invalid-'+offering_instance_id, + instance_identifier='invalid-' + offering_instance_id, x_auth_refresh_token=self.refresh_token_authorized, ) except ApiException as e: @@ -3708,7 +3697,7 @@ def test_delete_object_access_list_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.delete_object_access_list( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, object_identifier=object_id, accounts=[self.account_id], ) @@ -3755,7 +3744,7 @@ def test_delete_object_access_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.delete_object_access( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, object_identifier=object_id, account_identifier=self.account_id, ) @@ -3799,7 +3788,7 @@ def test_delete_object_returns_200_when_no_such_object(self): delete_object_response = self.catalog_management_service_authorized.delete_object( catalog_identifier=catalog_id, - object_identifier='invalid-'+object_id, + object_identifier='invalid-' + object_id, ) assert delete_object_response.get_status_code() == 200 @@ -3827,7 +3816,7 @@ def test_delete_offering_returns_200_when_no_such_offering(self): delete_offering_response = self.catalog_management_service_authorized.delete_offering( catalog_identifier=catalog_id, - offering_id='invalid-'+offering_id, + offering_id='invalid-' + offering_id, ) assert delete_offering_response.get_status_code() == 200 @@ -3867,7 +3856,7 @@ def test_delete_catalog_returns_404_when_no_such_catalog(self): try: self.catalog_management_service_authorized.delete_catalog( - catalog_identifier='invalid-'+catalog_id, + catalog_identifier='invalid-' + catalog_id, ) except ApiException as e: assert e.code == 404 diff --git a/test/integration/test_context_based_restrictions_v1.py b/test/integration/test_context_based_restrictions_v1.py index e43ab871..b5d6bb69 100644 --- a/test/integration/test_context_based_restrictions_v1.py +++ b/test/integration/test_context_based_restrictions_v1.py @@ -28,7 +28,7 @@ config_file = 'context_based_restrictions_v1.env' -class TestContextBasedRestrictionsV1(): +class TestContextBasedRestrictionsV1: """ Integration Test Class for ContextBasedRestrictionsV1 """ @@ -51,8 +51,7 @@ def setup_class(cls): cls.context_based_restrictions_service = ContextBasedRestrictionsV1.new_instance() assert cls.context_based_restrictions_service is not None - cls.config = read_external_sources( - ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.context_based_restrictions_service.enable_retries() @@ -89,7 +88,7 @@ def test_create_zone(self): account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[ip_address_model, service_ref_address_model], description='SDK TEST - this is an example of zone', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert create_zone_response.get_status_code() == 201 @@ -111,9 +110,8 @@ def test_create_zone_with_duplicated_name_error(self): account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[address_model], description='SDK TEST - this is an example of zone', - transaction_id=self.getTransactionID() - ) - + transaction_id=self.getTransactionID(), + ) @needscredentials def test_create_zone_with_invalid_ip_address_format_error(self): @@ -123,16 +121,14 @@ def test_create_zone_with_invalid_ip_address_format_error(self): 'value': '16.923.562.34', } with pytest.raises(ApiException, match="400"): - self.context_based_restrictions_service.create_zone( + self.context_based_restrictions_service.create_zone( name='SDK TEST - an example of zone', account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[address_model], description='SDK TEST - this is an example of zone', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) - - @needscredentials def test_list_zones(self): list_zones_response = self.context_based_restrictions_service.list_zones( @@ -147,16 +143,15 @@ def test_list_zones(self): @needscredentials def test_list_zones_with_invalid_account_id_parameter_error(self): with pytest.raises(ApiException, match="400"): - self.context_based_restrictions_service.list_zones( - account_id= self.InvalidID, + self.context_based_restrictions_service.list_zones( + account_id=self.InvalidID, transaction_id=self.getTransactionID(), ) @needscredentials def test_get_zone(self): get_zone_response = self.context_based_restrictions_service.get_zone( - zone_id=TestContextBasedRestrictionsV1.zone_id, - transaction_id=self.getTransactionID() + zone_id=TestContextBasedRestrictionsV1.zone_id, transaction_id=self.getTransactionID() ) assert get_zone_response.get_status_code() == 200 @@ -167,12 +162,10 @@ def test_get_zone(self): @needscredentials def test_get_zone_with_zone_not_found_error(self): with pytest.raises(ApiException, match="404"): - self.context_based_restrictions_service.get_zone( - zone_id=self.NonExistentID, - transaction_id=self.getTransactionID() + self.context_based_restrictions_service.get_zone( + zone_id=self.NonExistentID, transaction_id=self.getTransactionID() ) - @needscredentials def test_replace_zone(self): # Construct a dict representation of a AddressIPAddress model @@ -188,7 +181,7 @@ def test_replace_zone(self): account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[address_model], description='SDK TEST - this is an example of updated zone', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert replace_zone_response.get_status_code() == 200 @@ -204,14 +197,14 @@ def test_replace_zone_update_zone_with_zone_not_found_error(self): } with pytest.raises(ApiException, match="404"): - self.context_based_restrictions_service.replace_zone( + self.context_based_restrictions_service.replace_zone( zone_id=self.NonExistentID, if_match=TestContextBasedRestrictionsV1.zone_rev, name='SDK TEST - an example of updated zone', account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[address_model], description='SDK TEST - this is an example of updated zone', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) @needscredentials @@ -230,13 +223,13 @@ def test_replace_zone_update_zone_with_invalid_if_match_parameter_error(self): account_id=TestContextBasedRestrictionsV1.test_account_id, addresses=[address_model], description='SDK TEST - this is an example of updated zone', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) @needscredentials def test_list_available_serviceref_targets(self): - list_available_serviceref_targets_response = self.context_based_restrictions_service.list_available_serviceref_targets( - type='all' + list_available_serviceref_targets_response = ( + self.context_based_restrictions_service.list_available_serviceref_targets(type='all') ) assert list_available_serviceref_targets_response.get_status_code() == 200 @@ -246,9 +239,7 @@ def test_list_available_serviceref_targets(self): @needscredentials def test_list_available_serviceref_targets_list_with_invalid_type_parameter_error(self): with pytest.raises(ApiException, match="400"): - self.context_based_restrictions_service.list_available_serviceref_targets( - type='invalid-type' - ) + self.context_based_restrictions_service.list_available_serviceref_targets(type='invalid-type') @needscredentials def test_create_rule(self): @@ -284,7 +275,7 @@ def test_create_rule(self): resources=[resource_model], description='SDK TEST - this is an example of rule', enforcement_mode='enabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert create_rule_response.get_status_code() == 201 @@ -322,14 +313,10 @@ def test_create_rule_with_api_types(self): } # Construct a dict representation of a NewRuleOperationsApiTypesItem model - api_type_model = { - 'api_type_id': 'crn:v1:bluemix:public:containers-kubernetes::::api-type:management' - } + api_type_model = {'api_type_id': 'crn:v1:bluemix:public:containers-kubernetes::::api-type:management'} # Construct a dict representation of a NewRuleOperations model - operations_model = { - 'api_types': [api_type_model] - } + operations_model = {'api_types': [api_type_model]} create_rule_response = self.context_based_restrictions_service.create_rule( contexts=[rule_context_model], @@ -337,7 +324,7 @@ def test_create_rule_with_api_types(self): operations=operations_model, description='SDK TEST - this is an example of rule', enforcement_mode='enabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert create_rule_response.get_status_code() == 201 @@ -348,7 +335,7 @@ def test_create_rule_with_api_types(self): delete_rule_response = self.context_based_restrictions_service.delete_rule( rule_id=rule['id'], # Using the standard X-Correlation-Id header in this case - x_correlation_id=self.getTransactionID() + x_correlation_id=self.getTransactionID(), ) assert delete_rule_response.get_status_code() == 204 @@ -388,10 +375,9 @@ def test_create_rule_with_service_not_cbr_enabled_error(self): resources=[resource_model], description='SDK TEST - this is an example of rule', enforcement_mode='enabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) - @needscredentials def test_list_rules(self): list_rules_response = self.context_based_restrictions_service.list_rules( @@ -413,7 +399,7 @@ def list_rules_with_missing_required_account_id_parameter_error(self): @needscredentials def list_rules_with_invalid_account_id_parameter_error(self): with pytest.raises(ApiException, match="400"): - self.context_based_restrictions_service.list_rules( + self.context_based_restrictions_service.list_rules( account_id=self.InvalidID, transaction_id=self.getTransactionID(), ) @@ -452,7 +438,7 @@ def test_list_rule_with_service_group_id(self): resources=[resource_model], description='SDK TEST - this is an example of rule with a service group id', enforcement_mode='enabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert create_rule_response.get_status_code() == 201 @@ -474,7 +460,7 @@ def test_list_rule_with_service_group_id(self): delete_rule_response = self.context_based_restrictions_service.delete_rule( rule_id=rule['id'], # Using the standard X-Correlation-Id header in this case - x_correlation_id=self.getTransactionID() + x_correlation_id=self.getTransactionID(), ) assert delete_rule_response.get_status_code() == 204 @@ -482,8 +468,7 @@ def test_list_rule_with_service_group_id(self): @needscredentials def test_get_rule(self): get_rule_response = self.context_based_restrictions_service.get_rule( - rule_id=TestContextBasedRestrictionsV1.rule_id, - transaction_id=self.getTransactionID() + rule_id=TestContextBasedRestrictionsV1.rule_id, transaction_id=self.getTransactionID() ) assert get_rule_response.get_status_code() == 200 @@ -494,9 +479,8 @@ def test_get_rule(self): @needscredentials def test_get_rule_with_rule_not_found_error(self): with pytest.raises(ApiException, match="404"): - self.context_based_restrictions_service.get_rule( - rule_id=self.NonExistentID, - transaction_id=self.getTransactionID() + self.context_based_restrictions_service.get_rule( + rule_id=self.NonExistentID, transaction_id=self.getTransactionID() ) @needscredentials @@ -542,7 +526,7 @@ def test_replace_rule(self): resources=[resource_model], description='SDK TEST - this is an example of updated rule', enforcement_mode='disabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) assert replace_rule_response.get_status_code() == 200 @@ -593,7 +577,7 @@ def test_replace_rule_update_rule_with_rule_not_found_error(self): resources=[resource_model], description='SDK TEST - this is an example of updated rule', enforcement_mode='disabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) @needscredentials @@ -640,14 +624,13 @@ def test_replace_rule_update_rule_with_invalid_if_match_parameter_error(self): resources=[resource_model], description='SDK TEST - this is an example of updated rule', enforcement_mode='disabled', - transaction_id=self.getTransactionID() + transaction_id=self.getTransactionID(), ) @needscredentials def test_get_account_settings(self): get_account_settings_response = self.context_based_restrictions_service.get_account_settings( - account_id=TestContextBasedRestrictionsV1.test_account_id, - transaction_id=self.getTransactionID() + account_id=TestContextBasedRestrictionsV1.test_account_id, transaction_id=self.getTransactionID() ) assert get_account_settings_response.get_status_code() == 200 @@ -658,16 +641,16 @@ def test_get_account_settings(self): def test_get_account_settings_with_invalid_account_id_parameter(self): with pytest.raises(ApiException, match="400"): self.context_based_restrictions_service.get_account_settings( - account_id=self.InvalidID, - transaction_id=self.getTransactionID() + account_id=self.InvalidID, transaction_id=self.getTransactionID() ) @needscredentials def test_list_available_service_operations(self): - list_available_service_operations_response = self.context_based_restrictions_service.list_available_service_operations( - service_name='containers-kubernetes', - transaction_id=self.getTransactionID() + list_available_service_operations_response = ( + self.context_based_restrictions_service.list_available_service_operations( + service_name='containers-kubernetes', transaction_id=self.getTransactionID() + ) ) assert list_available_service_operations_response.get_status_code() == 200 @@ -679,7 +662,7 @@ def test_delete_rule(self): delete_rule_response = self.context_based_restrictions_service.delete_rule( rule_id=TestContextBasedRestrictionsV1.rule_id, # Using the standard X-Correlation-Id header in this case - x_correlation_id=self.getTransactionID() + x_correlation_id=self.getTransactionID(), ) assert delete_rule_response.get_status_code() == 204 @@ -688,16 +671,13 @@ def test_delete_rule(self): def test_delete_rule_with_rule_not_found_error(self): with pytest.raises(ApiException, match="404"): self.context_based_restrictions_service.delete_rule( - rule_id=self.NonExistentID, - transaction_id=self.getTransactionID() + rule_id=self.NonExistentID, transaction_id=self.getTransactionID() ) - @needscredentials def test_delete_zone(self): delete_zone_response = self.context_based_restrictions_service.delete_zone( - zone_id=TestContextBasedRestrictionsV1.zone_id, - transaction_id=self.getTransactionID() + zone_id=TestContextBasedRestrictionsV1.zone_id, transaction_id=self.getTransactionID() ) assert delete_zone_response.get_status_code() == 204 @@ -705,10 +685,9 @@ def test_delete_zone(self): @needscredentials def test_delete_zone_with_zone_not_found_error(self): with pytest.raises(ApiException, match="404"): - self.context_based_restrictions_service.delete_zone( - zone_id=self.NonExistentID, - transaction_id=self.getTransactionID() + self.context_based_restrictions_service.delete_zone( + zone_id=self.NonExistentID, transaction_id=self.getTransactionID() ) def getTransactionID(self): - return "sdk-test-" + str(uuid.uuid4()) \ No newline at end of file + return "sdk-test-" + str(uuid.uuid4()) diff --git a/test/integration/test_enterprise_billing_units_v1.py b/test/integration/test_enterprise_billing_units_v1.py index 717d18aa..3cabfa43 100644 --- a/test/integration/test_enterprise_billing_units_v1.py +++ b/test/integration/test_enterprise_billing_units_v1.py @@ -26,21 +26,20 @@ config_file = 'enterprise_billing_units.env' -class TestEnterpriseBillingUnitsV1(): +class TestEnterpriseBillingUnitsV1: """ Integration Test Class for EnterpriseBillingUnitsV1 """ + @classmethod def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.enterprise_billing_units_service = EnterpriseBillingUnitsV1.new_instance( - ) + cls.enterprise_billing_units_service = EnterpriseBillingUnitsV1.new_instance() assert cls.enterprise_billing_units_service is not None - cls.config = read_external_sources( - EnterpriseBillingUnitsV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(EnterpriseBillingUnitsV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.ENTERPRISE_ID = cls.config.get("ENTERPRISE_ID") @@ -52,19 +51,19 @@ def setup_class(cls): assert cls.ACCOUNT_GROUP_ID is not None assert cls.BILLING_UNIT_ID is not None - print('\nService URL: ', - cls.enterprise_billing_units_service.service_url) + print('\nService URL: ', cls.enterprise_billing_units_service.service_url) print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_get_billing_unit(self): get_billing_unit_response = self.enterprise_billing_units_service.get_billing_unit( - billing_unit_id=self.BILLING_UNIT_ID) + billing_unit_id=self.BILLING_UNIT_ID + ) assert get_billing_unit_response.get_status_code() == 200 billing_unit = get_billing_unit_response.get_result() @@ -75,55 +74,56 @@ def test_get_billing_unit(self): def test_list_billing_units_1(self): list_billing_units_response = self.enterprise_billing_units_service.list_billing_units( - enterprise_id=self.ENTERPRISE_ID) + enterprise_id=self.ENTERPRISE_ID + ) assert list_billing_units_response.get_status_code() == 200 billing_units_list = list_billing_units_response.get_result() assert billing_units_list is not None - print('list_billing_units(enterprise id) result: ', - json.dumps(billing_units_list)) + print('list_billing_units(enterprise id) result: ', json.dumps(billing_units_list)) @needscredentials def test_list_billing_units_2(self): list_billing_units_response = self.enterprise_billing_units_service.list_billing_units( - account_id=self.ACCOUNT_ID) + account_id=self.ACCOUNT_ID + ) assert list_billing_units_response.get_status_code() == 200 billing_units_list = list_billing_units_response.get_result() assert billing_units_list is not None - print('list_billing_units(account id) result: ', - json.dumps(billing_units_list)) + print('list_billing_units(account id) result: ', json.dumps(billing_units_list)) @needscredentials def test_list_billing_units_3(self): list_billing_units_response = self.enterprise_billing_units_service.list_billing_units( - account_group_id=self.ACCOUNT_GROUP_ID) + account_group_id=self.ACCOUNT_GROUP_ID + ) assert list_billing_units_response.get_status_code() == 200 billing_units_list = list_billing_units_response.get_result() assert billing_units_list is not None - print('list_billing_units(account group id) result: ', - json.dumps(billing_units_list)) + print('list_billing_units(account group id) result: ', json.dumps(billing_units_list)) @needscredentials def test_list_billing_options(self): list_billing_options_response = self.enterprise_billing_units_service.list_billing_options( - billing_unit_id=self.BILLING_UNIT_ID) + billing_unit_id=self.BILLING_UNIT_ID + ) assert list_billing_options_response.get_status_code() == 200 billing_options_list = list_billing_options_response.get_result() assert billing_options_list is not None - print('list_billing_options() result: ', - json.dumps(billing_options_list)) + print('list_billing_options() result: ', json.dumps(billing_options_list)) @needscredentials def test_get_credit_pools(self): get_credit_pools_response = self.enterprise_billing_units_service.get_credit_pools( - billing_unit_id=self.BILLING_UNIT_ID, type='PLATFORM') + billing_unit_id=self.BILLING_UNIT_ID, type='PLATFORM' + ) assert get_credit_pools_response.get_status_code() == 200 credit_pools_list = get_credit_pools_response.get_result() diff --git a/test/integration/test_enterprise_management_v1.py b/test/integration/test_enterprise_management_v1.py index 781e0bb0..f9994f79 100644 --- a/test/integration/test_enterprise_management_v1.py +++ b/test/integration/test_enterprise_management_v1.py @@ -36,7 +36,8 @@ first_example_account_group_id = None second_example_account_group_id = None -class TestEnterpriseManagementV1(): + +class TestEnterpriseManagementV1: """ Integration Test Class for EnterpriseManagementV1 """ @@ -49,8 +50,7 @@ def setup_class(cls): cls.enterprise_management_service = EnterpriseManagementV1.new_instance() assert cls.enterprise_management_service is not None - cls.config = read_external_sources( - EnterpriseManagementV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(EnterpriseManagementV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.enterprise_id = cls.config['ENTERPRISE_ID'] @@ -182,7 +182,12 @@ def test_create_account(self): assert first_example_account_group_id is not None - parent = 'crn:v1:bluemix:public:enterprise::a/' + self.account_id + '::account-group:' + first_example_account_group_id + parent = ( + 'crn:v1:bluemix:public:enterprise::a/' + + self.account_id + + '::account-group:' + + first_example_account_group_id + ) create_account_response = self.enterprise_management_service.create_account( parent=parent, @@ -267,7 +272,12 @@ def test_update_account(self): assert example_account_id is not None assert second_example_account_group_id is not None - new_parent = 'crn:v1:bluemix:public:enterprise::a/' + self.account_id + '::account-group:' + second_example_account_group_id + new_parent = ( + 'crn:v1:bluemix:public:enterprise::a/' + + self.account_id + + '::account-group:' + + second_example_account_group_id + ) update_account_response = self.enterprise_management_service.update_account( account_id=example_account_id, @@ -349,4 +359,3 @@ def test_update_enterprise(self): ) assert update_enterprise_response.get_status_code() == 204 - diff --git a/test/integration/test_enterprise_usage_reports_v1.py b/test/integration/test_enterprise_usage_reports_v1.py index 158998c7..fd9d9f9c 100644 --- a/test/integration/test_enterprise_usage_reports_v1.py +++ b/test/integration/test_enterprise_usage_reports_v1.py @@ -26,7 +26,7 @@ config_file = 'enterprise_usage_reports.env' -class TestEnterpriseUsageReportsV1(): +class TestEnterpriseUsageReportsV1: """ Integration Test Class for EnterpriseUsageReportsV1 """ @@ -36,12 +36,10 @@ def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.enterprise_usage_reports_service = EnterpriseUsageReportsV1.new_instance( - ) + cls.enterprise_usage_reports_service = EnterpriseUsageReportsV1.new_instance() assert cls.enterprise_usage_reports_service is not None - cls.config = read_external_sources( - EnterpriseUsageReportsV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(EnterpriseUsageReportsV1.DEFAULT_SERVICE_NAME) assert cls.config is not None # Retrieve and verify some additional test-related config properties. @@ -88,8 +86,7 @@ def test_get_resource_usage_report_enterprise(self): break numReports = len(results) - print( - f'get_resource_usage_report()/enterprise response contained {numReports} total reports.') + print(f'get_resource_usage_report()/enterprise response contained {numReports} total reports.') assert numReports > 0 @needscredentials @@ -121,8 +118,7 @@ def test_get_resource_usage_report_account(self): break numReports = len(results) - print( - f'get_resource_usage_report()/account response contained {numReports} total reports.') + print(f'get_resource_usage_report()/account response contained {numReports} total reports.') assert numReports > 0 @needscredentials @@ -154,8 +150,7 @@ def test_get_resource_usage_report_account_group(self): break numReports = len(results) - print( - f'get_resource_usage_report()/account-group response contained {numReports} total reports.') + print(f'get_resource_usage_report()/account-group response contained {numReports} total reports.') assert numReports > 0 @needscredentials @@ -183,4 +178,6 @@ def test_get_resource_usage_report_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nget_resource_usage_report() returned a total of {len(all_results)} items(s) using GetResourceUsageReportPager.') + print( + f'\nget_resource_usage_report() returned a total of {len(all_results)} items(s) using GetResourceUsageReportPager.' + ) diff --git a/test/integration/test_global_catalog_v1.py b/test/integration/test_global_catalog_v1.py index 71902e8c..f88950d5 100644 --- a/test/integration/test_global_catalog_v1.py +++ b/test/integration/test_global_catalog_v1.py @@ -30,13 +30,13 @@ class TestGlobalCatalogV1(unittest.TestCase): """ Integration Test Class for GlobalCatalogV1 """ + @classmethod def setUpClass(self): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file else: - raise unittest.SkipTest( - 'External configuration not available, skipping...') + raise unittest.SkipTest('External configuration not available, skipping...') self.service = GlobalCatalogV1.new_instance() @@ -49,33 +49,13 @@ def setUpClass(self): 'kind': 'service', 'disabled': False, 'tags': ['a', 'b', 'c'], - 'overview_ui': { - 'en': { - 'display_name': 'display', - 'long_description': 'longDesc', - 'description': 'desc' - } - }, - 'images': { - 'image': 'image', - 'small_image': 'small', - 'medium_image': 'medium', - 'feature_image': 'feature' - }, - 'provider': { - 'email': 'bogus@us.ibm.com', - 'name': 'someName' - }, + 'overview_ui': {'en': {'display_name': 'display', 'long_description': 'longDesc', 'description': 'desc'}}, + 'images': {'image': 'image', 'small_image': 'small', 'medium_image': 'medium', 'feature_image': 'feature'}, + 'provider': {'email': 'bogus@us.ibm.com', 'name': 'someName'}, 'restrictions': 'private', - 'metadata': { - 'pricing': { - 'origin': 'global_catalog' - } - }, + 'metadata': {'pricing': {'origin': 'global_catalog'}}, 'artifactId': 'someArtifactId.json', - 'artifact': { - 'someKey': 'someValue' - } + 'artifact': {'someKey': 'someValue'}, } self.defaultChildEntry = { @@ -86,23 +66,9 @@ def setUpClass(self): 'kind': 'service', 'disabled': False, 'tags': ['a', 'b', 'c'], - 'overview_ui': { - 'en': { - 'display_name': 'display', - 'long_description': 'longDesc', - 'description': 'desc' - } - }, - 'images': { - 'image': 'image', - 'small_image': 'small', - 'medium_image': 'medium', - 'feature_image': 'feature' - }, - 'provider': { - 'email': 'bogus@us.ibm.com', - 'name': 'someName' - } + 'overview_ui': {'en': {'display_name': 'display', 'long_description': 'longDesc', 'description': 'desc'}}, + 'images': {'image': 'image', 'small_image': 'small', 'medium_image': 'medium', 'feature_image': 'feature'}, + 'provider': {'email': 'bogus@us.ibm.com', 'name': 'someName'}, } self.updatedEntry = { @@ -116,28 +82,23 @@ def setUpClass(self): 'en': { 'display_name': 'displayUpdated', 'long_description': 'longDescUpdated', - 'description': 'descUpdated' + 'description': 'descUpdated', } }, 'images': { 'image': 'imageUpdated', 'small_image': 'smallUpdated', 'medium_image': 'mediumUpdated', - 'feature_image': 'featureUpdated' + 'feature_image': 'featureUpdated', }, - 'provider': { - 'email': 'bogus@us.ibm.com', - 'name': 'someNameUpdated' - } + 'provider': {'email': 'bogus@us.ibm.com', 'name': 'someNameUpdated'}, } def setUp(self): - self.service.delete_catalog_entry(id=self.defaultEntry['id'], - force=True) + self.service.delete_catalog_entry(id=self.defaultEntry['id'], force=True) def tearDown(self): - self.service.delete_catalog_entry(id=self.defaultEntry['id'], - force=True) + self.service.delete_catalog_entry(id=self.defaultEntry['id'], force=True) def test_create_catalog_entry(self): env = self.service.create_catalog_entry( @@ -148,7 +109,8 @@ def test_create_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) assert env is not None assert env.get_status_code() == 201 @@ -173,7 +135,8 @@ def test_get_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) env = self.service.get_catalog_entry(id=self.defaultEntry['id']) assert env is not None @@ -200,7 +163,8 @@ def test_update_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) env = self.service.update_catalog_entry( id=self.updatedEntry['id'], @@ -210,7 +174,8 @@ def test_update_catalog_entry(self): images=self.updatedEntry['images'], disabled=self.updatedEntry['disabled'], tags=self.updatedEntry['tags'], - provider=self.updatedEntry['provider']) + provider=self.updatedEntry['provider'], + ) assert env is not None assert env.get_status_code() == 200 @@ -233,10 +198,10 @@ def test_delete_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) - env = self.service.delete_catalog_entry(id=self.defaultEntry['id'], - force=True) + env = self.service.delete_catalog_entry(id=self.defaultEntry['id'], force=True) assert env is not None assert env.get_status_code() == 200 @@ -252,7 +217,8 @@ def test_get_catalog_entry_after_delete_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) self.service.delete_catalog_entry(id=self.defaultEntry['id']) with pytest.raises(ApiException) as e: @@ -282,7 +248,8 @@ def test_update_catalog_entry_failure(self): images=self.updatedEntry['images'], disabled=self.updatedEntry['disabled'], tags=self.updatedEntry['tags'], - provider=self.updatedEntry['provider']) + provider=self.updatedEntry['provider'], + ) assert e.value.code == 404 def test_create_catalog_entry_failure(self): @@ -294,7 +261,8 @@ def test_create_catalog_entry_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) with pytest.raises(ApiException) as e: self.service.create_catalog_entry( @@ -305,7 +273,8 @@ def test_create_catalog_entry_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) assert e.value.code == 409 def test_list_catalog_entries(self): @@ -331,7 +300,8 @@ def test_get_child_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) self.service.create_catalog_entry( id=self.defaultChildEntry['id'], parent_id=self.defaultChildEntry['parent_id'], @@ -341,10 +311,10 @@ def test_get_child_catalog_entry(self): images=self.defaultChildEntry['images'], disabled=self.defaultChildEntry['disabled'], tags=self.defaultChildEntry['tags'], - provider=self.defaultChildEntry['provider']) + provider=self.defaultChildEntry['provider'], + ) - env = self.service.get_child_objects(id=self.defaultEntry['id'], - kind=self.defaultEntry['kind']) + env = self.service.get_child_objects(id=self.defaultEntry['id'], kind=self.defaultEntry['kind']) assert env is not None assert env.get_status_code() == 200 @@ -359,12 +329,10 @@ def test_get_child_catalog_entry(self): assert resources[0].get('id') == self.defaultChildEntry['id'] assert resources[0].get('name') == self.defaultChildEntry['name'] assert resources[0].get('active') == self.defaultChildEntry['active'] - assert resources[0].get( - 'disabled') == self.defaultChildEntry['disabled'] + assert resources[0].get('disabled') == self.defaultChildEntry['disabled'] assert resources[0].get('kind') == self.defaultChildEntry['kind'] assert resources[0].get('images') == self.defaultChildEntry['images'] - assert resources[0].get( - 'provider') == self.defaultChildEntry['provider'] + assert resources[0].get('provider') == self.defaultChildEntry['provider'] assert resources[0].get('tags') == self.defaultChildEntry['tags'] results_obj = EntrySearchResult.from_dict(results) print("get_child_objects() response: ", results_obj) @@ -383,7 +351,8 @@ def test_restore_catalog_entry(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) self.service.delete_catalog_entry(id=self.defaultEntry['id']) env = self.service.restore_catalog_entry(self.defaultEntry['id']) @@ -419,7 +388,8 @@ def test_get_visibility(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) env = self.service.get_visibility(self.defaultEntry['id']) assert env is not None @@ -443,7 +413,8 @@ def test_update_visibility(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) with pytest.raises(ApiException) as e: self.service.update_visibility(id=self.defaultEntry['id']) @@ -463,7 +434,8 @@ def test_get_pricing_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) with pytest.raises(ApiException) as e: self.service.get_pricing(self.defaultEntry['id']) @@ -482,15 +454,17 @@ def test_list_artifacts(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) self.service.upload_artifact( object_id=self.defaultEntry['id'], artifact_id=self.defaultEntry['artifactId'], - artifact=self.defaultEntry['artifact']) + artifact=self.defaultEntry['artifact'], + ) env = self.service.list_artifacts( - object_id=self.defaultEntry['id'], - artifact_id=self.defaultEntry['artifactId']) + object_id=self.defaultEntry['id'], artifact_id=self.defaultEntry['artifactId'] + ) assert env is not None assert env.get_status_code() == 200 @@ -503,8 +477,8 @@ def test_list_artifacts(self): assert len(resources) == 1 assert resources[0].get('name') == self.defaultEntry['artifactId'] assert resources[0].get('url') == '{}/{}/artifacts/{}'.format( - self.service.service_url, self.defaultEntry['id'], - self.defaultEntry['artifactId']) + self.service.service_url, self.defaultEntry['id'], self.defaultEntry['artifactId'] + ) assert resources[0].get('size') == 24 def test_list_artifacts_failure(self): @@ -525,15 +499,15 @@ def test_get_artifact(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) self.service.upload_artifact( object_id=self.defaultEntry['id'], artifact_id=self.defaultEntry['artifactId'], - artifact=self.defaultEntry['artifact']) + artifact=self.defaultEntry['artifact'], + ) - env = self.service.get_artifact( - object_id=self.defaultEntry['id'], - artifact_id=self.defaultEntry['artifactId']) + env = self.service.get_artifact(object_id=self.defaultEntry['id'], artifact_id=self.defaultEntry['artifactId']) assert env is not None assert env.get_status_code() == 200 @@ -550,11 +524,11 @@ def test_get_artifact_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) with pytest.raises(ApiException) as e: - self.service.get_artifact(object_id=self.defaultEntry['id'], - artifact_id='bogus') + self.service.get_artifact(object_id=self.defaultEntry['id'], artifact_id='bogus') assert e.value.code == 404 with pytest.raises(ApiException) as e: @@ -570,12 +544,14 @@ def test_upload_artifact(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) env = self.service.upload_artifact( object_id=self.defaultEntry['id'], artifact_id=self.defaultEntry['artifactId'], - artifact=self.defaultEntry['artifact']) + artifact=self.defaultEntry['artifact'], + ) assert env is not None assert env.get_status_code() == 200 @@ -596,10 +572,10 @@ def test_delete_artifact(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) - env = self.service.delete_artifact(object_id=self.defaultEntry['id'], - artifact_id='bogus') + env = self.service.delete_artifact(object_id=self.defaultEntry['id'], artifact_id='bogus') assert env is not None assert env.get_status_code() == 200 @@ -615,10 +591,10 @@ def test_delete_artifact_failure(self): images=self.defaultEntry['images'], disabled=self.defaultEntry['disabled'], tags=self.defaultEntry['tags'], - provider=self.defaultEntry['provider']) + provider=self.defaultEntry['provider'], + ) - env = self.service.delete_artifact(object_id=self.defaultEntry['id'], - artifact_id='bogus') + env = self.service.delete_artifact(object_id=self.defaultEntry['id'], artifact_id='bogus') assert env is not None assert env.get_status_code() == 200 diff --git a/test/integration/test_global_search_v2.py b/test/integration/test_global_search_v2.py index c60bb52a..dd6c574e 100644 --- a/test/integration/test_global_search_v2.py +++ b/test/integration/test_global_search_v2.py @@ -28,10 +28,11 @@ transaction_id = str(uuid.uuid4()) -class TestGlobalSearchV2(): +class TestGlobalSearchV2: """ Integration Test Class for GlobalSearchV2 """ + @classmethod def setup_class(cls): if os.path.exists(config_file): @@ -43,8 +44,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_search(self): @@ -55,11 +56,8 @@ def test_search(self): while more_results: search_response = self.global_search_service.search( - query='GST-sdk-*', - fields=['*'], - search_cursor=search_cursor, - transaction_id=transaction_id, - limit=1) + query='GST-sdk-*', fields=['*'], search_cursor=search_cursor, transaction_id=transaction_id, limit=1 + ) assert search_response.get_status_code() == 200 scan_result = search_response.get_result() @@ -78,12 +76,10 @@ def test_search(self): @needscredentials def test_get_supported_types(self): - get_supported_types_response = self.global_search_service.get_supported_types( - ) + get_supported_types_response = self.global_search_service.get_supported_types() assert get_supported_types_response.get_status_code() == 200 supported_types_list = get_supported_types_response.get_result() assert supported_types_list is not None - print('get_supported_types() result: ', - json.dumps(supported_types_list, indent=2)) + print('get_supported_types() result: ', json.dumps(supported_types_list, indent=2)) diff --git a/test/integration/test_global_tagging_v1.py b/test/integration/test_global_tagging_v1.py index 0a36abb8..90aa2ef4 100644 --- a/test/integration/test_global_tagging_v1.py +++ b/test/integration/test_global_tagging_v1.py @@ -26,13 +26,14 @@ config_file = 'global_tagging.env' -class TestGlobalTaggingV1(): +class TestGlobalTaggingV1: """ Integration Test Class for GlobalTaggingV1 """ + needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @classmethod def setup_class(cls): @@ -43,8 +44,7 @@ def setup_class(cls): cls.global_tagging_service = GlobalTaggingV1.new_instance() assert cls.global_tagging_service is not None - cls.config = read_external_sources( - GlobalTaggingV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(GlobalTaggingV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.resource_crn = cls.config.get("RESOURCE_CRN") @@ -74,39 +74,31 @@ def teardown_class(cls): def clean_tags(self): print('\nStarted cleaning tags...') # Detach all user and access tags that contain our label. - tag_names = self.get_tag_names_for_resource(self, self.resource_crn, - 'user') + tag_names = self.get_tag_names_for_resource(self, self.resource_crn, 'user') for tag_name in tag_names: if self.sdk_label in tag_name: - print('Detaching user tag {0} from resource {1}'.format( - tag_name, self.resource_crn)) + print('Detaching user tag {0} from resource {1}'.format(tag_name, self.resource_crn)) self.detach_tag(self, self.resource_crn, tag_name, 'user') - tag_names = self.get_tag_names_for_resource(self, self.resource_crn, - 'user') + tag_names = self.get_tag_names_for_resource(self, self.resource_crn, 'user') print('Resource now has these user tags: {0}'.format(tag_names)) - tag_names = self.get_tag_names_for_resource(self, self.resource_crn, - 'access') + tag_names = self.get_tag_names_for_resource(self, self.resource_crn, 'access') for tag_name in tag_names: if self.sdk_label in tag_name: - print('Detaching access tag {0} from resource {1}'.format( - tag_name, self.resource_crn)) + print('Detaching access tag {0} from resource {1}'.format(tag_name, self.resource_crn)) self.detach_tag(self, self.resource_crn, tag_name, 'access') - tag_names = self.get_tag_names_for_resource(self, self.resource_crn, - 'access') + tag_names = self.get_tag_names_for_resource(self, self.resource_crn, 'access') print('Resource now has these access tags: {0}'.format(tag_names)) # Delete all user and access tags that contain our label. tag_names = self.list_tags_with_label(self, 'user', self.sdk_label) - print('Found {0} user tag(s) that contain our label.'.format( - len(tag_names))) + print('Found {0} user tag(s) that contain our label.'.format(len(tag_names))) for tag_name in tag_names: print('Deleting user tag: {0}'.format(tag_name)) self.delete_tag(self, tag_name, 'user') tag_names = self.list_tags_with_label(self, 'access', self.sdk_label) - print('Found {0} access tag(s) that contain our label.'.format( - len(tag_names))) + print('Found {0} access tag(s) that contain our label.'.format(len(tag_names))) for tag_name in tag_names: print('Deleting access tag: {0}'.format(tag_name)) self.delete_tag(self, tag_name, 'access') @@ -114,8 +106,7 @@ def clean_tags(self): print('\nFinished cleaning tags...') def delete_tag(self, tag_name, tag_type): - response = self.global_tagging_service.delete_tag(tag_name=tag_name, - tag_type=tag_type) + response = self.global_tagging_service.delete_tag(tag_name=tag_name, tag_type=tag_type) assert response.get_status_code() == 200 assert response.get_result() is not None delete_tag_results = DeleteTagResults.from_dict(response.get_result()) @@ -126,9 +117,8 @@ def delete_tag(self, tag_name, tag_type): def detach_tag(self, resource_id, tag_name, tag_type): resource_model = {'resource_id': resource_id} response = self.global_tagging_service.detach_tag( - resources=[resource_model], - tag_names=[tag_name], - tag_type=tag_type) + resources=[resource_model], tag_names=[tag_name], tag_type=tag_type + ) assert response.get_status_code() == 200 assert response.get_result() is not None tag_results = TagResults.from_dict(response.get_result()) @@ -138,8 +128,7 @@ def detach_tag(self, resource_id, tag_name, tag_type): def get_tag_names_for_resource(self, resource_id, tag_type): tag_names = [] - response = self.global_tagging_service.list_tags( - attached_to=resource_id, tag_type=tag_type) + response = self.global_tagging_service.list_tags(attached_to=resource_id, tag_type=tag_type) tag_list = TagList.from_dict(response.get_result()) if tag_list.items is not None: for item in tag_list.items: @@ -151,8 +140,7 @@ def list_tags_with_label(self, tag_type, label): offset = 0 more_results = True while more_results: - list_tags_response = self.global_tagging_service.list_tags( - offset=offset, limit=500, tag_type=tag_type) + list_tags_response = self.global_tagging_service.list_tags(offset=offset, limit=500, tag_type=tag_type) assert list_tags_response.get_status_code() == 200 assert list_tags_response.get_result() is not None @@ -170,16 +158,14 @@ def list_tags_with_label(self, tag_type, label): @needscredentials def test_create_tag(self): create_tag_response = self.global_tagging_service.create_tag( - tag_names=[self.access_tag_1, self.access_tag_2], - tag_type='access') + tag_names=[self.access_tag_1, self.access_tag_2], tag_type='access' + ) assert create_tag_response.get_status_code() == 200 assert create_tag_response.get_result() is not None - create_tag_results = CreateTagResults.from_dict( - create_tag_response.get_result()) + create_tag_results = CreateTagResults.from_dict(create_tag_response.get_result()) assert create_tag_results is not None - print('\ncreate_tag() result: ', - json.dumps(create_tag_results.to_dict(), indent=2)) + print('\ncreate_tag() result: ', json.dumps(create_tag_results.to_dict(), indent=2)) assert create_tag_results.results is not None for result in create_tag_results.results: assert result.is_error is False @@ -193,23 +179,20 @@ def test_attach_tag_user(self): } attach_tag_response = self.global_tagging_service.attach_tag( - resources=[resource_model], - tag_names=[self.user_tag_1, self.user_tag_2], - tag_type='user') + resources=[resource_model], tag_names=[self.user_tag_1, self.user_tag_2], tag_type='user' + ) assert attach_tag_response.get_status_code() == 200 assert attach_tag_response.get_result() is not None tag_results = TagResults.from_dict(attach_tag_response.get_result()) assert tag_results is not None - print('\nattach_tag(user) result: ', - json.dumps(tag_results.to_dict(), indent=2)) + print('\nattach_tag(user) result: ', json.dumps(tag_results.to_dict(), indent=2)) for elem in tag_results.results: assert elem.is_error is False # Make sure the tags are in fact attached to the resource. - tag_names = self.get_tag_names_for_resource( - resource_id=self.resource_crn, tag_type='user') + tag_names = self.get_tag_names_for_resource(resource_id=self.resource_crn, tag_type='user') assert self.user_tag_1 in tag_names assert self.user_tag_2 in tag_names @@ -222,23 +205,20 @@ def test_attach_tag_access(self): } attach_tag_response = self.global_tagging_service.attach_tag( - resources=[resource_model], - tag_names=[self.access_tag_1, self.access_tag_2], - tag_type='access') + resources=[resource_model], tag_names=[self.access_tag_1, self.access_tag_2], tag_type='access' + ) assert attach_tag_response.get_status_code() == 200 assert attach_tag_response.get_result() is not None tag_results = TagResults.from_dict(attach_tag_response.get_result()) assert tag_results is not None - print('\nattach_tag(access) result: ', - json.dumps(tag_results.to_dict(), indent=2)) + print('\nattach_tag(access) result: ', json.dumps(tag_results.to_dict(), indent=2)) for elem in tag_results.results: assert elem.is_error is False # Make sure the tags are in fact attached to the resource. - tag_names = self.get_tag_names_for_resource( - resource_id=self.resource_crn, tag_type='access') + tag_names = self.get_tag_names_for_resource(resource_id=self.resource_crn, tag_type='access') assert self.access_tag_1 in tag_names assert self.access_tag_2 in tag_names @@ -248,8 +228,7 @@ def test_list_tags_user(self): offset = 0 more_results = True while more_results: - list_tags_response = self.global_tagging_service.list_tags( - offset=offset, limit=500, tag_type='user') + list_tags_response = self.global_tagging_service.list_tags(offset=offset, limit=500, tag_type='user') assert list_tags_response.get_status_code() == 200 assert list_tags_response.get_result() is not None @@ -267,8 +246,7 @@ def test_list_tags_user(self): for tag in tags: if self.sdk_label in tag.name: matches.append(tag.name) - print('Found {0} user tags containing our label: {1}'.format( - len(matches), matches)) + print('Found {0} user tags containing our label: {1}'.format(len(matches), matches)) @needscredentials def test_list_tags_access(self): @@ -276,8 +254,7 @@ def test_list_tags_access(self): offset = 0 more_results = True while more_results: - list_tags_response = self.global_tagging_service.list_tags( - offset=offset, limit=500, tag_type='access') + list_tags_response = self.global_tagging_service.list_tags(offset=offset, limit=500, tag_type='access') assert list_tags_response.get_status_code() == 200 assert list_tags_response.get_result() is not None @@ -295,8 +272,7 @@ def test_list_tags_access(self): for tag in tags: if self.sdk_label in tag.name: matches.append(tag.name) - print('Found {0} access tags containing our label: {1}'.format( - len(matches), matches)) + print('Found {0} access tags containing our label: {1}'.format(len(matches), matches)) @needscredentials def test_detach_tag_user(self): @@ -305,16 +281,14 @@ def test_detach_tag_user(self): resource_model = {'resource_id': self.resource_crn} detach_tag_response = self.global_tagging_service.detach_tag( - resources=[resource_model], - tag_names=[self.user_tag_1, self.user_tag_2], - tag_type='user') + resources=[resource_model], tag_names=[self.user_tag_1, self.user_tag_2], tag_type='user' + ) assert detach_tag_response.get_status_code() == 200 assert detach_tag_response.get_result() is not None tag_results = TagResults.from_dict(detach_tag_response.get_result()) assert tag_results is not None - print('\ndetach_tag(user) result: ', - json.dumps(tag_results.to_dict(), indent=2)) + print('\ndetach_tag(user) result: ', json.dumps(tag_results.to_dict(), indent=2)) for elem in tag_results.results: assert elem.is_error is False @@ -331,86 +305,71 @@ def test_detach_tag_access(self): resource_model = {'resource_id': self.resource_crn} detach_tag_response = self.global_tagging_service.detach_tag( - resources=[resource_model], - tag_names=[self.access_tag_1, self.access_tag_2], - tag_type='access') + resources=[resource_model], tag_names=[self.access_tag_1, self.access_tag_2], tag_type='access' + ) assert detach_tag_response.get_status_code() == 200 assert detach_tag_response.get_result() is not None tag_results = TagResults.from_dict(detach_tag_response.get_result()) assert tag_results is not None - print('\ndetach_tag(access) result: ', - json.dumps(tag_results.to_dict(), indent=2)) + print('\ndetach_tag(access) result: ', json.dumps(tag_results.to_dict(), indent=2)) for elem in tag_results.results: assert elem.is_error is False # Make sure the tag is in fact attached to the resource - tag_names = self.get_tag_names_for_resource(self.resource_crn, - 'access') + tag_names = self.get_tag_names_for_resource(self.resource_crn, 'access') assert self.access_tag_1 not in tag_names assert self.access_tag_2 not in tag_names @needscredentials def test_delete_tag_user(self): - delete_tag_response = self.global_tagging_service.delete_tag( - tag_name=self.user_tag_1, tag_type='user') + delete_tag_response = self.global_tagging_service.delete_tag(tag_name=self.user_tag_1, tag_type='user') assert delete_tag_response.get_status_code() == 200 assert delete_tag_response.get_result() is not None - delete_tag_results = DeleteTagResults.from_dict( - delete_tag_response.get_result()) + delete_tag_results = DeleteTagResults.from_dict(delete_tag_response.get_result()) assert delete_tag_results is not None - print('\ndelete_tag(user) result: ', - json.dumps(delete_tag_results.to_dict(), indent=2)) + print('\ndelete_tag(user) result: ', json.dumps(delete_tag_results.to_dict(), indent=2)) for item in delete_tag_results.results: assert item.is_error is False @needscredentials def test_delete_tag_access(self): - delete_tag_response = self.global_tagging_service.delete_tag( - tag_name=self.access_tag_1, tag_type='access') + delete_tag_response = self.global_tagging_service.delete_tag(tag_name=self.access_tag_1, tag_type='access') assert delete_tag_response.get_status_code() == 200 assert delete_tag_response.get_result() is not None - delete_tag_results = DeleteTagResults.from_dict( - delete_tag_response.get_result()) + delete_tag_results = DeleteTagResults.from_dict(delete_tag_response.get_result()) assert delete_tag_results is not None - print('\ndelete_tag(access) result: ', - json.dumps(delete_tag_results.to_dict(), indent=2)) + print('\ndelete_tag(access) result: ', json.dumps(delete_tag_results.to_dict(), indent=2)) for item in delete_tag_results.results: assert item.is_error is False @needscredentials def test_delete_tag_all_user(self): - delete_tag_all_response = self.global_tagging_service.delete_tag_all( - tag_type='user') + delete_tag_all_response = self.global_tagging_service.delete_tag_all(tag_type='user') assert delete_tag_all_response.get_status_code() == 200 assert delete_tag_all_response.get_result() is not None - delete_tags_result = DeleteTagsResult.from_dict( - delete_tag_all_response.get_result()) + delete_tags_result = DeleteTagsResult.from_dict(delete_tag_all_response.get_result()) assert delete_tags_result is not None - print('\ndelete_tag_all(user) result: ', - json.dumps(delete_tags_result.to_dict(), indent=2)) + print('\ndelete_tag_all(user) result: ', json.dumps(delete_tags_result.to_dict(), indent=2)) for item in delete_tags_result.items: assert item.is_error is False @needscredentials def test_delete_tag_all_access(self): - delete_tag_all_response = self.global_tagging_service.delete_tag_all( - tag_type='access') + delete_tag_all_response = self.global_tagging_service.delete_tag_all(tag_type='access') assert delete_tag_all_response.get_status_code() == 200 assert delete_tag_all_response.get_result() is not None - delete_tags_result = DeleteTagsResult.from_dict( - delete_tag_all_response.get_result()) + delete_tags_result = DeleteTagsResult.from_dict(delete_tag_all_response.get_result()) assert delete_tags_result is not None - print('\ndelete_tag_all(access) result: ', - json.dumps(delete_tags_result.to_dict(), indent=2)) + print('\ndelete_tag_all(access) result: ', json.dumps(delete_tags_result.to_dict(), indent=2)) for item in delete_tags_result.items: assert item.is_error is False diff --git a/test/integration/test_iam_access_groups_v2.py b/test/integration/test_iam_access_groups_v2.py index 7d30246d..71419cca 100644 --- a/test/integration/test_iam_access_groups_v2.py +++ b/test/integration/test_iam_access_groups_v2.py @@ -29,7 +29,8 @@ # Config file name config_file = 'iam_access_groups_v2.env' -class TestIamAccessGroupsV2(): + +class TestIamAccessGroupsV2: """ Integration Test Class for IamAccessGroupsV2 """ @@ -39,25 +40,24 @@ def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.iam_access_groups_service = IamAccessGroupsV2.new_instance( - ) + cls.iam_access_groups_service = IamAccessGroupsV2.new_instance() assert cls.iam_access_groups_service is not None - cls.config = read_external_sources( - IamAccessGroupsV2.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(IamAccessGroupsV2.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.iam_access_groups_service.enable_retries() - cls.config = read_external_sources( - IamAccessGroupsV2.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(IamAccessGroupsV2.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.testAccountId = cls.config.get('TEST_ACCOUNT_ID') assert cls.testAccountId is not None cls.etagHeader = "ETag" cls.testGroupName = "SDK Test Group - Python" - cls.testGroupDescription = "This group is used for integration test purposes. It can be deleted at any time." + cls.testGroupDescription = ( + "This group is used for integration test purposes. It can be deleted at any time." + ) cls.testGroupETag = "" cls.testGroupId = "" cls.testUserId = "IBMid-" + str(random.randint(0, 99999)) @@ -78,7 +78,8 @@ def teardown_class(cls): # # List all groups in the account(minus the public access group) response = cls.iam_access_groups_service.list_access_groups( - account_id=cls.testAccountId, hide_public_access=True) + account_id=cls.testAccountId, hide_public_access=True + ) assert response is not None assert response.get_status_code() == 200 @@ -97,8 +98,7 @@ def teardown_class(cls): minutesDifference = (now - group.created_at).seconds / 60 if group.id == cls.testGroupId or minutesDifference > 5: - response = cls.iam_access_groups_service.delete_access_group( - access_group_id=group.id, force=True) + response = cls.iam_access_groups_service.delete_access_group(access_group_id=group.id, force=True) assert response is not None assert response.get_status_code() == 204 print('\nClean up complete.') @@ -111,7 +111,8 @@ def test_00_account_id(self): @needscredentials def test_01_create_access_group(self): response = self.iam_access_groups_service.create_access_group( - account_id=self.testAccountId, name=self.testGroupName) + account_id=self.testAccountId, name=self.testGroupName + ) assert response is not None assert response.get_status_code() == 201 @@ -130,8 +131,7 @@ def test_02_get_access_group(self): assert self.testGroupId print("Group ID: ", self.testGroupId) - response = self.iam_access_groups_service.get_access_group( - access_group_id=self.testGroupId) + response = self.iam_access_groups_service.get_access_group(access_group_id=self.testGroupId) assert response is not None assert response.get_status_code() == 200 @@ -154,7 +154,8 @@ def test_03_update_access_group(self): print("Group ID: ", self.testGroupId) response = self.iam_access_groups_service.update_access_group( - access_group_id=self.testGroupId, if_match=self.testGroupETag, description=self.testGroupDescription) + access_group_id=self.testGroupId, if_match=self.testGroupETag, description=self.testGroupDescription + ) assert response is not None assert response.get_status_code() == 200 @@ -173,7 +174,8 @@ def test_04_list_access_groups(self): print("Group ID: ", self.testGroupId) response = self.iam_access_groups_service.list_access_groups( - account_id=self.testAccountId, hide_public_access=True) + account_id=self.testAccountId, hide_public_access=True + ) assert response is not None assert response.get_status_code() == 200 @@ -224,11 +226,11 @@ def test_05_add_members_to_access_group(self): print("Group ID: ", self.testGroupId) print("User ID: ", self.testUserId) - members = [AddGroupMembersRequestMembersItem( - iam_id=self.testUserId, type=self.testUserType)] + members = [AddGroupMembersRequestMembersItem(iam_id=self.testUserId, type=self.testUserType)] response = self.iam_access_groups_service.add_members_to_access_group( - access_group_id=self.testGroupId, members=members) + access_group_id=self.testGroupId, members=members + ) assert response is not None assert response.get_status_code() == 207 @@ -252,11 +254,11 @@ def test_06_add_member_to_multiple_access_groups(self): print("Group ID: ", self.testGroupId) print("User ID: ", self.testUserId) - members = [AddGroupMembersRequestMembersItem( - iam_id=self.testUserId, type=self.testUserType)] + members = [AddGroupMembersRequestMembersItem(iam_id=self.testUserId, type=self.testUserType)] response = self.iam_access_groups_service.add_member_to_multiple_access_groups( - account_id=self.testAccountId, iam_id=self.testUserId, type=self.testUserType, groups=[self.testGroupId]) + account_id=self.testAccountId, iam_id=self.testUserId, type=self.testUserType, groups=[self.testGroupId] + ) assert response is not None assert response.get_status_code() == 207 @@ -281,7 +283,8 @@ def test_07_check_group_membership(self): print("User ID: ", self.testUserId) response = self.iam_access_groups_service.is_member_of_access_group( - access_group_id=self.testGroupId, iam_id=self.testUserId) + access_group_id=self.testGroupId, iam_id=self.testUserId + ) assert response is not None assert response.get_status_code() == 204 @@ -294,8 +297,7 @@ def test_08_list_access_group_members(self): print("Group ID: ", self.testGroupId) print("User ID: ", self.testUserId) - response = self.iam_access_groups_service.list_access_group_members( - access_group_id=self.testGroupId) + response = self.iam_access_groups_service.list_access_group_members(access_group_id=self.testGroupId) assert response is not None assert response.get_status_code() == 200 @@ -336,7 +338,9 @@ def test_08a_list_access_group_members_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_access_group_members() returned a total of {len(all_results)} items(s) using AccessGroupMembersPager.') + print( + f'\nlist_access_group_members() returned a total of {len(all_results)} items(s) using AccessGroupMembersPager.' + ) @needscredentials def test_09_delete_group_membership(self): @@ -345,7 +349,8 @@ def test_09_delete_group_membership(self): print("User ID: ", self.testUserId) response = self.iam_access_groups_service.remove_member_from_access_group( - access_group_id=self.testGroupId, iam_id=self.testUserId) + access_group_id=self.testGroupId, iam_id=self.testUserId + ) assert response is not None assert response.get_status_code() == 204 @@ -360,7 +365,8 @@ def test_10_delete_member_from_all_groups(self): try: response = self.iam_access_groups_service.remove_member_from_all_access_groups( - account_id=self.testAccountId, iam_id=self.testUserId) + account_id=self.testAccountId, iam_id=self.testUserId + ) except ApiException as e: assert e.http_response.status_code == 404 assert e.code == 404 @@ -374,7 +380,8 @@ def test_11_delete_bulk_members_from_access_group(self): try: response = self.iam_access_groups_service.remove_members_from_access_group( - access_group_id=self.testGroupId, members=[self.testUserId]) + access_group_id=self.testGroupId, members=[self.testUserId] + ) except ApiException as e: assert e.http_response.status_code == 404 assert e.code == 404 @@ -391,7 +398,7 @@ def test_12_create_access_group_rule(self): access_group_id=self.testGroupId, expiration=testExpiration, realm_name="test realm name", - conditions=[RuleConditions("test claim", "EQUALS", "1")] + conditions=[RuleConditions("test claim", "EQUALS", "1")], ) assert response is not None assert response.get_status_code() == 201 @@ -415,7 +422,8 @@ def test_13_get_access_group_rule(self): print("Rule ID: ", self.testClaimRuleId) response = self.iam_access_groups_service.get_access_group_rule( - access_group_id=self.testGroupId, rule_id=self.testClaimRuleId) + access_group_id=self.testGroupId, rule_id=self.testClaimRuleId + ) assert response is not None assert response.get_status_code() == 200 @@ -436,8 +444,7 @@ def test_14_list_access_group_rules(self): print("Group ID: ", self.testGroupId) print("Rule ID: ", self.testClaimRuleId) - response = self.iam_access_groups_service.list_access_group_rules( - access_group_id=self.testGroupId) + response = self.iam_access_groups_service.list_access_group_rules(access_group_id=self.testGroupId) assert response is not None assert response.get_status_code() == 200 @@ -470,7 +477,7 @@ def test_15_update_access_group_rule(self): if_match=self.testClaimRuleETag, expiration=testExpiration, realm_name="updated test realm name", - conditions=[RuleConditions("test claim", "EQUALS", "1")] + conditions=[RuleConditions("test claim", "EQUALS", "1")], ) assert response is not None assert response.get_status_code() == 200 @@ -492,7 +499,8 @@ def test_16_delete_access_group_rule(self): print("Rule ID: ", self.testClaimRuleId) response = self.iam_access_groups_service.remove_access_group_rule( - access_group_id=self.testGroupId, rule_id=self.testClaimRuleId) + access_group_id=self.testGroupId, rule_id=self.testClaimRuleId + ) assert response is not None assert response.get_status_code() == 204 @@ -501,8 +509,7 @@ def test_16_delete_access_group_rule(self): @needscredentials def test_17_get_account_settings(self): - response = self.iam_access_groups_service.get_account_settings( - account_id=self.testAccountId) + response = self.iam_access_groups_service.get_account_settings(account_id=self.testAccountId) assert response is not None assert response.get_status_code() == 200 @@ -518,8 +525,7 @@ def test_17_get_account_settings(self): @needscredentials def test_18_update_account_settings(self): response = self.iam_access_groups_service.update_account_settings( - account_id=self.testAccountId, - public_access_enabled=self.testAccountSettings.public_access_enabled + account_id=self.testAccountId, public_access_enabled=self.testAccountSettings.public_access_enabled ) assert response is not None assert response.get_status_code() == 200 diff --git a/test/integration/test_iam_identity_v1.py b/test/integration/test_iam_identity_v1.py index 353bc475..4c7802e6 100644 --- a/test/integration/test_iam_identity_v1.py +++ b/test/integration/test_iam_identity_v1.py @@ -52,7 +52,8 @@ report_reference = None -class TestIamIdentityV1(): + +class TestIamIdentityV1: """ Integration Test Class for IamIdentityV1 """ @@ -66,8 +67,7 @@ def setup_class(cls): assert cls.iam_identity_service is not None assert cls.iam_identity_service.service_url is not None - cls.config = read_external_sources( - IamIdentityV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(IamIdentityV1.DEFAULT_SERVICE_NAME) assert cls.config is not None assert cls.config['URL'] == cls.iam_identity_service.service_url @@ -113,16 +113,12 @@ def cleanup_resources(cls): for apikey in api_key_list['apikeys']: if apikey['name'] == cls.apikey_name: print('>>> deleting apikey: ', apikey['id']) - delete_response = cls.iam_identity_service.delete_api_key( - id=apikey['id'] - ) + delete_response = cls.iam_identity_service.delete_api_key(id=apikey['id']) assert delete_response.get_status_code() == 204 # list serviceIDs response = cls.iam_identity_service.list_service_ids( - account_id=cls.account_id, - name=cls.serviceid_name, - pagesize=100 + account_id=cls.account_id, name=cls.serviceid_name, pagesize=100 ) assert response.get_status_code() == 200 service_id_list = response.get_result() @@ -130,24 +126,18 @@ def cleanup_resources(cls): for serviceid in service_id_list['serviceids']: if serviceid['name'] == cls.serviceid_name: print('>>> deleting serviceid: ', serviceid['id']) - delete_response = cls.iam_identity_service.delete_service_id( - id=serviceid['id'] - ) + delete_response = cls.iam_identity_service.delete_service_id(id=serviceid['id']) assert delete_response.get_status_code() == 204 # list profiles - response = cls.iam_identity_service.list_profiles( - account_id=cls.account_id - ) + response = cls.iam_identity_service.list_profiles(account_id=cls.account_id) assert response.get_status_code() == 200 profile_list = response.get_result() if len(profile_list['profiles']) > 0: for profile in profile_list['profiles']: if profile['name'] == cls.profile_name1 or profile['name'] == cls.profile_name2: print('>>> deleting profile: ', profile['id']) - delete_response = cls.iam_identity_service.delete_profile( - profile_id=profile['id'] - ) + delete_response = cls.iam_identity_service.delete_profile(profile_id=profile['id']) assert delete_response.get_status_code() == 204 print('Finished cleaning up resources!') @@ -175,14 +165,14 @@ def get_profile(self, service, resource_id): def get_claimRule(self, service, profileId, claimRuleId): try: - response = service.get_claim_rule(profile_id=profileId,rule_id=claimRuleId) + response = service.get_claim_rule(profile_id=profileId, rule_id=claimRuleId) return response.get_result() except Exception: return None def get_link(self, service, profileId, linkId): try: - response = service.get_link(profile_id=profileId,link_id=linkId) + response = service.get_link(profile_id=profileId, link_id=linkId) return response.get_result() except Exception: return None @@ -205,7 +195,7 @@ def test_create_api_key1(self): name=self.apikey_name, iam_id=self.iam_id, description='PythonSDK test apikey #1', - account_id=self.account_id + account_id=self.account_id, ) assert create_api_key_response.get_status_code() == 201 @@ -223,7 +213,7 @@ def test_create_api_key2(self): name=self.apikey_name, iam_id=self.iam_id, description='PythonSDK test apikey #2', - account_id=self.account_id + account_id=self.account_id, ) assert create_api_key_response.get_status_code() == 201 @@ -266,15 +256,12 @@ def test_get_api_key(self): @needscredentials def test_get_api_keys_details(self): - get_api_keys_details_response = self.iam_identity_service.get_api_keys_details( - iam_api_key=self.apikey - ) + get_api_keys_details_response = self.iam_identity_service.get_api_keys_details(iam_api_key=self.apikey) assert get_api_keys_details_response.get_status_code() == 200 api_key = get_api_keys_details_response.get_result() assert api_key is not None - print('\nget_api_key_details() response: ', - json.dumps(api_key, indent=2)) + print('\nget_api_key_details() response: ', json.dumps(api_key, indent=2)) assert api_key['iam_id'] == self.iam_id assert api_key['account_id'] == self.account_id @@ -291,16 +278,12 @@ def test_list_api_keys(self): pagetoken_present = True while pagetoken_present: list_api_keys_response = self.iam_identity_service.list_api_keys( - account_id=self.account_id, - iam_id=self.iam_id, - pagesize=1, - pagetoken=pagetoken + account_id=self.account_id, iam_id=self.iam_id, pagesize=1, pagetoken=pagetoken ) assert list_api_keys_response.get_status_code() == 200 api_key_list = list_api_keys_response.get_result() assert api_key_list is not None - print('\nlist_api_keys() response: ', - json.dumps(api_key_list, indent=2)) + print('\nlist_api_keys() response: ', json.dumps(api_key_list, indent=2)) if len(api_key_list['apikeys']) > 0: for apikey in api_key_list['apikeys']: @@ -309,7 +292,7 @@ def test_list_api_keys(self): # fetch pagetoken value pagetoken = self.get_page_token(api_key_list.get('next')) - pagetoken_present = (pagetoken is not None) + pagetoken_present = pagetoken is not None # make sure we retrieved the two apikeys that we created previously. assert len(apikeys) == 2 @@ -324,9 +307,7 @@ def test_update_api_key(self): new_description = 'This is an updated description' update_api_key_response = self.iam_identity_service.update_api_key( - id=apikey_id1, - if_match=apikey_etag1, - description=new_description + id=apikey_id1, if_match=apikey_etag1, description=new_description ) assert update_api_key_response.get_status_code() == 200 @@ -340,14 +321,11 @@ def test_lock_api_key(self): global apikey_id1 assert apikey_id1 is not None - lock_api_key_response = self.iam_identity_service.lock_api_key( - id=apikey_id1 - ) + lock_api_key_response = self.iam_identity_service.lock_api_key(id=apikey_id1) assert lock_api_key_response.get_status_code() == 204 - api_key = self.get_api_key( - self.iam_identity_service, apikey_id1) + api_key = self.get_api_key(self.iam_identity_service, apikey_id1) assert api_key is not None assert api_key['id'] == apikey_id1 assert api_key['locked'] == True @@ -357,9 +335,7 @@ def test_unlock_api_key(self): global apikey_id1 assert apikey_id1 is not None - unlock_api_key_response = self.iam_identity_service.unlock_api_key( - id=apikey_id1 - ) + unlock_api_key_response = self.iam_identity_service.unlock_api_key(id=apikey_id1) assert unlock_api_key_response.get_status_code() == 204 @@ -373,9 +349,7 @@ def test_delete_api_key1(self): global apikey_id1 assert apikey_id1 is not None - delete_api_key_response = self.iam_identity_service.delete_api_key( - id=apikey_id1 - ) + delete_api_key_response = self.iam_identity_service.delete_api_key(id=apikey_id1) assert delete_api_key_response.get_status_code() == 204 @@ -387,9 +361,7 @@ def test_delete_api_key2(self): global apikey_id2 assert apikey_id2 is not None - delete_api_key_response = self.iam_identity_service.delete_api_key( - id=apikey_id2 - ) + delete_api_key_response = self.iam_identity_service.delete_api_key(id=apikey_id2) assert delete_api_key_response.get_status_code() == 204 @@ -407,8 +379,7 @@ def test_create_service_id(self): assert create_service_id_response.get_status_code() == 201 service_id = create_service_id_response.get_result() assert service_id is not None - print('\ncreate_service_id() response: ', - json.dumps(service_id, indent=2)) + print('\ncreate_service_id() response: ', json.dumps(service_id, indent=2)) global serviceid_id1 serviceid_id1 = service_id['id'] @@ -428,8 +399,7 @@ def test_get_service_id(self): assert get_service_id_response.get_status_code() == 200 service_id = get_service_id_response.get_result() assert service_id is not None - print('\nget_service_id() response: ', - json.dumps(service_id, indent=2)) + print('\nget_service_id() response: ', json.dumps(service_id, indent=2)) assert service_id['id'] == serviceid_id1 assert service_id['name'] == self.serviceid_name @@ -442,15 +412,12 @@ def test_get_service_id(self): def test_list_service_ids(self): list_service_ids_response = self.iam_identity_service.list_service_ids( - account_id=self.account_id, - name=self.serviceid_name, - pagesize=100 + account_id=self.account_id, name=self.serviceid_name, pagesize=100 ) assert list_service_ids_response.get_status_code() == 200 service_id_list = list_service_ids_response.get_result() - print('\nlist_service_ids() response: ', - json.dumps(service_id_list, indent=2)) + print('\nlist_service_ids() response: ', json.dumps(service_id_list, indent=2)) assert service_id_list is not None assert len(service_id_list['serviceids']) == 1 @@ -466,16 +433,13 @@ def test_update_service_id(self): new_description = 'This is an updated description' update_service_id_response = self.iam_identity_service.update_service_id( - id=serviceid_id1, - if_match=serviceid_etag1, - description=new_description + id=serviceid_id1, if_match=serviceid_etag1, description=new_description ) assert update_service_id_response.get_status_code() == 200 service_id = update_service_id_response.get_result() assert service_id is not None - print('\nupdate_service_id() response: ', - json.dumps(service_id, indent=2)) + print('\nupdate_service_id() response: ', json.dumps(service_id, indent=2)) assert service_id['description'] == new_description @needscredentials @@ -483,14 +447,11 @@ def test_lock_service_id(self): global serviceid_id1 assert serviceid_id1 is not None - lock_service_id_response = self.iam_identity_service.lock_service_id( - id=serviceid_id1 - ) + lock_service_id_response = self.iam_identity_service.lock_service_id(id=serviceid_id1) assert lock_service_id_response.get_status_code() == 204 - service_id = self.get_service_id( - self.iam_identity_service, serviceid_id1) + service_id = self.get_service_id(self.iam_identity_service, serviceid_id1) assert service_id is not None assert service_id['locked'] == True @@ -499,14 +460,11 @@ def test_unlock_service_id(self): global serviceid_id1 assert serviceid_id1 is not None - unlock_service_id_response = self.iam_identity_service.unlock_service_id( - id=serviceid_id1 - ) + unlock_service_id_response = self.iam_identity_service.unlock_service_id(id=serviceid_id1) assert unlock_service_id_response.get_status_code() == 204 - service_id = self.get_service_id( - self.iam_identity_service, serviceid_id1) + service_id = self.get_service_id(self.iam_identity_service, serviceid_id1) assert service_id is not None assert service_id['locked'] == False @@ -515,22 +473,17 @@ def test_delete_service_id(self): global serviceid_id1 assert serviceid_id1 is not None - delete_service_id_response = self.iam_identity_service.delete_service_id( - id=serviceid_id1 - ) + delete_service_id_response = self.iam_identity_service.delete_service_id(id=serviceid_id1) assert delete_service_id_response.get_status_code() == 204 - service_id = self.get_service_id( - self.iam_identity_service, serviceid_id1) + service_id = self.get_service_id(self.iam_identity_service, serviceid_id1) assert service_id is None @needscredentials def test_create_profile1(self): create_profile_response = self.iam_identity_service.create_profile( - name=self.profile_name1, - description='PythonSDK test profile #1', - account_id=self.account_id + name=self.profile_name1, description='PythonSDK test profile #1', account_id=self.account_id ) assert create_profile_response.get_status_code() == 201 @@ -548,9 +501,7 @@ def test_create_profile1(self): @needscredentials def test_create_profile2(self): create_profile_response = self.iam_identity_service.create_profile( - name=self.profile_name2, - description='PythonSDK test profile #2', - account_id=self.account_id + name=self.profile_name2, description='PythonSDK test profile #2', account_id=self.account_id ) assert create_profile_response.get_status_code() == 201 @@ -595,16 +546,12 @@ def test_list_profiles(self): pagetoken_present = True while pagetoken_present: list_profiles_response = self.iam_identity_service.list_profiles( - account_id=self.account_id, - pagesize=1, - pagetoken=pagetoken, - include_history= False + account_id=self.account_id, pagesize=1, pagetoken=pagetoken, include_history=False ) assert list_profiles_response.get_status_code() == 200 profile_list = list_profiles_response.get_result() assert profile_list is not None - print('\nlist_profiles() response: ', - json.dumps(profile_list, indent=2)) + print('\nlist_profiles() response: ', json.dumps(profile_list, indent=2)) if len(profile_list['profiles']) > 0: for profile in profile_list['profiles']: @@ -612,7 +559,7 @@ def test_list_profiles(self): profiles.append(profile) pagetoken = self.get_page_token(profile_list.get('next')) - pagetoken_present = (pagetoken is not None) + pagetoken_present = pagetoken is not None assert len(profiles) == 2 @@ -626,9 +573,7 @@ def test_update_profile(self): new_description = 'This is an updated description' update_profile_response = self.iam_identity_service.update_profile( - profile_id=profile_id1, - if_match=profile_etag, - description=new_description + profile_id=profile_id1, if_match=profile_etag, description=new_description ) assert update_profile_response.get_status_code() == 200 @@ -642,9 +587,7 @@ def test_delete_profile1(self): global profile_id1 assert profile_id1 is not None - delete_profile_response = self.iam_identity_service.delete_profile( - profile_id=profile_id1 - ) + delete_profile_response = self.iam_identity_service.delete_profile(profile_id=profile_id1) assert delete_profile_response.get_status_code() == 204 @@ -659,11 +602,11 @@ def test_create_claimRule1(self): profile_claim_rule_conditions_model['value'] = '\"cloud-docs-dev\"' create_claimRule_response = self.iam_identity_service.create_claim_rule( - profile_id = profile_id2, - type = self.claimRule_type, - realm_name = self.realm_name, - expiration = 43200, - conditions = [profile_claim_rule_conditions_model] + profile_id=profile_id2, + type=self.claimRule_type, + realm_name=self.realm_name, + expiration=43200, + conditions=[profile_claim_rule_conditions_model], ) assert create_claimRule_response.get_status_code() == 201 @@ -683,11 +626,11 @@ def test_create_claimRule2(self): profile_claim_rule_conditions_model['value'] = '\"Europe_Group\"' create_claimRule_response = self.iam_identity_service.create_claim_rule( - profile_id = profile_id2, - type = self.claimRule_type, - realm_name = self.realm_name, - expiration = 43200, - conditions = [profile_claim_rule_conditions_model] + profile_id=profile_id2, + type=self.claimRule_type, + realm_name=self.realm_name, + expiration=43200, + conditions=[profile_claim_rule_conditions_model], ) assert create_claimRule_response.get_status_code() == 201 @@ -704,10 +647,7 @@ def test_get_claimRule(self): global claimRule_id1 assert claimRule_id1 is not None - get_claimRule_response = self.iam_identity_service.get_claim_rule( - profile_id=profile_id2, - rule_id=claimRule_id1 - ) + get_claimRule_response = self.iam_identity_service.get_claim_rule(profile_id=profile_id2, rule_id=claimRule_id1) assert get_claimRule_response.get_status_code() == 200 claimRule = get_claimRule_response.get_result() @@ -727,14 +667,11 @@ def test_get_claimRule(self): def test_list_claimRules(self): claimRules = [] - list_claimRules_response = self.iam_identity_service.list_claim_rules( - profile_id=profile_id2 - ) + list_claimRules_response = self.iam_identity_service.list_claim_rules(profile_id=profile_id2) assert list_claimRules_response.get_status_code() == 200 claimRule_list = list_claimRules_response.get_result() assert claimRule_list is not None - print('\nlist_claimRules() response: ', - json.dumps(claimRule_list, indent=2)) + print('\nlist_claimRules() response: ', json.dumps(claimRule_list, indent=2)) if len(claimRule_list['rules']) > 0: for claimRule in claimRule_list['rules']: @@ -757,13 +694,13 @@ def test_update_claimRule(self): profile_claim_rule_conditions_model['value'] = '\"Europe_Group\"' update_claimRule_response = self.iam_identity_service.update_claim_rule( - profile_id = profile_id2, - rule_id = claimRule_id1, - if_match = claimRule_etag, - expiration = 33200, - conditions = [profile_claim_rule_conditions_model], - type = self.claimRule_type, - realm_name = self.realm_name + profile_id=profile_id2, + rule_id=claimRule_id1, + if_match=claimRule_etag, + expiration=33200, + conditions=[profile_claim_rule_conditions_model], + type=self.claimRule_type, + realm_name=self.realm_name, ) assert update_claimRule_response.get_status_code() == 200 @@ -777,8 +714,7 @@ def test_delete_claimRule1(self): assert claimRule_id1 is not None delete_claimRule_response = self.iam_identity_service.delete_claim_rule( - profile_id=profile_id2, - rule_id=claimRule_id1 + profile_id=profile_id2, rule_id=claimRule_id1 ) assert delete_claimRule_response.get_status_code() == 204 @@ -792,8 +728,7 @@ def test_delete_claimRule2(self): assert claimRule_id2 is not None delete_claimRule_response = self.iam_identity_service.delete_claim_rule( - profile_id=profile_id2, - rule_id=claimRule_id2 + profile_id=profile_id2, rule_id=claimRule_id2 ) assert delete_claimRule_response.get_status_code() == 204 @@ -804,15 +739,14 @@ def test_delete_claimRule2(self): @needscredentials def test_create_link(self): CreateProfileLinkRequestLink = {} - CreateProfileLinkRequestLink['crn'] = 'crn:v1:staging:public:iam-identity::a/'+ self.account_id +'::computeresource:Fake-Compute-Resource' + CreateProfileLinkRequestLink['crn'] = ( + 'crn:v1:staging:public:iam-identity::a/' + self.account_id + '::computeresource:Fake-Compute-Resource' + ) CreateProfileLinkRequestLink['namespace'] = 'default' CreateProfileLinkRequestLink['name'] = 'nice name' create_link_response = self.iam_identity_service.create_link( - profile_id = profile_id2, - name = 'nice link', - cr_type = 'ROKS_SA', - link = CreateProfileLinkRequestLink + profile_id=profile_id2, name='nice link', cr_type='ROKS_SA', link=CreateProfileLinkRequestLink ) assert create_link_response.get_status_code() == 201 @@ -829,10 +763,7 @@ def test_get_link(self): global link_id assert link_id is not None - get_link_response = self.iam_identity_service.get_link( - profile_id=profile_id2, - link_id=link_id - ) + get_link_response = self.iam_identity_service.get_link(profile_id=profile_id2, link_id=link_id) assert get_link_response.get_status_code() == 200 link = get_link_response.get_result() @@ -848,14 +779,11 @@ def test_get_link(self): def test_list_links(self): links = [] - list_links_response = self.iam_identity_service.list_links( - profile_id=profile_id2 - ) + list_links_response = self.iam_identity_service.list_links(profile_id=profile_id2) assert list_links_response.get_status_code() == 200 links_list = list_links_response.get_result() assert links_list is not None - print('\nlist_links() response: ', - json.dumps(links_list, indent=2)) + print('\nlist_links() response: ', json.dumps(links_list, indent=2)) if len(links_list['links']) > 0: for link in links_list['links']: @@ -869,10 +797,7 @@ def test_delete_link(self): global link_id assert link_id is not None - delete_link_response = self.iam_identity_service.delete_link( - profile_id=profile_id2, - link_id=link_id - ) + delete_link_response = self.iam_identity_service.delete_link(profile_id=profile_id2, link_id=link_id) assert delete_link_response.get_status_code() == 204 @@ -884,9 +809,7 @@ def test_delete_profile2(self): global profile_id2 assert profile_id2 is not None - delete_profile_response = self.iam_identity_service.delete_profile( - profile_id=profile_id2 - ) + delete_profile_response = self.iam_identity_service.delete_profile(profile_id=profile_id2) assert delete_profile_response.get_status_code() == 204 @@ -896,33 +819,23 @@ def test_delete_profile2(self): def test_create_profile_bad_request(self): with pytest.raises(ApiException) as e: self.iam_identity_service.create_profile( - name=self.profile_name1, - description='PythonSDK test profile #1', - account_id='invalid' + name=self.profile_name1, description='PythonSDK test profile #1', account_id='invalid' ) assert e.value.code == 400 def test_get_profile_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.get_profile( - profile_id='invalid' - ) + self.iam_identity_service.get_profile(profile_id='invalid') assert e.value.code == 404 def test_update_profile_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.update_profile( - profile_id='invalid', - if_match='invalid', - description='invalid' - ) + self.iam_identity_service.update_profile(profile_id='invalid', if_match='invalid', description='invalid') assert e.value.code == 404 def test_delete_profile_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.delete_profile( - profile_id='invalid' - ) + self.iam_identity_service.delete_profile(profile_id='invalid') assert e.value.code == 404 def test_create_claimRule_bad_request(self): @@ -932,20 +845,17 @@ def test_create_claimRule_bad_request(self): profile_claim_rule_conditions_model['value'] = '\"cloud-docs-dev\"' with pytest.raises(ApiException) as e: self.iam_identity_service.create_claim_rule( - profile_id = 'invalid', - type = self.claimRule_type, - realm_name = self.realm_name, - expiration = 43200, - conditions = [profile_claim_rule_conditions_model] + profile_id='invalid', + type=self.claimRule_type, + realm_name=self.realm_name, + expiration=43200, + conditions=[profile_claim_rule_conditions_model], ) assert e.value.code == 404 def test_get_claimRule_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.get_claim_rule( - profile_id='invalid', - rule_id='invalid' - ) + self.iam_identity_service.get_claim_rule(profile_id='invalid', rule_id='invalid') assert e.value.code == 404 def test_update_claimRule_not_found(self): @@ -955,52 +865,42 @@ def test_update_claimRule_not_found(self): profile_claim_rule_conditions_model['value'] = '\"Europe_Group\"' with pytest.raises(ApiException) as e: self.iam_identity_service.update_claim_rule( - profile_id = 'invalid', - rule_id = 'invalid', - if_match = 'invalid', - expiration = 33200, - conditions = [profile_claim_rule_conditions_model], - type = self.claimRule_type, - realm_name = self.realm_name + profile_id='invalid', + rule_id='invalid', + if_match='invalid', + expiration=33200, + conditions=[profile_claim_rule_conditions_model], + type=self.claimRule_type, + realm_name=self.realm_name, ) assert e.value.code == 404 def test_delete_claimRule_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.delete_claim_rule( - profile_id='invalid', - rule_id='invalid' - ) + self.iam_identity_service.delete_claim_rule(profile_id='invalid', rule_id='invalid') assert e.value.code == 404 def test_create_link_bad_request(self): CreateProfileLinkRequestLink = {} - CreateProfileLinkRequestLink['crn'] = 'crn:v1:staging:public:iam-identity::a/' + self.account_id + '::computeresource:Fake-Compute-Resource' + CreateProfileLinkRequestLink['crn'] = ( + 'crn:v1:staging:public:iam-identity::a/' + self.account_id + '::computeresource:Fake-Compute-Resource' + ) CreateProfileLinkRequestLink['namespace'] = 'default' CreateProfileLinkRequestLink['name'] = 'nice name' with pytest.raises(ApiException) as e: self.iam_identity_service.create_link( - profile_id = 'invalid', - name = 'nice link', - cr_type = 'ROKS_SA', - link = CreateProfileLinkRequestLink + profile_id='invalid', name='nice link', cr_type='ROKS_SA', link=CreateProfileLinkRequestLink ) assert e.value.code == 404 def test_get_link_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.get_link( - profile_id='invalid', - link_id='invalid' - ) + self.iam_identity_service.get_link(profile_id='invalid', link_id='invalid') assert e.value.code == 404 def test_delete_link_not_found(self): with pytest.raises(ApiException) as e: - self.iam_identity_service.delete_link( - profile_id='invalid', - link_id='invalid' - ) + self.iam_identity_service.delete_link(profile_id='invalid', link_id='invalid') assert e.value.code == 404 @needscredentials @@ -1009,8 +909,7 @@ def test_get_account_settings(self): assert account_setting_etag is None get_account_settings_response = self.iam_identity_service.get_account_settings( - account_id=self.account_id, - include_history=False + account_id=self.account_id, include_history=False ) assert get_account_settings_response.get_status_code() == 200 @@ -1049,8 +948,7 @@ def test_update_account_settings(self): assert update_account_settings_response.get_status_code() == 200 settings = update_account_settings_response.get_result() assert settings is not None - print('\ntest_update_account_settings() response: ', - json.dumps(settings, indent=2)) + print('\ntest_update_account_settings() response: ', json.dumps(settings, indent=2)) assert settings["account_id"] == self.account_id assert settings["restrict_create_service_id"] == "NOT_RESTRICTED" @@ -1077,7 +975,6 @@ def test_create_report(self): assert reportReference is not None print('\ncreate_report() response: ', json.dumps(reportReference, indent=2)) - report_reference = reportReference['reference'] assert report_reference is not None @@ -1100,20 +997,21 @@ def test_get_inactivity_report_complete(self): for x in range(30): get_report_response = self.iam_identity_service.get_report( - account_id=self.account_id, - reference=report_reference, + account_id=self.account_id, + reference=report_reference, ) - if(get_report_response.get_status_code()!=204): - report = get_report_response.get_result() - assert report is not None - assert report['created_by'] is not None - assert report['reference'] is not None - assert report['report_duration'] is not None - assert report['report_start_time'] is not None - assert report['report_end_time'] is not None - break + if get_report_response.get_status_code() != 204: + report = get_report_response.get_result() + assert report is not None + assert report['created_by'] is not None + assert report['reference'] is not None + assert report['report_duration'] is not None + assert report['report_start_time'] is not None + assert report['report_end_time'] is not None + break time.sleep(1) + @needscredentials def test_get_inactivity_report_notfound(self): with pytest.raises(ApiException) as e: @@ -1122,4 +1020,3 @@ def test_get_inactivity_report_notfound(self): reference='test123', ) assert e.value.code == 404 - diff --git a/test/integration/test_iam_policy_management_v1.py b/test/integration/test_iam_policy_management_v1.py index dd59293a..a7fed97c 100644 --- a/test/integration/test_iam_policy_management_v1.py +++ b/test/integration/test_iam_policy_management_v1.py @@ -60,27 +60,27 @@ def setUpClass(cls): cls.testViewerRoleCrn = "crn:v1:bluemix:public:iam::::role:Viewer" cls.testEditorRoleCrn = "crn:v1:bluemix:public:iam::::role:Editor" cls.testServiceName = "iam-groups" - cls.testPolicySubject = PolicySubject(attributes= - [SubjectAttribute(name='iam_id', value=cls.testUserId)]) + cls.testPolicySubject = PolicySubject(attributes=[SubjectAttribute(name='iam_id', value=cls.testUserId)]) cls.testPolicyRole = PolicyRole(role_id=cls.testViewerRoleCrn) - resource_tag = ResourceTag(name='project', value='prototype', - operator='stringEquals') - cls.testPolicyResources = PolicyResource(attributes= - [ResourceAttribute(name='accountId', value=cls.testAccountId, - operator='stringEquals'), - ResourceAttribute(name='serviceType', value='service', - operator='stringEquals')], tags=[resource_tag]) + resource_tag = ResourceTag(name='project', value='prototype', operator='stringEquals') + cls.testPolicyResources = PolicyResource( + attributes=[ + ResourceAttribute(name='accountId', value=cls.testAccountId, operator='stringEquals'), + ResourceAttribute(name='serviceType', value='service', operator='stringEquals'), + ], + tags=[resource_tag], + ) cls.testCustomRoleId = "" cls.testCustomRoleETag = "" cls.testCustomRoleName = 'TestPythonRole' + str(random.randint(0, 99999)) cls.testCustomRole = CustomRole( - name = cls.testCustomRoleName, - display_name = 'SDK Test role', - description = 'SDK Test role description ', - account_id = cls.testAccountId, - service_name = cls.testServiceName, - actions = ['iam-groups.groups.read'] + name=cls.testCustomRoleName, + display_name='SDK Test role', + description='SDK Test role description ', + account_id=cls.testAccountId, + service_name=cls.testServiceName, + actions=['iam-groups.groups.read'], ) print('\nSetup complete.') @@ -90,8 +90,7 @@ def tearDownClass(cls): # Delete all the access policies that we created during the test. # # List all policies in the account for the test user - response = cls.service.list_policies( - account_id=cls.testAccountId, iam_id=cls.testUserId) + response = cls.service.list_policies(account_id=cls.testAccountId, iam_id=cls.testUserId) assert response is not None assert response.get_status_code() == 200 @@ -107,8 +106,7 @@ def tearDownClass(cls): minutesDifference = (now - policy.created_at).seconds / 60 if policy.id == cls.testPolicyId or minutesDifference < 5: - response = cls.service.delete_policy( - policy_id=policy.id) + response = cls.service.delete_policy(policy_id=policy.id) assert response is not None assert response.get_status_code() == 204 @@ -125,10 +123,12 @@ def test_00_account_id(self): print('\nTest account id: ', self.testAccountId) def test_01_create_access_policy(self): - response = self.service.create_policy(type='access', - subjects=[self.testPolicySubject], - roles=[self.testPolicyRole], - resources=[self.testPolicyResources]) + response = self.service.create_policy( + type='access', + subjects=[self.testPolicySubject], + roles=[self.testPolicyRole], + resources=[self.testPolicyResources], + ) assert response is not None assert response.get_status_code() == 201 @@ -173,11 +173,13 @@ def test_03_update_access_policy(self): self.testPolicyRole.role_id = self.testEditorRoleCrn response = self.service.update_policy( - policy_id=self.testPolicyId, if_match=self.testPolicyETag, + policy_id=self.testPolicyId, + if_match=self.testPolicyETag, type='access', subjects=[self.testPolicySubject], roles=[self.testPolicyRole], - resources=[self.testPolicyResources]) + resources=[self.testPolicyResources], + ) assert response is not None assert response.get_status_code() == 200 @@ -196,8 +198,7 @@ def test_03_update_access_policy(self): def test_04_list_access_policies(self): print("Policy ID: ", self.testPolicyId) - response = self.service.list_policies( - account_id=self.testAccountId, iam_id=self.testUserId) + response = self.service.list_policies(account_id=self.testAccountId, iam_id=self.testUserId) assert response is not None assert response.get_status_code() == 200 @@ -224,8 +225,8 @@ def test_05_create_custom_role(self): service_name=self.testCustomRole.service_name, display_name=self.testCustomRole.display_name, description=self.testCustomRole.description, - actions=self.testCustomRole.actions - ) + actions=self.testCustomRole.actions, + ) assert response is not None assert response.get_status_code() == 201 @@ -275,7 +276,8 @@ def test_07_update_custom_role(self): if_match=self.testCustomRoleETag, display_name='Updated ' + self.testCustomRole.display_name, description='Updated ' + self.testCustomRole.description, - actions=self.testCustomRole.actions) + actions=self.testCustomRole.actions, + ) assert response is not None assert response.get_status_code() == 200 @@ -295,8 +297,8 @@ def test_08_list_custom_roles(self): print("Custom Role ID: ", self.testCustomRoleId) response = self.service.list_roles( - account_id=self.testCustomRole.account_id, - service_name=self.testCustomRole.service_name) + account_id=self.testCustomRole.account_id, service_name=self.testCustomRole.service_name + ) assert response is not None assert response.get_status_code() == 200 @@ -321,9 +323,7 @@ def test_09_patch_access_policy(self): assert self.testPolicyETag print("Policy ID: ", self.testPolicyId) - response = self.service.patch_policy( - policy_id=self.testPolicyId, if_match=self.testPolicyETag, - state='active') + response = self.service.patch_policy(policy_id=self.testPolicyId, if_match=self.testPolicyETag, state='active') assert response is not None assert response.get_status_code() == 200 diff --git a/test/integration/test_ibm_cloud_shell_v1.py b/test/integration/test_ibm_cloud_shell_v1.py index c323ab0b..e6eeb75a 100644 --- a/test/integration/test_ibm_cloud_shell_v1.py +++ b/test/integration/test_ibm_cloud_shell_v1.py @@ -26,6 +26,7 @@ # Config file name config_file = 'ibm_cloud_shell_v1.env' + class IbmCloudShellV1IntegrationTests(unittest.TestCase): """ Integration Test Class for IbmCloudShellV1 @@ -36,12 +37,10 @@ def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.ibm_cloud_shell_service = IbmCloudShellV1.new_instance( - ) + cls.ibm_cloud_shell_service = IbmCloudShellV1.new_instance() assert cls.ibm_cloud_shell_service is not None - cls.config = read_external_sources( - IbmCloudShellV1.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(IbmCloudShellV1.DEFAULT_SERVICE_NAME) assert cls.config is not None cls.ACCOUNT_ID = cls.config['ACCOUNT_ID'] @@ -56,9 +55,7 @@ def setup_class(cls): @needscredentials def test_get_account_settings(self): - get_account_settings_response = self.ibm_cloud_shell_service.get_account_settings( - account_id=self.ACCOUNT_ID - ) + get_account_settings_response = self.ibm_cloud_shell_service.get_account_settings(account_id=self.ACCOUNT_ID) assert get_account_settings_response.get_status_code() == 200 account_settings = get_account_settings_response.get_result() @@ -67,37 +64,39 @@ def test_get_account_settings(self): @needscredentials def test_update_account_settings(self): - get_account_settings_response = self.ibm_cloud_shell_service.get_account_settings( - account_id=self.ACCOUNT_ID - ) + get_account_settings_response = self.ibm_cloud_shell_service.get_account_settings(account_id=self.ACCOUNT_ID) assert get_account_settings_response.get_status_code() == 200 existing_account_settings = get_account_settings_response.get_result() assert existing_account_settings is not None # Construct a dict representation of a Feature model - feature_model = [{ - 'enabled': False, - 'key': 'server.file_manager', - }, - { - 'enabled': True, - 'key': 'server.web_preview', - }] + feature_model = [ + { + 'enabled': False, + 'key': 'server.file_manager', + }, + { + 'enabled': True, + 'key': 'server.web_preview', + }, + ] # Construct a dict representation of a RegionSetting model - region_setting_model = [{ - 'enabled': True, - 'key': 'eu-de', - }, - { - 'enabled': False, - 'key': 'jp-tok', - }, - { - 'enabled': False, - 'key': 'us-south', - }] + region_setting_model = [ + { + 'enabled': True, + 'key': 'eu-de', + }, + { + 'enabled': False, + 'key': 'jp-tok', + }, + { + 'enabled': False, + 'key': 'us-south', + }, + ] update_account_settings_response = self.ibm_cloud_shell_service.update_account_settings( account_id=self.ACCOUNT_ID, @@ -106,7 +105,7 @@ def test_update_account_settings(self): default_enable_new_regions=True, enabled=True, features=feature_model, - regions=region_setting_model + regions=region_setting_model, ) assert update_account_settings_response.get_status_code() == 200 @@ -117,5 +116,3 @@ def test_update_account_settings(self): assert account_settings.get('enabled') == True assert account_settings.get('features') == feature_model assert account_settings.get('regions') == region_setting_model - - diff --git a/test/integration/test_open_service_broker_v1.py b/test/integration/test_open_service_broker_v1.py index 921fffcf..c2e33e56 100644 --- a/test/integration/test_open_service_broker_v1.py +++ b/test/integration/test_open_service_broker_v1.py @@ -41,8 +41,7 @@ def setUpClass(cls): if os.path.exists(configFile): os.environ['IBM_CREDENTIALS_FILE'] = configFile else: - raise unittest.SkipTest( - 'External configuration not available, skipping...') + raise unittest.SkipTest('External configuration not available, skipping...') cls.service = OpenServiceBrokerV1.new_instance() assert cls.service is not None @@ -55,10 +54,14 @@ def setUpClass(cls): cls.testPlanId1 = 'a10e4820-3685-11e9-b210-d663bd873d93' cls.testPlanId2 = 'a10e4410-3685-11e9-b210-d663bd873d933' cls.testPlanId3 = 'a10e4960-3685-11e9-b210-d663bd873d93' - cls.testInstanceId = 'crn:v1:staging:public:bss-monitor:global:a/bc2b2fca0af84354a916dc1de6eee42e:sdkTestInstance::' + cls.testInstanceId = ( + 'crn:v1:staging:public:bss-monitor:global:a/bc2b2fca0af84354a916dc1de6eee42e:sdkTestInstance::' + ) cls.testInstanceId2 = 'crn:v1:staging:public:bss-monitor:us-south:a/bc2b2fca0af84354a916dc1de6eee42e:osb-sdk-test00:resource-binding:osb-sdk-binding-test00' cls.testBindingId = 'crn:v1:staging:public:bss-monitor:us-south:a/bc2b2fca0af84354a916dc1de6eee42e:sdkTestInstance:resource-binding:sdkTestBinding' - cls.testBindingId2 = 'crnL:v1:staging:public:bss-monitor:global:a/bc2b2fca0af84354a916dc1de6eee42e:osb-sdk-test00::' + cls.testBindingId2 = ( + 'crnL:v1:staging:public:bss-monitor:global:a/bc2b2fca0af84354a916dc1de6eee42e:osb-sdk-test00::' + ) cls.testPlatform = 'ibmcloud' cls.testReasonCode = 'test_reason' @@ -78,11 +81,9 @@ def setUpClass(cls): def test_00_create_service_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test00-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test00-" + self.transactionId - testContext = Context(account_id=self.testAccountId, - crn=self.testInstanceId, platform=self.testPlatform) + testContext = Context(account_id=self.testAccountId, crn=self.testInstanceId, platform=self.testPlatform) testPars = {} response = self.service.replace_service_instance( @@ -94,7 +95,7 @@ def test_00_create_service_instance(self): context=testContext, parameters=testPars, accepts_incomplete=True, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -106,11 +107,9 @@ def test_00_create_service_instance(self): def test_01_update_service_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test01-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test01-" + self.transactionId - testContext = Context(account_id=self.testAccountId, - crn=self.testInstanceId, platform=self.testPlatform) + testContext = Context(account_id=self.testAccountId, crn=self.testInstanceId, platform=self.testPlatform) testPars = {} testPrevValues = {} @@ -122,7 +121,7 @@ def test_01_update_service_instance(self): plan_id=self.testPlanId1, previous_values=testPrevValues, accepts_incomplete=True, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -135,15 +134,14 @@ def test_01_update_service_instance(self): def test_02_disable_service_instance_state(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test02-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test02-" + self.transactionId response = self.service.replace_service_instance_state( instance_id=self.testInstanceId, enabled=False, initiator_id=self.testInitiatorId, reason_code=self.testReasonCode, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -156,15 +154,14 @@ def test_02_disable_service_instance_state(self): def test_03_enable_service_instance_state(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test03-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test03-" + self.transactionId response = self.service.replace_service_instance_state( instance_id=self.testInstanceId, enabled=True, initiator_id=self.testInitiatorId, reason_code=self.testReasonCode, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -177,11 +174,9 @@ def test_03_enable_service_instance_state(self): def test_04_bind_service_instance_state(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test04-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test04-" + self.transactionId testParams = {} - testBindResource = BindResource( - account_id=self.testAccountId, serviceid_crn=self.testAppGuid) + testBindResource = BindResource(account_id=self.testAccountId, serviceid_crn=self.testAppGuid) response = self.service.replace_service_binding( binding_id=self.testBindingId2, @@ -190,7 +185,7 @@ def test_04_bind_service_instance_state(self): service_id=self.testServiceId, bind_resource=testBindResource, parameters=testParams, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -202,13 +197,9 @@ def test_04_bind_service_instance_state(self): def test_05_get_service_instance_state(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test05-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test05-" + self.transactionId - response = self.service.get_service_instance_state( - instance_id=self.testInstanceId, - headers=customHeaders - ) + response = self.service.get_service_instance_state(instance_id=self.testInstanceId, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -220,12 +211,9 @@ def test_05_get_service_instance_state(self): def test_06_get_catalog_metadata(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test06-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test06-" + self.transactionId - response = self.service.list_catalog( - headers=customHeaders - ) + response = self.service.list_catalog(headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -239,15 +227,14 @@ def test_06_get_catalog_metadata(self): def test_07_delete_service_binding(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test07-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test07-" + self.transactionId response = self.service.delete_service_binding( binding_id=self.testBindingId2, instance_id=self.testInstanceId2, plan_id=self.testPlanId3, service_id=self.testServiceId, - headers=customHeaders + headers=customHeaders, ) assert response is not None @@ -255,14 +242,13 @@ def test_07_delete_service_binding(self): def test_08_delete_service_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "osb-sdk-python-test08-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "osb-sdk-python-test08-" + self.transactionId response = self.service.delete_service_instance( service_id=self.testServiceId, plan_id=self.testPlanId3, instance_id=self.testInstanceId2, - headers=customHeaders + headers=customHeaders, ) assert response is not None diff --git a/test/integration/test_resource_controller_v2.py b/test/integration/test_resource_controller_v2.py index 25bc1fa6..da2f73d2 100644 --- a/test/integration/test_resource_controller_v2.py +++ b/test/integration/test_resource_controller_v2.py @@ -43,8 +43,7 @@ def setup_class(cls): if os.path.exists(configFile): os.environ['IBM_CREDENTIALS_FILE'] = configFile - cls.config = read_external_sources( - ResourceControllerV2.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(ResourceControllerV2.DEFAULT_SERVICE_NAME) cls.testAccountId = cls.config['ACCOUNT_ID'] cls.testResourceGroupGuid = cls.config['RESOURCE_GROUP'] cls.testOrgGuid = cls.config['ORGANIZATION_GUID'] @@ -54,8 +53,7 @@ def setup_class(cls): cls.testPlanId2 = cls.config['RECLAMATION_PLAN_ID'] else: - raise unittest.SkipTest( - 'External configuration not available, skipping...') + raise unittest.SkipTest('External configuration not available, skipping...') cls.resource_controller_service = ResourceControllerV2.new_instance() assert cls.resource_controller_service is not None @@ -81,14 +79,15 @@ def setup_class(cls): cls.reclaimInstanceName = 'RcSdkReclaimInstance1' cls.lockedInstanceNameUpdate = 'RcSdkLockedInstanceUpdate1' - cls.instanceNames = {'name': 'RcSdkInstance1Python', - 'update': 'RcSdkInstanceUpdate1Python'} - cls.keyNames = {'name': 'RcSdkKey1Python', 'update': 'RcSdkKeyUpdate1Python', - 'name2': 'RcSdkKey2Python', 'update2': 'RcSdkKeyUpdate2Python'} - cls.bindingNames = {'name': 'RcSdkBinding1Python', - 'update': 'RcSdkBindingUpdate1Python'} - cls.aliasNames = {'name': 'RcSdkAlias1Python', - 'update': 'RcSdkAliasUpdate1Python'} + cls.instanceNames = {'name': 'RcSdkInstance1Python', 'update': 'RcSdkInstanceUpdate1Python'} + cls.keyNames = { + 'name': 'RcSdkKey1Python', + 'update': 'RcSdkKeyUpdate1Python', + 'name2': 'RcSdkKey2Python', + 'update2': 'RcSdkKeyUpdate2Python', + } + cls.bindingNames = {'name': 'RcSdkBinding1Python', 'update': 'RcSdkBindingUpdate1Python'} + cls.aliasNames = {'name': 'RcSdkAlias1Python', 'update': 'RcSdkAliasUpdate1Python'} cls.transactionId = str(uuid.uuid4()) print('\nTransaction-Id for Test Run: ' + cls.transactionId) @@ -106,15 +105,14 @@ def teardown_class(cls): def test_00_create_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test00-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test00-" + self.transactionId response = self.resource_controller_service.create_resource_instance( self.instanceNames['name'], self.testRegionId1, self.testResourceGroupGuid, self.testPlanId1, - headers=customHeaders + headers=customHeaders, ) assert response is not None assert response.get_status_code() == 201 @@ -142,11 +140,9 @@ def test_00_create_resource_instance(self): def test_01_get_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test01-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test01-" + self.transactionId - response = self.resource_controller_service.get_resource_instance( - self.testInstanceGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_instance(self.testInstanceGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -167,17 +163,13 @@ def test_01_get_resource_instance(self): def test_02_update_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test02-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test02-" + self.transactionId params = {} params["hello"] = "bye" response = self.resource_controller_service.update_resource_instance( - self.testInstanceGuid, - name=self.instanceNames['update'], - parameters=params, - headers=customHeaders + self.testInstanceGuid, name=self.instanceNames['update'], parameters=params, headers=customHeaders ) assert response is not None assert response.get_status_code() == 200 @@ -193,16 +185,14 @@ def test_02_update_resource_instance(self): def test_03_list_resource_instances_no_filter(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test03-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test03-" + self.transactionId start = None while True: response = self.resource_controller_service.list_resource_instances( - limit=results_per_page, - start=start, - headers=customHeaders) + limit=results_per_page, start=start, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -220,11 +210,11 @@ def test_03_list_resource_instances_no_filter(self): def test_04_list_resource_instances_by_guid(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test04-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test04-" + self.transactionId response = self.resource_controller_service.list_resource_instances( - guid=self.testInstanceGuid, headers=customHeaders) + guid=self.testInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -244,12 +234,11 @@ def test_04_list_resource_instances_by_guid(self): def test_05_list_resource_instances_by_name(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test05-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test05-" + self.transactionId response = self.resource_controller_service.list_resource_instances( - name=self.instanceNames['update'], - headers=customHeaders) + name=self.instanceNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -280,24 +269,22 @@ def test_05a_list_resource_instances_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_resource_instances() returned a total of {len(all_results)} items(s) using ResourceInstancesPager.') + print( + f'\nlist_resource_instances() returned a total of {len(all_results)} items(s) using ResourceInstancesPager.' + ) def test_06_create_resource_alias(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test06-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test06-" + self.transactionId - target = "crn:v1:bluemix:public:bluemix:us-south:o/" + \ - self.testOrgGuid + "::cf-space:" + self.testSpaceGuid - self.__class__.aliasTargetCrn = "crn:v1:bluemix:public:cf:us-south:o/" + \ - self.testOrgGuid + "::cf-space:" + self.testSpaceGuid + target = "crn:v1:bluemix:public:bluemix:us-south:o/" + self.testOrgGuid + "::cf-space:" + self.testSpaceGuid + self.__class__.aliasTargetCrn = ( + "crn:v1:bluemix:public:cf:us-south:o/" + self.testOrgGuid + "::cf-space:" + self.testSpaceGuid + ) assert self.aliasTargetCrn != '' response = self.resource_controller_service.create_resource_alias( - self.aliasNames['name'], - self.testInstanceGuid, - target, - headers=customHeaders + self.aliasNames['name'], self.testInstanceGuid, target, headers=customHeaders ) assert response is not None assert response.get_status_code() == 201 @@ -322,11 +309,9 @@ def test_06_create_resource_alias(self): def test_07_get_resource_alias(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test07-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test07-" + self.transactionId - response = self.resource_controller_service.get_resource_alias( - self.testAliasGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_alias(self.testAliasGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -344,13 +329,10 @@ def test_07_get_resource_alias(self): def test_08_update_resource_alias(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test08-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test08-" + self.transactionId response = self.resource_controller_service.update_resource_alias( - self.testAliasGuid, - name=self.aliasNames['update'], - headers=customHeaders + self.testAliasGuid, name=self.aliasNames['update'], headers=customHeaders ) assert response is not None assert response.get_status_code() == 200 @@ -363,16 +345,14 @@ def test_08_update_resource_alias(self): def test_09_list_resource_aliases_no_filter(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test09-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test09-" + self.transactionId start = None while True: response = self.resource_controller_service.list_resource_aliases( - limit=results_per_page, - start=start, - headers=customHeaders) + limit=results_per_page, start=start, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -390,11 +370,11 @@ def test_09_list_resource_aliases_no_filter(self): def test_10_list_resource_aliases_by_guid(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test10-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test10-" + self.transactionId response = self.resource_controller_service.list_resource_aliases( - guid=self.testAliasGuid, headers=customHeaders) + guid=self.testAliasGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -414,12 +394,11 @@ def test_10_list_resource_aliases_by_guid(self): def test_11_list_resource_aliases_by_name(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test11-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test11-" + self.transactionId response = self.resource_controller_service.list_resource_aliases( - name=self.aliasNames['update'], - headers=customHeaders) + name=self.aliasNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -458,9 +437,8 @@ def test_11b_list_resource_aliases_for_instance(self): while True: response = self.resource_controller_service.list_resource_aliases_for_instance( - id=self.testInstanceGuid, - limit=results_per_page, - start=start) + id=self.testInstanceGuid, limit=results_per_page, start=start + ) assert response is not None assert response.get_status_code() == 200 @@ -497,22 +475,22 @@ def test_11c_list_resource_aliases_for_instance_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_resource_aliases_for_instance() returned a total of {len(all_results)} items(s) using ResourceAliasesForInstancePager.') + print( + f'\nlist_resource_aliases_for_instance() returned a total of {len(all_results)} items(s) using ResourceAliasesForInstancePager.' + ) def test_12_create_resource_binding(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test12-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test12-" + self.transactionId - parameters = { - 'parameter1': 'value1', - 'parameter2': 'value2' - } + parameters = {'parameter1': 'value1', 'parameter2': 'value2'} - target = "crn:v1:staging:public:bluemix:us-south:s/" + \ - self.testSpaceGuid + "::cf-application:" + self.testAppGuid - self.__class__.bindTargetCrn = "crn:v1:staging:public:cf:us-south:s/" + \ - self.testSpaceGuid + "::cf-application:" + self.testAppGuid + target = ( + "crn:v1:staging:public:bluemix:us-south:s/" + self.testSpaceGuid + "::cf-application:" + self.testAppGuid + ) + self.__class__.bindTargetCrn = ( + "crn:v1:staging:public:cf:us-south:s/" + self.testSpaceGuid + "::cf-application:" + self.testAppGuid + ) assert self.bindTargetCrn != '' response = self.resource_controller_service.create_resource_binding( @@ -520,7 +498,7 @@ def test_12_create_resource_binding(self): target=target, name=self.bindingNames['name'], parameters=parameters, - headers=customHeaders + headers=customHeaders, ) assert response is not None assert response.get_status_code() == 201 @@ -545,11 +523,9 @@ def test_12_create_resource_binding(self): def test_13_get_resource_binding(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test13-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test13-" + self.transactionId - response = self.resource_controller_service.get_resource_binding( - self.testBindingGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_binding(self.testBindingGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -567,13 +543,11 @@ def test_13_get_resource_binding(self): def test_14_update_resource_binding(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test14-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test14-" + self.transactionId response = self.resource_controller_service.update_resource_binding( - self.testBindingGuid, - self.bindingNames['update'], - headers=customHeaders) + self.testBindingGuid, self.bindingNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -585,16 +559,14 @@ def test_14_update_resource_binding(self): def test_15_list_resource_bindings_no_filter(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test15-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test15-" + self.transactionId start = None while True: response = self.resource_controller_service.list_resource_bindings( - limit=results_per_page, - start=start, - headers=customHeaders) + limit=results_per_page, start=start, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -612,11 +584,11 @@ def test_15_list_resource_bindings_no_filter(self): def test_16_list_resource_bindings_by_guid(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test16-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test16-" + self.transactionId response = self.resource_controller_service.list_resource_bindings( - guid=self.testBindingGuid, headers=customHeaders) + guid=self.testBindingGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -636,12 +608,11 @@ def test_16_list_resource_bindings_by_guid(self): def test_17_list_resource_bindings_by_name(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test17-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test17-" + self.transactionId response = self.resource_controller_service.list_resource_bindings( - name=self.bindingNames['update'], - headers=customHeaders) + name=self.bindingNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -666,12 +637,14 @@ def test_17a_list_resource_bindings_with_pager(self): # Test get_all(). pager = ResourceBindingsPager( client=self.resource_controller_service, - ) + ) all_items = pager.get_all() assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_resource_bindings() returned a total of {len(all_results)} items(s) using ResourceBindingsPager.') + print( + f'\nlist_resource_bindings() returned a total of {len(all_results)} items(s) using ResourceBindingsPager.' + ) def test_17b_list_resource_bindings_for_alias(self): assert self.testAliasGuid is not None @@ -680,9 +653,8 @@ def test_17b_list_resource_bindings_for_alias(self): while True: response = self.resource_controller_service.list_resource_bindings_for_alias( - id=self.testAliasGuid, - limit=results_per_page, - start=start) + id=self.testAliasGuid, limit=results_per_page, start=start + ) assert response is not None assert response.get_status_code() == 200 @@ -719,23 +691,19 @@ def test_17c_list_resource_bindings_for_alias_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_resource_bindings_for_alias() returned a total of {len(all_results)} items(s) using ResourceBindingsForAliasPager.') + print( + f'\nlist_resource_bindings_for_alias() returned a total of {len(all_results)} items(s) using ResourceBindingsForAliasPager.' + ) def test_18_create_resource_key_for_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test18-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test18-" + self.transactionId - parameters = { - 'parameter1': 'value1', - 'parameter2': 'value2' - } + parameters = {'parameter1': 'value1', 'parameter2': 'value2'} response = self.resource_controller_service.create_resource_key( - name=self.keyNames['name'], - source=self.testInstanceGuid, - parameters=parameters, - headers=customHeaders) + name=self.keyNames['name'], source=self.testInstanceGuid, parameters=parameters, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 201 @@ -759,11 +727,9 @@ def test_18_create_resource_key_for_instance(self): def test_19_get_resource_key(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test19-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test19-" + self.transactionId - response = self.resource_controller_service.get_resource_key( - self.testInstanceKeyGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_key(self.testInstanceKeyGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -780,11 +746,11 @@ def test_19_get_resource_key(self): def test_20_update_resource_key(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test20-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test20-" + self.transactionId response = self.resource_controller_service.update_resource_key( - self.testInstanceKeyGuid, self.keyNames['update'], headers=customHeaders) + self.testInstanceKeyGuid, self.keyNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -796,23 +762,21 @@ def test_20_update_resource_key(self): def test_21_list_resource_keys_no_filter(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test21-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test21-" + self.transactionId start = None result_count = 0 while True: response = self.resource_controller_service.list_resource_keys( - limit=results_per_page, - start=start, - headers=customHeaders) + limit=results_per_page, start=start, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 result = response.get_result() assert result is not None - result_count+= result.get('rows_count') + result_count += result.get('rows_count') start = get_query_param(result.get('next_url'), 'start') if start is None: @@ -821,11 +785,11 @@ def test_21_list_resource_keys_no_filter(self): def test_22_list_resource_keys_by_guid(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test22-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test22-" + self.transactionId response = self.resource_controller_service.list_resource_keys( - guid=self.testInstanceKeyGuid, headers=customHeaders) + guid=self.testInstanceKeyGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -844,11 +808,11 @@ def test_22_list_resource_keys_by_guid(self): def test_23_list_resource_keys_by_name(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test23-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test23-" + self.transactionId response = self.resource_controller_service.list_resource_keys( - name=self.keyNames['update'], headers=customHeaders) + name=self.keyNames['update'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -886,9 +850,8 @@ def test_23b_list_resource_keys_for_instance(self): while True: response = self.resource_controller_service.list_resource_keys_for_instance( - id=self.testInstanceGuid, - limit=results_per_page, - start=start) + id=self.testInstanceGuid, limit=results_per_page, start=start + ) assert response is not None assert response.get_status_code() == 200 @@ -925,17 +888,17 @@ def test_23c_list_resource_keys_for_instance_with_pager(self): assert all_items is not None assert len(all_results) == len(all_items) - print(f'\nlist_resource_keys_for_instance() returned a total of {len(all_results)} items(s) using ResourceKeysForInstancePager.') + print( + f'\nlist_resource_keys_for_instance() returned a total of {len(all_results)} items(s) using ResourceKeysForInstancePager.' + ) def test_24_create_resource_key_for_alias(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test24-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test24-" + self.transactionId response = self.resource_controller_service.create_resource_key( - self.keyNames['name2'], - self.testAliasGuid, - headers=customHeaders) + self.keyNames['name2'], self.testAliasGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 201 @@ -958,11 +921,9 @@ def test_24_create_resource_key_for_alias(self): def test_25_get_resource_key(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test25-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test25-" + self.transactionId - response = self.resource_controller_service.get_resource_key( - self.testAliasKeyGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_key(self.testAliasKeyGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -979,11 +940,11 @@ def test_25_get_resource_key(self): def test_26_update_resource_key(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test26-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test26-" + self.transactionId response = self.resource_controller_service.update_resource_key( - self.testAliasKeyGuid, self.keyNames['update2'], headers=customHeaders) + self.testAliasKeyGuid, self.keyNames['update2'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -995,8 +956,7 @@ def test_26_update_resource_key(self): def test_27_list_resource_keys_no_filter(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test27-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test27-" + self.transactionId response = self.resource_controller_service.list_resource_keys(headers=customHeaders) assert response is not None @@ -1009,11 +969,11 @@ def test_27_list_resource_keys_no_filter(self): def test_28_list_resource_keys_by_guid(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test28-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test28-" + self.transactionId response = self.resource_controller_service.list_resource_keys( - guid=self.testAliasKeyGuid, headers=customHeaders) + guid=self.testAliasKeyGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -1032,11 +992,11 @@ def test_28_list_resource_keys_by_guid(self): def test_29_list_resource_keys_by_name(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test29-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test29-" + self.transactionId response = self.resource_controller_service.list_resource_keys( - name=self.keyNames['update2'], headers=customHeaders) + name=self.keyNames['update2'], headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -1047,47 +1007,37 @@ def test_29_list_resource_keys_by_name(self): def test_30_delete_resource_alias_fail(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test30-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test30-" + self.transactionId with pytest.raises(ApiException) as e: - response = self.resource_controller_service.delete_resource_alias( - self.testAliasGuid, - headers=customHeaders) + response = self.resource_controller_service.delete_resource_alias(self.testAliasGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 400 def test_31_delete_resource_instance_fail(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test31-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test31-" + self.transactionId with pytest.raises(ApiException) as e: response = self.resource_controller_service.delete_resource_instance( - self.testInstanceGuid, - headers=customHeaders) + self.testInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 400 def test_32_delete_resource_binding(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test32-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test32-" + self.transactionId - response = self.resource_controller_service.delete_resource_binding( - self.testBindingGuid, - headers=customHeaders) + response = self.resource_controller_service.delete_resource_binding(self.testBindingGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 204 def test_33_verify_resource_binding_was_deleted(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test33-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test33-" + self.transactionId - response = self.resource_controller_service.get_resource_binding( - self.testBindingGuid, - headers=customHeaders) + response = self.resource_controller_service.get_resource_binding(self.testBindingGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -1098,31 +1048,24 @@ def test_33_verify_resource_binding_was_deleted(self): def test_34_delete_resource_keys(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test34-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test34-" + self.transactionId - response = self.resource_controller_service.delete_resource_key( - self.testInstanceKeyGuid, headers=customHeaders) + response = self.resource_controller_service.delete_resource_key(self.testInstanceKeyGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 204 customHeaders2 = {} - customHeaders2["Transaction-Id"] = "rc-sdk-python-test34-" + \ - self.transactionId + customHeaders2["Transaction-Id"] = "rc-sdk-python-test34-" + self.transactionId - response2 = self.resource_controller_service.delete_resource_key( - self.testAliasKeyGuid, headers=customHeaders2) + response2 = self.resource_controller_service.delete_resource_key(self.testAliasKeyGuid, headers=customHeaders2) assert response2 is not None assert response2.get_status_code() == 204 def test_35_verify_resource_keys_were_deleted(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test35-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test35-" + self.transactionId - response = self.resource_controller_service.get_resource_key( - self.testInstanceKeyGuid, - headers=customHeaders) + response = self.resource_controller_service.get_resource_key(self.testInstanceKeyGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -1132,11 +1075,9 @@ def test_35_verify_resource_keys_were_deleted(self): assert result.get('state') == "removed" customHeaders2 = {} - customHeaders2["Transaction-Id"] = "rc-sdk-python-test35-" + \ - self.transactionId + customHeaders2["Transaction-Id"] = "rc-sdk-python-test35-" + self.transactionId - response2 = self.resource_controller_service.get_resource_key( - self.testAliasKeyGuid, headers=customHeaders2) + response2 = self.resource_controller_service.get_resource_key(self.testAliasKeyGuid, headers=customHeaders2) assert response2 is not None assert response2.get_status_code() == 200 @@ -1147,21 +1088,17 @@ def test_35_verify_resource_keys_were_deleted(self): def test_36_delete_resource_alias(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test36-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test36-" + self.transactionId - response = self.resource_controller_service.delete_resource_alias( - self.testAliasGuid, headers=customHeaders) + response = self.resource_controller_service.delete_resource_alias(self.testAliasGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 204 def test_37_verify_resource_alias_was_deleted(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test37-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test37-" + self.transactionId - response = self.resource_controller_service.get_resource_alias( - self.testAliasGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_alias(self.testAliasGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -1172,11 +1109,9 @@ def test_37_verify_resource_alias_was_deleted(self): def test_38_lock_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test38-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test38-" + self.transactionId - response = self.resource_controller_service.lock_resource_instance( - self.testInstanceGuid, headers=customHeaders) + response = self.resource_controller_service.lock_resource_instance(self.testInstanceGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -1190,36 +1125,33 @@ def test_38_lock_resource_instance(self): def test_39_update_locked_resource_instance_fail(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test39-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test39-" + self.transactionId with pytest.raises(ApiException) as e: response = self.resource_controller_service.update_resource_instance( - self.testInstanceGuid, - name=self.lockedInstanceNameUpdate, - headers=customHeaders + self.testInstanceGuid, name=self.lockedInstanceNameUpdate, headers=customHeaders ) assert response is not None assert response.get_status_code() == 400 def test_40_delete__locked_resource_instance_fail(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test40-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test40-" + self.transactionId with pytest.raises(ApiException) as e: response = self.resource_controller_service.delete_resource_instance( - self.testInstanceGuid, headers=customHeaders) + self.testInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 400 def test_41_unlock_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test41-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test41-" + self.transactionId response = self.resource_controller_service.unlock_resource_instance( - self.testInstanceGuid, headers=customHeaders) + self.testInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 @@ -1233,23 +1165,19 @@ def test_41_unlock_resource_instance(self): def test_42_delete_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test42-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test42-" + self.transactionId response = self.resource_controller_service.delete_resource_instance( - id=self.testInstanceGuid, - recursive=False, - headers=customHeaders) + id=self.testInstanceGuid, recursive=False, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 204 def test_43_verify_resource_instance_was_deleted(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test43-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test43-" + self.transactionId - response = self.resource_controller_service.get_resource_instance( - self.testInstanceGuid, headers=customHeaders) + response = self.resource_controller_service.get_resource_instance(self.testInstanceGuid, headers=customHeaders) assert response is not None assert response.get_status_code() == 200 @@ -1261,15 +1189,14 @@ def test_43_verify_resource_instance_was_deleted(self): def test_44_create_resource_instance_for_reclamation_enabled_plan(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test44-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test44-" + self.transactionId response = self.resource_controller_service.create_resource_instance( self.reclaimInstanceName, self.testRegionId2, self.testResourceGroupGuid, self.testPlanId2, - headers=customHeaders + headers=customHeaders, ) assert response is not None assert response.get_status_code() == 201 @@ -1297,11 +1224,11 @@ def test_44_create_resource_instance_for_reclamation_enabled_plan(self): def test_45_schedule_resource_instance_for_reclamation(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test45-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test45-" + self.transactionId response = self.resource_controller_service.delete_resource_instance( - self.testReclaimInstanceGuid, headers=customHeaders) + self.testReclaimInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 204 @@ -1327,14 +1254,13 @@ def test_45_schedule_resource_instance_for_reclamation(self): def test_47_list_reclamation_for_account_id(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test47-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test47-" + self.transactionId response = self.resource_controller_service.list_reclamations( # account_id=self.testAccountId, # checking reclamations with instance guid for more test reliability resource_instance_id=self.testReclaimInstanceGuid, - headers=customHeaders + headers=customHeaders, ) assert response is not None assert response.get_status_code() == 200 @@ -1345,11 +1271,9 @@ def test_47_list_reclamation_for_account_id(self): foundReclamation = False for res in result.get('resources'): if res.get('resource_instance_id') == self.testReclaimInstanceGuid: - assert res.get( - 'resource_instance_id') == self.testReclaimInstanceGuid + assert res.get('resource_instance_id') == self.testReclaimInstanceGuid assert res.get('account_id') == self.testAccountId - assert res.get( - 'resource_group_id') == self.testResourceGroupGuid + assert res.get('resource_group_id') == self.testResourceGroupGuid assert res.get('state') == 'SCHEDULED' foundReclamation = True @@ -1359,18 +1283,17 @@ def test_47_list_reclamation_for_account_id(self): def test_48_restore_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test48-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test48-" + self.transactionId response = self.resource_controller_service.run_reclamation_action( - self.testReclamationId1, 'restore', headers=customHeaders) + self.testReclamationId1, 'restore', headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 result = response.get_result() assert result.get('id') == self.testReclamationId1 - assert result.get( - 'resource_instance_id') == self.testReclaimInstanceGuid + assert result.get('resource_instance_id') == self.testReclaimInstanceGuid assert result.get('account_id') == self.testAccountId assert result.get('resource_group_id') == self.testResourceGroupGuid assert result.get('state') == 'RESTORING' @@ -1397,11 +1320,11 @@ def test_48_restore_resource_instance(self): def test_50_schedule_resource_instance_for_reclamation2(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test50-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test50-" + self.transactionId response = self.resource_controller_service.delete_resource_instance( - self.testReclaimInstanceGuid, headers=customHeaders) + self.testReclaimInstanceGuid, headers=customHeaders + ) assert response is not None assert response.get_status_code() == 204 @@ -1409,13 +1332,10 @@ def test_50_schedule_resource_instance_for_reclamation2(self): def test_51_list_reclamation_for_account_id_and_resource_instance_id(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test51-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test51-" + self.transactionId response = self.resource_controller_service.list_reclamations( - account_id=self.testAccountId, - resource_instance_id=self.testReclaimInstanceGuid, - headers=customHeaders + account_id=self.testAccountId, resource_instance_id=self.testReclaimInstanceGuid, headers=customHeaders ) assert response is not None assert response.get_status_code() == 200 @@ -1434,18 +1354,17 @@ def test_51_list_reclamation_for_account_id_and_resource_instance_id(self): def test_52_reclaim_resource_instance(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test52-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test52-" + self.transactionId response = self.resource_controller_service.run_reclamation_action( - self.testReclamationId2, 'reclaim', headers=customHeaders) + self.testReclamationId2, 'reclaim', headers=customHeaders + ) assert response is not None assert response.get_status_code() == 200 result = response.get_result() assert result.get('id') == self.testReclamationId2 - assert result.get( - 'resource_instance_id') == self.testReclaimInstanceGuid + assert result.get('resource_instance_id') == self.testReclaimInstanceGuid assert result.get('account_id') == self.testAccountId assert result.get('resource_group_id') == self.testResourceGroupGuid assert result.get('state') == 'RECLAIMING' @@ -1455,17 +1374,15 @@ def test_52_reclaim_resource_instance(self): def test_53_cancel_last_operation(self): customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-test53-" + \ - self.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-test53-" + self.transactionId try: response = self.resource_controller_service.cancel_lastop_resource_instance( - id=self.testInstanceGuid, - headers=customHeaders) + id=self.testInstanceGuid, headers=customHeaders + ) assert response is not None except ApiException as e: assert e.message == "The instance is not cancelable." - # Commented because redis timeouts cause intermittent failure # def test_53_verify_resource_instance_is_reclaimed(self): @@ -1489,76 +1406,56 @@ def cleanupResources(cls): if cls.testInstanceKeyGuid != '': try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_key( - cls.testInstanceKeyGuid, headers=customHeaders) - print('\nSuccessfully cleaned up key ' + - cls.testInstanceKeyGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId + cls.resource_controller_service.delete_resource_key(cls.testInstanceKeyGuid, headers=customHeaders) + print('\nSuccessfully cleaned up key ' + cls.testInstanceKeyGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nKey ' + cls.testInstanceKeyGuid + - ' was already deleted by the tests.') + print('\nKey ' + cls.testInstanceKeyGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up key ' + - cls.testInstanceKeyGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up key ' + cls.testInstanceKeyGuid + '. Error: ' + errResponse.message) else: print('\nKey was not created. No cleanup needed.') if cls.testAliasKeyGuid != '': try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_key( - cls.testAliasKeyGuid, headers=customHeaders) - print('\nSuccessfully cleaned up key ' + - cls.testAliasKeyGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId + cls.resource_controller_service.delete_resource_key(cls.testAliasKeyGuid, headers=customHeaders) + print('\nSuccessfully cleaned up key ' + cls.testAliasKeyGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nKey ' + cls.testAliasKeyGuid + - ' was already deleted by the tests.') + print('\nKey ' + cls.testAliasKeyGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up key ' + - cls.testAliasKeyGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up key ' + cls.testAliasKeyGuid + '. Error: ' + errResponse.message) else: print('\nKey was not created. No cleanup needed.') if cls.testBindingGuid != '': try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_binding( - cls.testBindingGuid, headers=customHeaders) - print('\nSuccessfully cleaned up binding ' + - cls.testBindingGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId + cls.resource_controller_service.delete_resource_binding(cls.testBindingGuid, headers=customHeaders) + print('\nSuccessfully cleaned up binding ' + cls.testBindingGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nBinding ' + cls.testBindingGuid + - ' was already deleted by the tests.') + print('\nBinding ' + cls.testBindingGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up binding ' + - cls.testBindingGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up binding ' + cls.testBindingGuid + '. Error: ' + errResponse.message) else: print('\nBinding was not created. No cleanup needed.') if cls.testAliasGuid != '': try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_alias( - cls.testAliasGuid, headers=customHeaders) - print('\nSuccessfully cleaned up alias ' + - cls.testAliasGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId + cls.resource_controller_service.delete_resource_alias(cls.testAliasGuid, headers=customHeaders) + print('\nSuccessfully cleaned up alias ' + cls.testAliasGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nAlias ' + cls.testAliasGuid + - ' was already deleted by the tests.') + print('\nAlias ' + cls.testAliasGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up alias ' + - cls.testAliasGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up alias ' + cls.testAliasGuid + '. Error: ' + errResponse.message) else: print('\nAlias was not created. No cleanup needed.') @@ -1574,32 +1471,32 @@ def cleanupByName(cls): for resourceKeyName in cls.keyNames.values(): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId response = cls.resource_controller_service.list_resource_keys( - name=resourceKeyName, headers=customHeaders) + name=resourceKeyName, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve key with name' + resourceKeyName + - ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve key with name' + + resourceKeyName + + ' for cleanup. Error: ' + + errResponse.message + ) else: resources = response.get_result().get('resources') - if (len(resources) > 0): + if len(resources) > 0: for res in resources: keyGuid = res.get('guid') try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_key( - keyGuid, headers=customHeaders) + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId + cls.resource_controller_service.delete_resource_key(keyGuid, headers=customHeaders) print('\nSuccessfully cleaned up key ' + keyGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nKey ' + keyGuid + - ' was already deleted by the tests.') + print('\nKey ' + keyGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up key ' + - keyGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up key ' + keyGuid + '. Error: ' + errResponse.message) else: print('\nNo keys found for name ' + resourceKeyName) @@ -1607,47 +1504,53 @@ def cleanupByName(cls): for resourceInstanceName in cls.instanceNames.values(): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId response = cls.resource_controller_service.list_resource_instances( - name=resourceInstanceName, headers=customHeaders) + name=resourceInstanceName, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve instance with name' + - resourceInstanceName + ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve instance with name' + + resourceInstanceName + + ' for cleanup. Error: ' + + errResponse.message + ) else: resources = response.get_result().get('resources') - if (len(resources) > 0): + if len(resources) > 0: for res in resources: instanceGuid = res.get('guid') # unlock instance if it is locked if res.get('state') == "active" and res.get('locked'): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name" + cls.transactionId cls.resource_controller_service.unlock_resource_instance( - instanceGuid, headers=customHeaders) - print('\nSuccessfully unlocked instance ' + - instanceGuid + ' for cleanup.') + instanceGuid, headers=customHeaders + ) + print('\nSuccessfully unlocked instance ' + instanceGuid + ' for cleanup.') except ApiException as errResponse: - print('\nFailed to unlock instance ' + instanceGuid + - ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to unlock instance ' + + instanceGuid + + ' for cleanup. Error: ' + + errResponse.message + ) try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId cls.resource_controller_service.delete_resource_instance( - instanceGuid, headers=customHeaders) - print('\nSuccessfully cleaned up instance ' + - instanceGuid + '.') + instanceGuid, headers=customHeaders + ) + print('\nSuccessfully cleaned up instance ' + instanceGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nInstance ' + instanceGuid + - ' was already deleted by the tests.') + print('\nInstance ' + instanceGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up instance ' + - instanceGuid + '. Error: ' + errResponse.message) + print( + '\nFailed to clean up instance ' + instanceGuid + '. Error: ' + errResponse.message + ) else: print('\nNo instances found for name ' + resourceInstanceName) @@ -1655,33 +1558,32 @@ def cleanupByName(cls): for resourceBindingName in cls.bindingNames.values(): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId response = cls.resource_controller_service.list_resource_bindings( - name=resourceBindingName, headers=customHeaders) + name=resourceBindingName, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve binding with name' + - resourceBindingName + ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve binding with name' + + resourceBindingName + + ' for cleanup. Error: ' + + errResponse.message + ) else: resources = response.get_result().get('resources') - if (len(resources) > 0): + if len(resources) > 0: for res in resources: bindingGuid = res.get('guid') try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_key( - bindingGuid, headers=customHeaders) - print('\nSuccessfully cleaned up binding ' + - bindingGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId + cls.resource_controller_service.delete_resource_key(bindingGuid, headers=customHeaders) + print('\nSuccessfully cleaned up binding ' + bindingGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nBinding ' + bindingGuid + - ' was already deleted by the tests.') + print('\nBinding ' + bindingGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up binding ' + - bindingGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up binding ' + bindingGuid + '. Error: ' + errResponse.message) else: print('\nNo bindings found for name ' + resourceBindingName) @@ -1689,33 +1591,32 @@ def cleanupByName(cls): for resourceAliasName in cls.aliasNames.values(): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId response = cls.resource_controller_service.list_resource_aliases( - name=resourceAliasName, headers=customHeaders) + name=resourceAliasName, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve alias with name' + - resourceAliasName + ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve alias with name' + + resourceAliasName + + ' for cleanup. Error: ' + + errResponse.message + ) else: resources = response.get_result().get('resources') - if (len(resources) > 0): + if len(resources) > 0: for res in resources: aliasGuid = res.get('guid') try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_alias( - aliasGuid, headers=customHeaders) - print('\nSuccessfully cleaned up alias ' + - aliasGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-by-name-" + cls.transactionId + cls.resource_controller_service.delete_resource_alias(aliasGuid, headers=customHeaders) + print('\nSuccessfully cleaned up alias ' + aliasGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nAlias ' + aliasGuid + - ' was already deleted by the tests.') + print('\nAlias ' + aliasGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up alias ' + - aliasGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up alias ' + aliasGuid + '. Error: ' + errResponse.message) else: print('\nNo aliases found for name ' + resourceAliasName) @@ -1723,73 +1624,78 @@ def cleanupByName(cls): def cleanupInstance(cls): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId response = cls.resource_controller_service.get_resource_instance( - cls.testInstanceGuid, headers=customHeaders) + cls.testInstanceGuid, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve instance ' + cls.testInstanceGuid + - ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve instance ' + cls.testInstanceGuid + ' for cleanup. Error: ' + errResponse.message + ) else: if response.get_result().get('state') == "active" and response.get_result().get('locked'): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId cls.resource_controller_service.unlock_resource_instance( - cls.testInstanceGuid, headers=customHeaders) - print('\nSuccessfully unlocked instance ' + - cls.testInstanceGuid + ' for cleanup.') + cls.testInstanceGuid, headers=customHeaders + ) + print('\nSuccessfully unlocked instance ' + cls.testInstanceGuid + ' for cleanup.') except ApiException as errResponse: - print('\nFailed to unlock instance ' + cls.testInstanceGuid + - ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to unlock instance ' + + cls.testInstanceGuid + + ' for cleanup. Error: ' + + errResponse.message + ) try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId - cls.resource_controller_service.delete_resource_instance( - cls.testInstanceGuid, headers=customHeaders) - print('\nSuccessfully cleaned up instance ' + - cls.testInstanceGuid + '.') + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId + cls.resource_controller_service.delete_resource_instance(cls.testInstanceGuid, headers=customHeaders) + print('\nSuccessfully cleaned up instance ' + cls.testInstanceGuid + '.') except ApiException as errResponse: if errResponse.code == 410: - print('\nInstance ' + cls.testInstanceGuid + - ' was already deleted by the tests.') + print('\nInstance ' + cls.testInstanceGuid + ' was already deleted by the tests.') else: - print('\nFailed to clean up instance ' + - cls.testInstanceGuid + '. Error: ' + errResponse.message) + print('\nFailed to clean up instance ' + cls.testInstanceGuid + '. Error: ' + errResponse.message) @classmethod def cleanupReclamationInstance(cls): if cls.testReclaimInstanceGuid != '': try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId response = cls.resource_controller_service.get_resource_instance( - cls.testReclaimInstanceGuid, headers=customHeaders) + cls.testReclaimInstanceGuid, headers=customHeaders + ) except ApiException as errResponse: - print('\nFailed to retrieve instance ' + cls.testReclaimInstanceGuid + - ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve instance ' + + cls.testReclaimInstanceGuid + + ' for cleanup. Error: ' + + errResponse.message + ) else: if response.get_result().get('state') == "removed": - print('\nInstance ' + cls.testReclaimInstanceGuid + - ' was already reclaimed by the tests.') + print('\nInstance ' + cls.testReclaimInstanceGuid + ' was already reclaimed by the tests.') elif response.get_result().get('state') == "pending_reclamation": cls.cleanupInstancePendingReclamation() else: try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId cls.resource_controller_service.delete_resource_instance( - cls.testReclaimInstanceGuid, headers=customHeaders) - print('\nSuccessfully scheduled instance ' + - cls.testReclaimInstanceGuid + ' for reclamation.') + cls.testReclaimInstanceGuid, headers=customHeaders + ) + print('\nSuccessfully scheduled instance ' + cls.testReclaimInstanceGuid + ' for reclamation.') except ApiException as errResponse: - print('\nFailed to schedule instance ' + cls.testReclaimInstanceGuid + - ' for reclamation. Error: ' + errResponse.message) + print( + '\nFailed to schedule instance ' + + cls.testReclaimInstanceGuid + + ' for reclamation. Error: ' + + errResponse.message + ) else: time.sleep(20) cls.cleanupInstancePendingReclamation() @@ -1800,31 +1706,36 @@ def cleanupReclamationInstance(cls): def cleanupInstancePendingReclamation(cls): try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId response = cls.resource_controller_service.list_reclamations( - account_id=cls.testAccountId, - resource_instance_id=cls.testReclaimInstanceGuid, - headers=customHeaders + account_id=cls.testAccountId, resource_instance_id=cls.testReclaimInstanceGuid, headers=customHeaders ) except ApiException as errResponse: - print('\nFailed to retrieve reclamation to process to reclaim instance ' + - cls.testReclaimInstanceGuid + ' for cleanup. Error: ' + errResponse.message) + print( + '\nFailed to retrieve reclamation to process to reclaim instance ' + + cls.testReclaimInstanceGuid + + ' for cleanup. Error: ' + + errResponse.message + ) else: res = response.get_result().get('resources') if len(res) == 0: - print('\nNo reclamations for instance ' + - cls.testReclaimInstanceGuid + ' were returned.') + print('\nNo reclamations for instance ' + cls.testReclaimInstanceGuid + ' were returned.') else: reclamationId = res[0].get('id') try: customHeaders = {} - customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + \ - cls.transactionId + customHeaders["Transaction-Id"] = "rc-sdk-python-cleanup-" + cls.transactionId response = cls.resource_controller_service.run_reclamation_action( - reclamationId, 'reclaim', headers=customHeaders) - print('\nSuccessfully reclaimed instance ' + - cls.testReclaimInstanceGuid) + reclamationId, 'reclaim', headers=customHeaders + ) + print('\nSuccessfully reclaimed instance ' + cls.testReclaimInstanceGuid) except ApiException as errResponse: - print('\nFailed to process reclamation ' + reclamationId + - ' for instance ' + cls.testInstanceGuid + '. Error: ' + errResponse.message) + print( + '\nFailed to process reclamation ' + + reclamationId + + ' for instance ' + + cls.testInstanceGuid + + '. Error: ' + + errResponse.message + ) diff --git a/test/integration/test_resource_manager_v2.py b/test/integration/test_resource_manager_v2.py index b6c19f4f..045a2bcd 100644 --- a/test/integration/test_resource_manager_v2.py +++ b/test/integration/test_resource_manager_v2.py @@ -30,6 +30,7 @@ # Location of our config file. config_file = 'resource_manager.env' + class TestResourceManagerV2(unittest.TestCase): """ Integration Test Class for ResourceManagerV2 @@ -40,9 +41,7 @@ def setUpClass(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.config = read_external_sources( - ResourceManagerV2.DEFAULT_SERVICE_NAME - ) + cls.config = read_external_sources(ResourceManagerV2.DEFAULT_SERVICE_NAME) assert cls.config is not None # Construct the first service instance. @@ -87,8 +86,7 @@ def test_02_get_quota_definition(self): assert result is not None def test_03_list_resource_groups_in_an_account(self): - response = self.service.list_resource_groups( - account_id=self.test_user_account_id) + response = self.service.list_resource_groups(account_id=self.test_user_account_id) assert response is not None assert response.get_status_code() == 200 @@ -110,8 +108,7 @@ def test_03_list_resource_groups_in_an_account(self): assert resources.get('updated_at') is not None def test_04_create_resource_group_in_an_account(self): - response = self.service.create_resource_group( - name='TestGroup', account_id=self.test_user_account_id) + response = self.service.create_resource_group(name='TestGroup', account_id=self.test_user_account_id) assert response is not None assert response.get_status_code() == 201 @@ -122,8 +119,7 @@ def test_04_create_resource_group_in_an_account(self): self.__class__.new_resource_group_id = result.get('id') def test_05_get_resource_group_by_id(self): - response = self.service.get_resource_group( - id=self.new_resource_group_id) + response = self.service.get_resource_group(id=self.new_resource_group_id) assert response is not None assert response.get_status_code() == 200 @@ -131,8 +127,7 @@ def test_05_get_resource_group_by_id(self): assert result is not None def test_06_update_resource_group_by_id(self): - response = self.service.update_resource_group( - id=self.new_resource_group_id, name='TestGroup2', state='ACTIVE') + response = self.service.update_resource_group(id=self.new_resource_group_id, name='TestGroup2', state='ACTIVE') assert response is not None assert response.get_status_code() == 200 @@ -140,7 +135,6 @@ def test_06_update_resource_group_by_id(self): assert result is not None def test_07_delete_resource_group_by_id(self): - response = self.alt_service.delete_resource_group( - id=self.new_resource_group_id) + response = self.alt_service.delete_resource_group(id=self.new_resource_group_id) assert response is not None assert response.get_status_code() == 204 diff --git a/test/integration/test_usage_metering_v4.py b/test/integration/test_usage_metering_v4.py index 1ac8c3e9..1df354bf 100644 --- a/test/integration/test_usage_metering_v4.py +++ b/test/integration/test_usage_metering_v4.py @@ -26,10 +26,11 @@ config_file = 'usage_metering.env' -class TestUsageMeteringV4(): +class TestUsageMeteringV4: """ Integration Test Class for UsageMeteringV4 """ + @classmethod def setup_class(cls): if os.path.exists(config_file): @@ -41,8 +42,8 @@ def setup_class(cls): print('Setup complete.') needscredentials = pytest.mark.skipif( - not os.path.exists(config_file), - reason="External configuration not available, skipping...") + not os.path.exists(config_file), reason="External configuration not available, skipping..." + ) @needscredentials def test_report_resource_usage(self): @@ -85,11 +86,10 @@ def test_report_resource_usage(self): } report_resource_usage_response = self.usage_metering_service.report_resource_usage( - resource_id=resource_id, - resource_usage=[resource_instance_usage_model]) + resource_id=resource_id, resource_usage=[resource_instance_usage_model] + ) assert report_resource_usage_response.get_status_code() == 202 response_accepted = report_resource_usage_response.get_result() assert response_accepted is not None - print('report_resource_usage() result: ', - json.dumps(response_accepted)) + print('report_resource_usage() result: ', json.dumps(response_accepted)) diff --git a/test/integration/test_usage_reports_v4.py b/test/integration/test_usage_reports_v4.py index f4cdedd6..874852f1 100644 --- a/test/integration/test_usage_reports_v4.py +++ b/test/integration/test_usage_reports_v4.py @@ -26,7 +26,7 @@ config_file = 'usage_reports.env' -class TestUsageReportsV4(): +class TestUsageReportsV4: """ Integration Test Class for UsageReportsV4 """ @@ -36,12 +36,10 @@ def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file - cls.usage_reports_service = UsageReportsV4.new_instance( - ) + cls.usage_reports_service = UsageReportsV4.new_instance() assert cls.usage_reports_service is not None - cls.config = read_external_sources( - UsageReportsV4.DEFAULT_SERVICE_NAME) + cls.config = read_external_sources(UsageReportsV4.DEFAULT_SERVICE_NAME) assert cls.config is not None # Retrieve and verify some additional test-related config properties. @@ -80,10 +78,7 @@ def test_get_account_summary(self): def test_get_account_usage(self): get_account_usage_response = self.usage_reports_service.get_account_usage( - account_id=self.ACCOUNT_ID, - billingmonth=self.BILLING_MONTH, - names=True, - accept_language='English' + account_id=self.ACCOUNT_ID, billingmonth=self.BILLING_MONTH, names=True, accept_language='English' ) assert get_account_usage_response.get_status_code() == 200 @@ -156,8 +151,7 @@ def test_get_resource_usage_account(self): break numResources = len(resources) - print( - f'get_resource_usage_account() response contained {numResources} total resources') + print(f'get_resource_usage_account() response contained {numResources} total resources') assert numResources > 0 @needscredentials @@ -190,8 +184,7 @@ def test_get_resource_usage_resource_group(self): break numResources = len(resources) - print( - f'get_resource_usage_resource_group() response contained {numResources} total resources') + print(f'get_resource_usage_resource_group() response contained {numResources} total resources') assert numResources > 0 @needscredentials @@ -224,6 +217,5 @@ def test_get_resource_usage_org(self): break numResources = len(resources) - print( - f'get_resource_usage_org() response contained {numResources} total resources') + print(f'get_resource_usage_org() response contained {numResources} total resources') assert numResources > 0 diff --git a/test/integration/test_user_management_v1.py b/test/integration/test_user_management_v1.py index 3d405670..27c4f447 100644 --- a/test/integration/test_user_management_v1.py +++ b/test/integration/test_user_management_v1.py @@ -35,25 +35,21 @@ class TestUserManagementV1(unittest.TestCase): """ Integration Test Class for UserManagementV1 """ + @classmethod def setup_class(cls): if os.path.exists(config_file): os.environ['IBM_CREDENTIALS_FILE'] = config_file else: - raise unittest.SkipTest( - 'External configuration not available, skipping...') + raise unittest.SkipTest('External configuration not available, skipping...') - cls.config = read_external_sources( - UserManagementV1.DEFAULT_SERVICE_NAME - ) + cls.config = read_external_sources(UserManagementV1.DEFAULT_SERVICE_NAME) assert cls.config is not None - cls.user_management_service = UserManagementV1.new_instance( - service_name=UserManagementV1.DEFAULT_SERVICE_NAME) + cls.user_management_service = UserManagementV1.new_instance(service_name=UserManagementV1.DEFAULT_SERVICE_NAME) assert cls.user_management_service is not None - cls.user_management_admin_service = UserManagementV1.new_instance( - service_name='USER_MANAGEMENT_ADMIN') + cls.user_management_admin_service = UserManagementV1.new_instance(service_name='USER_MANAGEMENT_ADMIN') assert cls.user_management_admin_service is not None cls.ACCOUNT_ID = cls.config['ACCOUNT_ID'] @@ -68,12 +64,12 @@ def setup_class(cls): def test_01_get_user_settings(self): user_settings = self.user_management_service.get_user_settings( - account_id=self.ACCOUNT_ID, iam_id=self.IAM_USERID) + account_id=self.ACCOUNT_ID, iam_id=self.IAM_USERID + ) assert user_settings.get_status_code() == 200 assert user_settings.get_result() is not None - print('\nget_user_settings() result: ', - json.dumps(user_settings.get_result(), indent=2)) + print('\nget_user_settings() result: ', json.dumps(user_settings.get_result(), indent=2)) def test_02_update_user_settings(self): @@ -83,7 +79,8 @@ def test_02_update_user_settings(self): language='French', notification_language='English', allowed_ip_addresses='32.96.110.50,172.16.254.1', - self_manage=True) + self_manage=True, + ) assert user_settings.get_status_code() == 204 @@ -92,8 +89,7 @@ def test_03_list_users(self): start = None while True: - response = self.user_management_service.list_users( - account_id=self.ACCOUNT_ID, limit=10, start=start) + response = self.user_management_service.list_users(account_id=self.ACCOUNT_ID, limit=10, start=start) assert response.get_status_code() == 200 user_list = response.get_result() @@ -141,10 +137,7 @@ def test_03a_list_users_with_pager(self): def test_04_invite_users(self): # Construct a dict representation of a InviteUser model - invite_user_model = { - 'email': self.INVITED_USER_EMAIL, - 'account_role': 'Member' - } + invite_user_model = {'email': self.INVITED_USER_EMAIL, 'account_role': 'Member'} # Construct a dict representation of a Role model role_model = {'role_id': self.VIEWER_ROLEID} @@ -158,22 +151,18 @@ def test_04_invite_users(self): resource_model = {'attributes': [attribute_model, attribute_model2]} # Construct a dict representation of a InviteUserIamPolicy model - invite_user_iam_policy_model = { - 'type': 'access', - 'roles': [role_model], - 'resources': [resource_model] - } + invite_user_iam_policy_model = {'type': 'access', 'roles': [role_model], 'resources': [resource_model]} response = self.user_management_admin_service.invite_users( account_id=self.ACCOUNT_ID, users=[invite_user_model], iam_policy=[invite_user_iam_policy_model], - access_groups=[self.ACCESS_GROUP_ID]) + access_groups=[self.ACCESS_GROUP_ID], + ) assert response.get_status_code() == 202 assert response.get_result() is not None - print('\ninvite_users() result: ', - json.dumps(response.get_result(), indent=2)) + print('\ninvite_users() result: ', json.dumps(response.get_result(), indent=2)) invited_users = response.get_result().get('resources') assert invited_users is not None @@ -184,13 +173,11 @@ def test_04_invite_users(self): def test_05_get_user_profile(self): - user_profile = self.user_management_service.get_user_profile( - account_id=self.ACCOUNT_ID, iam_id=self.IAM_USERID) + user_profile = self.user_management_service.get_user_profile(account_id=self.ACCOUNT_ID, iam_id=self.IAM_USERID) assert user_profile.get_status_code() == 200 assert user_profile.get_result() is not None - print('\nget_user_profile() result: ', - json.dumps(user_profile.get_result(), indent=2)) + print('\nget_user_profile() result: ', json.dumps(user_profile.get_result(), indent=2)) def test_06_update_user_profile(self): @@ -200,8 +187,8 @@ def test_06_update_user_profile(self): firstname='John', lastname='Doe', state='ACTIVE', - email= - 'do_not_delete_user_without_iam_policy_stage@mail.test.ibm.com') + email='do_not_delete_user_without_iam_policy_stage@mail.test.ibm.com', + ) assert response.get_status_code() == 204 @@ -209,8 +196,7 @@ def test_07_remove_user(self): global REMOVED_USERID assert REMOVED_USERID is not None - response = self.user_management_service.remove_user( - account_id=self.ACCOUNT_ID, iam_id=REMOVED_USERID) + response = self.user_management_service.remove_user(account_id=self.ACCOUNT_ID, iam_id=REMOVED_USERID) assert response.get_status_code() == 204 diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 541ebb2f..b4d543ee 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -2,4 +2,4 @@ """Unit Tests""" -# this file is present so that pylint will lint-check the files in this directory \ No newline at end of file +# this file is present so that pylint will lint-check the files in this directory diff --git a/test/unit/test_case_management_v1.py b/test/unit/test_case_management_v1.py index 26f4bcc2..661dc4b3 100644 --- a/test/unit/test_case_management_v1.py +++ b/test/unit/test_case_management_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.case_management_v1 import * -_service = CaseManagementV1( - authenticator=NoAuthAuthenticator() -) +_service = CaseManagementV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://support-center.cloud.ibm.com/case-management/v1' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetCases(): + +class TestGetCases: """ Test Class for get_cases """ @@ -110,11 +110,7 @@ def test_get_cases_all_params(self): # Set up mock url = preprocess_url('/cases') mock_response = '{"total_count": 11, "first": {"href": "href"}, "next": {"href": "href"}, "previous": {"href": "href"}, "last": {"href": "href"}, "cases": [{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values offset = 38 @@ -126,20 +122,14 @@ def test_get_cases_all_params(self): # Invoke method response = _service.get_cases( - offset=offset, - limit=limit, - search=search, - sort=sort, - status=status, - fields=fields, - headers={} + offset=offset, limit=limit, search=search, sort=sort, status=status, fields=fields, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'offset={}'.format(offset) in query_string assert 'limit={}'.format(limit) in query_string @@ -165,16 +155,11 @@ def test_get_cases_required_params(self): # Set up mock url = preprocess_url('/cases') mock_response = '{"total_count": 11, "first": {"href": "href"}, "next": {"href": "href"}, "previous": {"href": "href"}, "last": {"href": "href"}, "cases": [{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_cases() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -197,16 +182,8 @@ def test_get_cases_with_pager_get_next(self): url = preprocess_url('/cases') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"cases":[{"number":"number","short_description":"short_description","description":"description","created_at":"created_at","created_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"updated_at":"updated_at","updated_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"contact_type":"Cloud Support Center","contact":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"status":"status","severity":8,"support_tier":"Free","resolution":"resolution","close_notes":"close_notes","eu":{"support":false,"data_center":"data_center"},"watchlist":[{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}],"attachments":[{"id":"id","filename":"filename","size_in_bytes":13,"created_at":"created_at","url":"url"}],"offering":{"name":"name","type":{"group":"crn_service_name","key":"key","kind":"kind","id":"id"}},"resources":[{"crn":"crn","name":"name","type":"type","url":"url","note":"note"}],"comments":[{"value":"value","added_at":"added_at","added_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}}]}],"total_count":2,"limit":1}' mock_response2 = '{"cases":[{"number":"number","short_description":"short_description","description":"description","created_at":"created_at","created_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"updated_at":"updated_at","updated_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"contact_type":"Cloud Support Center","contact":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"status":"status","severity":8,"support_tier":"Free","resolution":"resolution","close_notes":"close_notes","eu":{"support":false,"data_center":"data_center"},"watchlist":[{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}],"attachments":[{"id":"id","filename":"filename","size_in_bytes":13,"created_at":"created_at","url":"url"}],"offering":{"name":"name","type":{"group":"crn_service_name","key":"key","kind":"kind","id":"id"}},"resources":[{"crn":"crn","name":"name","type":"type","url":"url","note":"note"}],"comments":[{"value":"value","added_at":"added_at","added_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}}]}],"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) + 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 = [] @@ -233,16 +210,8 @@ def test_get_cases_with_pager_get_all(self): url = preprocess_url('/cases') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"cases":[{"number":"number","short_description":"short_description","description":"description","created_at":"created_at","created_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"updated_at":"updated_at","updated_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"contact_type":"Cloud Support Center","contact":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"status":"status","severity":8,"support_tier":"Free","resolution":"resolution","close_notes":"close_notes","eu":{"support":false,"data_center":"data_center"},"watchlist":[{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}],"attachments":[{"id":"id","filename":"filename","size_in_bytes":13,"created_at":"created_at","url":"url"}],"offering":{"name":"name","type":{"group":"crn_service_name","key":"key","kind":"kind","id":"id"}},"resources":[{"crn":"crn","name":"name","type":"type","url":"url","note":"note"}],"comments":[{"value":"value","added_at":"added_at","added_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}}]}],"total_count":2,"limit":1}' mock_response2 = '{"cases":[{"number":"number","short_description":"short_description","description":"description","created_at":"created_at","created_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"updated_at":"updated_at","updated_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"contact_type":"Cloud Support Center","contact":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"},"status":"status","severity":8,"support_tier":"Free","resolution":"resolution","close_notes":"close_notes","eu":{"support":false,"data_center":"data_center"},"watchlist":[{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}],"attachments":[{"id":"id","filename":"filename","size_in_bytes":13,"created_at":"created_at","url":"url"}],"offering":{"name":"name","type":{"group":"crn_service_name","key":"key","kind":"kind","id":"id"}},"resources":[{"crn":"crn","name":"name","type":"type","url":"url","note":"note"}],"comments":[{"value":"value","added_at":"added_at","added_by":{"name":"name","realm":"IBMid","user_id":"abc@ibm.com"}}]}],"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) + 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 = GetCasesPager( @@ -257,7 +226,8 @@ def test_get_cases_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestCreateCase(): + +class TestCreateCase: """ Test Class for create_case """ @@ -270,11 +240,7 @@ def test_create_case_all_params(self): # Set up mock url = preprocess_url('/cases') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a CasePayloadEu model case_payload_eu_model = {} @@ -329,7 +295,7 @@ def test_create_case_all_params(self): watchlist=watchlist, invoice_number=invoice_number, sla_credit_request=sla_credit_request, - headers={} + headers={}, ) # Check for correct operation @@ -365,11 +331,7 @@ def test_create_case_value_error(self): # Set up mock url = preprocess_url('/cases') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a CasePayloadEu model case_payload_eu_model = {} @@ -419,7 +381,7 @@ def test_create_case_value_error(self): "description": description, } 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()} + 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_case(**req_copy) @@ -432,7 +394,8 @@ def test_create_case_value_error_with_retries(self): _service.disable_retries() self.test_create_case_value_error() -class TestGetCase(): + +class TestGetCase: """ Test Class for get_case """ @@ -445,28 +408,20 @@ def test_get_case_all_params(self): # Set up mock url = preprocess_url('/cases/testString') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' fields = ['number'] # Invoke method - response = _service.get_case( - case_number, - fields=fields, - headers={} - ) + response = _service.get_case(case_number, fields=fields, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'fields={}'.format(','.join(fields)) in query_string @@ -487,20 +442,13 @@ def test_get_case_required_params(self): # Set up mock url = preprocess_url('/cases/testString') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' # Invoke method - response = _service.get_case( - case_number, - headers={} - ) + response = _service.get_case(case_number, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -523,11 +471,7 @@ def test_get_case_value_error(self): # Set up mock url = preprocess_url('/cases/testString') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' @@ -537,7 +481,7 @@ def test_get_case_value_error(self): "case_number": case_number, } 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()} + 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_case(**req_copy) @@ -550,7 +494,8 @@ def test_get_case_value_error_with_retries(self): _service.disable_retries() self.test_get_case_value_error() -class TestUpdateCaseStatus(): + +class TestUpdateCaseStatus: """ Test Class for update_case_status """ @@ -563,11 +508,7 @@ def test_update_case_status_all_params(self): # Set up mock url = preprocess_url('/cases/testString/status') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a ResolvePayload model status_payload_model = {} @@ -580,11 +521,7 @@ def test_update_case_status_all_params(self): status_payload = status_payload_model # Invoke method - response = _service.update_case_status( - case_number, - status_payload, - headers={} - ) + response = _service.update_case_status(case_number, status_payload, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -610,11 +547,7 @@ def test_update_case_status_value_error(self): # Set up mock url = preprocess_url('/cases/testString/status') mock_response = '{"number": "number", "short_description": "short_description", "description": "description", "created_at": "created_at", "created_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "updated_at": "updated_at", "updated_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "contact_type": "Cloud Support Center", "contact": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}, "status": "status", "severity": 8, "support_tier": "Free", "resolution": "resolution", "close_notes": "close_notes", "eu": {"support": false, "data_center": "data_center"}, "watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}], "offering": {"name": "name", "type": {"group": "crn_service_name", "key": "key", "kind": "kind", "id": "id"}}, "resources": [{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}], "comments": [{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a ResolvePayload model status_payload_model = {} @@ -632,7 +565,7 @@ def test_update_case_status_value_error(self): "status_payload": status_payload, } 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()} + 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_case_status(**req_copy) @@ -645,7 +578,8 @@ def test_update_case_status_value_error_with_retries(self): _service.disable_retries() self.test_update_case_status_value_error() -class TestAddComment(): + +class TestAddComment: """ Test Class for add_comment """ @@ -658,22 +592,14 @@ def test_add_comment_all_params(self): # Set up mock url = preprocess_url('/cases/testString/comments') mock_response = '{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' comment = 'This is a test comment' # Invoke method - response = _service.add_comment( - case_number, - comment, - headers={} - ) + response = _service.add_comment(case_number, comment, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -699,11 +625,7 @@ def test_add_comment_value_error(self): # Set up mock url = preprocess_url('/cases/testString/comments') mock_response = '{"value": "value", "added_at": "added_at", "added_by": {"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' @@ -715,7 +637,7 @@ def test_add_comment_value_error(self): "comment": comment, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_comment(**req_copy) @@ -728,7 +650,8 @@ def test_add_comment_value_error_with_retries(self): _service.disable_retries() self.test_add_comment_value_error() -class TestAddWatchlist(): + +class TestAddWatchlist: """ Test Class for add_watchlist """ @@ -741,11 +664,7 @@ def test_add_watchlist_all_params(self): # Set up mock url = preprocess_url('/cases/testString/watchlist') mock_response = '{"added": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "failed": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a User model user_model = {} @@ -757,11 +676,7 @@ def test_add_watchlist_all_params(self): watchlist = [user_model] # Invoke method - response = _service.add_watchlist( - case_number, - watchlist=watchlist, - headers={} - ) + response = _service.add_watchlist(case_number, watchlist=watchlist, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -787,11 +702,7 @@ def test_add_watchlist_value_error(self): # Set up mock url = preprocess_url('/cases/testString/watchlist') mock_response = '{"added": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}], "failed": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a User model user_model = {} @@ -807,7 +718,7 @@ def test_add_watchlist_value_error(self): "case_number": case_number, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_watchlist(**req_copy) @@ -820,7 +731,8 @@ def test_add_watchlist_value_error_with_retries(self): _service.disable_retries() self.test_add_watchlist_value_error() -class TestRemoveWatchlist(): + +class TestRemoveWatchlist: """ Test Class for remove_watchlist """ @@ -833,11 +745,7 @@ def test_remove_watchlist_all_params(self): # Set up mock url = preprocess_url('/cases/testString/watchlist') mock_response = '{"watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a User model user_model = {} @@ -849,11 +757,7 @@ def test_remove_watchlist_all_params(self): watchlist = [user_model] # Invoke method - response = _service.remove_watchlist( - case_number, - watchlist=watchlist, - headers={} - ) + response = _service.remove_watchlist(case_number, watchlist=watchlist, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -879,11 +783,7 @@ def test_remove_watchlist_value_error(self): # Set up mock url = preprocess_url('/cases/testString/watchlist') mock_response = '{"watchlist": [{"name": "name", "realm": "IBMid", "user_id": "abc@ibm.com"}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a User model user_model = {} @@ -899,7 +799,7 @@ def test_remove_watchlist_value_error(self): "case_number": case_number, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_watchlist(**req_copy) @@ -912,7 +812,8 @@ def test_remove_watchlist_value_error_with_retries(self): _service.disable_retries() self.test_remove_watchlist_value_error() -class TestAddResource(): + +class TestAddResource: """ Test Class for add_resource """ @@ -925,11 +826,7 @@ def test_add_resource_all_params(self): # Set up mock url = preprocess_url('/cases/testString/resources') mock_response = '{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' @@ -939,14 +836,7 @@ def test_add_resource_all_params(self): note = 'testString' # Invoke method - response = _service.add_resource( - case_number, - crn=crn, - type=type, - id=id, - note=note, - headers={} - ) + response = _service.add_resource(case_number, crn=crn, type=type, id=id, note=note, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -975,11 +865,7 @@ def test_add_resource_value_error(self): # Set up mock url = preprocess_url('/cases/testString/resources') mock_response = '{"crn": "crn", "name": "name", "type": "type", "url": "url", "note": "note"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' @@ -993,7 +879,7 @@ def test_add_resource_value_error(self): "case_number": case_number, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_resource(**req_copy) @@ -1006,7 +892,8 @@ def test_add_resource_value_error_with_retries(self): _service.disable_retries() self.test_add_resource_value_error() -class TestUploadFile(): + +class TestUploadFile: """ Test Class for upload_file """ @@ -1018,12 +905,10 @@ def test_upload_file_all_params(self): """ # Set up mock url = preprocess_url('/cases/testString/attachments') - mock_response = '{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + mock_response = ( + '{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}' + ) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a FileWithMetadata model file_with_metadata_model = {} @@ -1036,11 +921,7 @@ def test_upload_file_all_params(self): file = [file_with_metadata_model] # Invoke method - response = _service.upload_file( - case_number, - file, - headers={} - ) + response = _service.upload_file(case_number, file, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1062,12 +943,10 @@ def test_upload_file_value_error(self): """ # Set up mock url = preprocess_url('/cases/testString/attachments') - mock_response = '{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + mock_response = ( + '{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}' + ) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a FileWithMetadata model file_with_metadata_model = {} @@ -1085,7 +964,7 @@ def test_upload_file_value_error(self): "file": file, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.upload_file(**req_copy) @@ -1098,7 +977,8 @@ def test_upload_file_value_error_with_retries(self): _service.disable_retries() self.test_upload_file_value_error() -class TestDownloadFile(): + +class TestDownloadFile: """ Test Class for download_file """ @@ -1111,22 +991,14 @@ def test_download_file_all_params(self): # Set up mock url = preprocess_url('/cases/testString/attachments/testString') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/octet-stream', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/octet-stream', status=200) # Set up parameter values case_number = 'testString' file_id = 'testString' # Invoke method - response = _service.download_file( - case_number, - file_id, - headers={} - ) + response = _service.download_file(case_number, file_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1149,11 +1021,7 @@ def test_download_file_value_error(self): # Set up mock url = preprocess_url('/cases/testString/attachments/testString') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/octet-stream', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/octet-stream', status=200) # Set up parameter values case_number = 'testString' @@ -1165,7 +1033,7 @@ def test_download_file_value_error(self): "file_id": file_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.download_file(**req_copy) @@ -1178,7 +1046,8 @@ def test_download_file_value_error_with_retries(self): _service.disable_retries() self.test_download_file_value_error() -class TestDeleteFile(): + +class TestDeleteFile: """ Test Class for delete_file """ @@ -1191,22 +1060,14 @@ def test_delete_file_all_params(self): # Set up mock url = preprocess_url('/cases/testString/attachments/testString') mock_response = '{"attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' file_id = 'testString' # Invoke method - response = _service.delete_file( - case_number, - file_id, - headers={} - ) + response = _service.delete_file(case_number, file_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1229,11 +1090,7 @@ def test_delete_file_value_error(self): # Set up mock url = preprocess_url('/cases/testString/attachments/testString') mock_response = '{"attachments": [{"id": "id", "filename": "filename", "size_in_bytes": 13, "created_at": "created_at", "url": "url"}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values case_number = 'testString' @@ -1245,7 +1102,7 @@ def test_delete_file_value_error(self): "file_id": file_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()} + 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_file(**req_copy) @@ -1258,6 +1115,7 @@ def test_delete_file_value_error_with_retries(self): _service.disable_retries() self.test_delete_file_value_error() + # endregion ############################################################################## # End of Service: Default @@ -1268,7 +1126,7 @@ def test_delete_file_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_Attachment(): +class TestModel_Attachment: """ Test Class for Attachment """ @@ -1301,7 +1159,8 @@ def test_attachment_serialization(self): attachment_model_json2 = attachment_model.to_dict() assert attachment_model_json2 == attachment_model_json -class TestModel_AttachmentList(): + +class TestModel_AttachmentList: """ Test Class for AttachmentList """ @@ -1313,7 +1172,7 @@ def test_attachment_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - attachment_model = {} # Attachment + attachment_model = {} # Attachment attachment_model['id'] = 'string' attachment_model['filename'] = 'string' attachment_model['size_in_bytes'] = 0 @@ -1339,7 +1198,8 @@ def test_attachment_list_serialization(self): attachment_list_model_json2 = attachment_list_model.to_dict() assert attachment_list_model_json2 == attachment_list_model_json -class TestModel_Case(): + +class TestModel_Case: """ Test Class for Case """ @@ -1351,39 +1211,39 @@ def test_case_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_model = {} # User + user_model = {} # User user_model['realm'] = 'IBMid' user_model['user_id'] = 'abc@ibm.com' - case_eu_model = {} # CaseEu + case_eu_model = {} # CaseEu case_eu_model['support'] = True case_eu_model['data_center'] = 'testString' - attachment_model = {} # Attachment + attachment_model = {} # Attachment attachment_model['id'] = 'testString' attachment_model['filename'] = 'testString' attachment_model['size_in_bytes'] = 38 attachment_model['created_at'] = 'testString' attachment_model['url'] = 'testString' - offering_type_model = {} # OfferingType + offering_type_model = {} # OfferingType offering_type_model['group'] = 'crn_service_name' offering_type_model['key'] = 'testString' offering_type_model['kind'] = 'testString' offering_type_model['id'] = 'testString' - offering_model = {} # Offering + offering_model = {} # Offering offering_model['name'] = 'testString' offering_model['type'] = offering_type_model - resource_model = {} # Resource + resource_model = {} # Resource resource_model['crn'] = 'testString' resource_model['name'] = 'testString' resource_model['type'] = 'testString' resource_model['url'] = 'testString' resource_model['note'] = 'testString' - comment_model = {} # Comment + comment_model = {} # Comment comment_model['value'] = 'testString' comment_model['added_at'] = 'testString' comment_model['added_by'] = user_model @@ -1426,7 +1286,8 @@ def test_case_serialization(self): case_model_json2 = case_model.to_dict() assert case_model_json2 == case_model_json -class TestModel_CaseEu(): + +class TestModel_CaseEu: """ Test Class for CaseEu """ @@ -1456,7 +1317,8 @@ def test_case_eu_serialization(self): case_eu_model_json2 = case_eu_model.to_dict() assert case_eu_model_json2 == case_eu_model_json -class TestModel_CaseList(): + +class TestModel_CaseList: """ Test Class for CaseList """ @@ -1468,47 +1330,47 @@ def test_case_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - pagination_link_model = {} # PaginationLink + pagination_link_model = {} # PaginationLink pagination_link_model['href'] = 'testString' - user_model = {} # User + user_model = {} # User user_model['realm'] = 'IBMid' user_model['user_id'] = 'abc@ibm.com' - case_eu_model = {} # CaseEu + case_eu_model = {} # CaseEu case_eu_model['support'] = True case_eu_model['data_center'] = 'testString' - attachment_model = {} # Attachment + attachment_model = {} # Attachment attachment_model['id'] = 'testString' attachment_model['filename'] = 'testString' attachment_model['size_in_bytes'] = 38 attachment_model['created_at'] = 'testString' attachment_model['url'] = 'testString' - offering_type_model = {} # OfferingType + offering_type_model = {} # OfferingType offering_type_model['group'] = 'crn_service_name' offering_type_model['key'] = 'testString' offering_type_model['kind'] = 'testString' offering_type_model['id'] = 'testString' - offering_model = {} # Offering + offering_model = {} # Offering offering_model['name'] = 'testString' offering_model['type'] = offering_type_model - resource_model = {} # Resource + resource_model = {} # Resource resource_model['crn'] = 'testString' resource_model['name'] = 'testString' resource_model['type'] = 'testString' resource_model['url'] = 'testString' resource_model['note'] = 'testString' - comment_model = {} # Comment + comment_model = {} # Comment comment_model['value'] = 'testString' comment_model['added_at'] = 'testString' comment_model['added_by'] = user_model - case_model = {} # Case + case_model = {} # Case case_model['number'] = 'testString' case_model['short_description'] = 'testString' case_model['description'] = 'testString' @@ -1554,7 +1416,8 @@ def test_case_list_serialization(self): case_list_model_json2 = case_list_model.to_dict() assert case_list_model_json2 == case_list_model_json -class TestModel_CasePayloadEu(): + +class TestModel_CasePayloadEu: """ Test Class for CasePayloadEu """ @@ -1584,7 +1447,8 @@ def test_case_payload_eu_serialization(self): case_payload_eu_model_json2 = case_payload_eu_model.to_dict() assert case_payload_eu_model_json2 == case_payload_eu_model_json -class TestModel_Comment(): + +class TestModel_Comment: """ Test Class for Comment """ @@ -1596,7 +1460,7 @@ def test_comment_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_model = {} # User + user_model = {} # User user_model['realm'] = 'IBMid' user_model['user_id'] = 'abc@ibm.com' @@ -1621,7 +1485,8 @@ def test_comment_serialization(self): comment_model_json2 = comment_model.to_dict() assert comment_model_json2 == comment_model_json -class TestModel_Offering(): + +class TestModel_Offering: """ Test Class for Offering """ @@ -1633,7 +1498,7 @@ def test_offering_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - offering_type_model = {} # OfferingType + offering_type_model = {} # OfferingType offering_type_model['group'] = 'crn_service_name' offering_type_model['key'] = 'testString' offering_type_model['kind'] = 'testString' @@ -1659,7 +1524,8 @@ def test_offering_serialization(self): offering_model_json2 = offering_model.to_dict() assert offering_model_json2 == offering_model_json -class TestModel_OfferingType(): + +class TestModel_OfferingType: """ Test Class for OfferingType """ @@ -1691,7 +1557,8 @@ def test_offering_type_serialization(self): offering_type_model_json2 = offering_type_model.to_dict() assert offering_type_model_json2 == offering_type_model_json -class TestModel_PaginationLink(): + +class TestModel_PaginationLink: """ Test Class for PaginationLink """ @@ -1720,7 +1587,8 @@ def test_pagination_link_serialization(self): pagination_link_model_json2 = pagination_link_model.to_dict() assert pagination_link_model_json2 == pagination_link_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -1753,7 +1621,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_ResourcePayload(): + +class TestModel_ResourcePayload: """ Test Class for ResourcePayload """ @@ -1785,7 +1654,8 @@ def test_resource_payload_serialization(self): resource_payload_model_json2 = resource_payload_model.to_dict() assert resource_payload_model_json2 == resource_payload_model_json -class TestModel_User(): + +class TestModel_User: """ Test Class for User """ @@ -1815,7 +1685,8 @@ def test_user_serialization(self): user_model_json2 = user_model.to_dict() assert user_model_json2 == user_model_json -class TestModel_Watchlist(): + +class TestModel_Watchlist: """ Test Class for Watchlist """ @@ -1827,7 +1698,7 @@ def test_watchlist_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_model = {} # User + user_model = {} # User user_model['realm'] = 'IBMid' user_model['user_id'] = 'abc@ibm.com' @@ -1850,7 +1721,8 @@ def test_watchlist_serialization(self): watchlist_model_json2 = watchlist_model.to_dict() assert watchlist_model_json2 == watchlist_model_json -class TestModel_WatchlistAddResponse(): + +class TestModel_WatchlistAddResponse: """ Test Class for WatchlistAddResponse """ @@ -1862,7 +1734,7 @@ def test_watchlist_add_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_model = {} # User + user_model = {} # User user_model['realm'] = 'IBMid' user_model['user_id'] = 'johndoe@ibm.com' @@ -1886,7 +1758,8 @@ def test_watchlist_add_response_serialization(self): watchlist_add_response_model_json2 = watchlist_add_response_model.to_dict() assert watchlist_add_response_model_json2 == watchlist_add_response_model_json -class TestModel_AcceptPayload(): + +class TestModel_AcceptPayload: """ Test Class for AcceptPayload """ @@ -1916,7 +1789,8 @@ def test_accept_payload_serialization(self): accept_payload_model_json2 = accept_payload_model.to_dict() assert accept_payload_model_json2 == accept_payload_model_json -class TestModel_ResolvePayload(): + +class TestModel_ResolvePayload: """ Test Class for ResolvePayload """ @@ -1947,7 +1821,8 @@ def test_resolve_payload_serialization(self): resolve_payload_model_json2 = resolve_payload_model.to_dict() assert resolve_payload_model_json2 == resolve_payload_model_json -class TestModel_UnresolvePayload(): + +class TestModel_UnresolvePayload: """ Test Class for UnresolvePayload """ @@ -1977,7 +1852,8 @@ def test_unresolve_payload_serialization(self): unresolve_payload_model_json2 = unresolve_payload_model.to_dict() assert unresolve_payload_model_json2 == unresolve_payload_model_json -class TestModel_FileWithMetadata(): + +class TestModel_FileWithMetadata: """ Test Class for FileWithMetadata """ diff --git a/test/unit/test_catalog_management_v1.py b/test/unit/test_catalog_management_v1.py index c4ae5a55..7aa3fc03 100644 --- a/test/unit/test_catalog_management_v1.py +++ b/test/unit/test_catalog_management_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.catalog_management_v1 import * -_service = CatalogManagementV1( - authenticator=NoAuthAuthenticator() -) +_service = CatalogManagementV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://cm.globalcatalog.cloud.ibm.com/api/v1-beta' _service.set_service_url(_base_url) @@ -43,7 +41,8 @@ ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -66,10 +65,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() + -class TestGetCatalogAccount(): +class TestGetCatalogAccount: """ Test Class for get_catalog_account """ @@ -78,7 +77,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -93,16 +92,11 @@ def test_get_catalog_account_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount') mock_response = '{"id": "id", "hide_IBM_cloud_catalog": true, "account_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_catalog_account() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -116,7 +110,8 @@ def test_get_catalog_account_all_params_with_retries(self): _service.disable_retries() self.test_get_catalog_account_all_params() -class TestUpdateCatalogAccount(): + +class TestUpdateCatalogAccount: """ Test Class for update_catalog_account """ @@ -125,7 +120,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -139,9 +134,7 @@ def test_update_catalog_account_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Construct a dict representation of a FilterTerms model filter_terms_model = {} @@ -170,10 +163,7 @@ def test_update_catalog_account_all_params(self): # Invoke method response = _service.update_catalog_account( - id=id, - hide_ibm_cloud_catalog=hide_ibm_cloud_catalog, - account_filters=account_filters, - headers={} + id=id, hide_ibm_cloud_catalog=hide_ibm_cloud_catalog, account_filters=account_filters, headers={} ) # Check for correct operation @@ -201,14 +191,11 @@ def test_update_catalog_account_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Invoke method response = _service.update_catalog_account() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -222,7 +209,8 @@ def test_update_catalog_account_required_params_with_retries(self): _service.disable_retries() self.test_update_catalog_account_required_params() -class TestGetCatalogAccountAudit(): + +class TestGetCatalogAccountAudit: """ Test Class for get_catalog_account_audit """ @@ -231,7 +219,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -246,16 +234,11 @@ def test_get_catalog_account_audit_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_catalog_account_audit() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -269,7 +252,8 @@ def test_get_catalog_account_audit_all_params_with_retries(self): _service.disable_retries() self.test_get_catalog_account_audit_all_params() -class TestGetCatalogAccountFilters(): + +class TestGetCatalogAccountFilters: """ Test Class for get_catalog_account_filters """ @@ -278,7 +262,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -293,26 +277,19 @@ def test_get_catalog_account_filters_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount/filters') mock_response = '{"account_filters": [{"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}], "catalog_filters": [{"catalog": {"id": "id", "name": "name"}, "filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog = 'testString' # Invoke method - response = _service.get_catalog_account_filters( - catalog=catalog, - headers={} - ) + response = _service.get_catalog_account_filters(catalog=catalog, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'catalog={}'.format(catalog) in query_string @@ -333,16 +310,11 @@ def test_get_catalog_account_filters_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogaccount/filters') mock_response = '{"account_filters": [{"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}], "catalog_filters": [{"catalog": {"id": "id", "name": "name"}, "filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_catalog_account_filters() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -356,6 +328,7 @@ def test_get_catalog_account_filters_required_params_with_retries(self): _service.disable_retries() self.test_get_catalog_account_filters_required_params() + # endregion ############################################################################## # End of Service: Account @@ -366,7 +339,8 @@ def test_get_catalog_account_filters_required_params_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -389,10 +363,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() + -class TestListCatalogs(): +class TestListCatalogs: """ Test Class for list_catalogs """ @@ -401,7 +375,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -416,16 +390,11 @@ def test_list_catalogs_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs') mock_response = '{"total_count": 11, "resources": [{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_catalogs() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -439,7 +408,8 @@ def test_list_catalogs_all_params_with_retries(self): _service.disable_retries() self.test_list_catalogs_all_params() -class TestCreateCatalog(): + +class TestCreateCatalog: """ Test Class for create_catalog """ @@ -448,7 +418,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -463,11 +433,7 @@ def test_create_catalog_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a Feature model feature_model = {} @@ -552,7 +518,7 @@ def test_create_catalog_all_params(self): catalog_filters=catalog_filters, syndication_settings=syndication_settings, kind=kind, - headers={} + headers={}, ) # Check for correct operation @@ -591,16 +557,11 @@ def test_create_catalog_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Invoke method response = _service.create_catalog() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 @@ -614,7 +575,8 @@ def test_create_catalog_required_params_with_retries(self): _service.disable_retries() self.test_create_catalog_required_params() -class TestGetCatalog(): + +class TestGetCatalog: """ Test Class for get_catalog """ @@ -623,7 +585,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -638,20 +600,13 @@ def test_get_catalog_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.get_catalog( - catalog_identifier, - headers={} - ) + response = _service.get_catalog(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -674,11 +629,7 @@ def test_get_catalog_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -688,11 +639,10 @@ def test_get_catalog_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_catalog(**req_copy) - def test_get_catalog_value_error_with_retries(self): # Enable retries and run test_get_catalog_value_error. _service.enable_retries() @@ -702,7 +652,8 @@ def test_get_catalog_value_error_with_retries(self): _service.disable_retries() self.test_get_catalog_value_error() -class TestReplaceCatalog(): + +class TestReplaceCatalog: """ Test Class for replace_catalog """ @@ -711,7 +662,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -726,11 +677,7 @@ def test_replace_catalog_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Feature model feature_model = {} @@ -817,7 +764,7 @@ def test_replace_catalog_all_params(self): catalog_filters=catalog_filters, syndication_settings=syndication_settings, kind=kind, - headers={} + headers={}, ) # Check for correct operation @@ -856,20 +803,13 @@ def test_replace_catalog_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.replace_catalog( - catalog_identifier, - headers={} - ) + response = _service.replace_catalog(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -892,11 +832,7 @@ def test_replace_catalog_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') mock_response = '{"id": "id", "_rev": "rev", "label": "label", "short_description": "short_description", "catalog_icon_url": "catalog_icon_url", "tags": ["tags"], "url": "url", "crn": "crn", "offerings_url": "offerings_url", "features": [{"title": "title", "description": "description"}], "disabled": true, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "resource_group_id": "resource_group_id", "owning_account": "owning_account", "catalog_filters": {"include_all": false, "category_filters": {"mapKey": {"include": false, "filter": {"filter_terms": ["filter_terms"]}}}, "id_filters": {"include": {"filter_terms": ["filter_terms"]}, "exclude": {"filter_terms": ["filter_terms"]}}}, "syndication_settings": {"remove_related_components": false, "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "history": {"namespaces": ["namespaces"], "clusters": [{"region": "region", "id": "id", "name": "name", "resource_group_name": "resource_group_name", "type": "type", "namespaces": ["namespaces"], "all_namespaces": true}], "last_run": "2019-01-01T12:00:00.000Z"}, "authorization": {"token": "token", "last_run": "2019-01-01T12:00:00.000Z"}}, "kind": "kind"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -906,11 +842,10 @@ def test_replace_catalog_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_catalog(**req_copy) - def test_replace_catalog_value_error_with_retries(self): # Enable retries and run test_replace_catalog_value_error. _service.enable_retries() @@ -920,7 +855,8 @@ def test_replace_catalog_value_error_with_retries(self): _service.disable_retries() self.test_replace_catalog_value_error() -class TestDeleteCatalog(): + +class TestDeleteCatalog: """ Test Class for delete_catalog """ @@ -929,7 +865,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -943,18 +879,13 @@ def test_delete_catalog_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.delete_catalog( - catalog_identifier, - headers={} - ) + response = _service.delete_catalog(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -976,9 +907,7 @@ def test_delete_catalog_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' @@ -988,11 +917,10 @@ def test_delete_catalog_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_catalog(**req_copy) - def test_delete_catalog_value_error_with_retries(self): # Enable retries and run test_delete_catalog_value_error. _service.enable_retries() @@ -1002,7 +930,8 @@ def test_delete_catalog_value_error_with_retries(self): _service.disable_retries() self.test_delete_catalog_value_error() -class TestGetCatalogAudit(): + +class TestGetCatalogAudit: """ Test Class for get_catalog_audit """ @@ -1011,7 +940,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1026,20 +955,13 @@ def test_get_catalog_audit_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.get_catalog_audit( - catalog_identifier, - headers={} - ) + response = _service.get_catalog_audit(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1062,11 +984,7 @@ def test_get_catalog_audit_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -1076,11 +994,10 @@ def test_get_catalog_audit_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_catalog_audit(**req_copy) - def test_get_catalog_audit_value_error_with_retries(self): # Enable retries and run test_get_catalog_audit_value_error. _service.enable_retries() @@ -1090,6 +1007,7 @@ def test_get_catalog_audit_value_error_with_retries(self): _service.disable_retries() self.test_get_catalog_audit_value_error() + # endregion ############################################################################## # End of Service: Catalogs @@ -1100,7 +1018,8 @@ def test_get_catalog_audit_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1123,10 +1042,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() -class TestGetConsumptionOfferings(): + +class TestGetConsumptionOfferings: """ Test Class for get_consumption_offerings """ @@ -1135,7 +1054,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1150,11 +1069,7 @@ def test_get_consumption_offerings_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/offerings') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values digest = True @@ -1172,14 +1087,14 @@ def test_get_consumption_offerings_all_params(self): include_hidden=include_hidden, limit=limit, offset=offset, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'digest={}'.format('true' if digest else 'false') in query_string assert 'catalog={}'.format(catalog) in query_string @@ -1205,16 +1120,11 @@ def test_get_consumption_offerings_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/offerings') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_consumption_offerings() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -1228,7 +1138,8 @@ def test_get_consumption_offerings_required_params_with_retries(self): _service.disable_retries() self.test_get_consumption_offerings_required_params() -class TestListOfferings(): + +class TestListOfferings: """ Test Class for list_offerings """ @@ -1237,7 +1148,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1252,11 +1163,7 @@ def test_list_offerings_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -1268,20 +1175,14 @@ def test_list_offerings_all_params(self): # Invoke method response = _service.list_offerings( - catalog_identifier, - digest=digest, - limit=limit, - offset=offset, - name=name, - sort=sort, - headers={} + catalog_identifier, digest=digest, limit=limit, offset=offset, name=name, sort=sort, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'digest={}'.format('true' if digest else 'false') in query_string assert 'limit={}'.format(limit) in query_string @@ -1306,20 +1207,13 @@ def test_list_offerings_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.list_offerings( - catalog_identifier, - headers={} - ) + response = _service.list_offerings(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1342,11 +1236,7 @@ def test_list_offerings_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -1356,11 +1246,10 @@ def test_list_offerings_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_offerings(**req_copy) - def test_list_offerings_value_error_with_retries(self): # Enable retries and run test_list_offerings_value_error. _service.enable_retries() @@ -1370,7 +1259,8 @@ def test_list_offerings_value_error_with_retries(self): _service.disable_retries() self.test_list_offerings_value_error() -class TestCreateOffering(): + +class TestCreateOffering: """ Test Class for create_offering """ @@ -1379,7 +1269,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1394,11 +1284,7 @@ def test_create_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a Rating model rating_model = {} @@ -1641,7 +1527,7 @@ def test_create_offering_all_params(self): repo_info=repo_info, support=support, media=media, - headers={} + headers={}, ) # Check for correct operation @@ -1702,20 +1588,13 @@ def test_create_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.create_offering( - catalog_identifier, - headers={} - ) + response = _service.create_offering(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1738,11 +1617,7 @@ def test_create_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -1752,11 +1627,10 @@ def test_create_offering_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_offering(**req_copy) - def test_create_offering_value_error_with_retries(self): # Enable retries and run test_create_offering_value_error. _service.enable_retries() @@ -1766,7 +1640,8 @@ def test_create_offering_value_error_with_retries(self): _service.disable_retries() self.test_create_offering_value_error() -class TestImportOfferingVersion(): + +class TestImportOfferingVersion: """ Test Class for import_offering_version """ @@ -1775,7 +1650,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1790,11 +1665,7 @@ def test_import_offering_version_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/version') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -1820,14 +1691,14 @@ def test_import_offering_version_all_params(self): include_config=include_config, is_vsi=is_vsi, repo_type=repo_type, - headers={} + headers={}, ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'zipurl={}'.format(zipurl) in query_string assert 'targetVersion={}'.format(target_version) in query_string @@ -1857,22 +1728,14 @@ def test_import_offering_version_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/version') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' offering_id = 'testString' # Invoke method - response = _service.import_offering_version( - catalog_identifier, - offering_id, - headers={} - ) + response = _service.import_offering_version(catalog_identifier, offering_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1895,11 +1758,7 @@ def test_import_offering_version_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/version') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -1911,11 +1770,10 @@ def test_import_offering_version_value_error(self): "offering_id": offering_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.import_offering_version(**req_copy) - def test_import_offering_version_value_error_with_retries(self): # Enable retries and run test_import_offering_version_value_error. _service.enable_retries() @@ -1925,7 +1783,8 @@ def test_import_offering_version_value_error_with_retries(self): _service.disable_retries() self.test_import_offering_version_value_error() -class TestImportOffering(): + +class TestImportOffering: """ Test Class for import_offering """ @@ -1934,7 +1793,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1949,11 +1808,7 @@ def test_import_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/import/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -1981,14 +1836,14 @@ def test_import_offering_all_params(self): is_vsi=is_vsi, repo_type=repo_type, x_auth_token=x_auth_token, - headers={} + headers={}, ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'zipurl={}'.format(zipurl) in query_string assert 'offeringID={}'.format(offering_id) in query_string @@ -2019,20 +1874,13 @@ def test_import_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/import/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.import_offering( - catalog_identifier, - headers={} - ) + response = _service.import_offering(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2055,11 +1903,7 @@ def test_import_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/import/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -2069,11 +1913,10 @@ def test_import_offering_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.import_offering(**req_copy) - def test_import_offering_value_error_with_retries(self): # Enable retries and run test_import_offering_value_error. _service.enable_retries() @@ -2083,7 +1926,8 @@ def test_import_offering_value_error_with_retries(self): _service.disable_retries() self.test_import_offering_value_error() -class TestReloadOffering(): + +class TestReloadOffering: """ Test Class for reload_offering """ @@ -2092,7 +1936,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -2107,11 +1951,7 @@ def test_reload_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/reload') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -2133,14 +1973,14 @@ def test_reload_offering_all_params(self): content=content, zipurl=zipurl, repo_type=repo_type, - headers={} + headers={}, ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'targetVersion={}'.format(target_version) in query_string assert 'zipurl={}'.format(zipurl) in query_string @@ -2168,11 +2008,7 @@ def test_reload_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/reload') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -2180,18 +2016,13 @@ def test_reload_offering_required_params(self): target_version = 'testString' # Invoke method - response = _service.reload_offering( - catalog_identifier, - offering_id, - target_version, - headers={} - ) + response = _service.reload_offering(catalog_identifier, offering_id, target_version, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'targetVersion={}'.format(target_version) in query_string @@ -2212,11 +2043,7 @@ def test_reload_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/reload') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -2230,11 +2057,10 @@ def test_reload_offering_value_error(self): "target_version": target_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.reload_offering(**req_copy) - def test_reload_offering_value_error_with_retries(self): # Enable retries and run test_reload_offering_value_error. _service.enable_retries() @@ -2244,7 +2070,8 @@ def test_reload_offering_value_error_with_retries(self): _service.disable_retries() self.test_reload_offering_value_error() -class TestGetOffering(): + +class TestGetOffering: """ Test Class for get_offering """ @@ -2253,7 +2080,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -2268,11 +2095,7 @@ def test_get_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -2281,19 +2104,13 @@ def test_get_offering_all_params(self): digest = True # Invoke method - response = _service.get_offering( - catalog_identifier, - offering_id, - type=type, - digest=digest, - headers={} - ) + response = _service.get_offering(catalog_identifier, offering_id, type=type, digest=digest, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'type={}'.format(type) in query_string assert 'digest={}'.format('true' if digest else 'false') in query_string @@ -2315,22 +2132,14 @@ def test_get_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' offering_id = 'testString' # Invoke method - response = _service.get_offering( - catalog_identifier, - offering_id, - headers={} - ) + response = _service.get_offering(catalog_identifier, offering_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2353,11 +2162,7 @@ def test_get_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -2369,11 +2174,10 @@ def test_get_offering_value_error(self): "offering_id": offering_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()} + 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_offering(**req_copy) - def test_get_offering_value_error_with_retries(self): # Enable retries and run test_get_offering_value_error. _service.enable_retries() @@ -2383,7 +2187,8 @@ def test_get_offering_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_value_error() -class TestReplaceOffering(): + +class TestReplaceOffering: """ Test Class for replace_offering """ @@ -2392,7 +2197,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -2407,11 +2212,7 @@ def test_replace_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Rating model rating_model = {} @@ -2656,7 +2457,7 @@ def test_replace_offering_all_params(self): repo_info=repo_info, support=support, media=media, - headers={} + headers={}, ) # Check for correct operation @@ -2717,22 +2518,14 @@ def test_replace_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' offering_id = 'testString' # Invoke method - response = _service.replace_offering( - catalog_identifier, - offering_id, - headers={} - ) + response = _service.replace_offering(catalog_identifier, offering_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2755,11 +2548,7 @@ def test_replace_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -2771,11 +2560,10 @@ def test_replace_offering_value_error(self): "offering_id": offering_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_offering(**req_copy) - def test_replace_offering_value_error_with_retries(self): # Enable retries and run test_replace_offering_value_error. _service.enable_retries() @@ -2785,7 +2573,8 @@ def test_replace_offering_value_error_with_retries(self): _service.disable_retries() self.test_replace_offering_value_error() -class TestUpdateOffering(): + +class TestUpdateOffering: """ Test Class for update_offering """ @@ -2794,7 +2583,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -2809,11 +2598,7 @@ def test_update_offering_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a JsonPatchOperation model json_patch_operation_model = {} @@ -2829,13 +2614,7 @@ def test_update_offering_all_params(self): updates = [json_patch_operation_model] # Invoke method - response = _service.update_offering( - catalog_identifier, - offering_id, - if_match, - updates=updates, - headers={} - ) + response = _service.update_offering(catalog_identifier, offering_id, if_match, updates=updates, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2861,11 +2640,7 @@ def test_update_offering_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -2873,12 +2648,7 @@ def test_update_offering_required_params(self): if_match = 'testString' # Invoke method - response = _service.update_offering( - catalog_identifier, - offering_id, - if_match, - headers={} - ) + response = _service.update_offering(catalog_identifier, offering_id, if_match, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2901,11 +2671,7 @@ def test_update_offering_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -2919,11 +2685,10 @@ def test_update_offering_value_error(self): "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()} + 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_offering(**req_copy) - def test_update_offering_value_error_with_retries(self): # Enable retries and run test_update_offering_value_error. _service.enable_retries() @@ -2933,7 +2698,8 @@ def test_update_offering_value_error_with_retries(self): _service.disable_retries() self.test_update_offering_value_error() -class TestDeleteOffering(): + +class TestDeleteOffering: """ Test Class for delete_offering """ @@ -2942,7 +2708,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -2956,20 +2722,14 @@ def test_delete_offering_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' offering_id = 'testString' # Invoke method - response = _service.delete_offering( - catalog_identifier, - offering_id, - headers={} - ) + response = _service.delete_offering(catalog_identifier, offering_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2991,9 +2751,7 @@ def test_delete_offering_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3005,11 +2763,10 @@ def test_delete_offering_value_error(self): "offering_id": offering_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()} + 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_offering(**req_copy) - def test_delete_offering_value_error_with_retries(self): # Enable retries and run test_delete_offering_value_error. _service.enable_retries() @@ -3019,7 +2776,8 @@ def test_delete_offering_value_error_with_retries(self): _service.disable_retries() self.test_delete_offering_value_error() -class TestGetOfferingAudit(): + +class TestGetOfferingAudit: """ Test Class for get_offering_audit """ @@ -3028,7 +2786,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3043,22 +2801,14 @@ def test_get_offering_audit_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' offering_id = 'testString' # Invoke method - response = _service.get_offering_audit( - catalog_identifier, - offering_id, - headers={} - ) + response = _service.get_offering_audit(catalog_identifier, offering_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3081,11 +2831,7 @@ def test_get_offering_audit_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3097,11 +2843,10 @@ def test_get_offering_audit_value_error(self): "offering_id": offering_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()} + 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_offering_audit(**req_copy) - def test_get_offering_audit_value_error_with_retries(self): # Enable retries and run test_get_offering_audit_value_error. _service.enable_retries() @@ -3111,7 +2856,8 @@ def test_get_offering_audit_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_audit_value_error() -class TestReplaceOfferingIcon(): + +class TestReplaceOfferingIcon: """ Test Class for replace_offering_icon """ @@ -3120,7 +2866,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3135,11 +2881,7 @@ def test_replace_offering_icon_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/icon/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3147,12 +2889,7 @@ def test_replace_offering_icon_all_params(self): file_name = 'testString' # Invoke method - response = _service.replace_offering_icon( - catalog_identifier, - offering_id, - file_name, - headers={} - ) + response = _service.replace_offering_icon(catalog_identifier, offering_id, file_name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3175,11 +2912,7 @@ def test_replace_offering_icon_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/icon/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3193,11 +2926,10 @@ def test_replace_offering_icon_value_error(self): "file_name": file_name, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_offering_icon(**req_copy) - def test_replace_offering_icon_value_error_with_retries(self): # Enable retries and run test_replace_offering_icon_value_error. _service.enable_retries() @@ -3207,7 +2939,8 @@ def test_replace_offering_icon_value_error_with_retries(self): _service.disable_retries() self.test_replace_offering_icon_value_error() -class TestUpdateOfferingIbm(): + +class TestUpdateOfferingIbm: """ Test Class for update_offering_ibm """ @@ -3216,7 +2949,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3231,11 +2964,7 @@ def test_update_offering_ibm_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/publish/pc_managed/true') mock_response = '{"allow_request": false, "ibm": false, "public": true, "changed": false}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3244,13 +2973,7 @@ def test_update_offering_ibm_all_params(self): approved = 'true' # Invoke method - response = _service.update_offering_ibm( - catalog_identifier, - offering_id, - approval_type, - approved, - headers={} - ) + response = _service.update_offering_ibm(catalog_identifier, offering_id, approval_type, approved, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3273,11 +2996,7 @@ def test_update_offering_ibm_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/publish/pc_managed/true') mock_response = '{"allow_request": false, "ibm": false, "public": true, "changed": false}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3293,11 +3012,10 @@ def test_update_offering_ibm_value_error(self): "approved": approved, } 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()} + 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_offering_ibm(**req_copy) - def test_update_offering_ibm_value_error_with_retries(self): # Enable retries and run test_update_offering_ibm_value_error. _service.enable_retries() @@ -3307,7 +3025,8 @@ def test_update_offering_ibm_value_error_with_retries(self): _service.disable_retries() self.test_update_offering_ibm_value_error() -class TestDeprecateOffering(): + +class TestDeprecateOffering: """ Test Class for deprecate_offering """ @@ -3316,7 +3035,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3330,9 +3049,7 @@ def test_deprecate_offering_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -3348,7 +3065,7 @@ def test_deprecate_offering_all_params(self): setting, description=description, days_until_deprecate=days_until_deprecate, - headers={} + headers={}, ) # Check for correct operation @@ -3375,9 +3092,7 @@ def test_deprecate_offering_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -3385,12 +3100,7 @@ def test_deprecate_offering_required_params(self): setting = 'true' # Invoke method - response = _service.deprecate_offering( - catalog_identifier, - offering_id, - setting, - headers={} - ) + response = _service.deprecate_offering(catalog_identifier, offering_id, setting, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3412,9 +3122,7 @@ def test_deprecate_offering_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -3428,11 +3136,10 @@ def test_deprecate_offering_value_error(self): "setting": setting, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.deprecate_offering(**req_copy) - def test_deprecate_offering_value_error_with_retries(self): # Enable retries and run test_deprecate_offering_value_error. _service.enable_retries() @@ -3442,7 +3149,8 @@ def test_deprecate_offering_value_error_with_retries(self): _service.disable_retries() self.test_deprecate_offering_value_error() -class TestGetOfferingUpdates(): + +class TestGetOfferingUpdates: """ Test Class for get_offering_updates """ @@ -3451,7 +3159,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3466,11 +3174,7 @@ def test_get_offering_updates_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/updates') mock_response = '[{"version_locator": "version_locator", "version": "version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "required_resources": [{"type": "mem", "value": "anyValue"}], "package_version": "package_version", "sha": "sha", "can_update": true, "messages": {"mapKey": "inner"}}]' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3504,14 +3208,14 @@ def test_get_offering_updates_all_params(self): channel=channel, namespaces=namespaces, all_namespaces=all_namespaces, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'kind={}'.format(kind) in query_string assert 'target={}'.format(target) in query_string @@ -3542,11 +3246,7 @@ def test_get_offering_updates_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/updates') mock_response = '[{"version_locator": "version_locator", "version": "version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "required_resources": [{"type": "mem", "value": "anyValue"}], "package_version": "package_version", "sha": "sha", "can_update": true, "messages": {"mapKey": "inner"}}]' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3556,18 +3256,14 @@ def test_get_offering_updates_required_params(self): # Invoke method response = _service.get_offering_updates( - catalog_identifier, - offering_id, - kind, - x_auth_refresh_token, - headers={} + catalog_identifier, offering_id, kind, x_auth_refresh_token, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'kind={}'.format(kind) in query_string @@ -3588,11 +3284,7 @@ def test_get_offering_updates_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/offerings/testString/updates') mock_response = '[{"version_locator": "version_locator", "version": "version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "required_resources": [{"type": "mem", "value": "anyValue"}], "package_version": "package_version", "sha": "sha", "can_update": true, "messages": {"mapKey": "inner"}}]' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -3608,11 +3300,10 @@ def test_get_offering_updates_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_offering_updates(**req_copy) - def test_get_offering_updates_value_error_with_retries(self): # Enable retries and run test_get_offering_updates_value_error. _service.enable_retries() @@ -3622,7 +3313,8 @@ def test_get_offering_updates_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_updates_value_error() -class TestGetOfferingSource(): + +class TestGetOfferingSource: """ Test Class for get_offering_source """ @@ -3631,7 +3323,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3646,11 +3338,7 @@ def test_get_offering_source_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/offering/source') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/yaml', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/yaml', status=200) # Set up parameter values version = 'testString' @@ -3663,21 +3351,14 @@ def test_get_offering_source_all_params(self): # Invoke method response = _service.get_offering_source( - version, - accept=accept, - catalog_id=catalog_id, - name=name, - id=id, - kind=kind, - channel=channel, - headers={} + version, accept=accept, catalog_id=catalog_id, name=name, id=id, kind=kind, channel=channel, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'version={}'.format(version) in query_string assert 'catalogID={}'.format(catalog_id) in query_string @@ -3703,26 +3384,19 @@ def test_get_offering_source_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/offering/source') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/yaml', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/yaml', status=200) # Set up parameter values version = 'testString' # Invoke method - response = _service.get_offering_source( - version, - headers={} - ) + response = _service.get_offering_source(version, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'version={}'.format(version) in query_string @@ -3743,11 +3417,7 @@ def test_get_offering_source_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/offering/source') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/yaml', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/yaml', status=200) # Set up parameter values version = 'testString' @@ -3757,11 +3427,10 @@ def test_get_offering_source_value_error(self): "version": version, } for param in req_param_dict.keys(): - req_copy = {key:val if key is not param else None for (key,val) in req_param_dict.items()} + 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_offering_source(**req_copy) - def test_get_offering_source_value_error_with_retries(self): # Enable retries and run test_get_offering_source_value_error. _service.enable_retries() @@ -3771,6 +3440,7 @@ def test_get_offering_source_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_source_value_error() + # endregion ############################################################################## # End of Service: Offerings @@ -3781,7 +3451,8 @@ def test_get_offering_source_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -3804,10 +3475,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() + -class TestGetOfferingAbout(): +class TestGetOfferingAbout: """ Test Class for get_offering_about """ @@ -3816,7 +3487,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3831,20 +3502,13 @@ def test_get_offering_about_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/about') mock_response = '"operation_response"' - responses.add(responses.GET, - url, - body=mock_response, - content_type='text/markdown', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='text/markdown', status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.get_offering_about( - version_loc_id, - headers={} - ) + response = _service.get_offering_about(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3867,11 +3531,7 @@ def test_get_offering_about_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/about') mock_response = '"operation_response"' - responses.add(responses.GET, - url, - body=mock_response, - content_type='text/markdown', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='text/markdown', status=200) # Set up parameter values version_loc_id = 'testString' @@ -3881,11 +3541,10 @@ def test_get_offering_about_value_error(self): "version_loc_id": version_loc_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()} + 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_offering_about(**req_copy) - def test_get_offering_about_value_error_with_retries(self): # Enable retries and run test_get_offering_about_value_error. _service.enable_retries() @@ -3895,7 +3554,8 @@ def test_get_offering_about_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_about_value_error() -class TestGetOfferingLicense(): + +class TestGetOfferingLicense: """ Test Class for get_offering_license """ @@ -3904,7 +3564,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -3919,22 +3579,14 @@ def test_get_offering_license_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/licenses/testString') mock_response = '"operation_response"' - responses.add(responses.GET, - url, - body=mock_response, - content_type='text/plain', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='text/plain', status=200) # Set up parameter values version_loc_id = 'testString' license_id = 'testString' # Invoke method - response = _service.get_offering_license( - version_loc_id, - license_id, - headers={} - ) + response = _service.get_offering_license(version_loc_id, license_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3957,11 +3609,7 @@ def test_get_offering_license_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/licenses/testString') mock_response = '"operation_response"' - responses.add(responses.GET, - url, - body=mock_response, - content_type='text/plain', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='text/plain', status=200) # Set up parameter values version_loc_id = 'testString' @@ -3973,11 +3621,10 @@ def test_get_offering_license_value_error(self): "license_id": license_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()} + 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_offering_license(**req_copy) - def test_get_offering_license_value_error_with_retries(self): # Enable retries and run test_get_offering_license_value_error. _service.enable_retries() @@ -3987,7 +3634,8 @@ def test_get_offering_license_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_license_value_error() -class TestGetOfferingContainerImages(): + +class TestGetOfferingContainerImages: """ Test Class for get_offering_container_images """ @@ -3996,7 +3644,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4011,20 +3659,13 @@ def test_get_offering_container_images_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/containerImages') mock_response = '{"description": "description", "images": [{"image": "image"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.get_offering_container_images( - version_loc_id, - headers={} - ) + response = _service.get_offering_container_images(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4047,11 +3688,7 @@ def test_get_offering_container_images_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/containerImages') mock_response = '{"description": "description", "images": [{"image": "image"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -4061,11 +3698,10 @@ def test_get_offering_container_images_value_error(self): "version_loc_id": version_loc_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()} + 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_offering_container_images(**req_copy) - def test_get_offering_container_images_value_error_with_retries(self): # Enable retries and run test_get_offering_container_images_value_error. _service.enable_retries() @@ -4075,7 +3711,8 @@ def test_get_offering_container_images_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_container_images_value_error() -class TestDeprecateVersion(): + +class TestDeprecateVersion: """ Test Class for deprecate_version """ @@ -4084,7 +3721,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4098,18 +3735,13 @@ def test_deprecate_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/deprecate') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.deprecate_version( - version_loc_id, - headers={} - ) + response = _service.deprecate_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4131,9 +3763,7 @@ def test_deprecate_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/deprecate') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4143,11 +3773,10 @@ def test_deprecate_version_value_error(self): "version_loc_id": version_loc_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.deprecate_version(**req_copy) - def test_deprecate_version_value_error_with_retries(self): # Enable retries and run test_deprecate_version_value_error. _service.enable_retries() @@ -4157,7 +3786,8 @@ def test_deprecate_version_value_error_with_retries(self): _service.disable_retries() self.test_deprecate_version_value_error() -class TestSetDeprecateVersion(): + +class TestSetDeprecateVersion: """ Test Class for set_deprecate_version """ @@ -4166,7 +3796,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4180,9 +3810,7 @@ def test_set_deprecate_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4192,11 +3820,7 @@ def test_set_deprecate_version_all_params(self): # Invoke method response = _service.set_deprecate_version( - version_loc_id, - setting, - description=description, - days_until_deprecate=days_until_deprecate, - headers={} + version_loc_id, setting, description=description, days_until_deprecate=days_until_deprecate, headers={} ) # Check for correct operation @@ -4223,20 +3847,14 @@ def test_set_deprecate_version_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' setting = 'true' # Invoke method - response = _service.set_deprecate_version( - version_loc_id, - setting, - headers={} - ) + response = _service.set_deprecate_version(version_loc_id, setting, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4258,9 +3876,7 @@ def test_set_deprecate_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/deprecate/true') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4272,11 +3888,10 @@ def test_set_deprecate_version_value_error(self): "setting": setting, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.set_deprecate_version(**req_copy) - def test_set_deprecate_version_value_error_with_retries(self): # Enable retries and run test_set_deprecate_version_value_error. _service.enable_retries() @@ -4286,7 +3901,8 @@ def test_set_deprecate_version_value_error_with_retries(self): _service.disable_retries() self.test_set_deprecate_version_value_error() -class TestAccountPublishVersion(): + +class TestAccountPublishVersion: """ Test Class for account_publish_version """ @@ -4295,7 +3911,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4309,18 +3925,13 @@ def test_account_publish_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/account-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.account_publish_version( - version_loc_id, - headers={} - ) + response = _service.account_publish_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4342,9 +3953,7 @@ def test_account_publish_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/account-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4354,11 +3963,10 @@ def test_account_publish_version_value_error(self): "version_loc_id": version_loc_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.account_publish_version(**req_copy) - def test_account_publish_version_value_error_with_retries(self): # Enable retries and run test_account_publish_version_value_error. _service.enable_retries() @@ -4368,7 +3976,8 @@ def test_account_publish_version_value_error_with_retries(self): _service.disable_retries() self.test_account_publish_version_value_error() -class TestIbmPublishVersion(): + +class TestIbmPublishVersion: """ Test Class for ibm_publish_version """ @@ -4377,7 +3986,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4391,18 +4000,13 @@ def test_ibm_publish_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/ibm-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.ibm_publish_version( - version_loc_id, - headers={} - ) + response = _service.ibm_publish_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4424,9 +4028,7 @@ def test_ibm_publish_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/ibm-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4436,11 +4038,10 @@ def test_ibm_publish_version_value_error(self): "version_loc_id": version_loc_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.ibm_publish_version(**req_copy) - def test_ibm_publish_version_value_error_with_retries(self): # Enable retries and run test_ibm_publish_version_value_error. _service.enable_retries() @@ -4450,7 +4051,8 @@ def test_ibm_publish_version_value_error_with_retries(self): _service.disable_retries() self.test_ibm_publish_version_value_error() -class TestPublicPublishVersion(): + +class TestPublicPublishVersion: """ Test Class for public_publish_version """ @@ -4459,7 +4061,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4473,18 +4075,13 @@ def test_public_publish_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/public-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.public_publish_version( - version_loc_id, - headers={} - ) + response = _service.public_publish_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4506,9 +4103,7 @@ def test_public_publish_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/public-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -4518,11 +4113,10 @@ def test_public_publish_version_value_error(self): "version_loc_id": version_loc_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.public_publish_version(**req_copy) - def test_public_publish_version_value_error_with_retries(self): # Enable retries and run test_public_publish_version_value_error. _service.enable_retries() @@ -4532,7 +4126,8 @@ def test_public_publish_version_value_error_with_retries(self): _service.disable_retries() self.test_public_publish_version_value_error() -class TestCommitVersion(): + +class TestCommitVersion: """ Test Class for commit_version """ @@ -4541,7 +4136,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4555,18 +4150,13 @@ def test_commit_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/commit') - responses.add(responses.POST, - url, - status=200) + responses.add(responses.POST, url, status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.commit_version( - version_loc_id, - headers={} - ) + response = _service.commit_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4588,9 +4178,7 @@ def test_commit_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/commit') - responses.add(responses.POST, - url, - status=200) + responses.add(responses.POST, url, status=200) # Set up parameter values version_loc_id = 'testString' @@ -4600,11 +4188,10 @@ def test_commit_version_value_error(self): "version_loc_id": version_loc_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()} + 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_version(**req_copy) - def test_commit_version_value_error_with_retries(self): # Enable retries and run test_commit_version_value_error. _service.enable_retries() @@ -4614,7 +4201,8 @@ def test_commit_version_value_error_with_retries(self): _service.disable_retries() self.test_commit_version_value_error() -class TestCopyVersion(): + +class TestCopyVersion: """ Test Class for copy_version """ @@ -4623,7 +4211,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4637,9 +4225,7 @@ def test_copy_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/copy') - responses.add(responses.POST, - url, - status=200) + responses.add(responses.POST, url, status=200) # Set up parameter values version_loc_id = 'testString' @@ -4649,11 +4235,7 @@ def test_copy_version_all_params(self): # Invoke method response = _service.copy_version( - version_loc_id, - tags=tags, - target_kinds=target_kinds, - content=content, - headers={} + version_loc_id, tags=tags, target_kinds=target_kinds, content=content, headers={} ) # Check for correct operation @@ -4681,18 +4263,13 @@ def test_copy_version_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/copy') - responses.add(responses.POST, - url, - status=200) + responses.add(responses.POST, url, status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.copy_version( - version_loc_id, - headers={} - ) + response = _service.copy_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4714,9 +4291,7 @@ def test_copy_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/copy') - responses.add(responses.POST, - url, - status=200) + responses.add(responses.POST, url, status=200) # Set up parameter values version_loc_id = 'testString' @@ -4726,11 +4301,10 @@ def test_copy_version_value_error(self): "version_loc_id": version_loc_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.copy_version(**req_copy) - def test_copy_version_value_error_with_retries(self): # Enable retries and run test_copy_version_value_error. _service.enable_retries() @@ -4740,7 +4314,8 @@ def test_copy_version_value_error_with_retries(self): _service.disable_retries() self.test_copy_version_value_error() -class TestGetOfferingWorkingCopy(): + +class TestGetOfferingWorkingCopy: """ Test Class for get_offering_working_copy """ @@ -4749,7 +4324,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4764,20 +4339,13 @@ def test_get_offering_working_copy_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/workingcopy') mock_response = '{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.get_offering_working_copy( - version_loc_id, - headers={} - ) + response = _service.get_offering_working_copy(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4800,11 +4368,7 @@ def test_get_offering_working_copy_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/workingcopy') mock_response = '{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -4814,11 +4378,10 @@ def test_get_offering_working_copy_value_error(self): "version_loc_id": version_loc_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()} + 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_offering_working_copy(**req_copy) - def test_get_offering_working_copy_value_error_with_retries(self): # Enable retries and run test_get_offering_working_copy_value_error. _service.enable_retries() @@ -4828,7 +4391,8 @@ def test_get_offering_working_copy_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_working_copy_value_error() -class TestGetVersion(): + +class TestGetVersion: """ Test Class for get_version """ @@ -4837,7 +4401,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4852,20 +4416,13 @@ def test_get_version_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.get_version( - version_loc_id, - headers={} - ) + response = _service.get_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4888,11 +4445,7 @@ def test_get_version_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "name": "name", "offering_icon_url": "offering_icon_url", "offering_docs_url": "offering_docs_url", "offering_support_url": "offering_support_url", "tags": ["tags"], "keywords": ["keywords"], "rating": {"one_star_count": 14, "two_star_count": 14, "three_star_count": 16, "four_star_count": 15}, "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "long_description": "long_description", "features": [{"title": "title", "description": "description"}], "kinds": [{"id": "id", "format_kind": "format_kind", "target_kind": "target_kind", "metadata": {"mapKey": "anyValue"}, "install_description": "install_description", "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "versions": [{"id": "id", "_rev": "rev", "crn": "crn", "version": "version", "sha": "sha", "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "offering_id": "offering_id", "catalog_id": "catalog_id", "kind_id": "kind_id", "tags": ["tags"], "repo_url": "repo_url", "source_url": "source_url", "tgz_url": "tgz_url", "configuration": [{"key": "key", "type": "type", "default_value": "anyValue", "value_constraint": "value_constraint", "description": "description", "required": true, "options": ["anyValue"], "hidden": true}], "metadata": {"mapKey": "anyValue"}, "validation": {"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}, "required_resources": [{"type": "mem", "value": "anyValue"}], "single_instance": false, "install": {"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}, "pre_install": [{"instructions": "instructions", "script": "script", "script_permission": "script_permission", "delete_script": "delete_script", "scope": "scope"}], "entitlement": {"provider_name": "provider_name", "provider_id": "provider_id", "product_id": "product_id", "part_numbers": ["part_numbers"], "image_repo_name": "image_repo_name"}, "licenses": [{"id": "id", "name": "name", "type": "type", "url": "url", "description": "description"}], "image_manifest_url": "image_manifest_url", "deprecated": true, "package_version": "package_version", "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "version_locator": "version_locator", "console_url": "console_url", "long_description": "long_description", "whitelisted_accounts": ["whitelisted_accounts"]}], "plans": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "additional_features": [{"title": "title", "description": "description"}], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "deployments": [{"id": "id", "label": "label", "name": "name", "short_description": "short_description", "long_description": "long_description", "metadata": {"mapKey": "anyValue"}, "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}]}], "permit_request_ibm_public_publish": false, "ibm_publish_approved": true, "public_publish_approved": false, "public_original_crn": "public_original_crn", "publish_public_crn": "publish_public_crn", "portal_approval_record": "portal_approval_record", "portal_ui_url": "portal_ui_url", "catalog_id": "catalog_id", "catalog_name": "catalog_name", "metadata": {"mapKey": "anyValue"}, "disclaimer": "disclaimer", "hidden": true, "provider": "provider", "provider_info": {"id": "id", "name": "name"}, "repo_info": {"token": "token", "type": "type"}, "support": {"url": "url", "process": "process", "locations": ["locations"]}, "media": [{"url": "url", "caption": "caption", "type": "type", "thumbnail_url": "thumbnail_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -4902,11 +4455,10 @@ def test_get_version_value_error(self): "version_loc_id": version_loc_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()} + 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_version(**req_copy) - def test_get_version_value_error_with_retries(self): # Enable retries and run test_get_version_value_error. _service.enable_retries() @@ -4916,7 +4468,8 @@ def test_get_version_value_error_with_retries(self): _service.disable_retries() self.test_get_version_value_error() -class TestDeleteVersion(): + +class TestDeleteVersion: """ Test Class for delete_version """ @@ -4925,7 +4478,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -4939,18 +4492,13 @@ def test_delete_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.delete_version( - version_loc_id, - headers={} - ) + response = _service.delete_version(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -4972,9 +4520,7 @@ def test_delete_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values version_loc_id = 'testString' @@ -4984,11 +4530,10 @@ def test_delete_version_value_error(self): "version_loc_id": version_loc_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()} + 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_version(**req_copy) - def test_delete_version_value_error_with_retries(self): # Enable retries and run test_delete_version_value_error. _service.enable_retries() @@ -4998,6 +4543,7 @@ def test_delete_version_value_error_with_retries(self): _service.disable_retries() self.test_delete_version_value_error() + # endregion ############################################################################## # End of Service: Versions @@ -5008,7 +4554,8 @@ def test_delete_version_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -5031,10 +4578,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() + -class TestGetCluster(): +class TestGetCluster: """ Test Class for get_cluster """ @@ -5043,7 +4590,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5058,11 +4605,7 @@ def test_get_cluster_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/clusters/testString') mock_response = '{"resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "id": "id", "name": "name", "region": "region"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values cluster_id = 'testString' @@ -5070,18 +4613,13 @@ def test_get_cluster_all_params(self): x_auth_refresh_token = 'testString' # Invoke method - response = _service.get_cluster( - cluster_id, - region, - x_auth_refresh_token, - headers={} - ) + response = _service.get_cluster(cluster_id, region, x_auth_refresh_token, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'region={}'.format(region) in query_string @@ -5102,11 +4640,7 @@ def test_get_cluster_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/clusters/testString') mock_response = '{"resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "id": "id", "name": "name", "region": "region"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values cluster_id = 'testString' @@ -5120,11 +4654,10 @@ def test_get_cluster_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_cluster(**req_copy) - def test_get_cluster_value_error_with_retries(self): # Enable retries and run test_get_cluster_value_error. _service.enable_retries() @@ -5134,7 +4667,8 @@ def test_get_cluster_value_error_with_retries(self): _service.disable_retries() self.test_get_cluster_value_error() -class TestGetNamespaces(): + +class TestGetNamespaces: """ Test Class for get_namespaces """ @@ -5143,7 +4677,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5158,11 +4692,7 @@ def test_get_namespaces_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/clusters/testString/namespaces') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": ["resources"]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values cluster_id = 'testString' @@ -5173,19 +4703,14 @@ def test_get_namespaces_all_params(self): # Invoke method response = _service.get_namespaces( - cluster_id, - region, - x_auth_refresh_token, - limit=limit, - offset=offset, - headers={} + cluster_id, region, x_auth_refresh_token, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'region={}'.format(region) in query_string assert 'limit={}'.format(limit) in query_string @@ -5208,11 +4733,7 @@ def test_get_namespaces_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/clusters/testString/namespaces') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": ["resources"]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values cluster_id = 'testString' @@ -5220,18 +4741,13 @@ def test_get_namespaces_required_params(self): x_auth_refresh_token = 'testString' # Invoke method - response = _service.get_namespaces( - cluster_id, - region, - x_auth_refresh_token, - headers={} - ) + response = _service.get_namespaces(cluster_id, region, x_auth_refresh_token, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'region={}'.format(region) in query_string @@ -5252,11 +4768,7 @@ def test_get_namespaces_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/clusters/testString/namespaces') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": ["resources"]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values cluster_id = 'testString' @@ -5270,11 +4782,10 @@ def test_get_namespaces_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_namespaces(**req_copy) - def test_get_namespaces_value_error_with_retries(self): # Enable retries and run test_get_namespaces_value_error. _service.enable_retries() @@ -5284,7 +4795,8 @@ def test_get_namespaces_value_error_with_retries(self): _service.disable_retries() self.test_get_namespaces_value_error() -class TestDeployOperators(): + +class TestDeployOperators: """ Test Class for deploy_operators """ @@ -5293,7 +4805,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5308,11 +4820,7 @@ def test_deploy_operators_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5330,7 +4838,7 @@ def test_deploy_operators_all_params(self): namespaces=namespaces, all_namespaces=all_namespaces, version_locator_id=version_locator_id, - headers={} + headers={}, ) # Check for correct operation @@ -5361,20 +4869,13 @@ def test_deploy_operators_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' # Invoke method - response = _service.deploy_operators( - x_auth_refresh_token, - headers={} - ) + response = _service.deploy_operators(x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -5397,11 +4898,7 @@ def test_deploy_operators_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5411,11 +4908,10 @@ def test_deploy_operators_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.deploy_operators(**req_copy) - def test_deploy_operators_value_error_with_retries(self): # Enable retries and run test_deploy_operators_value_error. _service.enable_retries() @@ -5425,7 +4921,8 @@ def test_deploy_operators_value_error_with_retries(self): _service.disable_retries() self.test_deploy_operators_value_error() -class TestListOperators(): + +class TestListOperators: """ Test Class for list_operators """ @@ -5434,7 +4931,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5449,11 +4946,7 @@ def test_list_operators_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5462,19 +4955,13 @@ def test_list_operators_all_params(self): version_locator_id = 'testString' # Invoke method - response = _service.list_operators( - x_auth_refresh_token, - cluster_id, - region, - version_locator_id, - headers={} - ) + response = _service.list_operators(x_auth_refresh_token, cluster_id, region, version_locator_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'cluster_id={}'.format(cluster_id) in query_string assert 'region={}'.format(region) in query_string @@ -5497,11 +4984,7 @@ def test_list_operators_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5517,11 +5000,10 @@ def test_list_operators_value_error(self): "version_locator_id": version_locator_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()} + 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_operators(**req_copy) - def test_list_operators_value_error_with_retries(self): # Enable retries and run test_list_operators_value_error. _service.enable_retries() @@ -5531,7 +5013,8 @@ def test_list_operators_value_error_with_retries(self): _service.disable_retries() self.test_list_operators_value_error() -class TestReplaceOperators(): + +class TestReplaceOperators: """ Test Class for replace_operators """ @@ -5540,7 +5023,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5555,11 +5038,7 @@ def test_replace_operators_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5577,7 +5056,7 @@ def test_replace_operators_all_params(self): namespaces=namespaces, all_namespaces=all_namespaces, version_locator_id=version_locator_id, - headers={} + headers={}, ) # Check for correct operation @@ -5608,20 +5087,13 @@ def test_replace_operators_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' # Invoke method - response = _service.replace_operators( - x_auth_refresh_token, - headers={} - ) + response = _service.replace_operators(x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -5644,11 +5116,7 @@ def test_replace_operators_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') mock_response = '[{"phase": "phase", "message": "message", "link": "link", "name": "name", "version": "version", "namespace": "namespace", "package_name": "package_name", "catalog_id": "catalog_id"}]' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5658,11 +5126,10 @@ def test_replace_operators_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_operators(**req_copy) - def test_replace_operators_value_error_with_retries(self): # Enable retries and run test_replace_operators_value_error. _service.enable_retries() @@ -5672,7 +5139,8 @@ def test_replace_operators_value_error_with_retries(self): _service.disable_retries() self.test_replace_operators_value_error() -class TestDeleteOperators(): + +class TestDeleteOperators: """ Test Class for delete_operators """ @@ -5681,7 +5149,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5695,9 +5163,7 @@ def test_delete_operators_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5706,19 +5172,13 @@ def test_delete_operators_all_params(self): version_locator_id = 'testString' # Invoke method - response = _service.delete_operators( - x_auth_refresh_token, - cluster_id, - region, - version_locator_id, - headers={} - ) + response = _service.delete_operators(x_auth_refresh_token, cluster_id, region, version_locator_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'cluster_id={}'.format(cluster_id) in query_string assert 'region={}'.format(region) in query_string @@ -5740,9 +5200,7 @@ def test_delete_operators_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/deploy/kubernetes/olm/operator') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values x_auth_refresh_token = 'testString' @@ -5758,11 +5216,10 @@ def test_delete_operators_value_error(self): "version_locator_id": version_locator_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()} + 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_operators(**req_copy) - def test_delete_operators_value_error_with_retries(self): # Enable retries and run test_delete_operators_value_error. _service.enable_retries() @@ -5772,7 +5229,8 @@ def test_delete_operators_value_error_with_retries(self): _service.disable_retries() self.test_delete_operators_value_error() -class TestInstallVersion(): + +class TestInstallVersion: """ Test Class for install_version """ @@ -5781,7 +5239,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5795,9 +5253,7 @@ def test_install_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Construct a dict representation of a DeployRequestBodySchematics model deploy_request_body_schematics_model = {} @@ -5842,7 +5298,7 @@ def test_install_version_all_params(self): vcenter_password=vcenter_password, vcenter_location=vcenter_location, vcenter_datastore=vcenter_datastore, - headers={} + headers={}, ) # Check for correct operation @@ -5881,20 +5337,14 @@ def test_install_version_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.install_version( - version_loc_id, - x_auth_refresh_token, - headers={} - ) + response = _service.install_version(version_loc_id, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -5916,9 +5366,7 @@ def test_install_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -5930,11 +5378,10 @@ def test_install_version_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.install_version(**req_copy) - def test_install_version_value_error_with_retries(self): # Enable retries and run test_install_version_value_error. _service.enable_retries() @@ -5944,7 +5391,8 @@ def test_install_version_value_error_with_retries(self): _service.disable_retries() self.test_install_version_value_error() -class TestPreinstallVersion(): + +class TestPreinstallVersion: """ Test Class for preinstall_version """ @@ -5953,7 +5401,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -5967,9 +5415,7 @@ def test_preinstall_version_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Construct a dict representation of a DeployRequestBodySchematics model deploy_request_body_schematics_model = {} @@ -6014,7 +5460,7 @@ def test_preinstall_version_all_params(self): vcenter_password=vcenter_password, vcenter_location=vcenter_location, vcenter_datastore=vcenter_datastore, - headers={} + headers={}, ) # Check for correct operation @@ -6053,20 +5499,14 @@ def test_preinstall_version_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.preinstall_version( - version_loc_id, - x_auth_refresh_token, - headers={} - ) + response = _service.preinstall_version(version_loc_id, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6088,9 +5528,7 @@ def test_preinstall_version_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -6102,11 +5540,10 @@ def test_preinstall_version_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.preinstall_version(**req_copy) - def test_preinstall_version_value_error_with_retries(self): # Enable retries and run test_preinstall_version_value_error. _service.enable_retries() @@ -6116,7 +5553,8 @@ def test_preinstall_version_value_error_with_retries(self): _service.disable_retries() self.test_preinstall_version_value_error() -class TestGetPreinstall(): + +class TestGetPreinstall: """ Test Class for get_preinstall """ @@ -6125,7 +5563,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6140,11 +5578,7 @@ def test_get_preinstall_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') mock_response = '{"metadata": {"cluster_id": "cluster_id", "region": "region", "namespace": "namespace", "workspace_id": "workspace_id", "workspace_name": "workspace_name"}, "release": {"deployments": [{"mapKey": "anyValue"}], "replicasets": [{"mapKey": "anyValue"}], "statefulsets": [{"mapKey": "anyValue"}], "pods": [{"mapKey": "anyValue"}], "errors": [{"mapKey": "inner"}]}, "content_mgmt": {"pods": [{"mapKey": "inner"}], "errors": [{"mapKey": "inner"}]}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -6155,19 +5589,14 @@ def test_get_preinstall_all_params(self): # Invoke method response = _service.get_preinstall( - version_loc_id, - x_auth_refresh_token, - cluster_id=cluster_id, - region=region, - namespace=namespace, - headers={} + version_loc_id, x_auth_refresh_token, cluster_id=cluster_id, region=region, namespace=namespace, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'cluster_id={}'.format(cluster_id) in query_string assert 'region={}'.format(region) in query_string @@ -6190,22 +5619,14 @@ def test_get_preinstall_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') mock_response = '{"metadata": {"cluster_id": "cluster_id", "region": "region", "namespace": "namespace", "workspace_id": "workspace_id", "workspace_name": "workspace_name"}, "release": {"deployments": [{"mapKey": "anyValue"}], "replicasets": [{"mapKey": "anyValue"}], "statefulsets": [{"mapKey": "anyValue"}], "pods": [{"mapKey": "anyValue"}], "errors": [{"mapKey": "inner"}]}, "content_mgmt": {"pods": [{"mapKey": "inner"}], "errors": [{"mapKey": "inner"}]}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.get_preinstall( - version_loc_id, - x_auth_refresh_token, - headers={} - ) + response = _service.get_preinstall(version_loc_id, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6228,11 +5649,7 @@ def test_get_preinstall_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/preinstall') mock_response = '{"metadata": {"cluster_id": "cluster_id", "region": "region", "namespace": "namespace", "workspace_id": "workspace_id", "workspace_name": "workspace_name"}, "release": {"deployments": [{"mapKey": "anyValue"}], "replicasets": [{"mapKey": "anyValue"}], "statefulsets": [{"mapKey": "anyValue"}], "pods": [{"mapKey": "anyValue"}], "errors": [{"mapKey": "inner"}]}, "content_mgmt": {"pods": [{"mapKey": "inner"}], "errors": [{"mapKey": "inner"}]}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -6244,11 +5661,10 @@ def test_get_preinstall_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_preinstall(**req_copy) - def test_get_preinstall_value_error_with_retries(self): # Enable retries and run test_get_preinstall_value_error. _service.enable_retries() @@ -6258,7 +5674,8 @@ def test_get_preinstall_value_error_with_retries(self): _service.disable_retries() self.test_get_preinstall_value_error() -class TestValidateInstall(): + +class TestValidateInstall: """ Test Class for validate_install """ @@ -6267,7 +5684,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6281,9 +5698,7 @@ def test_validate_install_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Construct a dict representation of a DeployRequestBodySchematics model deploy_request_body_schematics_model = {} @@ -6328,7 +5743,7 @@ def test_validate_install_all_params(self): vcenter_password=vcenter_password, vcenter_location=vcenter_location, vcenter_datastore=vcenter_datastore, - headers={} + headers={}, ) # Check for correct operation @@ -6367,20 +5782,14 @@ def test_validate_install_required_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.validate_install( - version_loc_id, - x_auth_refresh_token, - headers={} - ) + response = _service.validate_install(version_loc_id, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6402,9 +5811,7 @@ def test_validate_install_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/install') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values version_loc_id = 'testString' @@ -6416,11 +5823,10 @@ def test_validate_install_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.validate_install(**req_copy) - def test_validate_install_value_error_with_retries(self): # Enable retries and run test_validate_install_value_error. _service.enable_retries() @@ -6430,7 +5836,8 @@ def test_validate_install_value_error_with_retries(self): _service.disable_retries() self.test_validate_install_value_error() -class TestGetValidationStatus(): + +class TestGetValidationStatus: """ Test Class for get_validation_status """ @@ -6439,7 +5846,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6454,22 +5861,14 @@ def test_get_validation_status_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/install') mock_response = '{"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.get_validation_status( - version_loc_id, - x_auth_refresh_token, - headers={} - ) + response = _service.get_validation_status(version_loc_id, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6492,11 +5891,7 @@ def test_get_validation_status_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/install') mock_response = '{"validated": "2019-01-01T12:00:00.000Z", "requested": "2019-01-01T12:00:00.000Z", "state": "state", "last_operation": "last_operation", "target": {"mapKey": "anyValue"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -6508,11 +5903,10 @@ def test_get_validation_status_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_validation_status(**req_copy) - def test_get_validation_status_value_error_with_retries(self): # Enable retries and run test_get_validation_status_value_error. _service.enable_retries() @@ -6522,7 +5916,8 @@ def test_get_validation_status_value_error_with_retries(self): _service.disable_retries() self.test_get_validation_status_value_error() -class TestGetOverrideValues(): + +class TestGetOverrideValues: """ Test Class for get_override_values """ @@ -6531,7 +5926,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6546,20 +5941,13 @@ def test_get_override_values_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/overridevalues') mock_response = '{"mapKey": "anyValue"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' # Invoke method - response = _service.get_override_values( - version_loc_id, - headers={} - ) + response = _service.get_override_values(version_loc_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6582,11 +5970,7 @@ def test_get_override_values_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/versions/testString/validation/overridevalues') mock_response = '{"mapKey": "anyValue"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values version_loc_id = 'testString' @@ -6596,11 +5980,10 @@ def test_get_override_values_value_error(self): "version_loc_id": version_loc_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()} + 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_override_values(**req_copy) - def test_get_override_values_value_error_with_retries(self): # Enable retries and run test_get_override_values_value_error. _service.enable_retries() @@ -6610,6 +5993,7 @@ def test_get_override_values_value_error_with_retries(self): _service.disable_retries() self.test_get_override_values_value_error() + # endregion ############################################################################## # End of Service: Deploy @@ -6620,7 +6004,8 @@ def test_get_override_values_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -6643,10 +6028,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() + -class TestSearchObjects(): +class TestSearchObjects: """ Test Class for search_objects """ @@ -6655,7 +6040,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6670,11 +6055,7 @@ def test_search_objects_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values query = 'testString' @@ -6685,19 +6066,14 @@ def test_search_objects_all_params(self): # Invoke method response = _service.search_objects( - query, - limit=limit, - offset=offset, - collapse=collapse, - digest=digest, - headers={} + query, limit=limit, offset=offset, collapse=collapse, digest=digest, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'query={}'.format(query) in query_string assert 'limit={}'.format(limit) in query_string @@ -6722,26 +6098,19 @@ def test_search_objects_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values query = 'testString' # Invoke method - response = _service.search_objects( - query, - headers={} - ) + response = _service.search_objects(query, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'query={}'.format(query) in query_string @@ -6762,11 +6131,7 @@ def test_search_objects_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values query = 'testString' @@ -6776,11 +6141,10 @@ def test_search_objects_value_error(self): "query": query, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.search_objects(**req_copy) - def test_search_objects_value_error_with_retries(self): # Enable retries and run test_search_objects_value_error. _service.enable_retries() @@ -6790,7 +6154,8 @@ def test_search_objects_value_error_with_retries(self): _service.disable_retries() self.test_search_objects_value_error() -class TestListObjects(): + +class TestListObjects: """ Test Class for list_objects """ @@ -6799,7 +6164,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6814,11 +6179,7 @@ def test_list_objects_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -6829,19 +6190,14 @@ def test_list_objects_all_params(self): # Invoke method response = _service.list_objects( - catalog_identifier, - limit=limit, - offset=offset, - name=name, - sort=sort, - headers={} + catalog_identifier, limit=limit, offset=offset, name=name, sort=sort, 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 = 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 @@ -6865,20 +6221,13 @@ def test_list_objects_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.list_objects( - catalog_identifier, - headers={} - ) + response = _service.list_objects(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -6901,11 +6250,7 @@ def test_list_objects_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -6915,11 +6260,10 @@ def test_list_objects_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_objects(**req_copy) - def test_list_objects_value_error_with_retries(self): # Enable retries and run test_list_objects_value_error. _service.enable_retries() @@ -6929,7 +6273,8 @@ def test_list_objects_value_error_with_retries(self): _service.disable_retries() self.test_list_objects_value_error() -class TestCreateObject(): + +class TestCreateObject: """ Test Class for create_object """ @@ -6938,7 +6283,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -6953,11 +6298,7 @@ def test_create_object_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a PublishObject model publish_object_model = {} @@ -7019,7 +6360,7 @@ def test_create_object_all_params(self): catalog_id=catalog_id, catalog_name=catalog_name, data=data, - headers={} + headers={}, ) # Check for correct operation @@ -7064,20 +6405,13 @@ def test_create_object_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' # Invoke method - response = _service.create_object( - catalog_identifier, - headers={} - ) + response = _service.create_object(catalog_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7100,11 +6434,7 @@ def test_create_object_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values catalog_identifier = 'testString' @@ -7114,11 +6444,10 @@ def test_create_object_value_error(self): "catalog_identifier": catalog_identifier, } 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()} + 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_object(**req_copy) - def test_create_object_value_error_with_retries(self): # Enable retries and run test_create_object_value_error. _service.enable_retries() @@ -7128,7 +6457,8 @@ def test_create_object_value_error_with_retries(self): _service.disable_retries() self.test_create_object_value_error() -class TestGetObject(): + +class TestGetObject: """ Test Class for get_object """ @@ -7137,7 +6467,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7152,22 +6482,14 @@ def test_get_object_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.get_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.get_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7190,11 +6512,7 @@ def test_get_object_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -7206,11 +6524,10 @@ def test_get_object_value_error(self): "object_identifier": object_identifier, } 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()} + 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_object(**req_copy) - def test_get_object_value_error_with_retries(self): # Enable retries and run test_get_object_value_error. _service.enable_retries() @@ -7220,7 +6537,8 @@ def test_get_object_value_error_with_retries(self): _service.disable_retries() self.test_get_object_value_error() -class TestReplaceObject(): + +class TestReplaceObject: """ Test Class for replace_object """ @@ -7229,7 +6547,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7244,11 +6562,7 @@ def test_replace_object_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a PublishObject model publish_object_model = {} @@ -7312,7 +6626,7 @@ def test_replace_object_all_params(self): catalog_id=catalog_id, catalog_name=catalog_name, data=data, - headers={} + headers={}, ) # Check for correct operation @@ -7357,22 +6671,14 @@ def test_replace_object_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.replace_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.replace_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7395,11 +6701,7 @@ def test_replace_object_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') mock_response = '{"id": "id", "name": "name", "_rev": "rev", "crn": "crn", "url": "url", "parent_id": "parent_id", "label_i18n": "label_i18n", "label": "label", "tags": ["tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z", "short_description": "short_description", "short_description_i18n": "short_description_i18n", "kind": "kind", "publish": {"permit_ibm_public_publish": false, "ibm_approved": true, "public_approved": false, "portal_approval_record": "portal_approval_record", "portal_url": "portal_url"}, "state": {"current": "current", "current_entered": "2019-01-01T12:00:00.000Z", "pending": "pending", "pending_requested": "2019-01-01T12:00:00.000Z", "previous": "previous"}, "catalog_id": "catalog_id", "catalog_name": "catalog_name", "data": {"mapKey": "anyValue"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -7411,11 +6713,10 @@ def test_replace_object_value_error(self): "object_identifier": object_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_object(**req_copy) - def test_replace_object_value_error_with_retries(self): # Enable retries and run test_replace_object_value_error. _service.enable_retries() @@ -7425,7 +6726,8 @@ def test_replace_object_value_error_with_retries(self): _service.disable_retries() self.test_replace_object_value_error() -class TestDeleteObject(): + +class TestDeleteObject: """ Test Class for delete_object """ @@ -7434,7 +6736,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7448,20 +6750,14 @@ def test_delete_object_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.delete_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.delete_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7483,9 +6779,7 @@ def test_delete_object_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' @@ -7497,11 +6791,10 @@ def test_delete_object_value_error(self): "object_identifier": object_identifier, } 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()} + 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_object(**req_copy) - def test_delete_object_value_error_with_retries(self): # Enable retries and run test_delete_object_value_error. _service.enable_retries() @@ -7511,7 +6804,8 @@ def test_delete_object_value_error_with_retries(self): _service.disable_retries() self.test_delete_object_value_error() -class TestGetObjectAudit(): + +class TestGetObjectAudit: """ Test Class for get_object_audit """ @@ -7520,7 +6814,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7535,22 +6829,14 @@ def test_get_object_audit_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.get_object_audit( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.get_object_audit(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7573,11 +6859,7 @@ def test_get_object_audit_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/audit') mock_response = '{"list": [{"id": "id", "created": "2019-01-01T12:00:00.000Z", "change_type": "change_type", "target_type": "target_type", "target_id": "target_id", "who_delegate_email": "who_delegate_email", "message": "message"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -7589,11 +6871,10 @@ def test_get_object_audit_value_error(self): "object_identifier": object_identifier, } 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()} + 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_object_audit(**req_copy) - def test_get_object_audit_value_error_with_retries(self): # Enable retries and run test_get_object_audit_value_error. _service.enable_retries() @@ -7603,7 +6884,8 @@ def test_get_object_audit_value_error_with_retries(self): _service.disable_retries() self.test_get_object_audit_value_error() -class TestAccountPublishObject(): + +class TestAccountPublishObject: """ Test Class for account_publish_object """ @@ -7612,7 +6894,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7626,20 +6908,14 @@ def test_account_publish_object_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/account-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.account_publish_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.account_publish_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7661,9 +6937,7 @@ def test_account_publish_object_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/account-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -7675,11 +6949,10 @@ def test_account_publish_object_value_error(self): "object_identifier": object_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.account_publish_object(**req_copy) - def test_account_publish_object_value_error_with_retries(self): # Enable retries and run test_account_publish_object_value_error. _service.enable_retries() @@ -7689,7 +6962,8 @@ def test_account_publish_object_value_error_with_retries(self): _service.disable_retries() self.test_account_publish_object_value_error() -class TestSharedPublishObject(): + +class TestSharedPublishObject: """ Test Class for shared_publish_object """ @@ -7698,7 +6972,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7712,20 +6986,14 @@ def test_shared_publish_object_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/shared-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.shared_publish_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.shared_publish_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7747,9 +7015,7 @@ def test_shared_publish_object_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/shared-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -7761,11 +7027,10 @@ def test_shared_publish_object_value_error(self): "object_identifier": object_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.shared_publish_object(**req_copy) - def test_shared_publish_object_value_error_with_retries(self): # Enable retries and run test_shared_publish_object_value_error. _service.enable_retries() @@ -7775,7 +7040,8 @@ def test_shared_publish_object_value_error_with_retries(self): _service.disable_retries() self.test_shared_publish_object_value_error() -class TestIbmPublishObject(): + +class TestIbmPublishObject: """ Test Class for ibm_publish_object """ @@ -7784,7 +7050,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7798,20 +7064,14 @@ def test_ibm_publish_object_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/ibm-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.ibm_publish_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.ibm_publish_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7833,9 +7093,7 @@ def test_ibm_publish_object_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/ibm-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -7847,11 +7105,10 @@ def test_ibm_publish_object_value_error(self): "object_identifier": object_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.ibm_publish_object(**req_copy) - def test_ibm_publish_object_value_error_with_retries(self): # Enable retries and run test_ibm_publish_object_value_error. _service.enable_retries() @@ -7861,7 +7118,8 @@ def test_ibm_publish_object_value_error_with_retries(self): _service.disable_retries() self.test_ibm_publish_object_value_error() -class TestPublicPublishObject(): + +class TestPublicPublishObject: """ Test Class for public_publish_object """ @@ -7870,7 +7128,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7884,20 +7142,14 @@ def test_public_publish_object_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/public-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.public_publish_object( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.public_publish_object(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -7919,9 +7171,7 @@ def test_public_publish_object_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/public-publish') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values catalog_identifier = 'testString' @@ -7933,11 +7183,10 @@ def test_public_publish_object_value_error(self): "object_identifier": object_identifier, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.public_publish_object(**req_copy) - def test_public_publish_object_value_error_with_retries(self): # Enable retries and run test_public_publish_object_value_error. _service.enable_retries() @@ -7947,7 +7196,8 @@ def test_public_publish_object_value_error_with_retries(self): _service.disable_retries() self.test_public_publish_object_value_error() -class TestCreateObjectAccess(): + +class TestCreateObjectAccess: """ Test Class for create_object_access """ @@ -7956,7 +7206,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -7970,9 +7220,7 @@ def test_create_object_access_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') - responses.add(responses.POST, - url, - status=201) + responses.add(responses.POST, url, status=201) # Set up parameter values catalog_identifier = 'testString' @@ -7980,12 +7228,7 @@ def test_create_object_access_all_params(self): account_identifier = 'testString' # Invoke method - response = _service.create_object_access( - catalog_identifier, - object_identifier, - account_identifier, - headers={} - ) + response = _service.create_object_access(catalog_identifier, object_identifier, account_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8007,9 +7250,7 @@ def test_create_object_access_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') - responses.add(responses.POST, - url, - status=201) + responses.add(responses.POST, url, status=201) # Set up parameter values catalog_identifier = 'testString' @@ -8023,11 +7264,10 @@ def test_create_object_access_value_error(self): "account_identifier": account_identifier, } 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()} + 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_object_access(**req_copy) - def test_create_object_access_value_error_with_retries(self): # Enable retries and run test_create_object_access_value_error. _service.enable_retries() @@ -8037,7 +7277,8 @@ def test_create_object_access_value_error_with_retries(self): _service.disable_retries() self.test_create_object_access_value_error() -class TestGetObjectAccess(): + +class TestGetObjectAccess: """ Test Class for get_object_access """ @@ -8046,7 +7287,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8061,11 +7302,7 @@ def test_get_object_access_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') mock_response = '{"id": "id", "account": "account", "catalog_id": "catalog_id", "target_id": "target_id", "create": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8073,12 +7310,7 @@ def test_get_object_access_all_params(self): account_identifier = 'testString' # Invoke method - response = _service.get_object_access( - catalog_identifier, - object_identifier, - account_identifier, - headers={} - ) + response = _service.get_object_access(catalog_identifier, object_identifier, account_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8101,11 +7333,7 @@ def test_get_object_access_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') mock_response = '{"id": "id", "account": "account", "catalog_id": "catalog_id", "target_id": "target_id", "create": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8119,11 +7347,10 @@ def test_get_object_access_value_error(self): "account_identifier": account_identifier, } 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()} + 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_object_access(**req_copy) - def test_get_object_access_value_error_with_retries(self): # Enable retries and run test_get_object_access_value_error. _service.enable_retries() @@ -8133,7 +7360,8 @@ def test_get_object_access_value_error_with_retries(self): _service.disable_retries() self.test_get_object_access_value_error() -class TestDeleteObjectAccess(): + +class TestDeleteObjectAccess: """ Test Class for delete_object_access """ @@ -8142,7 +7370,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8156,9 +7384,7 @@ def test_delete_object_access_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8166,12 +7392,7 @@ def test_delete_object_access_all_params(self): account_identifier = 'testString' # Invoke method - response = _service.delete_object_access( - catalog_identifier, - object_identifier, - account_identifier, - headers={} - ) + response = _service.delete_object_access(catalog_identifier, object_identifier, account_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8193,9 +7414,7 @@ def test_delete_object_access_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8209,11 +7428,10 @@ def test_delete_object_access_value_error(self): "account_identifier": account_identifier, } 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()} + 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_object_access(**req_copy) - def test_delete_object_access_value_error_with_retries(self): # Enable retries and run test_delete_object_access_value_error. _service.enable_retries() @@ -8223,7 +7441,8 @@ def test_delete_object_access_value_error_with_retries(self): _service.disable_retries() self.test_delete_object_access_value_error() -class TestGetObjectAccessList(): + +class TestGetObjectAccessList: """ Test Class for get_object_access_list """ @@ -8232,7 +7451,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8247,11 +7466,7 @@ def test_get_object_access_list_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "account": "account", "catalog_id": "catalog_id", "target_id": "target_id", "create": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8261,18 +7476,14 @@ def test_get_object_access_list_all_params(self): # Invoke method response = _service.get_object_access_list( - catalog_identifier, - object_identifier, - limit=limit, - offset=offset, - headers={} + catalog_identifier, object_identifier, 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 = 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 @@ -8294,22 +7505,14 @@ def test_get_object_access_list_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "account": "account", "catalog_id": "catalog_id", "target_id": "target_id", "create": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' object_identifier = 'testString' # Invoke method - response = _service.get_object_access_list( - catalog_identifier, - object_identifier, - headers={} - ) + response = _service.get_object_access_list(catalog_identifier, object_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8332,11 +7535,7 @@ def test_get_object_access_list_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"offset": 6, "limit": 5, "total_count": 11, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "account": "account", "catalog_id": "catalog_id", "target_id": "target_id", "create": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8348,11 +7547,10 @@ def test_get_object_access_list_value_error(self): "object_identifier": object_identifier, } 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()} + 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_object_access_list(**req_copy) - def test_get_object_access_list_value_error_with_retries(self): # Enable retries and run test_get_object_access_list_value_error. _service.enable_retries() @@ -8362,7 +7560,8 @@ def test_get_object_access_list_value_error_with_retries(self): _service.disable_retries() self.test_get_object_access_list_value_error() -class TestDeleteObjectAccessList(): + +class TestDeleteObjectAccessList: """ Test Class for delete_object_access_list """ @@ -8371,7 +7570,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8386,11 +7585,7 @@ def test_delete_object_access_list_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"errors": {"mapKey": "inner"}}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8398,12 +7593,7 @@ def test_delete_object_access_list_all_params(self): accounts = ['testString'] # Invoke method - response = _service.delete_object_access_list( - catalog_identifier, - object_identifier, - accounts, - headers={} - ) + response = _service.delete_object_access_list(catalog_identifier, object_identifier, accounts, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8429,11 +7619,7 @@ def test_delete_object_access_list_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"errors": {"mapKey": "inner"}}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8447,11 +7633,10 @@ def test_delete_object_access_list_value_error(self): "accounts": accounts, } 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()} + 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_object_access_list(**req_copy) - def test_delete_object_access_list_value_error_with_retries(self): # Enable retries and run test_delete_object_access_list_value_error. _service.enable_retries() @@ -8461,7 +7646,8 @@ def test_delete_object_access_list_value_error_with_retries(self): _service.disable_retries() self.test_delete_object_access_list_value_error() -class TestAddObjectAccessList(): + +class TestAddObjectAccessList: """ Test Class for add_object_access_list """ @@ -8470,7 +7656,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8485,11 +7671,7 @@ def test_add_object_access_list_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"errors": {"mapKey": "inner"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8497,12 +7679,7 @@ def test_add_object_access_list_all_params(self): accounts = ['testString'] # Invoke method - response = _service.add_object_access_list( - catalog_identifier, - object_identifier, - accounts, - headers={} - ) + response = _service.add_object_access_list(catalog_identifier, object_identifier, accounts, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8528,11 +7705,7 @@ def test_add_object_access_list_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/catalogs/testString/objects/testString/access') mock_response = '{"errors": {"mapKey": "inner"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values catalog_identifier = 'testString' @@ -8546,11 +7719,10 @@ def test_add_object_access_list_value_error(self): "accounts": accounts, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_object_access_list(**req_copy) - def test_add_object_access_list_value_error_with_retries(self): # Enable retries and run test_add_object_access_list_value_error. _service.enable_retries() @@ -8560,6 +7732,7 @@ def test_add_object_access_list_value_error_with_retries(self): _service.disable_retries() self.test_add_object_access_list_value_error() + # endregion ############################################################################## # End of Service: Objects @@ -8570,7 +7743,8 @@ def test_add_object_access_list_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -8593,10 +7767,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = CatalogManagementV1.new_instance( - ) + service = CatalogManagementV1.new_instance() -class TestCreateOfferingInstance(): + +class TestCreateOfferingInstance: """ Test Class for create_offering_instance """ @@ -8605,7 +7779,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8620,11 +7794,7 @@ def test_create_offering_instance_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a OfferingInstanceLastOperation model offering_instance_last_operation_model = {} @@ -8678,7 +7848,7 @@ def test_create_offering_instance_all_params(self): channel=channel, metadata=metadata, last_operation=last_operation, - headers={} + headers={}, ) # Check for correct operation @@ -8723,20 +7893,13 @@ def test_create_offering_instance_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values x_auth_refresh_token = 'testString' # Invoke method - response = _service.create_offering_instance( - x_auth_refresh_token, - headers={} - ) + response = _service.create_offering_instance(x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8759,11 +7922,7 @@ def test_create_offering_instance_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values x_auth_refresh_token = 'testString' @@ -8773,11 +7932,10 @@ def test_create_offering_instance_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_offering_instance(**req_copy) - def test_create_offering_instance_value_error_with_retries(self): # Enable retries and run test_create_offering_instance_value_error. _service.enable_retries() @@ -8787,7 +7945,8 @@ def test_create_offering_instance_value_error_with_retries(self): _service.disable_retries() self.test_create_offering_instance_value_error() -class TestGetOfferingInstance(): + +class TestGetOfferingInstance: """ Test Class for get_offering_instance """ @@ -8796,7 +7955,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8811,20 +7970,13 @@ def test_get_offering_instance_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_identifier = 'testString' # Invoke method - response = _service.get_offering_instance( - instance_identifier, - headers={} - ) + response = _service.get_offering_instance(instance_identifier, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -8847,11 +7999,7 @@ def test_get_offering_instance_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_identifier = 'testString' @@ -8861,11 +8009,10 @@ def test_get_offering_instance_value_error(self): "instance_identifier": instance_identifier, } 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()} + 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_offering_instance(**req_copy) - def test_get_offering_instance_value_error_with_retries(self): # Enable retries and run test_get_offering_instance_value_error. _service.enable_retries() @@ -8875,7 +8022,8 @@ def test_get_offering_instance_value_error_with_retries(self): _service.disable_retries() self.test_get_offering_instance_value_error() -class TestPutOfferingInstance(): + +class TestPutOfferingInstance: """ Test Class for put_offering_instance """ @@ -8884,7 +8032,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -8899,11 +8047,7 @@ def test_put_offering_instance_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a OfferingInstanceLastOperation model offering_instance_last_operation_model = {} @@ -8959,7 +8103,7 @@ def test_put_offering_instance_all_params(self): channel=channel, metadata=metadata, last_operation=last_operation, - headers={} + headers={}, ) # Check for correct operation @@ -9004,22 +8148,14 @@ def test_put_offering_instance_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_identifier = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.put_offering_instance( - instance_identifier, - x_auth_refresh_token, - headers={} - ) + response = _service.put_offering_instance(instance_identifier, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -9042,11 +8178,7 @@ def test_put_offering_instance_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') mock_response = '{"id": "id", "_rev": "rev", "url": "url", "crn": "crn", "label": "label", "catalog_id": "catalog_id", "offering_id": "offering_id", "kind_format": "kind_format", "version": "version", "cluster_id": "cluster_id", "cluster_region": "cluster_region", "cluster_namespaces": ["cluster_namespaces"], "cluster_all_namespaces": true, "schematics_workspace_id": "schematics_workspace_id", "resource_group_id": "resource_group_id", "install_plan": "install_plan", "channel": "channel", "metadata": {"mapKey": "anyValue"}, "last_operation": {"operation": "operation", "state": "state", "message": "message", "transaction_id": "transaction_id", "updated": "updated"}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_identifier = 'testString' @@ -9058,11 +8190,10 @@ def test_put_offering_instance_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.put_offering_instance(**req_copy) - def test_put_offering_instance_value_error_with_retries(self): # Enable retries and run test_put_offering_instance_value_error. _service.enable_retries() @@ -9072,7 +8203,8 @@ def test_put_offering_instance_value_error_with_retries(self): _service.disable_retries() self.test_put_offering_instance_value_error() -class TestDeleteOfferingInstance(): + +class TestDeleteOfferingInstance: """ Test Class for delete_offering_instance """ @@ -9081,7 +8213,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -9095,20 +8227,14 @@ def test_delete_offering_instance_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values instance_identifier = 'testString' x_auth_refresh_token = 'testString' # Invoke method - response = _service.delete_offering_instance( - instance_identifier, - x_auth_refresh_token, - headers={} - ) + response = _service.delete_offering_instance(instance_identifier, x_auth_refresh_token, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -9130,9 +8256,7 @@ def test_delete_offering_instance_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/instances/offerings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values instance_identifier = 'testString' @@ -9144,11 +8268,10 @@ def test_delete_offering_instance_value_error(self): "x_auth_refresh_token": x_auth_refresh_token, } 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()} + 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_offering_instance(**req_copy) - def test_delete_offering_instance_value_error_with_retries(self): # Enable retries and run test_delete_offering_instance_value_error. _service.enable_retries() @@ -9158,6 +8281,7 @@ def test_delete_offering_instance_value_error_with_retries(self): _service.disable_retries() self.test_delete_offering_instance_value_error() + # endregion ############################################################################## # End of Service: Instances @@ -9168,7 +8292,7 @@ def test_delete_offering_instance_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_AccessListBulkResponse(): +class TestModel_AccessListBulkResponse: """ Test Class for AccessListBulkResponse """ @@ -9187,7 +8311,9 @@ def test_access_list_bulk_response_serialization(self): assert access_list_bulk_response_model != False # Construct a model instance of AccessListBulkResponse by calling from_dict on the json representation - access_list_bulk_response_model_dict = AccessListBulkResponse.from_dict(access_list_bulk_response_model_json).__dict__ + access_list_bulk_response_model_dict = AccessListBulkResponse.from_dict( + access_list_bulk_response_model_json + ).__dict__ access_list_bulk_response_model2 = AccessListBulkResponse(**access_list_bulk_response_model_dict) # Verify the model instances are equivalent @@ -9197,7 +8323,8 @@ def test_access_list_bulk_response_serialization(self): access_list_bulk_response_model_json2 = access_list_bulk_response_model.to_dict() assert access_list_bulk_response_model_json2 == access_list_bulk_response_model_json -class TestModel_Account(): + +class TestModel_Account: """ Test Class for Account """ @@ -9209,18 +8336,18 @@ def test_account_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model - filters_model = {} # Filters + filters_model = {} # Filters filters_model['include_all'] = True filters_model['category_filters'] = {} filters_model['id_filters'] = id_filter_model @@ -9246,7 +8373,8 @@ def test_account_serialization(self): account_model_json2 = account_model.to_dict() assert account_model_json2 == account_model_json -class TestModel_AccumulatedFilters(): + +class TestModel_AccumulatedFilters: """ Test Class for AccumulatedFilters """ @@ -9258,28 +8386,30 @@ def test_accumulated_filters_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model - filters_model = {} # Filters + filters_model = {} # Filters filters_model['include_all'] = True filters_model['category_filters'] = {} filters_model['id_filters'] = id_filter_model - accumulated_filters_catalog_filters_item_catalog_model = {} # AccumulatedFiltersCatalogFiltersItemCatalog + accumulated_filters_catalog_filters_item_catalog_model = {} # AccumulatedFiltersCatalogFiltersItemCatalog accumulated_filters_catalog_filters_item_catalog_model['id'] = 'testString' accumulated_filters_catalog_filters_item_catalog_model['name'] = 'testString' - accumulated_filters_catalog_filters_item_model = {} # AccumulatedFiltersCatalogFiltersItem - accumulated_filters_catalog_filters_item_model['catalog'] = accumulated_filters_catalog_filters_item_catalog_model + accumulated_filters_catalog_filters_item_model = {} # AccumulatedFiltersCatalogFiltersItem + accumulated_filters_catalog_filters_item_model[ + 'catalog' + ] = accumulated_filters_catalog_filters_item_catalog_model accumulated_filters_catalog_filters_item_model['filters'] = filters_model # Construct a json representation of a AccumulatedFilters model @@ -9302,7 +8432,8 @@ def test_accumulated_filters_serialization(self): accumulated_filters_model_json2 = accumulated_filters_model.to_dict() assert accumulated_filters_model_json2 == accumulated_filters_model_json -class TestModel_AccumulatedFiltersCatalogFiltersItem(): + +class TestModel_AccumulatedFiltersCatalogFiltersItem: """ Test Class for AccumulatedFiltersCatalogFiltersItem """ @@ -9314,47 +8445,58 @@ def test_accumulated_filters_catalog_filters_item_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - accumulated_filters_catalog_filters_item_catalog_model = {} # AccumulatedFiltersCatalogFiltersItemCatalog + accumulated_filters_catalog_filters_item_catalog_model = {} # AccumulatedFiltersCatalogFiltersItemCatalog accumulated_filters_catalog_filters_item_catalog_model['id'] = 'testString' accumulated_filters_catalog_filters_item_catalog_model['name'] = 'testString' - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model - filters_model = {} # Filters + filters_model = {} # Filters filters_model['include_all'] = True filters_model['category_filters'] = {} filters_model['id_filters'] = id_filter_model # Construct a json representation of a AccumulatedFiltersCatalogFiltersItem model accumulated_filters_catalog_filters_item_model_json = {} - accumulated_filters_catalog_filters_item_model_json['catalog'] = accumulated_filters_catalog_filters_item_catalog_model + accumulated_filters_catalog_filters_item_model_json[ + 'catalog' + ] = accumulated_filters_catalog_filters_item_catalog_model accumulated_filters_catalog_filters_item_model_json['filters'] = filters_model # Construct a model instance of AccumulatedFiltersCatalogFiltersItem by calling from_dict on the json representation - accumulated_filters_catalog_filters_item_model = AccumulatedFiltersCatalogFiltersItem.from_dict(accumulated_filters_catalog_filters_item_model_json) + accumulated_filters_catalog_filters_item_model = AccumulatedFiltersCatalogFiltersItem.from_dict( + accumulated_filters_catalog_filters_item_model_json + ) assert accumulated_filters_catalog_filters_item_model != False # Construct a model instance of AccumulatedFiltersCatalogFiltersItem by calling from_dict on the json representation - accumulated_filters_catalog_filters_item_model_dict = AccumulatedFiltersCatalogFiltersItem.from_dict(accumulated_filters_catalog_filters_item_model_json).__dict__ - accumulated_filters_catalog_filters_item_model2 = AccumulatedFiltersCatalogFiltersItem(**accumulated_filters_catalog_filters_item_model_dict) + accumulated_filters_catalog_filters_item_model_dict = AccumulatedFiltersCatalogFiltersItem.from_dict( + accumulated_filters_catalog_filters_item_model_json + ).__dict__ + accumulated_filters_catalog_filters_item_model2 = AccumulatedFiltersCatalogFiltersItem( + **accumulated_filters_catalog_filters_item_model_dict + ) # Verify the model instances are equivalent assert accumulated_filters_catalog_filters_item_model == accumulated_filters_catalog_filters_item_model2 # Convert model instance back to dict and verify no loss of data accumulated_filters_catalog_filters_item_model_json2 = accumulated_filters_catalog_filters_item_model.to_dict() - assert accumulated_filters_catalog_filters_item_model_json2 == accumulated_filters_catalog_filters_item_model_json + assert ( + accumulated_filters_catalog_filters_item_model_json2 == accumulated_filters_catalog_filters_item_model_json + ) -class TestModel_AccumulatedFiltersCatalogFiltersItemCatalog(): + +class TestModel_AccumulatedFiltersCatalogFiltersItemCatalog: """ Test Class for AccumulatedFiltersCatalogFiltersItemCatalog """ @@ -9370,21 +8512,38 @@ def test_accumulated_filters_catalog_filters_item_catalog_serialization(self): accumulated_filters_catalog_filters_item_catalog_model_json['name'] = 'testString' # Construct a model instance of AccumulatedFiltersCatalogFiltersItemCatalog by calling from_dict on the json representation - accumulated_filters_catalog_filters_item_catalog_model = AccumulatedFiltersCatalogFiltersItemCatalog.from_dict(accumulated_filters_catalog_filters_item_catalog_model_json) + accumulated_filters_catalog_filters_item_catalog_model = AccumulatedFiltersCatalogFiltersItemCatalog.from_dict( + accumulated_filters_catalog_filters_item_catalog_model_json + ) assert accumulated_filters_catalog_filters_item_catalog_model != False # Construct a model instance of AccumulatedFiltersCatalogFiltersItemCatalog by calling from_dict on the json representation - accumulated_filters_catalog_filters_item_catalog_model_dict = AccumulatedFiltersCatalogFiltersItemCatalog.from_dict(accumulated_filters_catalog_filters_item_catalog_model_json).__dict__ - accumulated_filters_catalog_filters_item_catalog_model2 = AccumulatedFiltersCatalogFiltersItemCatalog(**accumulated_filters_catalog_filters_item_catalog_model_dict) + accumulated_filters_catalog_filters_item_catalog_model_dict = ( + AccumulatedFiltersCatalogFiltersItemCatalog.from_dict( + accumulated_filters_catalog_filters_item_catalog_model_json + ).__dict__ + ) + accumulated_filters_catalog_filters_item_catalog_model2 = AccumulatedFiltersCatalogFiltersItemCatalog( + **accumulated_filters_catalog_filters_item_catalog_model_dict + ) # Verify the model instances are equivalent - assert accumulated_filters_catalog_filters_item_catalog_model == accumulated_filters_catalog_filters_item_catalog_model2 + assert ( + accumulated_filters_catalog_filters_item_catalog_model + == accumulated_filters_catalog_filters_item_catalog_model2 + ) # Convert model instance back to dict and verify no loss of data - accumulated_filters_catalog_filters_item_catalog_model_json2 = accumulated_filters_catalog_filters_item_catalog_model.to_dict() - assert accumulated_filters_catalog_filters_item_catalog_model_json2 == accumulated_filters_catalog_filters_item_catalog_model_json + accumulated_filters_catalog_filters_item_catalog_model_json2 = ( + accumulated_filters_catalog_filters_item_catalog_model.to_dict() + ) + assert ( + accumulated_filters_catalog_filters_item_catalog_model_json2 + == accumulated_filters_catalog_filters_item_catalog_model_json + ) -class TestModel_ApprovalResult(): + +class TestModel_ApprovalResult: """ Test Class for ApprovalResult """ @@ -9416,7 +8575,8 @@ def test_approval_result_serialization(self): approval_result_model_json2 = approval_result_model.to_dict() assert approval_result_model_json2 == approval_result_model_json -class TestModel_AuditLog(): + +class TestModel_AuditLog: """ Test Class for AuditLog """ @@ -9428,7 +8588,7 @@ def test_audit_log_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - audit_record_model = {} # AuditRecord + audit_record_model = {} # AuditRecord audit_record_model['id'] = 'testString' audit_record_model['created'] = "2019-01-01T12:00:00Z" audit_record_model['change_type'] = 'testString' @@ -9456,7 +8616,8 @@ def test_audit_log_serialization(self): audit_log_model_json2 = audit_log_model.to_dict() assert audit_log_model_json2 == audit_log_model_json -class TestModel_AuditRecord(): + +class TestModel_AuditRecord: """ Test Class for AuditRecord """ @@ -9491,7 +8652,8 @@ def test_audit_record_serialization(self): audit_record_model_json2 = audit_record_model.to_dict() assert audit_record_model_json2 == audit_record_model_json -class TestModel_Catalog(): + +class TestModel_Catalog: """ Test Class for Catalog """ @@ -9503,27 +8665,27 @@ def test_catalog_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model - filters_model = {} # Filters + filters_model = {} # Filters filters_model['include_all'] = True filters_model['category_filters'] = {} filters_model['id_filters'] = id_filter_model - syndication_cluster_model = {} # SyndicationCluster + syndication_cluster_model = {} # SyndicationCluster syndication_cluster_model['region'] = 'testString' syndication_cluster_model['id'] = 'testString' syndication_cluster_model['name'] = 'testString' @@ -9532,16 +8694,16 @@ def test_catalog_serialization(self): syndication_cluster_model['namespaces'] = ['testString'] syndication_cluster_model['all_namespaces'] = True - syndication_history_model = {} # SyndicationHistory + syndication_history_model = {} # SyndicationHistory syndication_history_model['namespaces'] = ['testString'] syndication_history_model['clusters'] = [syndication_cluster_model] syndication_history_model['last_run'] = "2019-01-01T12:00:00Z" - syndication_authorization_model = {} # SyndicationAuthorization + syndication_authorization_model = {} # SyndicationAuthorization syndication_authorization_model['token'] = 'testString' syndication_authorization_model['last_run'] = "2019-01-01T12:00:00Z" - syndication_resource_model = {} # SyndicationResource + syndication_resource_model = {} # SyndicationResource syndication_resource_model['remove_related_components'] = True syndication_resource_model['clusters'] = [syndication_cluster_model] syndication_resource_model['history'] = syndication_history_model @@ -9583,7 +8745,8 @@ def test_catalog_serialization(self): catalog_model_json2 = catalog_model.to_dict() assert catalog_model_json2 == catalog_model_json -class TestModel_CatalogObject(): + +class TestModel_CatalogObject: """ Test Class for CatalogObject """ @@ -9595,14 +8758,14 @@ def test_catalog_object_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - publish_object_model = {} # PublishObject + publish_object_model = {} # PublishObject publish_object_model['permit_ibm_public_publish'] = True publish_object_model['ibm_approved'] = True publish_object_model['public_approved'] = True publish_object_model['portal_approval_record'] = 'testString' publish_object_model['portal_url'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' @@ -9646,7 +8809,8 @@ def test_catalog_object_serialization(self): catalog_object_model_json2 = catalog_object_model.to_dict() assert catalog_object_model_json2 == catalog_object_model_json -class TestModel_CatalogSearchResult(): + +class TestModel_CatalogSearchResult: """ Test Class for CatalogSearchResult """ @@ -9658,27 +8822,27 @@ def test_catalog_search_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model - filters_model = {} # Filters + filters_model = {} # Filters filters_model['include_all'] = True filters_model['category_filters'] = {} filters_model['id_filters'] = id_filter_model - syndication_cluster_model = {} # SyndicationCluster + syndication_cluster_model = {} # SyndicationCluster syndication_cluster_model['region'] = 'testString' syndication_cluster_model['id'] = 'testString' syndication_cluster_model['name'] = 'testString' @@ -9687,22 +8851,22 @@ def test_catalog_search_result_serialization(self): syndication_cluster_model['namespaces'] = ['testString'] syndication_cluster_model['all_namespaces'] = True - syndication_history_model = {} # SyndicationHistory + syndication_history_model = {} # SyndicationHistory syndication_history_model['namespaces'] = ['testString'] syndication_history_model['clusters'] = [syndication_cluster_model] syndication_history_model['last_run'] = "2019-01-01T12:00:00Z" - syndication_authorization_model = {} # SyndicationAuthorization + syndication_authorization_model = {} # SyndicationAuthorization syndication_authorization_model['token'] = 'testString' syndication_authorization_model['last_run'] = "2019-01-01T12:00:00Z" - syndication_resource_model = {} # SyndicationResource + syndication_resource_model = {} # SyndicationResource syndication_resource_model['remove_related_components'] = True syndication_resource_model['clusters'] = [syndication_cluster_model] syndication_resource_model['history'] = syndication_history_model syndication_resource_model['authorization'] = syndication_authorization_model - catalog_model = {} # Catalog + catalog_model = {} # Catalog catalog_model['id'] = 'testString' catalog_model['_rev'] = 'testString' catalog_model['label'] = 'testString' @@ -9742,7 +8906,8 @@ def test_catalog_search_result_serialization(self): catalog_search_result_model_json2 = catalog_search_result_model.to_dict() assert catalog_search_result_model_json2 == catalog_search_result_model_json -class TestModel_CategoryFilter(): + +class TestModel_CategoryFilter: """ Test Class for CategoryFilter """ @@ -9754,7 +8919,7 @@ def test_category_filter_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] # Construct a json representation of a CategoryFilter model @@ -9777,7 +8942,8 @@ def test_category_filter_serialization(self): category_filter_model_json2 = category_filter_model.to_dict() assert category_filter_model_json2 == category_filter_model_json -class TestModel_ClusterInfo(): + +class TestModel_ClusterInfo: """ Test Class for ClusterInfo """ @@ -9810,7 +8976,8 @@ def test_cluster_info_serialization(self): cluster_info_model_json2 = cluster_info_model.to_dict() assert cluster_info_model_json2 == cluster_info_model_json -class TestModel_Configuration(): + +class TestModel_Configuration: """ Test Class for Configuration """ @@ -9846,7 +9013,8 @@ def test_configuration_serialization(self): configuration_model_json2 = configuration_model.to_dict() assert configuration_model_json2 == configuration_model_json -class TestModel_DeployRequestBodySchematics(): + +class TestModel_DeployRequestBodySchematics: """ Test Class for DeployRequestBodySchematics """ @@ -9864,11 +9032,15 @@ def test_deploy_request_body_schematics_serialization(self): deploy_request_body_schematics_model_json['resource_group_id'] = 'testString' # Construct a model instance of DeployRequestBodySchematics by calling from_dict on the json representation - deploy_request_body_schematics_model = DeployRequestBodySchematics.from_dict(deploy_request_body_schematics_model_json) + deploy_request_body_schematics_model = DeployRequestBodySchematics.from_dict( + deploy_request_body_schematics_model_json + ) assert deploy_request_body_schematics_model != False # Construct a model instance of DeployRequestBodySchematics by calling from_dict on the json representation - deploy_request_body_schematics_model_dict = DeployRequestBodySchematics.from_dict(deploy_request_body_schematics_model_json).__dict__ + deploy_request_body_schematics_model_dict = DeployRequestBodySchematics.from_dict( + deploy_request_body_schematics_model_json + ).__dict__ deploy_request_body_schematics_model2 = DeployRequestBodySchematics(**deploy_request_body_schematics_model_dict) # Verify the model instances are equivalent @@ -9878,7 +9050,8 @@ def test_deploy_request_body_schematics_serialization(self): deploy_request_body_schematics_model_json2 = deploy_request_body_schematics_model.to_dict() assert deploy_request_body_schematics_model_json2 == deploy_request_body_schematics_model_json -class TestModel_Deployment(): + +class TestModel_Deployment: """ Test Class for Deployment """ @@ -9915,7 +9088,8 @@ def test_deployment_serialization(self): deployment_model_json2 = deployment_model.to_dict() assert deployment_model_json2 == deployment_model_json -class TestModel_Feature(): + +class TestModel_Feature: """ Test Class for Feature """ @@ -9945,7 +9119,8 @@ def test_feature_serialization(self): feature_model_json2 = feature_model.to_dict() assert feature_model_json2 == feature_model_json -class TestModel_FilterTerms(): + +class TestModel_FilterTerms: """ Test Class for FilterTerms """ @@ -9974,7 +9149,8 @@ def test_filter_terms_serialization(self): filter_terms_model_json2 = filter_terms_model.to_dict() assert filter_terms_model_json2 == filter_terms_model_json -class TestModel_Filters(): + +class TestModel_Filters: """ Test Class for Filters """ @@ -9986,14 +9162,14 @@ def test_filters_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] - category_filter_model = {} # CategoryFilter + category_filter_model = {} # CategoryFilter category_filter_model['include'] = True category_filter_model['filter'] = filter_terms_model - id_filter_model = {} # IDFilter + id_filter_model = {} # IDFilter id_filter_model['include'] = filter_terms_model id_filter_model['exclude'] = filter_terms_model @@ -10018,7 +9194,8 @@ def test_filters_serialization(self): filters_model_json2 = filters_model.to_dict() assert filters_model_json2 == filters_model_json -class TestModel_IDFilter(): + +class TestModel_IDFilter: """ Test Class for IDFilter """ @@ -10030,7 +9207,7 @@ def test_id_filter_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - filter_terms_model = {} # FilterTerms + filter_terms_model = {} # FilterTerms filter_terms_model['filter_terms'] = ['testString'] # Construct a json representation of a IDFilter model @@ -10053,7 +9230,8 @@ def test_id_filter_serialization(self): id_filter_model_json2 = id_filter_model.to_dict() assert id_filter_model_json2 == id_filter_model_json -class TestModel_Image(): + +class TestModel_Image: """ Test Class for Image """ @@ -10082,7 +9260,8 @@ def test_image_serialization(self): image_model_json2 = image_model.to_dict() assert image_model_json2 == image_model_json -class TestModel_ImageManifest(): + +class TestModel_ImageManifest: """ Test Class for ImageManifest """ @@ -10094,7 +9273,7 @@ def test_image_manifest_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - image_model = {} # Image + image_model = {} # Image image_model['image'] = 'testString' # Construct a json representation of a ImageManifest model @@ -10117,7 +9296,8 @@ def test_image_manifest_serialization(self): image_manifest_model_json2 = image_manifest_model.to_dict() assert image_manifest_model_json2 == image_manifest_model_json -class TestModel_InstallStatus(): + +class TestModel_InstallStatus: """ Test Class for InstallStatus """ @@ -10129,21 +9309,21 @@ def test_install_status_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - install_status_metadata_model = {} # InstallStatusMetadata + install_status_metadata_model = {} # InstallStatusMetadata install_status_metadata_model['cluster_id'] = 'testString' install_status_metadata_model['region'] = 'testString' install_status_metadata_model['namespace'] = 'testString' install_status_metadata_model['workspace_id'] = 'testString' install_status_metadata_model['workspace_name'] = 'testString' - install_status_release_model = {} # InstallStatusRelease + install_status_release_model = {} # InstallStatusRelease install_status_release_model['deployments'] = [{}] install_status_release_model['replicasets'] = [{}] install_status_release_model['statefulsets'] = [{}] install_status_release_model['pods'] = [{}] install_status_release_model['errors'] = [{}] - install_status_content_mgmt_model = {} # InstallStatusContentMgmt + install_status_content_mgmt_model = {} # InstallStatusContentMgmt install_status_content_mgmt_model['pods'] = [{}] install_status_content_mgmt_model['errors'] = [{}] @@ -10168,7 +9348,8 @@ def test_install_status_serialization(self): install_status_model_json2 = install_status_model.to_dict() assert install_status_model_json2 == install_status_model_json -class TestModel_InstallStatusContentMgmt(): + +class TestModel_InstallStatusContentMgmt: """ Test Class for InstallStatusContentMgmt """ @@ -10188,7 +9369,9 @@ def test_install_status_content_mgmt_serialization(self): assert install_status_content_mgmt_model != False # Construct a model instance of InstallStatusContentMgmt by calling from_dict on the json representation - install_status_content_mgmt_model_dict = InstallStatusContentMgmt.from_dict(install_status_content_mgmt_model_json).__dict__ + install_status_content_mgmt_model_dict = InstallStatusContentMgmt.from_dict( + install_status_content_mgmt_model_json + ).__dict__ install_status_content_mgmt_model2 = InstallStatusContentMgmt(**install_status_content_mgmt_model_dict) # Verify the model instances are equivalent @@ -10198,7 +9381,8 @@ def test_install_status_content_mgmt_serialization(self): install_status_content_mgmt_model_json2 = install_status_content_mgmt_model.to_dict() assert install_status_content_mgmt_model_json2 == install_status_content_mgmt_model_json -class TestModel_InstallStatusMetadata(): + +class TestModel_InstallStatusMetadata: """ Test Class for InstallStatusMetadata """ @@ -10221,7 +9405,9 @@ def test_install_status_metadata_serialization(self): assert install_status_metadata_model != False # Construct a model instance of InstallStatusMetadata by calling from_dict on the json representation - install_status_metadata_model_dict = InstallStatusMetadata.from_dict(install_status_metadata_model_json).__dict__ + install_status_metadata_model_dict = InstallStatusMetadata.from_dict( + install_status_metadata_model_json + ).__dict__ install_status_metadata_model2 = InstallStatusMetadata(**install_status_metadata_model_dict) # Verify the model instances are equivalent @@ -10231,7 +9417,8 @@ def test_install_status_metadata_serialization(self): install_status_metadata_model_json2 = install_status_metadata_model.to_dict() assert install_status_metadata_model_json2 == install_status_metadata_model_json -class TestModel_InstallStatusRelease(): + +class TestModel_InstallStatusRelease: """ Test Class for InstallStatusRelease """ @@ -10264,7 +9451,8 @@ def test_install_status_release_serialization(self): install_status_release_model_json2 = install_status_release_model.to_dict() assert install_status_release_model_json2 == install_status_release_model_json -class TestModel_JsonPatchOperation(): + +class TestModel_JsonPatchOperation: """ Test Class for JsonPatchOperation """ @@ -10296,7 +9484,8 @@ def test_json_patch_operation_serialization(self): json_patch_operation_model_json2 = json_patch_operation_model.to_dict() assert json_patch_operation_model_json2 == json_patch_operation_model_json -class TestModel_Kind(): + +class TestModel_Kind: """ Test Class for Kind """ @@ -10308,11 +9497,11 @@ def test_kind_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - configuration_model = {} # Configuration + configuration_model = {} # Configuration configuration_model['key'] = 'testString' configuration_model['type'] = 'testString' configuration_model['default_value'] = 'testString' @@ -10322,46 +9511,46 @@ def test_kind_serialization(self): configuration_model['options'] = ['testString'] configuration_model['hidden'] = True - validation_model = {} # Validation + validation_model = {} # Validation validation_model['validated'] = "2019-01-01T12:00:00Z" validation_model['requested'] = "2019-01-01T12:00:00Z" validation_model['state'] = 'testString' validation_model['last_operation'] = 'testString' validation_model['target'] = {} - resource_model = {} # Resource + resource_model = {} # Resource resource_model['type'] = 'mem' resource_model['value'] = 'testString' - script_model = {} # Script + script_model = {} # Script script_model['instructions'] = 'testString' script_model['script'] = 'testString' script_model['script_permission'] = 'testString' script_model['delete_script'] = 'testString' script_model['scope'] = 'testString' - version_entitlement_model = {} # VersionEntitlement + version_entitlement_model = {} # VersionEntitlement version_entitlement_model['provider_name'] = 'testString' version_entitlement_model['provider_id'] = 'testString' version_entitlement_model['product_id'] = 'testString' version_entitlement_model['part_numbers'] = ['testString'] version_entitlement_model['image_repo_name'] = 'testString' - license_model = {} # License + license_model = {} # License license_model['id'] = 'testString' license_model['name'] = 'testString' license_model['type'] = 'testString' license_model['url'] = 'testString' license_model['description'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - version_model = {} # Version + version_model = {} # Version version_model['id'] = 'testString' version_model['_rev'] = 'testString' version_model['crn'] = 'testString' @@ -10394,7 +9583,7 @@ def test_kind_serialization(self): version_model['long_description'] = 'testString' version_model['whitelisted_accounts'] = ['testString'] - deployment_model = {} # Deployment + deployment_model = {} # Deployment deployment_model['id'] = 'testString' deployment_model['label'] = 'testString' deployment_model['name'] = 'testString' @@ -10405,7 +9594,7 @@ def test_kind_serialization(self): deployment_model['created'] = "2019-01-01T12:00:00Z" deployment_model['updated'] = "2019-01-01T12:00:00Z" - plan_model = {} # Plan + plan_model = {} # Plan plan_model['id'] = 'testString' plan_model['label'] = 'testString' plan_model['name'] = 'testString' @@ -10447,7 +9636,8 @@ def test_kind_serialization(self): kind_model_json2 = kind_model.to_dict() assert kind_model_json2 == kind_model_json -class TestModel_License(): + +class TestModel_License: """ Test Class for License """ @@ -10480,7 +9670,8 @@ def test_license_serialization(self): license_model_json2 = license_model.to_dict() assert license_model_json2 == license_model_json -class TestModel_MediaItem(): + +class TestModel_MediaItem: """ Test Class for MediaItem """ @@ -10512,7 +9703,8 @@ def test_media_item_serialization(self): media_item_model_json2 = media_item_model.to_dict() assert media_item_model_json2 == media_item_model_json -class TestModel_NamespaceSearchResult(): + +class TestModel_NamespaceSearchResult: """ Test Class for NamespaceSearchResult """ @@ -10539,7 +9731,9 @@ def test_namespace_search_result_serialization(self): assert namespace_search_result_model != False # Construct a model instance of NamespaceSearchResult by calling from_dict on the json representation - namespace_search_result_model_dict = NamespaceSearchResult.from_dict(namespace_search_result_model_json).__dict__ + namespace_search_result_model_dict = NamespaceSearchResult.from_dict( + namespace_search_result_model_json + ).__dict__ namespace_search_result_model2 = NamespaceSearchResult(**namespace_search_result_model_dict) # Verify the model instances are equivalent @@ -10549,7 +9743,8 @@ def test_namespace_search_result_serialization(self): namespace_search_result_model_json2 = namespace_search_result_model.to_dict() assert namespace_search_result_model_json2 == namespace_search_result_model_json -class TestModel_ObjectAccess(): + +class TestModel_ObjectAccess: """ Test Class for ObjectAccess """ @@ -10582,7 +9777,8 @@ def test_object_access_serialization(self): object_access_model_json2 = object_access_model.to_dict() assert object_access_model_json2 == object_access_model_json -class TestModel_ObjectAccessListResult(): + +class TestModel_ObjectAccessListResult: """ Test Class for ObjectAccessListResult """ @@ -10594,7 +9790,7 @@ def test_object_access_list_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - object_access_model = {} # ObjectAccess + object_access_model = {} # ObjectAccess object_access_model['id'] = 'testString' object_access_model['account'] = 'testString' object_access_model['catalog_id'] = 'testString' @@ -10618,7 +9814,9 @@ def test_object_access_list_result_serialization(self): assert object_access_list_result_model != False # Construct a model instance of ObjectAccessListResult by calling from_dict on the json representation - object_access_list_result_model_dict = ObjectAccessListResult.from_dict(object_access_list_result_model_json).__dict__ + object_access_list_result_model_dict = ObjectAccessListResult.from_dict( + object_access_list_result_model_json + ).__dict__ object_access_list_result_model2 = ObjectAccessListResult(**object_access_list_result_model_dict) # Verify the model instances are equivalent @@ -10628,7 +9826,8 @@ def test_object_access_list_result_serialization(self): object_access_list_result_model_json2 = object_access_list_result_model.to_dict() assert object_access_list_result_model_json2 == object_access_list_result_model_json -class TestModel_ObjectListResult(): + +class TestModel_ObjectListResult: """ Test Class for ObjectListResult """ @@ -10640,21 +9839,21 @@ def test_object_list_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - publish_object_model = {} # PublishObject + publish_object_model = {} # PublishObject publish_object_model['permit_ibm_public_publish'] = True publish_object_model['ibm_approved'] = True publish_object_model['public_approved'] = True publish_object_model['portal_approval_record'] = 'testString' publish_object_model['portal_url'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - catalog_object_model = {} # CatalogObject + catalog_object_model = {} # CatalogObject catalog_object_model['id'] = 'testString' catalog_object_model['name'] = 'testString' catalog_object_model['_rev'] = 'testString' @@ -10702,7 +9901,8 @@ def test_object_list_result_serialization(self): object_list_result_model_json2 = object_list_result_model.to_dict() assert object_list_result_model_json2 == object_list_result_model_json -class TestModel_ObjectSearchResult(): + +class TestModel_ObjectSearchResult: """ Test Class for ObjectSearchResult """ @@ -10714,21 +9914,21 @@ def test_object_search_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - publish_object_model = {} # PublishObject + publish_object_model = {} # PublishObject publish_object_model['permit_ibm_public_publish'] = True publish_object_model['ibm_approved'] = True publish_object_model['public_approved'] = True publish_object_model['portal_approval_record'] = 'testString' publish_object_model['portal_url'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - catalog_object_model = {} # CatalogObject + catalog_object_model = {} # CatalogObject catalog_object_model['id'] = 'testString' catalog_object_model['name'] = 'testString' catalog_object_model['_rev'] = 'testString' @@ -10776,7 +9976,8 @@ def test_object_search_result_serialization(self): object_search_result_model_json2 = object_search_result_model.to_dict() assert object_search_result_model_json2 == object_search_result_model_json -class TestModel_Offering(): + +class TestModel_Offering: """ Test Class for Offering """ @@ -10788,17 +9989,17 @@ def test_offering_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rating_model = {} # Rating + rating_model = {} # Rating rating_model['one_star_count'] = 38 rating_model['two_star_count'] = 38 rating_model['three_star_count'] = 38 rating_model['four_star_count'] = 38 - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - configuration_model = {} # Configuration + configuration_model = {} # Configuration configuration_model['key'] = 'testString' configuration_model['type'] = 'testString' configuration_model['default_value'] = 'testString' @@ -10808,46 +10009,46 @@ def test_offering_serialization(self): configuration_model['options'] = ['testString'] configuration_model['hidden'] = True - validation_model = {} # Validation + validation_model = {} # Validation validation_model['validated'] = "2019-01-01T12:00:00Z" validation_model['requested'] = "2019-01-01T12:00:00Z" validation_model['state'] = 'testString' validation_model['last_operation'] = 'testString' validation_model['target'] = {} - resource_model = {} # Resource + resource_model = {} # Resource resource_model['type'] = 'mem' resource_model['value'] = 'testString' - script_model = {} # Script + script_model = {} # Script script_model['instructions'] = 'testString' script_model['script'] = 'testString' script_model['script_permission'] = 'testString' script_model['delete_script'] = 'testString' script_model['scope'] = 'testString' - version_entitlement_model = {} # VersionEntitlement + version_entitlement_model = {} # VersionEntitlement version_entitlement_model['provider_name'] = 'testString' version_entitlement_model['provider_id'] = 'testString' version_entitlement_model['product_id'] = 'testString' version_entitlement_model['part_numbers'] = ['testString'] version_entitlement_model['image_repo_name'] = 'testString' - license_model = {} # License + license_model = {} # License license_model['id'] = 'testString' license_model['name'] = 'testString' license_model['type'] = 'testString' license_model['url'] = 'testString' license_model['description'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - version_model = {} # Version + version_model = {} # Version version_model['id'] = 'testString' version_model['_rev'] = 'testString' version_model['crn'] = 'testString' @@ -10880,7 +10081,7 @@ def test_offering_serialization(self): version_model['long_description'] = 'testString' version_model['whitelisted_accounts'] = ['testString'] - deployment_model = {} # Deployment + deployment_model = {} # Deployment deployment_model['id'] = 'testString' deployment_model['label'] = 'testString' deployment_model['name'] = 'testString' @@ -10891,7 +10092,7 @@ def test_offering_serialization(self): deployment_model['created'] = "2019-01-01T12:00:00Z" deployment_model['updated'] = "2019-01-01T12:00:00Z" - plan_model = {} # Plan + plan_model = {} # Plan plan_model['id'] = 'testString' plan_model['label'] = 'testString' plan_model['name'] = 'testString' @@ -10904,7 +10105,7 @@ def test_offering_serialization(self): plan_model['updated'] = "2019-01-01T12:00:00Z" plan_model['deployments'] = [deployment_model] - kind_model = {} # Kind + kind_model = {} # Kind kind_model['id'] = 'testString' kind_model['format_kind'] = 'testString' kind_model['target_kind'] = 'testString' @@ -10917,20 +10118,20 @@ def test_offering_serialization(self): kind_model['versions'] = [version_model] kind_model['plans'] = [plan_model] - provider_info_model = {} # ProviderInfo + provider_info_model = {} # ProviderInfo provider_info_model['id'] = 'testString' provider_info_model['name'] = 'testString' - repo_info_model = {} # RepoInfo + repo_info_model = {} # RepoInfo repo_info_model['token'] = 'testString' repo_info_model['type'] = 'testString' - support_model = {} # Support + support_model = {} # Support support_model['url'] = 'testString' support_model['process'] = 'testString' support_model['locations'] = ['testString'] - media_item_model = {} # MediaItem + media_item_model = {} # MediaItem media_item_model['url'] = 'testString' media_item_model['caption'] = 'testString' media_item_model['type'] = 'testString' @@ -10989,7 +10190,8 @@ def test_offering_serialization(self): offering_model_json2 = offering_model.to_dict() assert offering_model_json2 == offering_model_json -class TestModel_OfferingInstance(): + +class TestModel_OfferingInstance: """ Test Class for OfferingInstance """ @@ -11001,7 +10203,7 @@ def test_offering_instance_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - offering_instance_last_operation_model = {} # OfferingInstanceLastOperation + offering_instance_last_operation_model = {} # OfferingInstanceLastOperation offering_instance_last_operation_model['operation'] = 'testString' offering_instance_last_operation_model['state'] = 'testString' offering_instance_last_operation_model['message'] = 'testString' @@ -11045,7 +10247,8 @@ def test_offering_instance_serialization(self): offering_instance_model_json2 = offering_instance_model.to_dict() assert offering_instance_model_json2 == offering_instance_model_json -class TestModel_OfferingInstanceLastOperation(): + +class TestModel_OfferingInstanceLastOperation: """ Test Class for OfferingInstanceLastOperation """ @@ -11064,12 +10267,18 @@ def test_offering_instance_last_operation_serialization(self): offering_instance_last_operation_model_json['updated'] = 'testString' # Construct a model instance of OfferingInstanceLastOperation by calling from_dict on the json representation - offering_instance_last_operation_model = OfferingInstanceLastOperation.from_dict(offering_instance_last_operation_model_json) + offering_instance_last_operation_model = OfferingInstanceLastOperation.from_dict( + offering_instance_last_operation_model_json + ) assert offering_instance_last_operation_model != False # Construct a model instance of OfferingInstanceLastOperation by calling from_dict on the json representation - offering_instance_last_operation_model_dict = OfferingInstanceLastOperation.from_dict(offering_instance_last_operation_model_json).__dict__ - offering_instance_last_operation_model2 = OfferingInstanceLastOperation(**offering_instance_last_operation_model_dict) + offering_instance_last_operation_model_dict = OfferingInstanceLastOperation.from_dict( + offering_instance_last_operation_model_json + ).__dict__ + offering_instance_last_operation_model2 = OfferingInstanceLastOperation( + **offering_instance_last_operation_model_dict + ) # Verify the model instances are equivalent assert offering_instance_last_operation_model == offering_instance_last_operation_model2 @@ -11078,7 +10287,8 @@ def test_offering_instance_last_operation_serialization(self): offering_instance_last_operation_model_json2 = offering_instance_last_operation_model.to_dict() assert offering_instance_last_operation_model_json2 == offering_instance_last_operation_model_json -class TestModel_OfferingSearchResult(): + +class TestModel_OfferingSearchResult: """ Test Class for OfferingSearchResult """ @@ -11090,17 +10300,17 @@ def test_offering_search_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rating_model = {} # Rating + rating_model = {} # Rating rating_model['one_star_count'] = 38 rating_model['two_star_count'] = 38 rating_model['three_star_count'] = 38 rating_model['four_star_count'] = 38 - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - configuration_model = {} # Configuration + configuration_model = {} # Configuration configuration_model['key'] = 'testString' configuration_model['type'] = 'testString' configuration_model['default_value'] = 'testString' @@ -11110,46 +10320,46 @@ def test_offering_search_result_serialization(self): configuration_model['options'] = ['testString'] configuration_model['hidden'] = True - validation_model = {} # Validation + validation_model = {} # Validation validation_model['validated'] = "2019-01-01T12:00:00Z" validation_model['requested'] = "2019-01-01T12:00:00Z" validation_model['state'] = 'testString' validation_model['last_operation'] = 'testString' validation_model['target'] = {} - resource_model = {} # Resource + resource_model = {} # Resource resource_model['type'] = 'mem' resource_model['value'] = 'testString' - script_model = {} # Script + script_model = {} # Script script_model['instructions'] = 'testString' script_model['script'] = 'testString' script_model['script_permission'] = 'testString' script_model['delete_script'] = 'testString' script_model['scope'] = 'testString' - version_entitlement_model = {} # VersionEntitlement + version_entitlement_model = {} # VersionEntitlement version_entitlement_model['provider_name'] = 'testString' version_entitlement_model['provider_id'] = 'testString' version_entitlement_model['product_id'] = 'testString' version_entitlement_model['part_numbers'] = ['testString'] version_entitlement_model['image_repo_name'] = 'testString' - license_model = {} # License + license_model = {} # License license_model['id'] = 'testString' license_model['name'] = 'testString' license_model['type'] = 'testString' license_model['url'] = 'testString' license_model['description'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - version_model = {} # Version + version_model = {} # Version version_model['id'] = 'testString' version_model['_rev'] = 'testString' version_model['crn'] = 'testString' @@ -11182,7 +10392,7 @@ def test_offering_search_result_serialization(self): version_model['long_description'] = 'testString' version_model['whitelisted_accounts'] = ['testString'] - deployment_model = {} # Deployment + deployment_model = {} # Deployment deployment_model['id'] = 'testString' deployment_model['label'] = 'testString' deployment_model['name'] = 'testString' @@ -11193,7 +10403,7 @@ def test_offering_search_result_serialization(self): deployment_model['created'] = "2019-01-01T12:00:00Z" deployment_model['updated'] = "2019-01-01T12:00:00Z" - plan_model = {} # Plan + plan_model = {} # Plan plan_model['id'] = 'testString' plan_model['label'] = 'testString' plan_model['name'] = 'testString' @@ -11206,7 +10416,7 @@ def test_offering_search_result_serialization(self): plan_model['updated'] = "2019-01-01T12:00:00Z" plan_model['deployments'] = [deployment_model] - kind_model = {} # Kind + kind_model = {} # Kind kind_model['id'] = 'testString' kind_model['format_kind'] = 'testString' kind_model['target_kind'] = 'testString' @@ -11219,26 +10429,26 @@ def test_offering_search_result_serialization(self): kind_model['versions'] = [version_model] kind_model['plans'] = [plan_model] - provider_info_model = {} # ProviderInfo + provider_info_model = {} # ProviderInfo provider_info_model['id'] = 'testString' provider_info_model['name'] = 'testString' - repo_info_model = {} # RepoInfo + repo_info_model = {} # RepoInfo repo_info_model['token'] = 'testString' repo_info_model['type'] = 'testString' - support_model = {} # Support + support_model = {} # Support support_model['url'] = 'testString' support_model['process'] = 'testString' support_model['locations'] = ['testString'] - media_item_model = {} # MediaItem + media_item_model = {} # MediaItem media_item_model['url'] = 'testString' media_item_model['caption'] = 'testString' media_item_model['type'] = 'testString' media_item_model['thumbnail_url'] = 'testString' - offering_model = {} # Offering + offering_model = {} # Offering offering_model['id'] = 'testString' offering_model['_rev'] = 'testString' offering_model['url'] = 'testString' @@ -11302,7 +10512,8 @@ def test_offering_search_result_serialization(self): offering_search_result_model_json2 = offering_search_result_model.to_dict() assert offering_search_result_model_json2 == offering_search_result_model_json -class TestModel_OperatorDeployResult(): + +class TestModel_OperatorDeployResult: """ Test Class for OperatorDeployResult """ @@ -11338,7 +10549,8 @@ def test_operator_deploy_result_serialization(self): operator_deploy_result_model_json2 = operator_deploy_result_model.to_dict() assert operator_deploy_result_model_json2 == operator_deploy_result_model_json -class TestModel_Plan(): + +class TestModel_Plan: """ Test Class for Plan """ @@ -11350,11 +10562,11 @@ def test_plan_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - feature_model = {} # Feature + feature_model = {} # Feature feature_model['title'] = 'testString' feature_model['description'] = 'testString' - deployment_model = {} # Deployment + deployment_model = {} # Deployment deployment_model['id'] = 'testString' deployment_model['label'] = 'testString' deployment_model['name'] = 'testString' @@ -11394,7 +10606,8 @@ def test_plan_serialization(self): plan_model_json2 = plan_model.to_dict() assert plan_model_json2 == plan_model_json -class TestModel_ProviderInfo(): + +class TestModel_ProviderInfo: """ Test Class for ProviderInfo """ @@ -11424,7 +10637,8 @@ def test_provider_info_serialization(self): provider_info_model_json2 = provider_info_model.to_dict() assert provider_info_model_json2 == provider_info_model_json -class TestModel_PublishObject(): + +class TestModel_PublishObject: """ Test Class for PublishObject """ @@ -11457,7 +10671,8 @@ def test_publish_object_serialization(self): publish_object_model_json2 = publish_object_model.to_dict() assert publish_object_model_json2 == publish_object_model_json -class TestModel_Rating(): + +class TestModel_Rating: """ Test Class for Rating """ @@ -11489,7 +10704,8 @@ def test_rating_serialization(self): rating_model_json2 = rating_model.to_dict() assert rating_model_json2 == rating_model_json -class TestModel_RepoInfo(): + +class TestModel_RepoInfo: """ Test Class for RepoInfo """ @@ -11519,7 +10735,8 @@ def test_repo_info_serialization(self): repo_info_model_json2 = repo_info_model.to_dict() assert repo_info_model_json2 == repo_info_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -11549,7 +10766,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_Script(): + +class TestModel_Script: """ Test Class for Script """ @@ -11582,7 +10800,8 @@ def test_script_serialization(self): script_model_json2 = script_model.to_dict() assert script_model_json2 == script_model_json -class TestModel_State(): + +class TestModel_State: """ Test Class for State """ @@ -11615,7 +10834,8 @@ def test_state_serialization(self): state_model_json2 = state_model.to_dict() assert state_model_json2 == state_model_json -class TestModel_Support(): + +class TestModel_Support: """ Test Class for Support """ @@ -11646,7 +10866,8 @@ def test_support_serialization(self): support_model_json2 = support_model.to_dict() assert support_model_json2 == support_model_json -class TestModel_SyndicationAuthorization(): + +class TestModel_SyndicationAuthorization: """ Test Class for SyndicationAuthorization """ @@ -11666,7 +10887,9 @@ def test_syndication_authorization_serialization(self): assert syndication_authorization_model != False # Construct a model instance of SyndicationAuthorization by calling from_dict on the json representation - syndication_authorization_model_dict = SyndicationAuthorization.from_dict(syndication_authorization_model_json).__dict__ + syndication_authorization_model_dict = SyndicationAuthorization.from_dict( + syndication_authorization_model_json + ).__dict__ syndication_authorization_model2 = SyndicationAuthorization(**syndication_authorization_model_dict) # Verify the model instances are equivalent @@ -11676,7 +10899,8 @@ def test_syndication_authorization_serialization(self): syndication_authorization_model_json2 = syndication_authorization_model.to_dict() assert syndication_authorization_model_json2 == syndication_authorization_model_json -class TestModel_SyndicationCluster(): + +class TestModel_SyndicationCluster: """ Test Class for SyndicationCluster """ @@ -11711,7 +10935,8 @@ def test_syndication_cluster_serialization(self): syndication_cluster_model_json2 = syndication_cluster_model.to_dict() assert syndication_cluster_model_json2 == syndication_cluster_model_json -class TestModel_SyndicationHistory(): + +class TestModel_SyndicationHistory: """ Test Class for SyndicationHistory """ @@ -11723,7 +10948,7 @@ def test_syndication_history_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - syndication_cluster_model = {} # SyndicationCluster + syndication_cluster_model = {} # SyndicationCluster syndication_cluster_model['region'] = 'testString' syndication_cluster_model['id'] = 'testString' syndication_cluster_model['name'] = 'testString' @@ -11753,7 +10978,8 @@ def test_syndication_history_serialization(self): syndication_history_model_json2 = syndication_history_model.to_dict() assert syndication_history_model_json2 == syndication_history_model_json -class TestModel_SyndicationResource(): + +class TestModel_SyndicationResource: """ Test Class for SyndicationResource """ @@ -11765,7 +10991,7 @@ def test_syndication_resource_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - syndication_cluster_model = {} # SyndicationCluster + syndication_cluster_model = {} # SyndicationCluster syndication_cluster_model['region'] = 'testString' syndication_cluster_model['id'] = 'testString' syndication_cluster_model['name'] = 'testString' @@ -11774,12 +11000,12 @@ def test_syndication_resource_serialization(self): syndication_cluster_model['namespaces'] = ['testString'] syndication_cluster_model['all_namespaces'] = True - syndication_history_model = {} # SyndicationHistory + syndication_history_model = {} # SyndicationHistory syndication_history_model['namespaces'] = ['testString'] syndication_history_model['clusters'] = [syndication_cluster_model] syndication_history_model['last_run'] = "2019-01-01T12:00:00Z" - syndication_authorization_model = {} # SyndicationAuthorization + syndication_authorization_model = {} # SyndicationAuthorization syndication_authorization_model['token'] = 'testString' syndication_authorization_model['last_run'] = "2019-01-01T12:00:00Z" @@ -11805,7 +11031,8 @@ def test_syndication_resource_serialization(self): syndication_resource_model_json2 = syndication_resource_model.to_dict() assert syndication_resource_model_json2 == syndication_resource_model_json -class TestModel_Validation(): + +class TestModel_Validation: """ Test Class for Validation """ @@ -11838,7 +11065,8 @@ def test_validation_serialization(self): validation_model_json2 = validation_model.to_dict() assert validation_model_json2 == validation_model_json -class TestModel_Version(): + +class TestModel_Version: """ Test Class for Version """ @@ -11850,7 +11078,7 @@ def test_version_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - configuration_model = {} # Configuration + configuration_model = {} # Configuration configuration_model['key'] = 'testString' configuration_model['type'] = 'testString' configuration_model['default_value'] = 'testString' @@ -11860,39 +11088,39 @@ def test_version_serialization(self): configuration_model['options'] = ['testString'] configuration_model['hidden'] = True - validation_model = {} # Validation + validation_model = {} # Validation validation_model['validated'] = "2019-01-01T12:00:00Z" validation_model['requested'] = "2019-01-01T12:00:00Z" validation_model['state'] = 'testString' validation_model['last_operation'] = 'testString' validation_model['target'] = {} - resource_model = {} # Resource + resource_model = {} # Resource resource_model['type'] = 'mem' resource_model['value'] = 'testString' - script_model = {} # Script + script_model = {} # Script script_model['instructions'] = 'testString' script_model['script'] = 'testString' script_model['script_permission'] = 'testString' script_model['delete_script'] = 'testString' script_model['scope'] = 'testString' - version_entitlement_model = {} # VersionEntitlement + version_entitlement_model = {} # VersionEntitlement version_entitlement_model['provider_name'] = 'testString' version_entitlement_model['provider_id'] = 'testString' version_entitlement_model['product_id'] = 'testString' version_entitlement_model['part_numbers'] = ['testString'] version_entitlement_model['image_repo_name'] = 'testString' - license_model = {} # License + license_model = {} # License license_model['id'] = 'testString' license_model['name'] = 'testString' license_model['type'] = 'testString' license_model['url'] = 'testString' license_model['description'] = 'testString' - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' @@ -11948,7 +11176,8 @@ def test_version_serialization(self): version_model_json2 = version_model.to_dict() assert version_model_json2 == version_model_json -class TestModel_VersionEntitlement(): + +class TestModel_VersionEntitlement: """ Test Class for VersionEntitlement """ @@ -11981,7 +11210,8 @@ def test_version_entitlement_serialization(self): version_entitlement_model_json2 = version_entitlement_model.to_dict() assert version_entitlement_model_json2 == version_entitlement_model_json -class TestModel_VersionUpdateDescriptor(): + +class TestModel_VersionUpdateDescriptor: """ Test Class for VersionUpdateDescriptor """ @@ -11993,14 +11223,14 @@ def test_version_update_descriptor_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - state_model = {} # State + state_model = {} # State state_model['current'] = 'testString' state_model['current_entered'] = "2019-01-01T12:00:00Z" state_model['pending'] = 'testString' state_model['pending_requested'] = "2019-01-01T12:00:00Z" state_model['previous'] = 'testString' - resource_model = {} # Resource + resource_model = {} # Resource resource_model['type'] = 'mem' resource_model['value'] = 'testString' @@ -12020,7 +11250,9 @@ def test_version_update_descriptor_serialization(self): assert version_update_descriptor_model != False # Construct a model instance of VersionUpdateDescriptor by calling from_dict on the json representation - version_update_descriptor_model_dict = VersionUpdateDescriptor.from_dict(version_update_descriptor_model_json).__dict__ + version_update_descriptor_model_dict = VersionUpdateDescriptor.from_dict( + version_update_descriptor_model_json + ).__dict__ version_update_descriptor_model2 = VersionUpdateDescriptor(**version_update_descriptor_model_dict) # Verify the model instances are equivalent diff --git a/test/unit/test_common.py b/test/unit/test_common.py index 26926dec..e38e03c3 100644 --- a/test/unit/test_common.py +++ b/test/unit/test_common.py @@ -21,6 +21,7 @@ import unittest from ibm_platform_services import common + class TestCommon(unittest.TestCase): """ Test methods in the common module diff --git a/test/unit/test_context_based_restrictions_v1.py b/test/unit/test_context_based_restrictions_v1.py index a58bfbd7..ff70d7aa 100644 --- a/test/unit/test_context_based_restrictions_v1.py +++ b/test/unit/test_context_based_restrictions_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.context_based_restrictions_v1 import * -_service = ContextBasedRestrictionsV1( - authenticator=NoAuthAuthenticator() -) +_service = ContextBasedRestrictionsV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://cbr.cloud.ibm.com' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateZone(): + +class TestCreateZone: """ Test Class for create_zone """ @@ -110,11 +110,7 @@ def test_create_zone_all_params(self): # Set up mock url = preprocess_url('/v1/zones') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a AddressIPAddress model address_model = {} @@ -139,7 +135,7 @@ def test_create_zone_all_params(self): excluded=excluded, x_correlation_id=x_correlation_id, transaction_id=transaction_id, - headers={} + headers={}, ) # Check for correct operation @@ -170,16 +166,11 @@ def test_create_zone_required_params(self): # Set up mock url = preprocess_url('/v1/zones') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Invoke method response = _service.create_zone() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 @@ -193,7 +184,8 @@ def test_create_zone_required_params_with_retries(self): _service.disable_retries() self.test_create_zone_required_params() -class TestListZones(): + +class TestListZones: """ Test Class for list_zones """ @@ -206,11 +198,7 @@ def test_list_zones_all_params(self): # Set up mock url = preprocess_url('/v1/zones') mock_response = '{"count": 5, "zones": [{"id": "id", "crn": "crn", "name": "name", "description": "description", "addresses_preview": [{"type": "ipAddress", "value": "value"}], "address_count": 13, "excluded_count": 14, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -226,14 +214,14 @@ def test_list_zones_all_params(self): transaction_id=transaction_id, name=name, sort=sort, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account_id={}'.format(account_id) in query_string assert 'name={}'.format(name) in query_string @@ -256,26 +244,19 @@ def test_list_zones_required_params(self): # Set up mock url = preprocess_url('/v1/zones') mock_response = '{"count": 5, "zones": [{"id": "id", "crn": "crn", "name": "name", "description": "description", "addresses_preview": [{"type": "ipAddress", "value": "value"}], "address_count": 13, "excluded_count": 14, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_zones( - account_id, - headers={} - ) + response = _service.list_zones(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 = 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 @@ -296,11 +277,7 @@ def test_list_zones_value_error(self): # Set up mock url = preprocess_url('/v1/zones') mock_response = '{"count": 5, "zones": [{"id": "id", "crn": "crn", "name": "name", "description": "description", "addresses_preview": [{"type": "ipAddress", "value": "value"}], "address_count": 13, "excluded_count": 14, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -310,7 +287,7 @@ def test_list_zones_value_error(self): "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()} + 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_zones(**req_copy) @@ -323,7 +300,8 @@ def test_list_zones_value_error_with_retries(self): _service.disable_retries() self.test_list_zones_value_error() -class TestGetZone(): + +class TestGetZone: """ Test Class for get_zone """ @@ -336,11 +314,7 @@ def test_get_zone_all_params(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values zone_id = 'testString' @@ -349,10 +323,7 @@ def test_get_zone_all_params(self): # Invoke method response = _service.get_zone( - zone_id, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + zone_id, x_correlation_id=x_correlation_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -376,20 +347,13 @@ def test_get_zone_required_params(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values zone_id = 'testString' # Invoke method - response = _service.get_zone( - zone_id, - headers={} - ) + response = _service.get_zone(zone_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -412,11 +376,7 @@ def test_get_zone_value_error(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values zone_id = 'testString' @@ -426,7 +386,7 @@ def test_get_zone_value_error(self): "zone_id": zone_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()} + 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_zone(**req_copy) @@ -439,7 +399,8 @@ def test_get_zone_value_error_with_retries(self): _service.disable_retries() self.test_get_zone_value_error() -class TestReplaceZone(): + +class TestReplaceZone: """ Test Class for replace_zone """ @@ -452,11 +413,7 @@ def test_replace_zone_all_params(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a AddressIPAddress model address_model = {} @@ -485,7 +442,7 @@ def test_replace_zone_all_params(self): excluded=excluded, x_correlation_id=x_correlation_id, transaction_id=transaction_id, - headers={} + headers={}, ) # Check for correct operation @@ -516,22 +473,14 @@ def test_replace_zone_required_params(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values zone_id = 'testString' if_match = 'testString' # Invoke method - response = _service.replace_zone( - zone_id, - if_match, - headers={} - ) + response = _service.replace_zone(zone_id, if_match, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -554,11 +503,7 @@ def test_replace_zone_value_error(self): # Set up mock url = preprocess_url('/v1/zones/testString') mock_response = '{"id": "id", "crn": "crn", "address_count": 13, "excluded_count": 14, "name": "name", "account_id": "account_id", "description": "description", "addresses": [{"type": "ipAddress", "value": "value"}], "excluded": [{"type": "ipAddress", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values zone_id = 'testString' @@ -570,7 +515,7 @@ def test_replace_zone_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_zone(**req_copy) @@ -583,7 +528,8 @@ def test_replace_zone_value_error_with_retries(self): _service.disable_retries() self.test_replace_zone_value_error() -class TestDeleteZone(): + +class TestDeleteZone: """ Test Class for delete_zone """ @@ -595,9 +541,7 @@ def test_delete_zone_all_params(self): """ # Set up mock url = preprocess_url('/v1/zones/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values zone_id = 'testString' @@ -606,10 +550,7 @@ def test_delete_zone_all_params(self): # Invoke method response = _service.delete_zone( - zone_id, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + zone_id, x_correlation_id=x_correlation_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -632,18 +573,13 @@ def test_delete_zone_required_params(self): """ # Set up mock url = preprocess_url('/v1/zones/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values zone_id = 'testString' # Invoke method - response = _service.delete_zone( - zone_id, - headers={} - ) + response = _service.delete_zone(zone_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -665,9 +601,7 @@ def test_delete_zone_value_error(self): """ # Set up mock url = preprocess_url('/v1/zones/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values zone_id = 'testString' @@ -677,7 +611,7 @@ def test_delete_zone_value_error(self): "zone_id": zone_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()} + 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_zone(**req_copy) @@ -690,7 +624,8 @@ def test_delete_zone_value_error_with_retries(self): _service.disable_retries() self.test_delete_zone_value_error() -class TestListAvailableServicerefTargets(): + +class TestListAvailableServicerefTargets: """ Test Class for list_available_serviceref_targets """ @@ -703,11 +638,7 @@ def test_list_available_serviceref_targets_all_params(self): # Set up mock url = preprocess_url('/v1/zones/serviceref_targets') mock_response = '{"count": 5, "targets": [{"service_name": "service_name", "service_type": "service_type", "locations": [{"name": "name"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values x_correlation_id = 'testString' @@ -716,17 +647,14 @@ def test_list_available_serviceref_targets_all_params(self): # Invoke method response = _service.list_available_serviceref_targets( - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - type=type, - headers={} + x_correlation_id=x_correlation_id, transaction_id=transaction_id, type=type, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'type={}'.format(type) in query_string @@ -747,16 +675,11 @@ def test_list_available_serviceref_targets_required_params(self): # Set up mock url = preprocess_url('/v1/zones/serviceref_targets') mock_response = '{"count": 5, "targets": [{"service_name": "service_name", "service_type": "service_type", "locations": [{"name": "name"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_available_serviceref_targets() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -770,6 +693,7 @@ def test_list_available_serviceref_targets_required_params_with_retries(self): _service.disable_retries() self.test_list_available_serviceref_targets_required_params() + # endregion ############################################################################## # End of Service: Zones @@ -780,7 +704,8 @@ def test_list_available_serviceref_targets_required_params_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -807,7 +732,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateRule(): + +class TestCreateRule: """ Test Class for create_rule """ @@ -820,11 +746,7 @@ def test_create_rule_all_params(self): # Set up mock url = preprocess_url('/v1/rules') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a RuleContextAttribute model rule_context_attribute_model = {} @@ -878,7 +800,7 @@ def test_create_rule_all_params(self): enforcement_mode=enforcement_mode, x_correlation_id=x_correlation_id, transaction_id=transaction_id, - headers={} + headers={}, ) # Check for correct operation @@ -909,16 +831,11 @@ def test_create_rule_required_params(self): # Set up mock url = preprocess_url('/v1/rules') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Invoke method response = _service.create_rule() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 @@ -932,7 +849,8 @@ def test_create_rule_required_params_with_retries(self): _service.disable_retries() self.test_create_rule_required_params() -class TestListRules(): + +class TestListRules: """ Test Class for list_rules """ @@ -945,11 +863,7 @@ def test_list_rules_all_params(self): # Set up mock url = preprocess_url('/v1/rules') mock_response = '{"count": 5, "rules": [{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -981,14 +895,14 @@ def test_list_rules_all_params(self): zone_id=zone_id, sort=sort, enforcement_mode=enforcement_mode, - headers={} + 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 = 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 'region={}'.format(region) in query_string @@ -1019,26 +933,19 @@ def test_list_rules_required_params(self): # Set up mock url = preprocess_url('/v1/rules') mock_response = '{"count": 5, "rules": [{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_rules( - account_id, - headers={} - ) + response = _service.list_rules(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 = 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 @@ -1059,11 +966,7 @@ def test_list_rules_value_error(self): # Set up mock url = preprocess_url('/v1/rules') mock_response = '{"count": 5, "rules": [{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1073,7 +976,7 @@ def test_list_rules_value_error(self): "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()} + 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_rules(**req_copy) @@ -1086,7 +989,8 @@ def test_list_rules_value_error_with_retries(self): _service.disable_retries() self.test_list_rules_value_error() -class TestGetRule(): + +class TestGetRule: """ Test Class for get_rule """ @@ -1099,11 +1003,7 @@ def test_get_rule_all_params(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values rule_id = 'testString' @@ -1112,10 +1012,7 @@ def test_get_rule_all_params(self): # Invoke method response = _service.get_rule( - rule_id, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + rule_id, x_correlation_id=x_correlation_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1139,20 +1036,13 @@ def test_get_rule_required_params(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values rule_id = 'testString' # Invoke method - response = _service.get_rule( - rule_id, - headers={} - ) + response = _service.get_rule(rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1175,11 +1065,7 @@ def test_get_rule_value_error(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values rule_id = 'testString' @@ -1189,7 +1075,7 @@ def test_get_rule_value_error(self): "rule_id": rule_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()} + 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_rule(**req_copy) @@ -1202,7 +1088,8 @@ def test_get_rule_value_error_with_retries(self): _service.disable_retries() self.test_get_rule_value_error() -class TestReplaceRule(): + +class TestReplaceRule: """ Test Class for replace_rule """ @@ -1215,11 +1102,7 @@ def test_replace_rule_all_params(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a RuleContextAttribute model rule_context_attribute_model = {} @@ -1277,7 +1160,7 @@ def test_replace_rule_all_params(self): enforcement_mode=enforcement_mode, x_correlation_id=x_correlation_id, transaction_id=transaction_id, - headers={} + headers={}, ) # Check for correct operation @@ -1308,22 +1191,14 @@ def test_replace_rule_required_params(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values rule_id = 'testString' if_match = 'testString' # Invoke method - response = _service.replace_rule( - rule_id, - if_match, - headers={} - ) + response = _service.replace_rule(rule_id, if_match, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1346,11 +1221,7 @@ def test_replace_rule_value_error(self): # Set up mock url = preprocess_url('/v1/rules/testString') mock_response = '{"id": "id", "crn": "crn", "description": "description", "contexts": [{"attributes": [{"name": "name", "value": "value"}]}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "operations": {"api_types": [{"api_type_id": "api_type_id"}]}, "enforcement_mode": "enabled", "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values rule_id = 'testString' @@ -1362,7 +1233,7 @@ def test_replace_rule_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_rule(**req_copy) @@ -1375,7 +1246,8 @@ def test_replace_rule_value_error_with_retries(self): _service.disable_retries() self.test_replace_rule_value_error() -class TestDeleteRule(): + +class TestDeleteRule: """ Test Class for delete_rule """ @@ -1387,9 +1259,7 @@ def test_delete_rule_all_params(self): """ # Set up mock url = preprocess_url('/v1/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values rule_id = 'testString' @@ -1398,10 +1268,7 @@ def test_delete_rule_all_params(self): # Invoke method response = _service.delete_rule( - rule_id, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + rule_id, x_correlation_id=x_correlation_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1424,18 +1291,13 @@ def test_delete_rule_required_params(self): """ # Set up mock url = preprocess_url('/v1/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values rule_id = 'testString' # Invoke method - response = _service.delete_rule( - rule_id, - headers={} - ) + response = _service.delete_rule(rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1457,9 +1319,7 @@ def test_delete_rule_value_error(self): """ # Set up mock url = preprocess_url('/v1/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values rule_id = 'testString' @@ -1469,7 +1329,7 @@ def test_delete_rule_value_error(self): "rule_id": rule_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()} + 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_rule(**req_copy) @@ -1482,6 +1342,7 @@ def test_delete_rule_value_error_with_retries(self): _service.disable_retries() self.test_delete_rule_value_error() + # endregion ############################################################################## # End of Service: Rules @@ -1492,7 +1353,8 @@ def test_delete_rule_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1519,7 +1381,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetAccountSettings(): + +class TestGetAccountSettings: """ Test Class for get_account_settings """ @@ -1532,11 +1395,7 @@ def test_get_account_settings_all_params(self): # Set up mock url = preprocess_url('/v1/account_settings/testString') mock_response = '{"id": "id", "crn": "crn", "rule_count_limit": 16, "zone_count_limit": 16, "current_rule_count": 18, "current_zone_count": 18, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1545,10 +1404,7 @@ def test_get_account_settings_all_params(self): # Invoke method response = _service.get_account_settings( - account_id, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + account_id, x_correlation_id=x_correlation_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1572,20 +1428,13 @@ def test_get_account_settings_required_params(self): # Set up mock url = preprocess_url('/v1/account_settings/testString') mock_response = '{"id": "id", "crn": "crn", "rule_count_limit": 16, "zone_count_limit": 16, "current_rule_count": 18, "current_zone_count": 18, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.get_account_settings( - account_id, - headers={} - ) + response = _service.get_account_settings(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1608,11 +1457,7 @@ def test_get_account_settings_value_error(self): # Set up mock url = preprocess_url('/v1/account_settings/testString') mock_response = '{"id": "id", "crn": "crn", "rule_count_limit": 16, "zone_count_limit": 16, "current_rule_count": 18, "current_zone_count": 18, "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1622,7 +1467,7 @@ def test_get_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) @@ -1635,6 +1480,7 @@ def test_get_account_settings_value_error_with_retries(self): _service.disable_retries() self.test_get_account_settings_value_error() + # endregion ############################################################################## # End of Service: AccountSettings @@ -1645,7 +1491,8 @@ def test_get_account_settings_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1672,7 +1519,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListAvailableServiceOperations(): + +class TestListAvailableServiceOperations: """ Test Class for list_available_service_operations """ @@ -1685,11 +1533,7 @@ def test_list_available_service_operations_all_params(self): # Set up mock url = preprocess_url('/v1/operations') mock_response = '{"api_types": [{"api_type_id": "api_type_id", "display_name": "display_name", "description": "description", "actions": [{"action_id": "action_id", "description": "description"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_name = 'testString' @@ -1698,17 +1542,14 @@ def test_list_available_service_operations_all_params(self): # Invoke method response = _service.list_available_service_operations( - service_name, - x_correlation_id=x_correlation_id, - transaction_id=transaction_id, - headers={} + service_name, x_correlation_id=x_correlation_id, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'service_name={}'.format(service_name) in query_string @@ -1729,26 +1570,19 @@ def test_list_available_service_operations_required_params(self): # Set up mock url = preprocess_url('/v1/operations') mock_response = '{"api_types": [{"api_type_id": "api_type_id", "display_name": "display_name", "description": "description", "actions": [{"action_id": "action_id", "description": "description"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_name = 'testString' # Invoke method - response = _service.list_available_service_operations( - service_name, - headers={} - ) + response = _service.list_available_service_operations(service_name, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'service_name={}'.format(service_name) in query_string @@ -1769,11 +1603,7 @@ def test_list_available_service_operations_value_error(self): # Set up mock url = preprocess_url('/v1/operations') mock_response = '{"api_types": [{"api_type_id": "api_type_id", "display_name": "display_name", "description": "description", "actions": [{"action_id": "action_id", "description": "description"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_name = 'testString' @@ -1783,7 +1613,7 @@ def test_list_available_service_operations_value_error(self): "service_name": service_name, } 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()} + 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_available_service_operations(**req_copy) @@ -1796,6 +1626,7 @@ def test_list_available_service_operations_value_error_with_retries(self): _service.disable_retries() self.test_list_available_service_operations_value_error() + # endregion ############################################################################## # End of Service: Operations @@ -1806,7 +1637,7 @@ def test_list_available_service_operations_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_APIType(): +class TestModel_APIType: """ Test Class for APIType """ @@ -1818,7 +1649,7 @@ def test_api_type_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - action_model = {} # Action + action_model = {} # Action action_model['action_id'] = 'testString' action_model['description'] = 'testString' @@ -1844,7 +1675,8 @@ def test_api_type_serialization(self): api_type_model_json2 = api_type_model.to_dict() assert api_type_model_json2 == api_type_model_json -class TestModel_AccountSettings(): + +class TestModel_AccountSettings: """ Test Class for AccountSettings """ @@ -1883,7 +1715,8 @@ def test_account_settings_serialization(self): account_settings_model_json2 = account_settings_model.to_dict() assert account_settings_model_json2 == account_settings_model_json -class TestModel_Action(): + +class TestModel_Action: """ Test Class for Action """ @@ -1913,7 +1746,8 @@ def test_action_serialization(self): action_model_json2 = action_model.to_dict() assert action_model_json2 == action_model_json -class TestModel_NewRuleOperations(): + +class TestModel_NewRuleOperations: """ Test Class for NewRuleOperations """ @@ -1925,7 +1759,7 @@ def test_new_rule_operations_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem + new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem new_rule_operations_api_types_item_model['api_type_id'] = 'testString' # Construct a json representation of a NewRuleOperations model @@ -1947,7 +1781,8 @@ def test_new_rule_operations_serialization(self): new_rule_operations_model_json2 = new_rule_operations_model.to_dict() assert new_rule_operations_model_json2 == new_rule_operations_model_json -class TestModel_NewRuleOperationsApiTypesItem(): + +class TestModel_NewRuleOperationsApiTypesItem: """ Test Class for NewRuleOperationsApiTypesItem """ @@ -1962,12 +1797,18 @@ def test_new_rule_operations_api_types_item_serialization(self): new_rule_operations_api_types_item_model_json['api_type_id'] = 'testString' # Construct a model instance of NewRuleOperationsApiTypesItem by calling from_dict on the json representation - new_rule_operations_api_types_item_model = NewRuleOperationsApiTypesItem.from_dict(new_rule_operations_api_types_item_model_json) + new_rule_operations_api_types_item_model = NewRuleOperationsApiTypesItem.from_dict( + new_rule_operations_api_types_item_model_json + ) assert new_rule_operations_api_types_item_model != False # Construct a model instance of NewRuleOperationsApiTypesItem by calling from_dict on the json representation - new_rule_operations_api_types_item_model_dict = NewRuleOperationsApiTypesItem.from_dict(new_rule_operations_api_types_item_model_json).__dict__ - new_rule_operations_api_types_item_model2 = NewRuleOperationsApiTypesItem(**new_rule_operations_api_types_item_model_dict) + new_rule_operations_api_types_item_model_dict = NewRuleOperationsApiTypesItem.from_dict( + new_rule_operations_api_types_item_model_json + ).__dict__ + new_rule_operations_api_types_item_model2 = NewRuleOperationsApiTypesItem( + **new_rule_operations_api_types_item_model_dict + ) # Verify the model instances are equivalent assert new_rule_operations_api_types_item_model == new_rule_operations_api_types_item_model2 @@ -1976,7 +1817,8 @@ def test_new_rule_operations_api_types_item_serialization(self): new_rule_operations_api_types_item_model_json2 = new_rule_operations_api_types_item_model.to_dict() assert new_rule_operations_api_types_item_model_json2 == new_rule_operations_api_types_item_model_json -class TestModel_OperationsList(): + +class TestModel_OperationsList: """ Test Class for OperationsList """ @@ -1988,11 +1830,11 @@ def test_operations_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - action_model = {} # Action + action_model = {} # Action action_model['action_id'] = 'testString' action_model['description'] = 'testString' - api_type_model = {} # APIType + api_type_model = {} # APIType api_type_model['api_type_id'] = 'testString' api_type_model['display_name'] = 'testString' api_type_model['description'] = 'testString' @@ -2017,7 +1859,8 @@ def test_operations_list_serialization(self): operations_list_model_json2 = operations_list_model.to_dict() assert operations_list_model_json2 == operations_list_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -2029,12 +1872,12 @@ def test_resource_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_attribute_model = {} # ResourceTagAttribute + resource_tag_attribute_model = {} # ResourceTagAttribute resource_tag_attribute_model['name'] = 'testString' resource_tag_attribute_model['value'] = 'testString' resource_tag_attribute_model['operator'] = 'testString' @@ -2059,7 +1902,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_ResourceAttribute(): + +class TestModel_ResourceAttribute: """ Test Class for ResourceAttribute """ @@ -2090,7 +1934,8 @@ def test_resource_attribute_serialization(self): resource_attribute_model_json2 = resource_attribute_model.to_dict() assert resource_attribute_model_json2 == resource_attribute_model_json -class TestModel_ResourceTagAttribute(): + +class TestModel_ResourceTagAttribute: """ Test Class for ResourceTagAttribute """ @@ -2121,7 +1966,8 @@ def test_resource_tag_attribute_serialization(self): resource_tag_attribute_model_json2 = resource_tag_attribute_model.to_dict() assert resource_tag_attribute_model_json2 == resource_tag_attribute_model_json -class TestModel_Rule(): + +class TestModel_Rule: """ Test Class for Rule """ @@ -2133,31 +1979,31 @@ def test_rule_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rule_context_attribute_model = {} # RuleContextAttribute + rule_context_attribute_model = {} # RuleContextAttribute rule_context_attribute_model['name'] = 'testString' rule_context_attribute_model['value'] = 'testString' - rule_context_model = {} # RuleContext + rule_context_model = {} # RuleContext rule_context_model['attributes'] = [rule_context_attribute_model] - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_attribute_model = {} # ResourceTagAttribute + resource_tag_attribute_model = {} # ResourceTagAttribute resource_tag_attribute_model['name'] = 'testString' resource_tag_attribute_model['value'] = 'testString' resource_tag_attribute_model['operator'] = 'testString' - resource_model = {} # Resource + resource_model = {} # Resource resource_model['attributes'] = [resource_attribute_model] resource_model['tags'] = [resource_tag_attribute_model] - new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem + new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem new_rule_operations_api_types_item_model['api_type_id'] = 'testString' - new_rule_operations_model = {} # NewRuleOperations + new_rule_operations_model = {} # NewRuleOperations new_rule_operations_model['api_types'] = [new_rule_operations_api_types_item_model] # Construct a json representation of a Rule model @@ -2190,7 +2036,8 @@ def test_rule_serialization(self): rule_model_json2 = rule_model.to_dict() assert rule_model_json2 == rule_model_json -class TestModel_RuleContext(): + +class TestModel_RuleContext: """ Test Class for RuleContext """ @@ -2202,7 +2049,7 @@ def test_rule_context_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rule_context_attribute_model = {} # RuleContextAttribute + rule_context_attribute_model = {} # RuleContextAttribute rule_context_attribute_model['name'] = 'testString' rule_context_attribute_model['value'] = 'testString' @@ -2225,7 +2072,8 @@ def test_rule_context_serialization(self): rule_context_model_json2 = rule_context_model.to_dict() assert rule_context_model_json2 == rule_context_model_json -class TestModel_RuleContextAttribute(): + +class TestModel_RuleContextAttribute: """ Test Class for RuleContextAttribute """ @@ -2255,7 +2103,8 @@ def test_rule_context_attribute_serialization(self): rule_context_attribute_model_json2 = rule_context_attribute_model.to_dict() assert rule_context_attribute_model_json2 == rule_context_attribute_model_json -class TestModel_RuleList(): + +class TestModel_RuleList: """ Test Class for RuleList """ @@ -2267,34 +2116,34 @@ def test_rule_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rule_context_attribute_model = {} # RuleContextAttribute + rule_context_attribute_model = {} # RuleContextAttribute rule_context_attribute_model['name'] = 'testString' rule_context_attribute_model['value'] = 'testString' - rule_context_model = {} # RuleContext + rule_context_model = {} # RuleContext rule_context_model['attributes'] = [rule_context_attribute_model] - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_attribute_model = {} # ResourceTagAttribute + resource_tag_attribute_model = {} # ResourceTagAttribute resource_tag_attribute_model['name'] = 'testString' resource_tag_attribute_model['value'] = 'testString' resource_tag_attribute_model['operator'] = 'testString' - resource_model = {} # Resource + resource_model = {} # Resource resource_model['attributes'] = [resource_attribute_model] resource_model['tags'] = [resource_tag_attribute_model] - new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem + new_rule_operations_api_types_item_model = {} # NewRuleOperationsApiTypesItem new_rule_operations_api_types_item_model['api_type_id'] = 'testString' - new_rule_operations_model = {} # NewRuleOperations + new_rule_operations_model = {} # NewRuleOperations new_rule_operations_model['api_types'] = [new_rule_operations_api_types_item_model] - rule_model = {} # Rule + rule_model = {} # Rule rule_model['id'] = 'testString' rule_model['crn'] = 'testString' rule_model['description'] = 'testString' @@ -2328,7 +2177,8 @@ def test_rule_list_serialization(self): rule_list_model_json2 = rule_list_model.to_dict() assert rule_list_model_json2 == rule_list_model_json -class TestModel_ServiceRefTarget(): + +class TestModel_ServiceRefTarget: """ Test Class for ServiceRefTarget """ @@ -2340,7 +2190,7 @@ def test_service_ref_target_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - service_ref_target_locations_item_model = {} # ServiceRefTargetLocationsItem + service_ref_target_locations_item_model = {} # ServiceRefTargetLocationsItem service_ref_target_locations_item_model['name'] = 'testString' # Construct a json representation of a ServiceRefTarget model @@ -2364,7 +2214,8 @@ def test_service_ref_target_serialization(self): service_ref_target_model_json2 = service_ref_target_model.to_dict() assert service_ref_target_model_json2 == service_ref_target_model_json -class TestModel_ServiceRefTargetList(): + +class TestModel_ServiceRefTargetList: """ Test Class for ServiceRefTargetList """ @@ -2376,10 +2227,10 @@ def test_service_ref_target_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - service_ref_target_locations_item_model = {} # ServiceRefTargetLocationsItem + service_ref_target_locations_item_model = {} # ServiceRefTargetLocationsItem service_ref_target_locations_item_model['name'] = 'testString' - service_ref_target_model = {} # ServiceRefTarget + service_ref_target_model = {} # ServiceRefTarget service_ref_target_model['service_name'] = 'testString' service_ref_target_model['service_type'] = 'testString' service_ref_target_model['locations'] = [service_ref_target_locations_item_model] @@ -2404,7 +2255,8 @@ def test_service_ref_target_list_serialization(self): service_ref_target_list_model_json2 = service_ref_target_list_model.to_dict() assert service_ref_target_list_model_json2 == service_ref_target_list_model_json -class TestModel_ServiceRefTargetLocationsItem(): + +class TestModel_ServiceRefTargetLocationsItem: """ Test Class for ServiceRefTargetLocationsItem """ @@ -2419,12 +2271,18 @@ def test_service_ref_target_locations_item_serialization(self): service_ref_target_locations_item_model_json['name'] = 'testString' # Construct a model instance of ServiceRefTargetLocationsItem by calling from_dict on the json representation - service_ref_target_locations_item_model = ServiceRefTargetLocationsItem.from_dict(service_ref_target_locations_item_model_json) + service_ref_target_locations_item_model = ServiceRefTargetLocationsItem.from_dict( + service_ref_target_locations_item_model_json + ) assert service_ref_target_locations_item_model != False # Construct a model instance of ServiceRefTargetLocationsItem by calling from_dict on the json representation - service_ref_target_locations_item_model_dict = ServiceRefTargetLocationsItem.from_dict(service_ref_target_locations_item_model_json).__dict__ - service_ref_target_locations_item_model2 = ServiceRefTargetLocationsItem(**service_ref_target_locations_item_model_dict) + service_ref_target_locations_item_model_dict = ServiceRefTargetLocationsItem.from_dict( + service_ref_target_locations_item_model_json + ).__dict__ + service_ref_target_locations_item_model2 = ServiceRefTargetLocationsItem( + **service_ref_target_locations_item_model_dict + ) # Verify the model instances are equivalent assert service_ref_target_locations_item_model == service_ref_target_locations_item_model2 @@ -2433,7 +2291,8 @@ def test_service_ref_target_locations_item_serialization(self): service_ref_target_locations_item_model_json2 = service_ref_target_locations_item_model.to_dict() assert service_ref_target_locations_item_model_json2 == service_ref_target_locations_item_model_json -class TestModel_ServiceRefValue(): + +class TestModel_ServiceRefValue: """ Test Class for ServiceRefValue """ @@ -2466,7 +2325,8 @@ def test_service_ref_value_serialization(self): service_ref_value_model_json2 = service_ref_value_model.to_dict() assert service_ref_value_model_json2 == service_ref_value_model_json -class TestModel_Zone(): + +class TestModel_Zone: """ Test Class for Zone """ @@ -2478,7 +2338,7 @@ def test_zone_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - address_model = {} # AddressIPAddress + address_model = {} # AddressIPAddress address_model['type'] = 'ipAddress' address_model['value'] = 'testString' @@ -2514,7 +2374,8 @@ def test_zone_serialization(self): zone_model_json2 = zone_model.to_dict() assert zone_model_json2 == zone_model_json -class TestModel_ZoneList(): + +class TestModel_ZoneList: """ Test Class for ZoneList """ @@ -2526,11 +2387,11 @@ def test_zone_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - address_model = {} # AddressIPAddress + address_model = {} # AddressIPAddress address_model['type'] = 'ipAddress' address_model['value'] = 'testString' - zone_summary_model = {} # ZoneSummary + zone_summary_model = {} # ZoneSummary zone_summary_model['id'] = 'testString' zone_summary_model['crn'] = 'testString' zone_summary_model['name'] = 'testString' @@ -2564,7 +2425,8 @@ def test_zone_list_serialization(self): zone_list_model_json2 = zone_list_model.to_dict() assert zone_list_model_json2 == zone_list_model_json -class TestModel_ZoneSummary(): + +class TestModel_ZoneSummary: """ Test Class for ZoneSummary """ @@ -2576,7 +2438,7 @@ def test_zone_summary_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - address_model = {} # AddressIPAddress + address_model = {} # AddressIPAddress address_model['type'] = 'ipAddress' address_model['value'] = 'testString' @@ -2610,7 +2472,8 @@ def test_zone_summary_serialization(self): zone_summary_model_json2 = zone_summary_model.to_dict() assert zone_summary_model_json2 == zone_summary_model_json -class TestModel_AddressIPAddress(): + +class TestModel_AddressIPAddress: """ Test Class for AddressIPAddress """ @@ -2640,7 +2503,8 @@ def test_address_ip_address_serialization(self): address_ip_address_model_json2 = address_ip_address_model.to_dict() assert address_ip_address_model_json2 == address_ip_address_model_json -class TestModel_AddressIPAddressRange(): + +class TestModel_AddressIPAddressRange: """ Test Class for AddressIPAddressRange """ @@ -2660,7 +2524,9 @@ def test_address_ip_address_range_serialization(self): assert address_ip_address_range_model != False # Construct a model instance of AddressIPAddressRange by calling from_dict on the json representation - address_ip_address_range_model_dict = AddressIPAddressRange.from_dict(address_ip_address_range_model_json).__dict__ + address_ip_address_range_model_dict = AddressIPAddressRange.from_dict( + address_ip_address_range_model_json + ).__dict__ address_ip_address_range_model2 = AddressIPAddressRange(**address_ip_address_range_model_dict) # Verify the model instances are equivalent @@ -2670,7 +2536,8 @@ def test_address_ip_address_range_serialization(self): address_ip_address_range_model_json2 = address_ip_address_range_model.to_dict() assert address_ip_address_range_model_json2 == address_ip_address_range_model_json -class TestModel_AddressServiceRef(): + +class TestModel_AddressServiceRef: """ Test Class for AddressServiceRef """ @@ -2682,7 +2549,7 @@ def test_address_service_ref_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - service_ref_value_model = {} # ServiceRefValue + service_ref_value_model = {} # ServiceRefValue service_ref_value_model['account_id'] = 'testString' service_ref_value_model['service_type'] = 'testString' service_ref_value_model['service_name'] = 'testString' @@ -2709,7 +2576,8 @@ def test_address_service_ref_serialization(self): address_service_ref_model_json2 = address_service_ref_model.to_dict() assert address_service_ref_model_json2 == address_service_ref_model_json -class TestModel_AddressSubnet(): + +class TestModel_AddressSubnet: """ Test Class for AddressSubnet """ @@ -2739,7 +2607,8 @@ def test_address_subnet_serialization(self): address_subnet_model_json2 = address_subnet_model.to_dict() assert address_subnet_model_json2 == address_subnet_model_json -class TestModel_AddressVPC(): + +class TestModel_AddressVPC: """ Test Class for AddressVPC """ diff --git a/test/unit/test_enterprise_billing_units_v1.py b/test/unit/test_enterprise_billing_units_v1.py index 26f98827..7f7282e7 100644 --- a/test/unit/test_enterprise_billing_units_v1.py +++ b/test/unit/test_enterprise_billing_units_v1.py @@ -29,9 +29,7 @@ from ibm_platform_services.enterprise_billing_units_v1 import * -service = EnterpriseBillingUnitsV1( - authenticator=NoAuthAuthenticator() - ) +service = EnterpriseBillingUnitsV1(authenticator=NoAuthAuthenticator()) base_url = 'https://billing.cloud.ibm.com' service.set_service_url(base_url) @@ -41,7 +39,8 @@ ############################################################################## # region -class TestGetBillingUnit(): + +class TestGetBillingUnit: """ Test Class for get_billing_unit """ @@ -63,26 +62,18 @@ def test_get_billing_unit_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-units/testString') mock_response = '{"id": "id", "crn": "crn:v1:bluemix:public:billing::a/<>::billing-unit:<>", "name": "name", "enterprise_id": "enterprise_id", "currency_code": "USD", "country_code": "USA", "master": true, "created_at": "2019-01-01T12:00:00"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' # Invoke method - response = service.get_billing_unit( - billing_unit_id, - headers={} - ) + response = service.get_billing_unit(billing_unit_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_billing_unit_value_error(self): """ @@ -91,11 +82,7 @@ def test_get_billing_unit_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-units/testString') mock_response = '{"id": "id", "crn": "crn:v1:bluemix:public:billing::a/<>::billing-unit:<>", "name": "name", "enterprise_id": "enterprise_id", "currency_code": "USD", "country_code": "USA", "master": true, "created_at": "2019-01-01T12:00:00"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' @@ -105,13 +92,12 @@ def test_get_billing_unit_value_error(self): "billing_unit_id": billing_unit_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()} + 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_billing_unit(**req_copy) - -class TestListBillingUnits(): +class TestListBillingUnits: """ Test Class for list_billing_units """ @@ -133,11 +119,7 @@ def test_list_billing_units_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-units') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "crn": "crn:v1:bluemix:public:billing::a/<>::billing-unit:<>", "name": "name", "enterprise_id": "enterprise_id", "currency_code": "USD", "country_code": "USA", "master": true, "created_at": "2019-01-01T12:00:00"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -146,23 +128,19 @@ def test_list_billing_units_all_params(self): # Invoke method response = service.list_billing_units( - account_id=account_id, - enterprise_id=enterprise_id, - account_group_id=account_group_id, - headers={} + account_id=account_id, enterprise_id=enterprise_id, account_group_id=account_group_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 = 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 'enterprise_id={}'.format(enterprise_id) in query_string assert 'account_group_id={}'.format(account_group_id) in query_string - @responses.activate def test_list_billing_units_required_params(self): """ @@ -171,16 +149,11 @@ def test_list_billing_units_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-units') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "crn": "crn:v1:bluemix:public:billing::a/<>::billing-unit:<>", "name": "name", "enterprise_id": "enterprise_id", "currency_code": "USD", "country_code": "USA", "master": true, "created_at": "2019-01-01T12:00:00"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = service.list_billing_units() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -196,7 +169,8 @@ def test_list_billing_units_required_params(self): ############################################################################## # region -class TestListBillingOptions(): + +class TestListBillingOptions: """ Test Class for list_billing_options """ @@ -218,30 +192,22 @@ def test_list_billing_options_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-options') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "billing_unit_id": "billing_unit_id", "start_date": "2019-01-01T12:00:00", "end_date": "2019-01-01T12:00:00", "state": "ACTIVE", "type": "SUBSCRIPTION", "category": "PLATFORM", "payment_instrument": {"mapKey": {"anyKey": "anyValue"}}, "duration_in_months": 11, "line_item_id": 10, "billing_system": {"mapKey": {"anyKey": "anyValue"}}, "renewal_mode_code": "renewal_mode_code", "updated_at": "2019-01-01T12:00:00"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' # Invoke method - response = service.list_billing_options( - billing_unit_id, - headers={} - ) + response = service.list_billing_options(billing_unit_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'billing_unit_id={}'.format(billing_unit_id) in query_string - @responses.activate def test_list_billing_options_value_error(self): """ @@ -250,11 +216,7 @@ def test_list_billing_options_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v1/billing-options') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "billing_unit_id": "billing_unit_id", "start_date": "2019-01-01T12:00:00", "end_date": "2019-01-01T12:00:00", "state": "ACTIVE", "type": "SUBSCRIPTION", "category": "PLATFORM", "payment_instrument": {"mapKey": {"anyKey": "anyValue"}}, "duration_in_months": 11, "line_item_id": 10, "billing_system": {"mapKey": {"anyKey": "anyValue"}}, "renewal_mode_code": "renewal_mode_code", "updated_at": "2019-01-01T12:00:00"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' @@ -264,12 +226,11 @@ def test_list_billing_options_value_error(self): "billing_unit_id": billing_unit_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()} + 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_billing_options(**req_copy) - # endregion ############################################################################## # End of Service: BillingOptions @@ -280,7 +241,8 @@ def test_list_billing_options_value_error(self): ############################################################################## # region -class TestGetCreditPools(): + +class TestGetCreditPools: """ Test Class for get_credit_pools """ @@ -302,11 +264,7 @@ def test_get_credit_pools_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/credit-pools') mock_response = '{"rows_count": 2, "next_url": "next_url", "resources": [{"type": "PLATFORM", "currency_code": "USD", "billing_unit_id": "billing_unit_id", "term_credits": [{"billing_option_id": "JWX986YRGFSHACQUEFOI", "category": "PLATFORM", "start_date": "2019-01-01T12:00:00", "end_date": "2019-01-01T12:00:00", "total_credits": 10000, "starting_balance": 9000, "used_credits": 9500, "current_balance": 0, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}], "overage": {"cost": 500, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' @@ -314,24 +272,18 @@ def test_get_credit_pools_all_params(self): type = 'testString' # Invoke method - response = service.get_credit_pools( - billing_unit_id, - date=date, - type=type, - headers={} - ) + response = service.get_credit_pools(billing_unit_id, date=date, type=type, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'billing_unit_id={}'.format(billing_unit_id) in query_string assert 'date={}'.format(date) in query_string assert 'type={}'.format(type) in query_string - @responses.activate def test_get_credit_pools_required_params(self): """ @@ -340,30 +292,22 @@ def test_get_credit_pools_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v1/credit-pools') mock_response = '{"rows_count": 2, "next_url": "next_url", "resources": [{"type": "PLATFORM", "currency_code": "USD", "billing_unit_id": "billing_unit_id", "term_credits": [{"billing_option_id": "JWX986YRGFSHACQUEFOI", "category": "PLATFORM", "start_date": "2019-01-01T12:00:00", "end_date": "2019-01-01T12:00:00", "total_credits": 10000, "starting_balance": 9000, "used_credits": 9500, "current_balance": 0, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}], "overage": {"cost": 500, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' # Invoke method - response = service.get_credit_pools( - billing_unit_id, - headers={} - ) + response = service.get_credit_pools(billing_unit_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'billing_unit_id={}'.format(billing_unit_id) in query_string - @responses.activate def test_get_credit_pools_value_error(self): """ @@ -372,11 +316,7 @@ def test_get_credit_pools_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v1/credit-pools') mock_response = '{"rows_count": 2, "next_url": "next_url", "resources": [{"type": "PLATFORM", "currency_code": "USD", "billing_unit_id": "billing_unit_id", "term_credits": [{"billing_option_id": "JWX986YRGFSHACQUEFOI", "category": "PLATFORM", "start_date": "2019-01-01T12:00:00", "end_date": "2019-01-01T12:00:00", "total_credits": 10000, "starting_balance": 9000, "used_credits": 9500, "current_balance": 0, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}], "overage": {"cost": 500, "resources": [{"mapKey": {"anyKey": "anyValue"}}]}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values billing_unit_id = 'testString' @@ -386,12 +326,11 @@ def test_get_credit_pools_value_error(self): "billing_unit_id": billing_unit_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()} + 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_credit_pools(**req_copy) - # endregion ############################################################################## # End of Service: CreditPools @@ -402,7 +341,7 @@ def test_get_credit_pools_value_error(self): # Start of Model Tests ############################################################################## # region -class TestBillingOption(): +class TestBillingOption: """ Test Class for BillingOption """ @@ -443,7 +382,8 @@ def test_billing_option_serialization(self): billing_option_model_json2 = billing_option_model.to_dict() assert billing_option_model_json2 == billing_option_model_json -class TestBillingOptionsList(): + +class TestBillingOptionsList: """ Test Class for BillingOptionsList """ @@ -455,7 +395,7 @@ def test_billing_options_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - billing_option_model = {} # BillingOption + billing_option_model = {} # BillingOption billing_option_model['id'] = 'CFL_JJKLVZ2I0JE-_MGU' billing_option_model['billing_unit_id'] = 'e19fa97c9bb34963a31a2008044d8b59' billing_option_model['start_date'] = '2020-01-28T18:40:40.123456Z' @@ -491,7 +431,8 @@ def test_billing_options_list_serialization(self): billing_options_list_model_json2 = billing_options_list_model.to_dict() assert billing_options_list_model_json2 == billing_options_list_model_json -class TestBillingUnit(): + +class TestBillingUnit: """ Test Class for BillingUnit """ @@ -504,7 +445,9 @@ def test_billing_unit_serialization(self): # Construct a json representation of a BillingUnit model billing_unit_model_json = {} billing_unit_model_json['id'] = 'testString' - billing_unit_model_json['crn'] = 'crn:v1:bluemix:public:billing::a/<>::billing-unit:<>' + billing_unit_model_json[ + 'crn' + ] = 'crn:v1:bluemix:public:billing::a/<>::billing-unit:<>' billing_unit_model_json['name'] = 'testString' billing_unit_model_json['enterprise_id'] = 'testString' billing_unit_model_json['currency_code'] = 'USD' @@ -527,7 +470,8 @@ def test_billing_unit_serialization(self): billing_unit_model_json2 = billing_unit_model.to_dict() assert billing_unit_model_json2 == billing_unit_model_json -class TestBillingUnitsList(): + +class TestBillingUnitsList: """ Test Class for BillingUnitsList """ @@ -539,9 +483,11 @@ def test_billing_units_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - billing_unit_model = {} # BillingUnit + billing_unit_model = {} # BillingUnit billing_unit_model['id'] = '$BILLING_UNIT_ID' - billing_unit_model['crn'] = 'crn:v1:bluemix:public:billing::a/$ENTERPRISE_ACCOUNT_ID::billing-unit:$BILLING_UNIT_ID' + billing_unit_model[ + 'crn' + ] = 'crn:v1:bluemix:public:billing::a/$ENTERPRISE_ACCOUNT_ID::billing-unit:$BILLING_UNIT_ID' billing_unit_model['name'] = 'Sample Billing Unit' billing_unit_model['enterprise_id'] = '$ENTERPRISE_ID' billing_unit_model['currency_code'] = 'USD' @@ -570,7 +516,8 @@ def test_billing_units_list_serialization(self): billing_units_list_model_json2 = billing_units_list_model.to_dict() assert billing_units_list_model_json2 == billing_units_list_model_json -class TestCreditPool(): + +class TestCreditPool: """ Test Class for CreditPool """ @@ -582,7 +529,7 @@ def test_credit_pool_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - term_credits_model = {} # TermCredits + term_credits_model = {} # TermCredits term_credits_model['billing_option_id'] = '$BILLING_OPTION_ID' term_credits_model['category'] = 'PLATFORM' term_credits_model['start_date'] = '2020-01-28T18:40:40.123456Z' @@ -593,7 +540,7 @@ def test_credit_pool_serialization(self): term_credits_model['current_balance'] = 5000 term_credits_model['resources'] = [{}] - credit_pool_overage_model = {} # CreditPoolOverage + credit_pool_overage_model = {} # CreditPoolOverage credit_pool_overage_model['cost'] = 0 credit_pool_overage_model['resources'] = [{}] @@ -620,7 +567,8 @@ def test_credit_pool_serialization(self): credit_pool_model_json2 = credit_pool_model.to_dict() assert credit_pool_model_json2 == credit_pool_model_json -class TestCreditPoolOverage(): + +class TestCreditPoolOverage: """ Test Class for CreditPoolOverage """ @@ -650,7 +598,8 @@ def test_credit_pool_overage_serialization(self): credit_pool_overage_model_json2 = credit_pool_overage_model.to_dict() assert credit_pool_overage_model_json2 == credit_pool_overage_model_json -class TestCreditPoolsList(): + +class TestCreditPoolsList: """ Test Class for CreditPoolsList """ @@ -662,7 +611,7 @@ def test_credit_pools_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - term_credits_model = {} # TermCredits + term_credits_model = {} # TermCredits term_credits_model['billing_option_id'] = '$BILLING_OPTION_ID' term_credits_model['category'] = 'PLATFORM' term_credits_model['start_date'] = '2020-01-28T18:40:40.123456Z' @@ -673,11 +622,11 @@ def test_credit_pools_list_serialization(self): term_credits_model['current_balance'] = 5000 term_credits_model['resources'] = [{}] - credit_pool_overage_model = {} # CreditPoolOverage + credit_pool_overage_model = {} # CreditPoolOverage credit_pool_overage_model['cost'] = 0 credit_pool_overage_model['resources'] = [{}] - credit_pool_model = {} # CreditPool + credit_pool_model = {} # CreditPool credit_pool_model['type'] = 'PLATFORM' credit_pool_model['currency_code'] = 'USD' credit_pool_model['billing_unit_id'] = '$BILLING_UNIT_ID' @@ -705,7 +654,8 @@ def test_credit_pools_list_serialization(self): credit_pools_list_model_json2 = credit_pools_list_model.to_dict() assert credit_pools_list_model_json2 == credit_pools_list_model_json -class TestTermCredits(): + +class TestTermCredits: """ Test Class for TermCredits """ diff --git a/test/unit/test_enterprise_management_v1.py b/test/unit/test_enterprise_management_v1.py index 4f377f44..12af9159 100644 --- a/test/unit/test_enterprise_management_v1.py +++ b/test/unit/test_enterprise_management_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.enterprise_management_v1 import * -_service = EnterpriseManagementV1( - authenticator=NoAuthAuthenticator() -) +_service = EnterpriseManagementV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://enterprise.cloud.ibm.com/v1' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateEnterprise(): + +class TestCreateEnterprise: """ Test Class for create_enterprise """ @@ -110,11 +110,7 @@ def test_create_enterprise_all_params(self): # Set up mock url = preprocess_url('/enterprises') mock_response = '{"enterprise_id": "enterprise_id", "enterprise_account_id": "enterprise_account_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values source_account_id = 'testString' @@ -124,11 +120,7 @@ def test_create_enterprise_all_params(self): # Invoke method response = _service.create_enterprise( - source_account_id, - name, - primary_contact_iam_id, - domain=domain, - headers={} + source_account_id, name, primary_contact_iam_id, domain=domain, headers={} ) # Check for correct operation @@ -158,11 +150,7 @@ def test_create_enterprise_value_error(self): # Set up mock url = preprocess_url('/enterprises') mock_response = '{"enterprise_id": "enterprise_id", "enterprise_account_id": "enterprise_account_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values source_account_id = 'testString' @@ -177,7 +165,7 @@ def test_create_enterprise_value_error(self): "primary_contact_iam_id": primary_contact_iam_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()} + 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_enterprise(**req_copy) @@ -190,7 +178,8 @@ def test_create_enterprise_value_error_with_retries(self): _service.disable_retries() self.test_create_enterprise_value_error() -class TestListEnterprises(): + +class TestListEnterprises: """ Test Class for list_enterprises """ @@ -203,11 +192,7 @@ def test_list_enterprises_all_params(self): # Set up mock url = preprocess_url('/enterprises') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "enterprise_account_id": "enterprise_account_id", "crn": "crn", "name": "name", "domain": "domain", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_account_id = 'testString' @@ -223,14 +208,14 @@ def test_list_enterprises_all_params(self): account_id=account_id, next_docid=next_docid, limit=limit, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'enterprise_account_id={}'.format(enterprise_account_id) in query_string assert 'account_group_id={}'.format(account_group_id) in query_string @@ -255,16 +240,11 @@ def test_list_enterprises_required_params(self): # Set up mock url = preprocess_url('/enterprises') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "enterprise_account_id": "enterprise_account_id", "crn": "crn", "name": "name", "domain": "domain", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_enterprises() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -287,16 +267,8 @@ def test_list_enterprises_with_pager_get_next(self): url = preprocess_url('/enterprises') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","enterprise_account_id":"enterprise_account_id","crn":"crn","name":"name","domain":"domain","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","enterprise_account_id":"enterprise_account_id","crn":"crn","name":"name","domain":"domain","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = [] @@ -322,16 +294,8 @@ def test_list_enterprises_with_pager_get_all(self): url = preprocess_url('/enterprises') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","enterprise_account_id":"enterprise_account_id","crn":"crn","name":"name","domain":"domain","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","enterprise_account_id":"enterprise_account_id","crn":"crn","name":"name","domain":"domain","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = EnterprisesPager( @@ -345,7 +309,8 @@ def test_list_enterprises_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestGetEnterprise(): + +class TestGetEnterprise: """ Test Class for get_enterprise """ @@ -358,20 +323,13 @@ def test_get_enterprise_all_params(self): # Set up mock url = preprocess_url('/enterprises/testString') mock_response = '{"url": "url", "id": "id", "enterprise_account_id": "enterprise_account_id", "crn": "crn", "name": "name", "domain": "domain", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_id = 'testString' # Invoke method - response = _service.get_enterprise( - enterprise_id, - headers={} - ) + response = _service.get_enterprise(enterprise_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -394,11 +352,7 @@ def test_get_enterprise_value_error(self): # Set up mock url = preprocess_url('/enterprises/testString') mock_response = '{"url": "url", "id": "id", "enterprise_account_id": "enterprise_account_id", "crn": "crn", "name": "name", "domain": "domain", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_id = 'testString' @@ -408,7 +362,7 @@ def test_get_enterprise_value_error(self): "enterprise_id": enterprise_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()} + 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_enterprise(**req_copy) @@ -421,7 +375,8 @@ def test_get_enterprise_value_error_with_retries(self): _service.disable_retries() self.test_get_enterprise_value_error() -class TestUpdateEnterprise(): + +class TestUpdateEnterprise: """ Test Class for update_enterprise """ @@ -433,9 +388,7 @@ def test_update_enterprise_all_params(self): """ # Set up mock url = preprocess_url('/enterprises/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values enterprise_id = 'testString' @@ -445,11 +398,7 @@ def test_update_enterprise_all_params(self): # Invoke method response = _service.update_enterprise( - enterprise_id, - name=name, - domain=domain, - primary_contact_iam_id=primary_contact_iam_id, - headers={} + enterprise_id, name=name, domain=domain, primary_contact_iam_id=primary_contact_iam_id, headers={} ) # Check for correct operation @@ -477,9 +426,7 @@ def test_update_enterprise_value_error(self): """ # Set up mock url = preprocess_url('/enterprises/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values enterprise_id = 'testString' @@ -492,7 +439,7 @@ def test_update_enterprise_value_error(self): "enterprise_id": enterprise_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()} + 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_enterprise(**req_copy) @@ -505,6 +452,7 @@ def test_update_enterprise_value_error_with_retries(self): _service.disable_retries() self.test_update_enterprise_value_error() + # endregion ############################################################################## # End of Service: EnterpriseOperations @@ -515,7 +463,8 @@ def test_update_enterprise_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -542,7 +491,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestImportAccountToEnterprise(): + +class TestImportAccountToEnterprise: """ Test Class for import_account_to_enterprise """ @@ -554,9 +504,7 @@ def test_import_account_to_enterprise_all_params(self): """ # Set up mock url = preprocess_url('/enterprises/testString/import/accounts/testString') - responses.add(responses.PUT, - url, - status=202) + responses.add(responses.PUT, url, status=202) # Set up parameter values enterprise_id = 'testString' @@ -566,11 +514,7 @@ def test_import_account_to_enterprise_all_params(self): # Invoke method response = _service.import_account_to_enterprise( - enterprise_id, - account_id, - parent=parent, - billing_unit_id=billing_unit_id, - headers={} + enterprise_id, account_id, parent=parent, billing_unit_id=billing_unit_id, headers={} ) # Check for correct operation @@ -597,20 +541,14 @@ def test_import_account_to_enterprise_required_params(self): """ # Set up mock url = preprocess_url('/enterprises/testString/import/accounts/testString') - responses.add(responses.PUT, - url, - status=202) + responses.add(responses.PUT, url, status=202) # Set up parameter values enterprise_id = 'testString' account_id = 'testString' # Invoke method - response = _service.import_account_to_enterprise( - enterprise_id, - account_id, - headers={} - ) + response = _service.import_account_to_enterprise(enterprise_id, account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -632,9 +570,7 @@ def test_import_account_to_enterprise_value_error(self): """ # Set up mock url = preprocess_url('/enterprises/testString/import/accounts/testString') - responses.add(responses.PUT, - url, - status=202) + responses.add(responses.PUT, url, status=202) # Set up parameter values enterprise_id = 'testString' @@ -646,7 +582,7 @@ def test_import_account_to_enterprise_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.import_account_to_enterprise(**req_copy) @@ -659,7 +595,8 @@ def test_import_account_to_enterprise_value_error_with_retries(self): _service.disable_retries() self.test_import_account_to_enterprise_value_error() -class TestCreateAccount(): + +class TestCreateAccount: """ Test Class for create_account """ @@ -672,11 +609,7 @@ def test_create_account_all_params(self): # Set up mock url = preprocess_url('/accounts') mock_response = '{"account_id": "account_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values parent = 'testString' @@ -684,12 +617,7 @@ def test_create_account_all_params(self): owner_iam_id = 'testString' # Invoke method - response = _service.create_account( - parent, - name, - owner_iam_id, - headers={} - ) + response = _service.create_account(parent, name, owner_iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -717,11 +645,7 @@ def test_create_account_value_error(self): # Set up mock url = preprocess_url('/accounts') mock_response = '{"account_id": "account_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values parent = 'testString' @@ -735,7 +659,7 @@ def test_create_account_value_error(self): "owner_iam_id": owner_iam_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()} + 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_account(**req_copy) @@ -748,7 +672,8 @@ def test_create_account_value_error_with_retries(self): _service.disable_retries() self.test_create_account_value_error() -class TestListAccounts(): + +class TestListAccounts: """ Test Class for list_accounts """ @@ -761,11 +686,7 @@ def test_list_accounts_all_params(self): # Set up mock url = preprocess_url('/accounts') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "owner_iam_id": "owner_iam_id", "paid": true, "owner_email": "owner_email", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_id = 'testString' @@ -781,14 +702,14 @@ def test_list_accounts_all_params(self): next_docid=next_docid, parent=parent, limit=limit, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'enterprise_id={}'.format(enterprise_id) in query_string assert 'account_group_id={}'.format(account_group_id) in query_string @@ -813,16 +734,11 @@ def test_list_accounts_required_params(self): # Set up mock url = preprocess_url('/accounts') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "owner_iam_id": "owner_iam_id", "paid": true, "owner_email": "owner_email", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_accounts() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -845,16 +761,8 @@ def test_list_accounts_with_pager_get_next(self): url = preprocess_url('/accounts') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","owner_iam_id":"owner_iam_id","paid":true,"owner_email":"owner_email","is_enterprise_account":false,"created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","owner_iam_id":"owner_iam_id","paid":true,"owner_email":"owner_email","is_enterprise_account":false,"created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = [] @@ -880,16 +788,8 @@ def test_list_accounts_with_pager_get_all(self): url = preprocess_url('/accounts') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","owner_iam_id":"owner_iam_id","paid":true,"owner_email":"owner_email","is_enterprise_account":false,"created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","owner_iam_id":"owner_iam_id","paid":true,"owner_email":"owner_email","is_enterprise_account":false,"created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = AccountsPager( @@ -903,7 +803,8 @@ def test_list_accounts_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestGetAccount(): + +class TestGetAccount: """ Test Class for get_account """ @@ -916,20 +817,13 @@ def test_get_account_all_params(self): # Set up mock url = preprocess_url('/accounts/testString') mock_response = '{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "owner_iam_id": "owner_iam_id", "paid": true, "owner_email": "owner_email", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.get_account( - account_id, - headers={} - ) + response = _service.get_account(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -952,11 +846,7 @@ def test_get_account_value_error(self): # Set up mock url = preprocess_url('/accounts/testString') mock_response = '{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "owner_iam_id": "owner_iam_id", "paid": true, "owner_email": "owner_email", "is_enterprise_account": false, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -966,7 +856,7 @@ def test_get_account_value_error(self): "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()} + 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_account(**req_copy) @@ -979,7 +869,8 @@ def test_get_account_value_error_with_retries(self): _service.disable_retries() self.test_get_account_value_error() -class TestUpdateAccount(): + +class TestUpdateAccount: """ Test Class for update_account """ @@ -991,20 +882,14 @@ def test_update_account_all_params(self): """ # Set up mock url = preprocess_url('/accounts/testString') - responses.add(responses.PATCH, - url, - status=202) + responses.add(responses.PATCH, url, status=202) # Set up parameter values account_id = 'testString' parent = 'testString' # Invoke method - response = _service.update_account( - account_id, - parent, - headers={} - ) + response = _service.update_account(account_id, parent, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1029,9 +914,7 @@ def test_update_account_value_error(self): """ # Set up mock url = preprocess_url('/accounts/testString') - responses.add(responses.PATCH, - url, - status=202) + responses.add(responses.PATCH, url, status=202) # Set up parameter values account_id = 'testString' @@ -1043,7 +926,7 @@ def test_update_account_value_error(self): "parent": parent, } 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()} + 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_account(**req_copy) @@ -1056,6 +939,7 @@ def test_update_account_value_error_with_retries(self): _service.disable_retries() self.test_update_account_value_error() + # endregion ############################################################################## # End of Service: AccountOperations @@ -1066,7 +950,8 @@ def test_update_account_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1093,7 +978,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateAccountGroup(): + +class TestCreateAccountGroup: """ Test Class for create_account_group """ @@ -1106,11 +992,7 @@ def test_create_account_group_all_params(self): # Set up mock url = preprocess_url('/account-groups') mock_response = '{"account_group_id": "account_group_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values parent = 'testString' @@ -1118,12 +1000,7 @@ def test_create_account_group_all_params(self): primary_contact_iam_id = 'testString' # Invoke method - response = _service.create_account_group( - parent, - name, - primary_contact_iam_id, - headers={} - ) + response = _service.create_account_group(parent, name, primary_contact_iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1151,11 +1028,7 @@ def test_create_account_group_value_error(self): # Set up mock url = preprocess_url('/account-groups') mock_response = '{"account_group_id": "account_group_id"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values parent = 'testString' @@ -1169,7 +1042,7 @@ def test_create_account_group_value_error(self): "primary_contact_iam_id": primary_contact_iam_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()} + 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_account_group(**req_copy) @@ -1182,7 +1055,8 @@ def test_create_account_group_value_error_with_retries(self): _service.disable_retries() self.test_create_account_group_value_error() -class TestListAccountGroups(): + +class TestListAccountGroups: """ Test Class for list_account_groups """ @@ -1195,11 +1069,7 @@ def test_list_account_groups_all_params(self): # Set up mock url = preprocess_url('/account-groups') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_id = 'testString' @@ -1215,14 +1085,14 @@ def test_list_account_groups_all_params(self): next_docid=next_docid, parent=parent, limit=limit, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'enterprise_id={}'.format(enterprise_id) in query_string assert 'parent_account_group_id={}'.format(parent_account_group_id) in query_string @@ -1247,16 +1117,11 @@ def test_list_account_groups_required_params(self): # Set up mock url = preprocess_url('/account-groups') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_account_groups() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -1279,16 +1144,8 @@ def test_list_account_groups_with_pager_get_next(self): url = preprocess_url('/account-groups') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = [] @@ -1314,16 +1171,8 @@ def test_list_account_groups_with_pager_get_all(self): url = preprocess_url('/account-groups') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?next_docid=1","resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"url":"url","id":"id","crn":"crn","parent":"parent","enterprise_account_id":"enterprise_account_id","enterprise_id":"enterprise_id","enterprise_path":"enterprise_path","name":"name","state":"state","primary_contact_iam_id":"primary_contact_iam_id","primary_contact_email":"primary_contact_email","created_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_at":"2019-01-01T12:00:00.000Z","updated_by":"updated_by"}]}' - 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) + 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 = AccountGroupsPager( @@ -1337,7 +1186,8 @@ def test_list_account_groups_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestGetAccountGroup(): + +class TestGetAccountGroup: """ Test Class for get_account_group """ @@ -1350,20 +1200,13 @@ def test_get_account_group_all_params(self): # Set up mock url = preprocess_url('/account-groups/testString') mock_response = '{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_group_id = 'testString' # Invoke method - response = _service.get_account_group( - account_group_id, - headers={} - ) + response = _service.get_account_group(account_group_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1386,11 +1229,7 @@ def test_get_account_group_value_error(self): # Set up mock url = preprocess_url('/account-groups/testString') mock_response = '{"url": "url", "id": "id", "crn": "crn", "parent": "parent", "enterprise_account_id": "enterprise_account_id", "enterprise_id": "enterprise_id", "enterprise_path": "enterprise_path", "name": "name", "state": "state", "primary_contact_iam_id": "primary_contact_iam_id", "primary_contact_email": "primary_contact_email", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_group_id = 'testString' @@ -1400,7 +1239,7 @@ def test_get_account_group_value_error(self): "account_group_id": account_group_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()} + 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_account_group(**req_copy) @@ -1413,7 +1252,8 @@ def test_get_account_group_value_error_with_retries(self): _service.disable_retries() self.test_get_account_group_value_error() -class TestUpdateAccountGroup(): + +class TestUpdateAccountGroup: """ Test Class for update_account_group """ @@ -1425,9 +1265,7 @@ def test_update_account_group_all_params(self): """ # Set up mock url = preprocess_url('/account-groups/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_group_id = 'testString' @@ -1436,10 +1274,7 @@ def test_update_account_group_all_params(self): # Invoke method response = _service.update_account_group( - account_group_id, - name=name, - primary_contact_iam_id=primary_contact_iam_id, - headers={} + account_group_id, name=name, primary_contact_iam_id=primary_contact_iam_id, headers={} ) # Check for correct operation @@ -1466,9 +1301,7 @@ def test_update_account_group_value_error(self): """ # Set up mock url = preprocess_url('/account-groups/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_group_id = 'testString' @@ -1480,7 +1313,7 @@ def test_update_account_group_value_error(self): "account_group_id": account_group_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()} + 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_account_group(**req_copy) @@ -1493,6 +1326,7 @@ def test_update_account_group_value_error_with_retries(self): _service.disable_retries() self.test_update_account_group_value_error() + # endregion ############################################################################## # End of Service: AccountGroupOperations @@ -1503,7 +1337,7 @@ def test_update_account_group_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_Account(): +class TestModel_Account: """ Test Class for Account """ @@ -1548,7 +1382,8 @@ def test_account_serialization(self): account_model_json2 = account_model.to_dict() assert account_model_json2 == account_model_json -class TestModel_AccountGroup(): + +class TestModel_AccountGroup: """ Test Class for AccountGroup """ @@ -1591,7 +1426,8 @@ def test_account_group_serialization(self): account_group_model_json2 = account_group_model.to_dict() assert account_group_model_json2 == account_group_model_json -class TestModel_CreateAccountGroupResponse(): + +class TestModel_CreateAccountGroupResponse: """ Test Class for CreateAccountGroupResponse """ @@ -1606,11 +1442,15 @@ def test_create_account_group_response_serialization(self): create_account_group_response_model_json['account_group_id'] = 'testString' # Construct a model instance of CreateAccountGroupResponse by calling from_dict on the json representation - create_account_group_response_model = CreateAccountGroupResponse.from_dict(create_account_group_response_model_json) + create_account_group_response_model = CreateAccountGroupResponse.from_dict( + create_account_group_response_model_json + ) assert create_account_group_response_model != False # Construct a model instance of CreateAccountGroupResponse by calling from_dict on the json representation - create_account_group_response_model_dict = CreateAccountGroupResponse.from_dict(create_account_group_response_model_json).__dict__ + create_account_group_response_model_dict = CreateAccountGroupResponse.from_dict( + create_account_group_response_model_json + ).__dict__ create_account_group_response_model2 = CreateAccountGroupResponse(**create_account_group_response_model_dict) # Verify the model instances are equivalent @@ -1620,7 +1460,8 @@ def test_create_account_group_response_serialization(self): create_account_group_response_model_json2 = create_account_group_response_model.to_dict() assert create_account_group_response_model_json2 == create_account_group_response_model_json -class TestModel_CreateAccountResponse(): + +class TestModel_CreateAccountResponse: """ Test Class for CreateAccountResponse """ @@ -1639,7 +1480,9 @@ def test_create_account_response_serialization(self): assert create_account_response_model != False # Construct a model instance of CreateAccountResponse by calling from_dict on the json representation - create_account_response_model_dict = CreateAccountResponse.from_dict(create_account_response_model_json).__dict__ + create_account_response_model_dict = CreateAccountResponse.from_dict( + create_account_response_model_json + ).__dict__ create_account_response_model2 = CreateAccountResponse(**create_account_response_model_dict) # Verify the model instances are equivalent @@ -1649,7 +1492,8 @@ def test_create_account_response_serialization(self): create_account_response_model_json2 = create_account_response_model.to_dict() assert create_account_response_model_json2 == create_account_response_model_json -class TestModel_CreateEnterpriseResponse(): + +class TestModel_CreateEnterpriseResponse: """ Test Class for CreateEnterpriseResponse """ @@ -1669,7 +1513,9 @@ def test_create_enterprise_response_serialization(self): assert create_enterprise_response_model != False # Construct a model instance of CreateEnterpriseResponse by calling from_dict on the json representation - create_enterprise_response_model_dict = CreateEnterpriseResponse.from_dict(create_enterprise_response_model_json).__dict__ + create_enterprise_response_model_dict = CreateEnterpriseResponse.from_dict( + create_enterprise_response_model_json + ).__dict__ create_enterprise_response_model2 = CreateEnterpriseResponse(**create_enterprise_response_model_dict) # Verify the model instances are equivalent @@ -1679,7 +1525,8 @@ def test_create_enterprise_response_serialization(self): create_enterprise_response_model_json2 = create_enterprise_response_model.to_dict() assert create_enterprise_response_model_json2 == create_enterprise_response_model_json -class TestModel_Enterprise(): + +class TestModel_Enterprise: """ Test Class for Enterprise """ @@ -1720,7 +1567,8 @@ def test_enterprise_serialization(self): enterprise_model_json2 = enterprise_model.to_dict() assert enterprise_model_json2 == enterprise_model_json -class TestModel_ListAccountGroupsResponse(): + +class TestModel_ListAccountGroupsResponse: """ Test Class for ListAccountGroupsResponse """ @@ -1732,7 +1580,7 @@ def test_list_account_groups_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - account_group_model = {} # AccountGroup + account_group_model = {} # AccountGroup account_group_model['url'] = 'testString' account_group_model['id'] = 'testString' account_group_model['crn'] = 'testString' @@ -1756,11 +1604,15 @@ def test_list_account_groups_response_serialization(self): list_account_groups_response_model_json['resources'] = [account_group_model] # Construct a model instance of ListAccountGroupsResponse by calling from_dict on the json representation - list_account_groups_response_model = ListAccountGroupsResponse.from_dict(list_account_groups_response_model_json) + list_account_groups_response_model = ListAccountGroupsResponse.from_dict( + list_account_groups_response_model_json + ) assert list_account_groups_response_model != False # Construct a model instance of ListAccountGroupsResponse by calling from_dict on the json representation - list_account_groups_response_model_dict = ListAccountGroupsResponse.from_dict(list_account_groups_response_model_json).__dict__ + list_account_groups_response_model_dict = ListAccountGroupsResponse.from_dict( + list_account_groups_response_model_json + ).__dict__ list_account_groups_response_model2 = ListAccountGroupsResponse(**list_account_groups_response_model_dict) # Verify the model instances are equivalent @@ -1770,7 +1622,8 @@ def test_list_account_groups_response_serialization(self): list_account_groups_response_model_json2 = list_account_groups_response_model.to_dict() assert list_account_groups_response_model_json2 == list_account_groups_response_model_json -class TestModel_ListAccountsResponse(): + +class TestModel_ListAccountsResponse: """ Test Class for ListAccountsResponse """ @@ -1782,7 +1635,7 @@ def test_list_accounts_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - account_model = {} # Account + account_model = {} # Account account_model['url'] = 'testString' account_model['id'] = 'testString' account_model['crn'] = 'testString' @@ -1822,7 +1675,8 @@ def test_list_accounts_response_serialization(self): list_accounts_response_model_json2 = list_accounts_response_model.to_dict() assert list_accounts_response_model_json2 == list_accounts_response_model_json -class TestModel_ListEnterprisesResponse(): + +class TestModel_ListEnterprisesResponse: """ Test Class for ListEnterprisesResponse """ @@ -1834,7 +1688,7 @@ def test_list_enterprises_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - enterprise_model = {} # Enterprise + enterprise_model = {} # Enterprise enterprise_model['url'] = 'testString' enterprise_model['id'] = 'testString' enterprise_model['enterprise_account_id'] = 'testString' @@ -1860,7 +1714,9 @@ def test_list_enterprises_response_serialization(self): assert list_enterprises_response_model != False # Construct a model instance of ListEnterprisesResponse by calling from_dict on the json representation - list_enterprises_response_model_dict = ListEnterprisesResponse.from_dict(list_enterprises_response_model_json).__dict__ + list_enterprises_response_model_dict = ListEnterprisesResponse.from_dict( + list_enterprises_response_model_json + ).__dict__ list_enterprises_response_model2 = ListEnterprisesResponse(**list_enterprises_response_model_dict) # Verify the model instances are equivalent diff --git a/test/unit/test_enterprise_usage_reports_v1.py b/test/unit/test_enterprise_usage_reports_v1.py index 02a7a68a..09ad088c 100644 --- a/test/unit/test_enterprise_usage_reports_v1.py +++ b/test/unit/test_enterprise_usage_reports_v1.py @@ -29,9 +29,7 @@ from ibm_platform_services.enterprise_usage_reports_v1 import * -_service = EnterpriseUsageReportsV1( - authenticator=NoAuthAuthenticator() -) +_service = EnterpriseUsageReportsV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://enterprise.cloud.ibm.com' _service.set_service_url(_base_url) @@ -68,7 +66,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -95,7 +94,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetResourceUsageReport(): + +class TestGetResourceUsageReport: """ Test Class for get_resource_usage_report """ @@ -108,11 +108,7 @@ def test_get_resource_usage_report_all_params(self): # Set up mock url = preprocess_url('/v1/resource-usage-reports') mock_response = '{"limit": 5, "first": {"href": "href"}, "next": {"href": "href"}, "reports": [{"entity_id": "de129b787b86403db7d3a14be2ae5f76", "entity_type": "enterprise", "entity_crn": "crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76", "entity_name": "Platform-Services", "billing_unit_id": "65719a07280a4022a9efa2f6ff4c3369", "billing_unit_crn": "crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369", "billing_unit_name": "Operations", "country_code": "USA", "currency_code": "USD", "month": "2017-08", "billable_cost": 13, "non_billable_cost": 17, "billable_rated_cost": 19, "non_billable_rated_cost": 23, "resources": [{"resource_id": "resource_id", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "pricing_region": "pricing_region", "pricing_plan_id": "pricing_plan_id", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "unit": "HOURS", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130, "price": [{"anyKey": "anyValue"}]}]}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values enterprise_id = 'abc12340d4bf4e36b0423d209b286f24' @@ -134,14 +130,14 @@ def test_get_resource_usage_report_all_params(self): billing_unit_id=billing_unit_id, limit=limit, offset=offset, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'enterprise_id={}'.format(enterprise_id) in query_string assert 'account_group_id={}'.format(account_group_id) in query_string @@ -169,16 +165,11 @@ def test_get_resource_usage_report_required_params(self): # Set up mock url = preprocess_url('/v1/resource-usage-reports') mock_response = '{"limit": 5, "first": {"href": "href"}, "next": {"href": "href"}, "reports": [{"entity_id": "de129b787b86403db7d3a14be2ae5f76", "entity_type": "enterprise", "entity_crn": "crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76", "entity_name": "Platform-Services", "billing_unit_id": "65719a07280a4022a9efa2f6ff4c3369", "billing_unit_crn": "crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369", "billing_unit_name": "Operations", "country_code": "USA", "currency_code": "USD", "month": "2017-08", "billable_cost": 13, "non_billable_cost": 17, "billable_rated_cost": 19, "non_billable_rated_cost": 23, "resources": [{"resource_id": "resource_id", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "pricing_region": "pricing_region", "pricing_plan_id": "pricing_plan_id", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "unit": "HOURS", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130, "price": [{"anyKey": "anyValue"}]}]}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_resource_usage_report() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -201,16 +192,8 @@ def test_get_resource_usage_report_with_pager_get_next(self): url = preprocess_url('/v1/resource-usage-reports') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"reports":[{"entity_id":"de129b787b86403db7d3a14be2ae5f76","entity_type":"enterprise","entity_crn":"crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76","entity_name":"Platform-Services","billing_unit_id":"65719a07280a4022a9efa2f6ff4c3369","billing_unit_crn":"crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369","billing_unit_name":"Operations","country_code":"USA","currency_code":"USD","month":"2017-08","billable_cost":13,"non_billable_cost":17,"billable_rated_cost":19,"non_billable_rated_cost":23,"resources":[{"resource_id":"resource_id","billable_cost":13,"billable_rated_cost":19,"non_billable_cost":17,"non_billable_rated_cost":23,"plans":[{"plan_id":"plan_id","pricing_region":"pricing_region","pricing_plan_id":"pricing_plan_id","billable":true,"cost":4,"rated_cost":10,"usage":[{"metric":"UP-TIME","unit":"HOURS","quantity":711.11,"rateable_quantity":700,"cost":123.45,"rated_cost":130,"price":[{"anyKey":"anyValue"}]}]}]}]}],"total_count":2,"limit":1}' mock_response2 = '{"reports":[{"entity_id":"de129b787b86403db7d3a14be2ae5f76","entity_type":"enterprise","entity_crn":"crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76","entity_name":"Platform-Services","billing_unit_id":"65719a07280a4022a9efa2f6ff4c3369","billing_unit_crn":"crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369","billing_unit_name":"Operations","country_code":"USA","currency_code":"USD","month":"2017-08","billable_cost":13,"non_billable_cost":17,"billable_rated_cost":19,"non_billable_rated_cost":23,"resources":[{"resource_id":"resource_id","billable_cost":13,"billable_rated_cost":19,"non_billable_cost":17,"non_billable_rated_cost":23,"plans":[{"plan_id":"plan_id","pricing_region":"pricing_region","pricing_plan_id":"pricing_plan_id","billable":true,"cost":4,"rated_cost":10,"usage":[{"metric":"UP-TIME","unit":"HOURS","quantity":711.11,"rateable_quantity":700,"cost":123.45,"rated_cost":130,"price":[{"anyKey":"anyValue"}]}]}]}]}],"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) + 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 = [] @@ -239,16 +222,8 @@ def test_get_resource_usage_report_with_pager_get_all(self): url = preprocess_url('/v1/resource-usage-reports') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"reports":[{"entity_id":"de129b787b86403db7d3a14be2ae5f76","entity_type":"enterprise","entity_crn":"crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76","entity_name":"Platform-Services","billing_unit_id":"65719a07280a4022a9efa2f6ff4c3369","billing_unit_crn":"crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369","billing_unit_name":"Operations","country_code":"USA","currency_code":"USD","month":"2017-08","billable_cost":13,"non_billable_cost":17,"billable_rated_cost":19,"non_billable_rated_cost":23,"resources":[{"resource_id":"resource_id","billable_cost":13,"billable_rated_cost":19,"non_billable_cost":17,"non_billable_rated_cost":23,"plans":[{"plan_id":"plan_id","pricing_region":"pricing_region","pricing_plan_id":"pricing_plan_id","billable":true,"cost":4,"rated_cost":10,"usage":[{"metric":"UP-TIME","unit":"HOURS","quantity":711.11,"rateable_quantity":700,"cost":123.45,"rated_cost":130,"price":[{"anyKey":"anyValue"}]}]}]}]}],"total_count":2,"limit":1}' mock_response2 = '{"reports":[{"entity_id":"de129b787b86403db7d3a14be2ae5f76","entity_type":"enterprise","entity_crn":"crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76","entity_name":"Platform-Services","billing_unit_id":"65719a07280a4022a9efa2f6ff4c3369","billing_unit_crn":"crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369","billing_unit_name":"Operations","country_code":"USA","currency_code":"USD","month":"2017-08","billable_cost":13,"non_billable_cost":17,"billable_rated_cost":19,"non_billable_rated_cost":23,"resources":[{"resource_id":"resource_id","billable_cost":13,"billable_rated_cost":19,"non_billable_cost":17,"non_billable_rated_cost":23,"plans":[{"plan_id":"plan_id","pricing_region":"pricing_region","pricing_plan_id":"pricing_plan_id","billable":true,"cost":4,"rated_cost":10,"usage":[{"metric":"UP-TIME","unit":"HOURS","quantity":711.11,"rateable_quantity":700,"cost":123.45,"rated_cost":130,"price":[{"anyKey":"anyValue"}]}]}]}]}],"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) + 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 = GetResourceUsageReportPager( @@ -265,6 +240,7 @@ def test_get_resource_usage_report_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 + # endregion ############################################################################## # End of Service: EnterpriseUsageReports @@ -275,7 +251,7 @@ def test_get_resource_usage_report_with_pager_get_all(self): # Start of Model Tests ############################################################################## # region -class TestModel_Link(): +class TestModel_Link: """ Test Class for Link """ @@ -304,7 +280,8 @@ def test_link_serialization(self): link_model_json2 = link_model.to_dict() assert link_model_json2 == link_model_json -class TestModel_MetricUsage(): + +class TestModel_MetricUsage: """ Test Class for MetricUsage """ @@ -339,7 +316,8 @@ def test_metric_usage_serialization(self): metric_usage_model_json2 = metric_usage_model.to_dict() assert metric_usage_model_json2 == metric_usage_model_json -class TestModel_PlanUsage(): + +class TestModel_PlanUsage: """ Test Class for PlanUsage """ @@ -351,7 +329,7 @@ def test_plan_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - metric_usage_model = {} # MetricUsage + metric_usage_model = {} # MetricUsage metric_usage_model['metric'] = 'UP-TIME' metric_usage_model['unit'] = 'HOURS' metric_usage_model['quantity'] = 711.11 @@ -385,7 +363,8 @@ def test_plan_usage_serialization(self): plan_usage_model_json2 = plan_usage_model.to_dict() assert plan_usage_model_json2 == plan_usage_model_json -class TestModel_Reports(): + +class TestModel_Reports: """ Test Class for Reports """ @@ -397,10 +376,12 @@ def test_reports_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - link_model = {} # Link - link_model['href'] = '/v1/resource-usage-reports?enterprise_id=5ac9eb23c91b429b893e038aa5a2dec8&children=true&month=2019-06&limit=2' + link_model = {} # Link + link_model[ + 'href' + ] = '/v1/resource-usage-reports?enterprise_id=5ac9eb23c91b429b893e038aa5a2dec8&children=true&month=2019-06&limit=2' - metric_usage_model = {} # MetricUsage + metric_usage_model = {} # MetricUsage metric_usage_model['metric'] = 'GB_STORAGE_ACCRUED_PER_MONTH' metric_usage_model['unit'] = 'GIGABYTE_MONTHS' metric_usage_model['quantity'] = 10 @@ -409,7 +390,7 @@ def test_reports_serialization(self): metric_usage_model['rated_cost'] = 10 metric_usage_model['price'] = [{'foo': 'bar'}] - plan_usage_model = {} # PlanUsage + plan_usage_model = {} # PlanUsage plan_usage_model['plan_id'] = 'cloudant-standard' plan_usage_model['pricing_region'] = 'testString' plan_usage_model['pricing_plan_id'] = 'billable:v4:cloudant-standard::1552694400000:' @@ -418,7 +399,7 @@ def test_reports_serialization(self): plan_usage_model['rated_cost'] = 75 plan_usage_model['usage'] = [metric_usage_model] - resource_usage_model = {} # ResourceUsage + resource_usage_model = {} # ResourceUsage resource_usage_model['resource_id'] = 'cloudant' resource_usage_model['billable_cost'] = 75 resource_usage_model['billable_rated_cost'] = 75 @@ -426,13 +407,17 @@ def test_reports_serialization(self): resource_usage_model['non_billable_rated_cost'] = 0 resource_usage_model['plans'] = [plan_usage_model] - resource_usage_report_model = {} # ResourceUsageReport + resource_usage_report_model = {} # ResourceUsageReport resource_usage_report_model['entity_id'] = '41848d0e2711434bbc134242452f7fc7' resource_usage_report_model['entity_type'] = 'account' - resource_usage_report_model['entity_crn'] = 'crn:v1:bluemix:public:enterprise::a/3f99f8accbc848ea96f3c61a0ae22c44::account:41848d0e2711434bbc134242452f7fc7' + resource_usage_report_model[ + 'entity_crn' + ] = 'crn:v1:bluemix:public:enterprise::a/3f99f8accbc848ea96f3c61a0ae22c44::account:41848d0e2711434bbc134242452f7fc7' resource_usage_report_model['entity_name'] = 'Example Account' resource_usage_report_model['billing_unit_id'] = '65719a07280a4022a9efa2f6ff4c3369' - resource_usage_report_model['billing_unit_crn'] = 'crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369' + resource_usage_report_model[ + 'billing_unit_crn' + ] = 'crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369' resource_usage_report_model['billing_unit_name'] = 'Example Billing Unit' resource_usage_report_model['country_code'] = 'USA' resource_usage_report_model['currency_code'] = 'USD' @@ -465,7 +450,8 @@ def test_reports_serialization(self): reports_model_json2 = reports_model.to_dict() assert reports_model_json2 == reports_model_json -class TestModel_ResourceUsage(): + +class TestModel_ResourceUsage: """ Test Class for ResourceUsage """ @@ -477,7 +463,7 @@ def test_resource_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - metric_usage_model = {} # MetricUsage + metric_usage_model = {} # MetricUsage metric_usage_model['metric'] = 'UP-TIME' metric_usage_model['unit'] = 'HOURS' metric_usage_model['quantity'] = 711.11 @@ -486,7 +472,7 @@ def test_resource_usage_serialization(self): metric_usage_model['rated_cost'] = 130 metric_usage_model['price'] = [{'foo': 'bar'}] - plan_usage_model = {} # PlanUsage + plan_usage_model = {} # PlanUsage plan_usage_model['plan_id'] = 'testString' plan_usage_model['pricing_region'] = 'testString' plan_usage_model['pricing_plan_id'] = 'testString' @@ -519,7 +505,8 @@ def test_resource_usage_serialization(self): resource_usage_model_json2 = resource_usage_model.to_dict() assert resource_usage_model_json2 == resource_usage_model_json -class TestModel_ResourceUsageReport(): + +class TestModel_ResourceUsageReport: """ Test Class for ResourceUsageReport """ @@ -531,7 +518,7 @@ def test_resource_usage_report_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - metric_usage_model = {} # MetricUsage + metric_usage_model = {} # MetricUsage metric_usage_model['metric'] = 'UP-TIME' metric_usage_model['unit'] = 'HOURS' metric_usage_model['quantity'] = 711.11 @@ -540,7 +527,7 @@ def test_resource_usage_report_serialization(self): metric_usage_model['rated_cost'] = 130 metric_usage_model['price'] = [{'foo': 'bar'}] - plan_usage_model = {} # PlanUsage + plan_usage_model = {} # PlanUsage plan_usage_model['plan_id'] = 'testString' plan_usage_model['pricing_region'] = 'testString' plan_usage_model['pricing_plan_id'] = 'testString' @@ -549,7 +536,7 @@ def test_resource_usage_report_serialization(self): plan_usage_model['rated_cost'] = 72.5 plan_usage_model['usage'] = [metric_usage_model] - resource_usage_model = {} # ResourceUsage + resource_usage_model = {} # ResourceUsage resource_usage_model['resource_id'] = 'testString' resource_usage_model['billable_cost'] = 72.5 resource_usage_model['billable_rated_cost'] = 72.5 @@ -561,10 +548,14 @@ def test_resource_usage_report_serialization(self): resource_usage_report_model_json = {} resource_usage_report_model_json['entity_id'] = 'de129b787b86403db7d3a14be2ae5f76' resource_usage_report_model_json['entity_type'] = 'enterprise' - resource_usage_report_model_json['entity_crn'] = 'crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76' + resource_usage_report_model_json[ + 'entity_crn' + ] = 'crn:v1:bluemix:public:enterprise::a/e9a57260546c4b4aa9ebfa316a82e56e::enterprise:de129b787b86403db7d3a14be2ae5f76' resource_usage_report_model_json['entity_name'] = 'Platform-Services' resource_usage_report_model_json['billing_unit_id'] = '65719a07280a4022a9efa2f6ff4c3369' - resource_usage_report_model_json['billing_unit_crn'] = 'crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369' + resource_usage_report_model_json[ + 'billing_unit_crn' + ] = 'crn:v1:bluemix:public:billing::a/3f99f8accbc848ea96f3c61a0ae22c44::billing-unit:65719a07280a4022a9efa2f6ff4c3369' resource_usage_report_model_json['billing_unit_name'] = 'Operations' resource_usage_report_model_json['country_code'] = 'USA' resource_usage_report_model_json['currency_code'] = 'USD' diff --git a/test/unit/test_global_catalog_v1.py b/test/unit/test_global_catalog_v1.py index fc094dcb..8e714a99 100644 --- a/test/unit/test_global_catalog_v1.py +++ b/test/unit/test_global_catalog_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.global_catalog_v1 import * -service = GlobalCatalogV1( - authenticator=NoAuthAuthenticator() - ) +service = GlobalCatalogV1(authenticator=NoAuthAuthenticator()) base_url = 'https://globalcatalog.cloud.ibm.com/api/v1' service.set_service_url(base_url) @@ -43,7 +41,8 @@ ############################################################################## # region -class TestListCatalogEntries(): + +class TestListCatalogEntries: """ Test Class for list_catalog_entries """ @@ -65,11 +64,7 @@ def test_list_catalog_entries_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account = 'testString' @@ -95,14 +90,14 @@ def test_list_catalog_entries_all_params(self): complete=complete, offset=offset, limit=limit, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'include={}'.format(include) in query_string @@ -115,7 +110,6 @@ def test_list_catalog_entries_all_params(self): assert '_offset={}'.format(offset) in query_string assert '_limit={}'.format(limit) in query_string - @responses.activate def test_list_catalog_entries_required_params(self): """ @@ -124,22 +118,17 @@ def test_list_catalog_entries_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = service.list_catalog_entries() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 -class TestCreateCatalogEntry(): +class TestCreateCatalogEntry: """ Test Class for create_catalog_entry """ @@ -161,11 +150,7 @@ def test_create_catalog_entry_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a Overview model overview_model = {} @@ -412,14 +397,14 @@ def test_create_catalog_entry_all_params(self): active=active, metadata=metadata, account=account, - headers={} + headers={}, ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string # Validate body params @@ -437,7 +422,6 @@ def test_create_catalog_entry_all_params(self): assert req_body['active'] == True assert req_body['metadata'] == object_metadata_set_model - @responses.activate def test_create_catalog_entry_required_params(self): """ @@ -446,11 +430,7 @@ def test_create_catalog_entry_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a Overview model overview_model = {} @@ -695,7 +675,7 @@ def test_create_catalog_entry_required_params(self): group=group, active=active, metadata=metadata, - headers={} + headers={}, ) # Check for correct operation @@ -716,7 +696,6 @@ def test_create_catalog_entry_required_params(self): assert req_body['active'] == True assert req_body['metadata'] == object_metadata_set_model - @responses.activate def test_create_catalog_entry_value_error(self): """ @@ -725,11 +704,7 @@ def test_create_catalog_entry_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a Overview model overview_model = {} @@ -972,13 +947,12 @@ def test_create_catalog_entry_value_error(self): "id": 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()} + 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_catalog_entry(**req_copy) - -class TestGetCatalogEntry(): +class TestGetCatalogEntry: """ Test Class for get_catalog_entry """ @@ -1000,11 +974,7 @@ def test_get_catalog_entry_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1016,20 +986,14 @@ def test_get_catalog_entry_all_params(self): # Invoke method response = service.get_catalog_entry( - id, - account=account, - include=include, - languages=languages, - complete=complete, - depth=depth, - headers={} + id, account=account, include=include, languages=languages, complete=complete, depth=depth, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'include={}'.format(include) in query_string @@ -1037,7 +1001,6 @@ def test_get_catalog_entry_all_params(self): assert 'complete={}'.format('true' if complete else 'false') in query_string assert 'depth={}'.format(depth) in query_string - @responses.activate def test_get_catalog_entry_required_params(self): """ @@ -1046,26 +1009,18 @@ def test_get_catalog_entry_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.get_catalog_entry( - id, - headers={} - ) + response = service.get_catalog_entry(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_catalog_entry_value_error(self): """ @@ -1074,11 +1029,7 @@ def test_get_catalog_entry_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1088,13 +1039,12 @@ def test_get_catalog_entry_value_error(self): "id": 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()} + 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_catalog_entry(**req_copy) - -class TestUpdateCatalogEntry(): +class TestUpdateCatalogEntry: """ Test Class for update_catalog_entry """ @@ -1116,11 +1066,7 @@ def test_update_catalog_entry_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Overview model overview_model = {} @@ -1369,14 +1315,14 @@ def test_update_catalog_entry_all_params(self): metadata=metadata, account=account, move=move, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'move={}'.format(move) in query_string @@ -1394,7 +1340,6 @@ def test_update_catalog_entry_all_params(self): assert req_body['active'] == True assert req_body['metadata'] == object_metadata_set_model - @responses.activate def test_update_catalog_entry_required_params(self): """ @@ -1403,11 +1348,7 @@ def test_update_catalog_entry_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Overview model overview_model = {} @@ -1652,7 +1593,7 @@ def test_update_catalog_entry_required_params(self): group=group, active=active, metadata=metadata, - headers={} + headers={}, ) # Check for correct operation @@ -1672,7 +1613,6 @@ def test_update_catalog_entry_required_params(self): assert req_body['active'] == True assert req_body['metadata'] == object_metadata_set_model - @responses.activate def test_update_catalog_entry_value_error(self): """ @@ -1681,11 +1621,7 @@ def test_update_catalog_entry_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString') mock_response = '{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Overview model overview_model = {} @@ -1928,13 +1864,12 @@ def test_update_catalog_entry_value_error(self): "provider": provider, } 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()} + 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_catalog_entry(**req_copy) - -class TestDeleteCatalogEntry(): +class TestDeleteCatalogEntry: """ Test Class for delete_catalog_entry """ @@ -1955,9 +1890,7 @@ def test_delete_catalog_entry_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values id = 'testString' @@ -1965,23 +1898,17 @@ def test_delete_catalog_entry_all_params(self): force = True # Invoke method - response = service.delete_catalog_entry( - id, - account=account, - force=force, - headers={} - ) + response = service.delete_catalog_entry(id, account=account, force=force, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'force={}'.format('true' if force else 'false') in query_string - @responses.activate def test_delete_catalog_entry_required_params(self): """ @@ -1989,24 +1916,18 @@ def test_delete_catalog_entry_required_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.delete_catalog_entry( - id, - headers={} - ) + response = service.delete_catalog_entry(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_delete_catalog_entry_value_error(self): """ @@ -2014,9 +1935,7 @@ def test_delete_catalog_entry_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values id = 'testString' @@ -2026,13 +1945,12 @@ def test_delete_catalog_entry_value_error(self): "id": 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()} + 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_catalog_entry(**req_copy) - -class TestGetChildObjects(): +class TestGetChildObjects: """ Test Class for get_child_objects """ @@ -2054,11 +1972,7 @@ def test_get_child_objects_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/testString') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2086,14 +2000,14 @@ def test_get_child_objects_all_params(self): complete=complete, offset=offset, limit=limit, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'include={}'.format(include) in query_string @@ -2105,7 +2019,6 @@ def test_get_child_objects_all_params(self): assert '_offset={}'.format(offset) in query_string assert '_limit={}'.format(limit) in query_string - @responses.activate def test_get_child_objects_required_params(self): """ @@ -2114,28 +2027,19 @@ def test_get_child_objects_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/testString') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' kind = 'testString' # Invoke method - response = service.get_child_objects( - id, - kind, - headers={} - ) + response = service.get_child_objects(id, kind, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_child_objects_value_error(self): """ @@ -2144,11 +2048,7 @@ def test_get_child_objects_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/testString') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"name": "name", "kind": "service", "overview_ui": {"mapKey": {"display_name": "display_name", "long_description": "long_description", "description": "description", "featured_description": "featured_description"}}, "images": {"image": "image", "small_image": "small_image", "medium_image": "medium_image", "feature_image": "feature_image"}, "parent_id": "parent_id", "disabled": true, "tags": ["tags"], "group": false, "provider": {"email": "email", "name": "name", "contact": "contact", "support_email": "support_email", "phone": "phone"}, "active": true, "metadata": {"rc_compatible": false, "service": {"type": "type", "iam_compatible": true, "unique_api_key": true, "provisionable": false, "bindable": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "requires": ["requires"], "plan_updateable": false, "state": "state", "service_check_enabled": false, "test_check_interval": 19, "service_key_supported": false, "cf_guid": {"mapKey": "inner"}}, "plan": {"bindable": true, "reservable": true, "allow_internal_users": true, "async_provisioning_supported": true, "async_unprovisioning_supported": true, "test_check_interval": 19, "single_scope_instance": "single_scope_instance", "service_check_enabled": false, "cf_guid": {"mapKey": "inner"}}, "alias": {"type": "type", "plan_id": "plan_id"}, "template": {"services": ["services"], "default_memory": 14, "start_cmd": "start_cmd", "source": {"path": "path", "type": "type", "url": "url"}, "runtime_catalog_id": "runtime_catalog_id", "cf_runtime_id": "cf_runtime_id", "template_id": "template_id", "executable_file": "executable_file", "buildpack": "buildpack", "environment_variables": {"mapKey": "inner"}}, "ui": {"strings": {"mapKey": {"bullets": [{"title": "title", "description": "description", "icon": "icon", "quantity": 8}], "media": [{"caption": "caption", "thumbnail_url": "thumbnail_url", "type": "type", "URL": "url", "source": {"title": "title", "description": "description", "icon": "icon", "quantity": 8}}], "not_creatable_msg": "not_creatable_msg", "not_creatable__robot_msg": "not_creatable_robot_msg", "deprecation_warning": "deprecation_warning", "popup_warning_message": "popup_warning_message", "instruction": "instruction"}}, "urls": {"doc_url": "doc_url", "instructions_url": "instructions_url", "api_url": "api_url", "create_url": "create_url", "sdk_download_url": "sdk_download_url", "terms_url": "terms_url", "custom_create_page_url": "custom_create_page_url", "catalog_details_url": "catalog_details_url", "deprecation_doc_url": "deprecation_doc_url", "dashboard_url": "dashboard_url", "registration_url": "registration_url", "apidocsurl": "apidocsurl"}, "embeddable_dashboard": "embeddable_dashboard", "embeddable_dashboard_full_width": false, "navigation_order": ["navigation_order"], "not_creatable": false, "primary_offering_id": "primary_offering_id", "accessible_during_provision": false, "side_by_side_index": 18, "end_of_service_time": "2019-01-01T12:00:00.000Z", "hidden": true, "hide_lite_metering": true, "no_upgrade_next_step": true}, "compliance": ["compliance"], "sla": {"terms": "terms", "tenancy": "tenancy", "provisioning": "provisioning", "responsiveness": "responsiveness", "dr": {"dr": true, "description": "description"}}, "callbacks": {"controller_url": "controller_url", "broker_url": "broker_url", "broker_proxy_url": "broker_proxy_url", "dashboard_url": "dashboard_url", "dashboard_data_url": "dashboard_data_url", "dashboard_detail_tab_url": "dashboard_detail_tab_url", "dashboard_detail_tab_ext_url": "dashboard_detail_tab_ext_url", "service_monitor_api": "service_monitor_api", "service_monitor_app": "service_monitor_app", "api_endpoint": {"mapKey": "inner"}}, "original_name": "original_name", "version": "version", "other": {"mapKey": {"anyKey": "anyValue"}}, "pricing": {"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}, "deployment": {"location": "location", "location_url": "location_url", "original_location": "original_location", "target_crn": "target_crn", "service_crn": "service_crn", "mccp_id": "mccp_id", "broker": {"name": "name", "guid": "guid"}, "supports_rc_migration": false, "target_network": "target_network"}}, "id": "id", "catalog_crn": "catalog_crn", "url": "url", "children_url": "children_url", "geo_tags": ["geo_tags"], "pricing_tags": ["pricing_tags"], "created": "2019-01-01T12:00:00.000Z", "updated": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2160,13 +2060,12 @@ def test_get_child_objects_value_error(self): "kind": kind, } 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()} + 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_child_objects(**req_copy) - -class TestRestoreCatalogEntry(): +class TestRestoreCatalogEntry: """ Test Class for restore_catalog_entry """ @@ -2187,30 +2086,23 @@ def test_restore_catalog_entry_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/restore') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values id = 'testString' account = 'testString' # Invoke method - response = service.restore_catalog_entry( - id, - account=account, - headers={} - ) + response = service.restore_catalog_entry(id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_restore_catalog_entry_required_params(self): """ @@ -2218,24 +2110,18 @@ def test_restore_catalog_entry_required_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/restore') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.restore_catalog_entry( - id, - headers={} - ) + response = service.restore_catalog_entry(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_restore_catalog_entry_value_error(self): """ @@ -2243,9 +2129,7 @@ def test_restore_catalog_entry_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/restore') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values id = 'testString' @@ -2255,12 +2139,11 @@ def test_restore_catalog_entry_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.restore_catalog_entry(**req_copy) - # endregion ############################################################################## # End of Service: Object @@ -2271,7 +2154,8 @@ def test_restore_catalog_entry_value_error(self): ############################################################################## # region -class TestGetVisibility(): + +class TestGetVisibility: """ Test Class for get_visibility """ @@ -2293,32 +2177,23 @@ def test_get_visibility_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') mock_response = '{"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' account = 'testString' # Invoke method - response = service.get_visibility( - id, - account=account, - headers={} - ) + response = service.get_visibility(id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_get_visibility_required_params(self): """ @@ -2327,26 +2202,18 @@ def test_get_visibility_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') mock_response = '{"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.get_visibility( - id, - headers={} - ) + response = service.get_visibility(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_visibility_value_error(self): """ @@ -2355,11 +2222,7 @@ def test_get_visibility_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') mock_response = '{"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2369,13 +2232,12 @@ def test_get_visibility_value_error(self): "id": 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()} + 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_visibility(**req_copy) - -class TestUpdateVisibility(): +class TestUpdateVisibility: """ Test Class for update_visibility """ @@ -2396,9 +2258,7 @@ def test_update_visibility_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Construct a dict representation of a VisibilityDetailAccounts model visibility_detail_accounts_model = {} @@ -2417,19 +2277,14 @@ def test_update_visibility_all_params(self): # Invoke method response = service.update_visibility( - id, - extendable=extendable, - include=include, - exclude=exclude, - account=account, - headers={} + id, extendable=extendable, include=include, exclude=exclude, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string # Validate body params @@ -2438,7 +2293,6 @@ def test_update_visibility_all_params(self): assert req_body['include'] == visibility_detail_model assert req_body['exclude'] == visibility_detail_model - @responses.activate def test_update_visibility_required_params(self): """ @@ -2446,9 +2300,7 @@ def test_update_visibility_required_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Construct a dict representation of a VisibilityDetailAccounts model visibility_detail_accounts_model = {} @@ -2465,13 +2317,7 @@ def test_update_visibility_required_params(self): exclude = visibility_detail_model # Invoke method - response = service.update_visibility( - id, - extendable=extendable, - include=include, - exclude=exclude, - headers={} - ) + response = service.update_visibility(id, extendable=extendable, include=include, exclude=exclude, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2482,7 +2328,6 @@ def test_update_visibility_required_params(self): assert req_body['include'] == visibility_detail_model assert req_body['exclude'] == visibility_detail_model - @responses.activate def test_update_visibility_value_error(self): """ @@ -2490,9 +2335,7 @@ def test_update_visibility_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/visibility') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Construct a dict representation of a VisibilityDetailAccounts model visibility_detail_accounts_model = {} @@ -2513,12 +2356,11 @@ def test_update_visibility_value_error(self): "id": 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()} + 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_visibility(**req_copy) - # endregion ############################################################################## # End of Service: Visibility @@ -2529,7 +2371,8 @@ def test_update_visibility_value_error(self): ############################################################################## # region -class TestGetPricing(): + +class TestGetPricing: """ Test Class for get_pricing """ @@ -2551,32 +2394,23 @@ def test_get_pricing_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/pricing') mock_response = '{"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' account = 'testString' # Invoke method - response = service.get_pricing( - id, - account=account, - headers={} - ) + response = service.get_pricing(id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_get_pricing_required_params(self): """ @@ -2585,26 +2419,18 @@ def test_get_pricing_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/pricing') mock_response = '{"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.get_pricing( - id, - headers={} - ) + response = service.get_pricing(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_pricing_value_error(self): """ @@ -2613,11 +2439,7 @@ def test_get_pricing_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/pricing') mock_response = '{"type": "type", "origin": "origin", "starting_price": {"plan_id": "plan_id", "deployment_id": "deployment_id", "unit": "unit", "amount": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}, "metrics": [{"part_ref": "part_ref", "metric_id": "metric_id", "tier_model": "tier_model", "charge_unit": "charge_unit", "charge_unit_name": "charge_unit_name", "charge_unit_quantity": "charge_unit_quantity", "resource_display_name": "resource_display_name", "charge_unit_display_name": "charge_unit_display_name", "usage_cap_qty": 13, "display_cap": 11, "effective_from": "2019-01-01T12:00:00.000Z", "effective_until": "2019-01-01T12:00:00.000Z", "amounts": [{"country": "country", "currency": "currency", "prices": [{"quantity_tier": 13, "Price": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2627,12 +2449,11 @@ def test_get_pricing_value_error(self): "id": 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()} + 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_pricing(**req_copy) - # endregion ############################################################################## # End of Service: Pricing @@ -2643,7 +2464,8 @@ def test_get_pricing_value_error(self): ############################################################################## # region -class TestGetAuditLogs(): + +class TestGetAuditLogs: """ Test Class for get_audit_logs """ @@ -2665,11 +2487,7 @@ def test_get_audit_logs_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/logs') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "effective": {"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}, "time": "2019-01-01T12:00:00.000Z", "who_id": "who_id", "who_name": "who_name", "who_email": "who_email", "instance": "instance", "gid": "gid", "type": "type", "message": "message", "data": {"mapKey": {"anyKey": "anyValue"}}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2681,20 +2499,14 @@ def test_get_audit_logs_all_params(self): # Invoke method response = service.get_audit_logs( - id, - account=account, - ascending=ascending, - startat=startat, - offset=offset, - limit=limit, - headers={} + id, account=account, ascending=ascending, startat=startat, offset=offset, limit=limit, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string assert 'ascending={}'.format(ascending) in query_string @@ -2702,7 +2514,6 @@ def test_get_audit_logs_all_params(self): assert '_offset={}'.format(offset) in query_string assert '_limit={}'.format(limit) in query_string - @responses.activate def test_get_audit_logs_required_params(self): """ @@ -2711,26 +2522,18 @@ def test_get_audit_logs_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/logs') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "effective": {"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}, "time": "2019-01-01T12:00:00.000Z", "who_id": "who_id", "who_name": "who_name", "who_email": "who_email", "instance": "instance", "gid": "gid", "type": "type", "message": "message", "data": {"mapKey": {"anyKey": "anyValue"}}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = service.get_audit_logs( - id, - headers={} - ) + response = service.get_audit_logs(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_audit_logs_value_error(self): """ @@ -2739,11 +2542,7 @@ def test_get_audit_logs_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/logs') mock_response = '{"offset": 6, "limit": 5, "count": 5, "resource_count": 14, "first": "first", "last": "last", "prev": "prev", "next": "next", "resources": [{"id": "id", "effective": {"restrictions": "restrictions", "owner": "owner", "extendable": true, "include": {"accounts": {"_accountid_": "accountid"}}, "exclude": {"accounts": {"_accountid_": "accountid"}}, "approved": true}, "time": "2019-01-01T12:00:00.000Z", "who_id": "who_id", "who_name": "who_name", "who_email": "who_email", "instance": "instance", "gid": "gid", "type": "type", "message": "message", "data": {"mapKey": {"anyKey": "anyValue"}}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2753,12 +2552,11 @@ def test_get_audit_logs_value_error(self): "id": 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()} + 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_audit_logs(**req_copy) - # endregion ############################################################################## # End of Service: Audit @@ -2769,7 +2567,8 @@ def test_get_audit_logs_value_error(self): ############################################################################## # region -class TestListArtifacts(): + +class TestListArtifacts: """ Test Class for list_artifacts """ @@ -2791,32 +2590,23 @@ def test_list_artifacts_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts') mock_response = '{"count": 5, "resources": [{"name": "name", "updated": "2019-01-01T12:00:00.000Z", "url": "url", "etag": "etag", "size": 4}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values object_id = 'testString' account = 'testString' # Invoke method - response = service.list_artifacts( - object_id, - account=account, - headers={} - ) + response = service.list_artifacts(object_id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_list_artifacts_required_params(self): """ @@ -2825,26 +2615,18 @@ def test_list_artifacts_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts') mock_response = '{"count": 5, "resources": [{"name": "name", "updated": "2019-01-01T12:00:00.000Z", "url": "url", "etag": "etag", "size": 4}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values object_id = 'testString' # Invoke method - response = service.list_artifacts( - object_id, - headers={} - ) + response = service.list_artifacts(object_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_list_artifacts_value_error(self): """ @@ -2853,11 +2635,7 @@ def test_list_artifacts_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts') mock_response = '{"count": 5, "resources": [{"name": "name", "updated": "2019-01-01T12:00:00.000Z", "url": "url", "etag": "etag", "size": 4}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values object_id = 'testString' @@ -2867,13 +2645,12 @@ def test_list_artifacts_value_error(self): "object_id": object_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()} + 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_artifacts(**req_copy) - -class TestGetArtifact(): +class TestGetArtifact: """ Test Class for get_artifact """ @@ -2895,11 +2672,7 @@ def test_get_artifact_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='*/*', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='*/*', status=200) # Set up parameter values object_id = 'testString' @@ -2907,22 +2680,16 @@ def test_get_artifact_all_params(self): account = 'testString' # Invoke method - response = service.get_artifact( - object_id, - artifact_id, - account=account, - headers={} - ) + response = service.get_artifact(object_id, artifact_id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_get_artifact_required_params(self): """ @@ -2931,28 +2698,19 @@ def test_get_artifact_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='*/*', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='*/*', status=200) # Set up parameter values object_id = 'testString' artifact_id = 'testString' # Invoke method - response = service.get_artifact( - object_id, - artifact_id, - headers={} - ) + response = service.get_artifact(object_id, artifact_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_artifact_value_error(self): """ @@ -2961,11 +2719,7 @@ def test_get_artifact_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') mock_response = 'This is a mock binary response.' - responses.add(responses.GET, - url, - body=mock_response, - content_type='*/*', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='*/*', status=200) # Set up parameter values object_id = 'testString' @@ -2977,13 +2731,12 @@ def test_get_artifact_value_error(self): "artifact_id": artifact_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()} + 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_artifact(**req_copy) - -class TestUploadArtifact(): +class TestUploadArtifact: """ Test Class for upload_artifact """ @@ -3004,9 +2757,7 @@ def test_upload_artifact_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values object_id = 'testString' @@ -3017,24 +2768,18 @@ def test_upload_artifact_all_params(self): # Invoke method response = service.upload_artifact( - object_id, - artifact_id, - artifact=artifact, - content_type=content_type, - account=account, - headers={} + object_id, artifact_id, artifact=artifact, content_type=content_type, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string # Validate body params - @responses.activate def test_upload_artifact_required_params(self): """ @@ -3042,26 +2787,19 @@ def test_upload_artifact_required_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values object_id = 'testString' artifact_id = 'testString' # Invoke method - response = service.upload_artifact( - object_id, - artifact_id, - headers={} - ) + response = service.upload_artifact(object_id, artifact_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_upload_artifact_value_error(self): """ @@ -3069,9 +2807,7 @@ def test_upload_artifact_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.PUT, - url, - status=200) + responses.add(responses.PUT, url, status=200) # Set up parameter values object_id = 'testString' @@ -3083,13 +2819,12 @@ def test_upload_artifact_value_error(self): "artifact_id": artifact_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.upload_artifact(**req_copy) - -class TestDeleteArtifact(): +class TestDeleteArtifact: """ Test Class for delete_artifact """ @@ -3110,9 +2845,7 @@ def test_delete_artifact_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values object_id = 'testString' @@ -3120,22 +2853,16 @@ def test_delete_artifact_all_params(self): account = 'testString' # Invoke method - response = service.delete_artifact( - object_id, - artifact_id, - account=account, - headers={} - ) + response = service.delete_artifact(object_id, artifact_id, account=account, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account={}'.format(account) in query_string - @responses.activate def test_delete_artifact_required_params(self): """ @@ -3143,26 +2870,19 @@ def test_delete_artifact_required_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values object_id = 'testString' artifact_id = 'testString' # Invoke method - response = service.delete_artifact( - object_id, - artifact_id, - headers={} - ) + response = service.delete_artifact(object_id, artifact_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_delete_artifact_value_error(self): """ @@ -3170,9 +2890,7 @@ def test_delete_artifact_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/testString/artifacts/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values object_id = 'testString' @@ -3184,12 +2902,11 @@ def test_delete_artifact_value_error(self): "artifact_id": artifact_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()} + 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_artifact(**req_copy) - # endregion ############################################################################## # End of Service: Artifact @@ -3200,7 +2917,7 @@ def test_delete_artifact_value_error(self): # Start of Model Tests ############################################################################## # region -class TestAliasMetaData(): +class TestAliasMetaData: """ Test Class for AliasMetaData """ @@ -3230,7 +2947,8 @@ def test_alias_meta_data_serialization(self): alias_meta_data_model_json2 = alias_meta_data_model.to_dict() assert alias_meta_data_model_json2 == alias_meta_data_model_json -class TestAmount(): + +class TestAmount: """ Test Class for Amount """ @@ -3242,7 +2960,7 @@ def test_amount_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 @@ -3267,7 +2985,8 @@ def test_amount_serialization(self): amount_model_json2 = amount_model.to_dict() assert amount_model_json2 == amount_model_json -class TestArtifact(): + +class TestArtifact: """ Test Class for Artifact """ @@ -3300,7 +3019,8 @@ def test_artifact_serialization(self): artifact_model_json2 = artifact_model.to_dict() assert artifact_model_json2 == artifact_model_json -class TestArtifacts(): + +class TestArtifacts: """ Test Class for Artifacts """ @@ -3312,7 +3032,7 @@ def test_artifacts_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - artifact_model = {} # Artifact + artifact_model = {} # Artifact artifact_model['name'] = 'testString' artifact_model['updated'] = '2020-01-28T18:40:40.123456Z' artifact_model['url'] = 'testString' @@ -3339,7 +3059,8 @@ def test_artifacts_serialization(self): artifacts_model_json2 = artifacts_model.to_dict() assert artifacts_model_json2 == artifacts_model_json -class TestAuditSearchResult(): + +class TestAuditSearchResult: """ Test Class for AuditSearchResult """ @@ -3351,13 +3072,13 @@ def test_audit_search_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - visibility_detail_accounts_model = {} # VisibilityDetailAccounts + visibility_detail_accounts_model = {} # VisibilityDetailAccounts visibility_detail_accounts_model['_accountid_'] = 'testString' - visibility_detail_model = {} # VisibilityDetail + visibility_detail_model = {} # VisibilityDetail visibility_detail_model['accounts'] = visibility_detail_accounts_model - visibility_model = {} # Visibility + visibility_model = {} # Visibility visibility_model['restrictions'] = 'testString' visibility_model['owner'] = 'testString' visibility_model['extendable'] = True @@ -3365,7 +3086,7 @@ def test_audit_search_result_serialization(self): visibility_model['exclude'] = visibility_detail_model visibility_model['approved'] = True - message_model = {} # Message + message_model = {} # Message message_model['id'] = 'testString' message_model['effective'] = visibility_model message_model['time'] = '2020-01-28T18:40:40.123456Z' @@ -3405,7 +3126,8 @@ def test_audit_search_result_serialization(self): audit_search_result_model_json2 = audit_search_result_model.to_dict() assert audit_search_result_model_json2 == audit_search_result_model_json -class TestBroker(): + +class TestBroker: """ Test Class for Broker """ @@ -3435,7 +3157,8 @@ def test_broker_serialization(self): broker_model_json2 = broker_model.to_dict() assert broker_model_json2 == broker_model_json -class TestBullets(): + +class TestBullets: """ Test Class for Bullets """ @@ -3467,7 +3190,8 @@ def test_bullets_serialization(self): bullets_model_json2 = bullets_model.to_dict() assert bullets_model_json2 == bullets_model_json -class TestCFMetaData(): + +class TestCFMetaData: """ Test Class for CFMetaData """ @@ -3509,7 +3233,8 @@ def test_cf_meta_data_serialization(self): cf_meta_data_model_json2 = cf_meta_data_model.to_dict() assert cf_meta_data_model_json2 == cf_meta_data_model_json -class TestCallbacks(): + +class TestCallbacks: """ Test Class for Callbacks """ @@ -3547,7 +3272,8 @@ def test_callbacks_serialization(self): callbacks_model_json2 = callbacks_model.to_dict() assert callbacks_model_json2 == callbacks_model_json -class TestCatalogEntry(): + +class TestCatalogEntry: """ Test Class for CatalogEntry """ @@ -3559,26 +3285,26 @@ def test_catalog_entry_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - overview_model = {} # Overview + overview_model = {} # Overview overview_model['display_name'] = 'testString' overview_model['long_description'] = 'testString' overview_model['description'] = 'testString' overview_model['featured_description'] = 'testString' - image_model = {} # Image + image_model = {} # Image image_model['image'] = 'testString' image_model['small_image'] = 'testString' image_model['medium_image'] = 'testString' image_model['feature_image'] = 'testString' - provider_model = {} # Provider + provider_model = {} # Provider provider_model['email'] = 'testString' provider_model['name'] = 'testString' provider_model['contact'] = 'testString' provider_model['support_email'] = 'testString' provider_model['phone'] = 'testString' - cf_meta_data_model = {} # CFMetaData + cf_meta_data_model = {} # CFMetaData cf_meta_data_model['type'] = 'testString' cf_meta_data_model['iam_compatible'] = True cf_meta_data_model['unique_api_key'] = True @@ -3594,7 +3320,7 @@ def test_catalog_entry_serialization(self): cf_meta_data_model['service_key_supported'] = True cf_meta_data_model['cf_guid'] = {} - plan_meta_data_model = {} # PlanMetaData + plan_meta_data_model = {} # PlanMetaData plan_meta_data_model['bindable'] = True plan_meta_data_model['reservable'] = True plan_meta_data_model['allow_internal_users'] = True @@ -3605,16 +3331,16 @@ def test_catalog_entry_serialization(self): plan_meta_data_model['service_check_enabled'] = True plan_meta_data_model['cf_guid'] = {} - alias_meta_data_model = {} # AliasMetaData + alias_meta_data_model = {} # AliasMetaData alias_meta_data_model['type'] = 'testString' alias_meta_data_model['plan_id'] = 'testString' - source_meta_data_model = {} # SourceMetaData + source_meta_data_model = {} # SourceMetaData source_meta_data_model['path'] = 'testString' source_meta_data_model['type'] = 'testString' source_meta_data_model['url'] = 'testString' - template_meta_data_model = {} # TemplateMetaData + template_meta_data_model = {} # TemplateMetaData template_meta_data_model['services'] = ['testString'] template_meta_data_model['default_memory'] = 38 template_meta_data_model['start_cmd'] = 'testString' @@ -3626,20 +3352,20 @@ def test_catalog_entry_serialization(self): template_meta_data_model['buildpack'] = 'testString' template_meta_data_model['environment_variables'] = {} - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' ui_meta_media_model['URL'] = 'testString' ui_meta_media_model['source'] = bullets_model - strings_model = {} # Strings + strings_model = {} # Strings strings_model['bullets'] = [bullets_model] strings_model['media'] = [ui_meta_media_model] strings_model['not_creatable_msg'] = 'testString' @@ -3648,7 +3374,7 @@ def test_catalog_entry_serialization(self): strings_model['popup_warning_message'] = 'testString' strings_model['instruction'] = 'testString' - urls_model = {} # URLS + urls_model = {} # URLS urls_model['doc_url'] = 'testString' urls_model['instructions_url'] = 'testString' urls_model['api_url'] = 'testString' @@ -3662,7 +3388,7 @@ def test_catalog_entry_serialization(self): urls_model['registration_url'] = 'testString' urls_model['apidocsurl'] = 'testString' - ui_meta_data_model = {} # UIMetaData + ui_meta_data_model = {} # UIMetaData ui_meta_data_model['strings'] = {} ui_meta_data_model['urls'] = urls_model ui_meta_data_model['embeddable_dashboard'] = 'testString' @@ -3677,18 +3403,18 @@ def test_catalog_entry_serialization(self): ui_meta_data_model['hide_lite_metering'] = True ui_meta_data_model['no_upgrade_next_step'] = True - dr_meta_data_model = {} # DRMetaData + dr_meta_data_model = {} # DRMetaData dr_meta_data_model['dr'] = True dr_meta_data_model['description'] = 'testString' - sla_meta_data_model = {} # SLAMetaData + sla_meta_data_model = {} # SLAMetaData sla_meta_data_model['terms'] = 'testString' sla_meta_data_model['tenancy'] = 'testString' sla_meta_data_model['provisioning'] = 'testString' sla_meta_data_model['responsiveness'] = 'testString' sla_meta_data_model['dr'] = dr_meta_data_model - callbacks_model = {} # Callbacks + callbacks_model = {} # Callbacks callbacks_model['controller_url'] = 'testString' callbacks_model['broker_url'] = 'testString' callbacks_model['broker_proxy_url'] = 'testString' @@ -3700,22 +3426,22 @@ def test_catalog_entry_serialization(self): callbacks_model['service_monitor_app'] = 'testString' callbacks_model['api_endpoint'] = {} - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - metrics_model = {} # Metrics + metrics_model = {} # Metrics metrics_model['part_ref'] = 'testString' metrics_model['metric_id'] = 'testString' metrics_model['tier_model'] = 'testString' @@ -3730,17 +3456,17 @@ def test_catalog_entry_serialization(self): metrics_model['effective_until'] = '2020-01-28T18:40:40.123456Z' metrics_model['amounts'] = [amount_model] - catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing + catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing catalog_entry_metadata_pricing_model['type'] = 'testString' catalog_entry_metadata_pricing_model['origin'] = 'testString' catalog_entry_metadata_pricing_model['starting_price'] = starting_price_model catalog_entry_metadata_pricing_model['metrics'] = [metrics_model] - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' - catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment + catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment catalog_entry_metadata_deployment_model['location'] = 'testString' catalog_entry_metadata_deployment_model['location_url'] = 'testString' catalog_entry_metadata_deployment_model['original_location'] = 'testString' @@ -3751,7 +3477,7 @@ def test_catalog_entry_serialization(self): catalog_entry_metadata_deployment_model['supports_rc_migration'] = True catalog_entry_metadata_deployment_model['target_network'] = 'testString' - catalog_entry_metadata_model = {} # CatalogEntryMetadata + catalog_entry_metadata_model = {} # CatalogEntryMetadata catalog_entry_metadata_model['rc_compatible'] = True catalog_entry_metadata_model['service'] = cf_meta_data_model catalog_entry_metadata_model['plan'] = plan_meta_data_model @@ -3804,7 +3530,8 @@ def test_catalog_entry_serialization(self): catalog_entry_model_json2 = catalog_entry_model.to_dict() assert catalog_entry_model_json2 == catalog_entry_model_json -class TestCatalogEntryMetadata(): + +class TestCatalogEntryMetadata: """ Test Class for CatalogEntryMetadata """ @@ -3816,7 +3543,7 @@ def test_catalog_entry_metadata_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - cf_meta_data_model = {} # CFMetaData + cf_meta_data_model = {} # CFMetaData cf_meta_data_model['type'] = 'testString' cf_meta_data_model['iam_compatible'] = True cf_meta_data_model['unique_api_key'] = True @@ -3832,7 +3559,7 @@ def test_catalog_entry_metadata_serialization(self): cf_meta_data_model['service_key_supported'] = True cf_meta_data_model['cf_guid'] = {} - plan_meta_data_model = {} # PlanMetaData + plan_meta_data_model = {} # PlanMetaData plan_meta_data_model['bindable'] = True plan_meta_data_model['reservable'] = True plan_meta_data_model['allow_internal_users'] = True @@ -3843,16 +3570,16 @@ def test_catalog_entry_metadata_serialization(self): plan_meta_data_model['service_check_enabled'] = True plan_meta_data_model['cf_guid'] = {} - alias_meta_data_model = {} # AliasMetaData + alias_meta_data_model = {} # AliasMetaData alias_meta_data_model['type'] = 'testString' alias_meta_data_model['plan_id'] = 'testString' - source_meta_data_model = {} # SourceMetaData + source_meta_data_model = {} # SourceMetaData source_meta_data_model['path'] = 'testString' source_meta_data_model['type'] = 'testString' source_meta_data_model['url'] = 'testString' - template_meta_data_model = {} # TemplateMetaData + template_meta_data_model = {} # TemplateMetaData template_meta_data_model['services'] = ['testString'] template_meta_data_model['default_memory'] = 38 template_meta_data_model['start_cmd'] = 'testString' @@ -3864,20 +3591,20 @@ def test_catalog_entry_metadata_serialization(self): template_meta_data_model['buildpack'] = 'testString' template_meta_data_model['environment_variables'] = {} - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' ui_meta_media_model['URL'] = 'testString' ui_meta_media_model['source'] = bullets_model - strings_model = {} # Strings + strings_model = {} # Strings strings_model['bullets'] = [bullets_model] strings_model['media'] = [ui_meta_media_model] strings_model['not_creatable_msg'] = 'testString' @@ -3886,7 +3613,7 @@ def test_catalog_entry_metadata_serialization(self): strings_model['popup_warning_message'] = 'testString' strings_model['instruction'] = 'testString' - urls_model = {} # URLS + urls_model = {} # URLS urls_model['doc_url'] = 'testString' urls_model['instructions_url'] = 'testString' urls_model['api_url'] = 'testString' @@ -3900,7 +3627,7 @@ def test_catalog_entry_metadata_serialization(self): urls_model['registration_url'] = 'testString' urls_model['apidocsurl'] = 'testString' - ui_meta_data_model = {} # UIMetaData + ui_meta_data_model = {} # UIMetaData ui_meta_data_model['strings'] = {} ui_meta_data_model['urls'] = urls_model ui_meta_data_model['embeddable_dashboard'] = 'testString' @@ -3915,18 +3642,18 @@ def test_catalog_entry_metadata_serialization(self): ui_meta_data_model['hide_lite_metering'] = True ui_meta_data_model['no_upgrade_next_step'] = True - dr_meta_data_model = {} # DRMetaData + dr_meta_data_model = {} # DRMetaData dr_meta_data_model['dr'] = True dr_meta_data_model['description'] = 'testString' - sla_meta_data_model = {} # SLAMetaData + sla_meta_data_model = {} # SLAMetaData sla_meta_data_model['terms'] = 'testString' sla_meta_data_model['tenancy'] = 'testString' sla_meta_data_model['provisioning'] = 'testString' sla_meta_data_model['responsiveness'] = 'testString' sla_meta_data_model['dr'] = dr_meta_data_model - callbacks_model = {} # Callbacks + callbacks_model = {} # Callbacks callbacks_model['controller_url'] = 'testString' callbacks_model['broker_url'] = 'testString' callbacks_model['broker_proxy_url'] = 'testString' @@ -3938,22 +3665,22 @@ def test_catalog_entry_metadata_serialization(self): callbacks_model['service_monitor_app'] = 'testString' callbacks_model['api_endpoint'] = {} - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - metrics_model = {} # Metrics + metrics_model = {} # Metrics metrics_model['part_ref'] = 'testString' metrics_model['metric_id'] = 'testString' metrics_model['tier_model'] = 'testString' @@ -3968,17 +3695,17 @@ def test_catalog_entry_metadata_serialization(self): metrics_model['effective_until'] = '2020-01-28T18:40:40.123456Z' metrics_model['amounts'] = [amount_model] - catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing + catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing catalog_entry_metadata_pricing_model['type'] = 'testString' catalog_entry_metadata_pricing_model['origin'] = 'testString' catalog_entry_metadata_pricing_model['starting_price'] = starting_price_model catalog_entry_metadata_pricing_model['metrics'] = [metrics_model] - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' - catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment + catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment catalog_entry_metadata_deployment_model['location'] = 'testString' catalog_entry_metadata_deployment_model['location_url'] = 'testString' catalog_entry_metadata_deployment_model['original_location'] = 'testString' @@ -4021,7 +3748,8 @@ def test_catalog_entry_metadata_serialization(self): catalog_entry_metadata_model_json2 = catalog_entry_metadata_model.to_dict() assert catalog_entry_metadata_model_json2 == catalog_entry_metadata_model_json -class TestCatalogEntryMetadataDeployment(): + +class TestCatalogEntryMetadataDeployment: """ Test Class for CatalogEntryMetadataDeployment """ @@ -4033,7 +3761,7 @@ def test_catalog_entry_metadata_deployment_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' @@ -4050,12 +3778,18 @@ def test_catalog_entry_metadata_deployment_serialization(self): catalog_entry_metadata_deployment_model_json['target_network'] = 'testString' # Construct a model instance of CatalogEntryMetadataDeployment by calling from_dict on the json representation - catalog_entry_metadata_deployment_model = CatalogEntryMetadataDeployment.from_dict(catalog_entry_metadata_deployment_model_json) + catalog_entry_metadata_deployment_model = CatalogEntryMetadataDeployment.from_dict( + catalog_entry_metadata_deployment_model_json + ) assert catalog_entry_metadata_deployment_model != False # Construct a model instance of CatalogEntryMetadataDeployment by calling from_dict on the json representation - catalog_entry_metadata_deployment_model_dict = CatalogEntryMetadataDeployment.from_dict(catalog_entry_metadata_deployment_model_json).__dict__ - catalog_entry_metadata_deployment_model2 = CatalogEntryMetadataDeployment(**catalog_entry_metadata_deployment_model_dict) + catalog_entry_metadata_deployment_model_dict = CatalogEntryMetadataDeployment.from_dict( + catalog_entry_metadata_deployment_model_json + ).__dict__ + catalog_entry_metadata_deployment_model2 = CatalogEntryMetadataDeployment( + **catalog_entry_metadata_deployment_model_dict + ) # Verify the model instances are equivalent assert catalog_entry_metadata_deployment_model == catalog_entry_metadata_deployment_model2 @@ -4064,7 +3798,8 @@ def test_catalog_entry_metadata_deployment_serialization(self): catalog_entry_metadata_deployment_model_json2 = catalog_entry_metadata_deployment_model.to_dict() assert catalog_entry_metadata_deployment_model_json2 == catalog_entry_metadata_deployment_model_json -class TestCatalogEntryMetadataPricing(): + +class TestCatalogEntryMetadataPricing: """ Test Class for CatalogEntryMetadataPricing """ @@ -4076,22 +3811,22 @@ def test_catalog_entry_metadata_pricing_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - metrics_model = {} # Metrics + metrics_model = {} # Metrics metrics_model['part_ref'] = 'testString' metrics_model['metric_id'] = 'testString' metrics_model['tier_model'] = 'testString' @@ -4114,11 +3849,15 @@ def test_catalog_entry_metadata_pricing_serialization(self): catalog_entry_metadata_pricing_model_json['metrics'] = [metrics_model] # Construct a model instance of CatalogEntryMetadataPricing by calling from_dict on the json representation - catalog_entry_metadata_pricing_model = CatalogEntryMetadataPricing.from_dict(catalog_entry_metadata_pricing_model_json) + catalog_entry_metadata_pricing_model = CatalogEntryMetadataPricing.from_dict( + catalog_entry_metadata_pricing_model_json + ) assert catalog_entry_metadata_pricing_model != False # Construct a model instance of CatalogEntryMetadataPricing by calling from_dict on the json representation - catalog_entry_metadata_pricing_model_dict = CatalogEntryMetadataPricing.from_dict(catalog_entry_metadata_pricing_model_json).__dict__ + catalog_entry_metadata_pricing_model_dict = CatalogEntryMetadataPricing.from_dict( + catalog_entry_metadata_pricing_model_json + ).__dict__ catalog_entry_metadata_pricing_model2 = CatalogEntryMetadataPricing(**catalog_entry_metadata_pricing_model_dict) # Verify the model instances are equivalent @@ -4128,7 +3867,8 @@ def test_catalog_entry_metadata_pricing_serialization(self): catalog_entry_metadata_pricing_model_json2 = catalog_entry_metadata_pricing_model.to_dict() assert catalog_entry_metadata_pricing_model_json2 == catalog_entry_metadata_pricing_model_json -class TestDRMetaData(): + +class TestDRMetaData: """ Test Class for DRMetaData """ @@ -4158,7 +3898,8 @@ def test_dr_meta_data_serialization(self): dr_meta_data_model_json2 = dr_meta_data_model.to_dict() assert dr_meta_data_model_json2 == dr_meta_data_model_json -class TestDeploymentBase(): + +class TestDeploymentBase: """ Test Class for DeploymentBase """ @@ -4170,7 +3911,7 @@ def test_deployment_base_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' @@ -4201,7 +3942,8 @@ def test_deployment_base_serialization(self): deployment_base_model_json2 = deployment_base_model.to_dict() assert deployment_base_model_json2 == deployment_base_model_json -class TestEntrySearchResult(): + +class TestEntrySearchResult: """ Test Class for EntrySearchResult """ @@ -4213,26 +3955,26 @@ def test_entry_search_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - overview_model = {} # Overview + overview_model = {} # Overview overview_model['display_name'] = 'testString' overview_model['long_description'] = 'testString' overview_model['description'] = 'testString' overview_model['featured_description'] = 'testString' - image_model = {} # Image + image_model = {} # Image image_model['image'] = 'testString' image_model['small_image'] = 'testString' image_model['medium_image'] = 'testString' image_model['feature_image'] = 'testString' - provider_model = {} # Provider + provider_model = {} # Provider provider_model['email'] = 'testString' provider_model['name'] = 'testString' provider_model['contact'] = 'testString' provider_model['support_email'] = 'testString' provider_model['phone'] = 'testString' - cf_meta_data_model = {} # CFMetaData + cf_meta_data_model = {} # CFMetaData cf_meta_data_model['type'] = 'testString' cf_meta_data_model['iam_compatible'] = True cf_meta_data_model['unique_api_key'] = True @@ -4248,7 +3990,7 @@ def test_entry_search_result_serialization(self): cf_meta_data_model['service_key_supported'] = True cf_meta_data_model['cf_guid'] = {} - plan_meta_data_model = {} # PlanMetaData + plan_meta_data_model = {} # PlanMetaData plan_meta_data_model['bindable'] = True plan_meta_data_model['reservable'] = True plan_meta_data_model['allow_internal_users'] = True @@ -4259,16 +4001,16 @@ def test_entry_search_result_serialization(self): plan_meta_data_model['service_check_enabled'] = True plan_meta_data_model['cf_guid'] = {} - alias_meta_data_model = {} # AliasMetaData + alias_meta_data_model = {} # AliasMetaData alias_meta_data_model['type'] = 'testString' alias_meta_data_model['plan_id'] = 'testString' - source_meta_data_model = {} # SourceMetaData + source_meta_data_model = {} # SourceMetaData source_meta_data_model['path'] = 'testString' source_meta_data_model['type'] = 'testString' source_meta_data_model['url'] = 'testString' - template_meta_data_model = {} # TemplateMetaData + template_meta_data_model = {} # TemplateMetaData template_meta_data_model['services'] = ['testString'] template_meta_data_model['default_memory'] = 38 template_meta_data_model['start_cmd'] = 'testString' @@ -4280,20 +4022,20 @@ def test_entry_search_result_serialization(self): template_meta_data_model['buildpack'] = 'testString' template_meta_data_model['environment_variables'] = {} - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' ui_meta_media_model['URL'] = 'testString' ui_meta_media_model['source'] = bullets_model - strings_model = {} # Strings + strings_model = {} # Strings strings_model['bullets'] = [bullets_model] strings_model['media'] = [ui_meta_media_model] strings_model['not_creatable_msg'] = 'testString' @@ -4302,7 +4044,7 @@ def test_entry_search_result_serialization(self): strings_model['popup_warning_message'] = 'testString' strings_model['instruction'] = 'testString' - urls_model = {} # URLS + urls_model = {} # URLS urls_model['doc_url'] = 'testString' urls_model['instructions_url'] = 'testString' urls_model['api_url'] = 'testString' @@ -4316,7 +4058,7 @@ def test_entry_search_result_serialization(self): urls_model['registration_url'] = 'testString' urls_model['apidocsurl'] = 'testString' - ui_meta_data_model = {} # UIMetaData + ui_meta_data_model = {} # UIMetaData ui_meta_data_model['strings'] = {} ui_meta_data_model['urls'] = urls_model ui_meta_data_model['embeddable_dashboard'] = 'testString' @@ -4331,18 +4073,18 @@ def test_entry_search_result_serialization(self): ui_meta_data_model['hide_lite_metering'] = True ui_meta_data_model['no_upgrade_next_step'] = True - dr_meta_data_model = {} # DRMetaData + dr_meta_data_model = {} # DRMetaData dr_meta_data_model['dr'] = True dr_meta_data_model['description'] = 'testString' - sla_meta_data_model = {} # SLAMetaData + sla_meta_data_model = {} # SLAMetaData sla_meta_data_model['terms'] = 'testString' sla_meta_data_model['tenancy'] = 'testString' sla_meta_data_model['provisioning'] = 'testString' sla_meta_data_model['responsiveness'] = 'testString' sla_meta_data_model['dr'] = dr_meta_data_model - callbacks_model = {} # Callbacks + callbacks_model = {} # Callbacks callbacks_model['controller_url'] = 'testString' callbacks_model['broker_url'] = 'testString' callbacks_model['broker_proxy_url'] = 'testString' @@ -4354,22 +4096,22 @@ def test_entry_search_result_serialization(self): callbacks_model['service_monitor_app'] = 'testString' callbacks_model['api_endpoint'] = {} - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - metrics_model = {} # Metrics + metrics_model = {} # Metrics metrics_model['part_ref'] = 'testString' metrics_model['metric_id'] = 'testString' metrics_model['tier_model'] = 'testString' @@ -4384,17 +4126,17 @@ def test_entry_search_result_serialization(self): metrics_model['effective_until'] = '2020-01-28T18:40:40.123456Z' metrics_model['amounts'] = [amount_model] - catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing + catalog_entry_metadata_pricing_model = {} # CatalogEntryMetadataPricing catalog_entry_metadata_pricing_model['type'] = 'testString' catalog_entry_metadata_pricing_model['origin'] = 'testString' catalog_entry_metadata_pricing_model['starting_price'] = starting_price_model catalog_entry_metadata_pricing_model['metrics'] = [metrics_model] - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' - catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment + catalog_entry_metadata_deployment_model = {} # CatalogEntryMetadataDeployment catalog_entry_metadata_deployment_model['location'] = 'testString' catalog_entry_metadata_deployment_model['location_url'] = 'testString' catalog_entry_metadata_deployment_model['original_location'] = 'testString' @@ -4405,7 +4147,7 @@ def test_entry_search_result_serialization(self): catalog_entry_metadata_deployment_model['supports_rc_migration'] = True catalog_entry_metadata_deployment_model['target_network'] = 'testString' - catalog_entry_metadata_model = {} # CatalogEntryMetadata + catalog_entry_metadata_model = {} # CatalogEntryMetadata catalog_entry_metadata_model['rc_compatible'] = True catalog_entry_metadata_model['service'] = cf_meta_data_model catalog_entry_metadata_model['plan'] = plan_meta_data_model @@ -4421,7 +4163,7 @@ def test_entry_search_result_serialization(self): catalog_entry_metadata_model['pricing'] = catalog_entry_metadata_pricing_model catalog_entry_metadata_model['deployment'] = catalog_entry_metadata_deployment_model - catalog_entry_model = {} # CatalogEntry + catalog_entry_model = {} # CatalogEntry catalog_entry_model['name'] = 'testString' catalog_entry_model['kind'] = 'service' catalog_entry_model['overview_ui'] = {} @@ -4469,7 +4211,8 @@ def test_entry_search_result_serialization(self): entry_search_result_model_json2 = entry_search_result_model.to_dict() assert entry_search_result_model_json2 == entry_search_result_model_json -class TestImage(): + +class TestImage: """ Test Class for Image """ @@ -4501,7 +4244,8 @@ def test_image_serialization(self): image_model_json2 = image_model.to_dict() assert image_model_json2 == image_model_json -class TestMessage(): + +class TestMessage: """ Test Class for Message """ @@ -4513,13 +4257,13 @@ def test_message_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - visibility_detail_accounts_model = {} # VisibilityDetailAccounts + visibility_detail_accounts_model = {} # VisibilityDetailAccounts visibility_detail_accounts_model['_accountid_'] = 'testString' - visibility_detail_model = {} # VisibilityDetail + visibility_detail_model = {} # VisibilityDetail visibility_detail_model['accounts'] = visibility_detail_accounts_model - visibility_model = {} # Visibility + visibility_model = {} # Visibility visibility_model['restrictions'] = 'testString' visibility_model['owner'] = 'testString' visibility_model['extendable'] = True @@ -4556,7 +4300,8 @@ def test_message_serialization(self): message_model_json2 = message_model.to_dict() assert message_model_json2 == message_model_json -class TestMetrics(): + +class TestMetrics: """ Test Class for Metrics """ @@ -4568,11 +4313,11 @@ def test_metrics_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] @@ -4608,7 +4353,8 @@ def test_metrics_serialization(self): metrics_model_json2 = metrics_model.to_dict() assert metrics_model_json2 == metrics_model_json -class TestObjectMetadataSet(): + +class TestObjectMetadataSet: """ Test Class for ObjectMetadataSet """ @@ -4620,7 +4366,7 @@ def test_object_metadata_set_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - cf_meta_data_model = {} # CFMetaData + cf_meta_data_model = {} # CFMetaData cf_meta_data_model['type'] = 'testString' cf_meta_data_model['iam_compatible'] = True cf_meta_data_model['unique_api_key'] = True @@ -4636,7 +4382,7 @@ def test_object_metadata_set_serialization(self): cf_meta_data_model['service_key_supported'] = True cf_meta_data_model['cf_guid'] = {} - plan_meta_data_model = {} # PlanMetaData + plan_meta_data_model = {} # PlanMetaData plan_meta_data_model['bindable'] = True plan_meta_data_model['reservable'] = True plan_meta_data_model['allow_internal_users'] = True @@ -4647,16 +4393,16 @@ def test_object_metadata_set_serialization(self): plan_meta_data_model['service_check_enabled'] = True plan_meta_data_model['cf_guid'] = {} - alias_meta_data_model = {} # AliasMetaData + alias_meta_data_model = {} # AliasMetaData alias_meta_data_model['type'] = 'testString' alias_meta_data_model['plan_id'] = 'testString' - source_meta_data_model = {} # SourceMetaData + source_meta_data_model = {} # SourceMetaData source_meta_data_model['path'] = 'testString' source_meta_data_model['type'] = 'testString' source_meta_data_model['url'] = 'testString' - template_meta_data_model = {} # TemplateMetaData + template_meta_data_model = {} # TemplateMetaData template_meta_data_model['services'] = ['testString'] template_meta_data_model['default_memory'] = 38 template_meta_data_model['start_cmd'] = 'testString' @@ -4668,20 +4414,20 @@ def test_object_metadata_set_serialization(self): template_meta_data_model['buildpack'] = 'testString' template_meta_data_model['environment_variables'] = {} - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' ui_meta_media_model['URL'] = 'testString' ui_meta_media_model['source'] = bullets_model - strings_model = {} # Strings + strings_model = {} # Strings strings_model['bullets'] = [bullets_model] strings_model['media'] = [ui_meta_media_model] strings_model['not_creatable_msg'] = 'testString' @@ -4690,7 +4436,7 @@ def test_object_metadata_set_serialization(self): strings_model['popup_warning_message'] = 'testString' strings_model['instruction'] = 'testString' - urls_model = {} # URLS + urls_model = {} # URLS urls_model['doc_url'] = 'testString' urls_model['instructions_url'] = 'testString' urls_model['api_url'] = 'testString' @@ -4704,7 +4450,7 @@ def test_object_metadata_set_serialization(self): urls_model['registration_url'] = 'testString' urls_model['apidocsurl'] = 'testString' - ui_meta_data_model = {} # UIMetaData + ui_meta_data_model = {} # UIMetaData ui_meta_data_model['strings'] = {} ui_meta_data_model['urls'] = urls_model ui_meta_data_model['embeddable_dashboard'] = 'testString' @@ -4719,18 +4465,18 @@ def test_object_metadata_set_serialization(self): ui_meta_data_model['hide_lite_metering'] = True ui_meta_data_model['no_upgrade_next_step'] = True - dr_meta_data_model = {} # DRMetaData + dr_meta_data_model = {} # DRMetaData dr_meta_data_model['dr'] = True dr_meta_data_model['description'] = 'testString' - sla_meta_data_model = {} # SLAMetaData + sla_meta_data_model = {} # SLAMetaData sla_meta_data_model['terms'] = 'testString' sla_meta_data_model['tenancy'] = 'testString' sla_meta_data_model['provisioning'] = 'testString' sla_meta_data_model['responsiveness'] = 'testString' sla_meta_data_model['dr'] = dr_meta_data_model - callbacks_model = {} # Callbacks + callbacks_model = {} # Callbacks callbacks_model['controller_url'] = 'testString' callbacks_model['broker_url'] = 'testString' callbacks_model['broker_proxy_url'] = 'testString' @@ -4742,31 +4488,31 @@ def test_object_metadata_set_serialization(self): callbacks_model['service_monitor_app'] = 'testString' callbacks_model['api_endpoint'] = {} - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - pricing_set_model = {} # PricingSet + pricing_set_model = {} # PricingSet pricing_set_model['type'] = 'testString' pricing_set_model['origin'] = 'testString' pricing_set_model['starting_price'] = starting_price_model - broker_model = {} # Broker + broker_model = {} # Broker broker_model['name'] = 'testString' broker_model['guid'] = 'testString' - deployment_base_model = {} # DeploymentBase + deployment_base_model = {} # DeploymentBase deployment_base_model['location'] = 'testString' deployment_base_model['location_url'] = 'testString' deployment_base_model['original_location'] = 'testString' @@ -4809,7 +4555,8 @@ def test_object_metadata_set_serialization(self): object_metadata_set_model_json2 = object_metadata_set_model.to_dict() assert object_metadata_set_model_json2 == object_metadata_set_model_json -class TestOverview(): + +class TestOverview: """ Test Class for Overview """ @@ -4841,7 +4588,8 @@ def test_overview_serialization(self): overview_model_json2 = overview_model.to_dict() assert overview_model_json2 == overview_model_json -class TestPlanMetaData(): + +class TestPlanMetaData: """ Test Class for PlanMetaData """ @@ -4878,7 +4626,8 @@ def test_plan_meta_data_serialization(self): plan_meta_data_model_json2 = plan_meta_data_model.to_dict() assert plan_meta_data_model_json2 == plan_meta_data_model_json -class TestPrice(): + +class TestPrice: """ Test Class for Price """ @@ -4908,7 +4657,8 @@ def test_price_serialization(self): price_model_json2 = price_model.to_dict() assert price_model_json2 == price_model_json -class TestPricingGet(): + +class TestPricingGet: """ Test Class for PricingGet """ @@ -4920,22 +4670,22 @@ def test_pricing_get_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' starting_price_model['amount'] = [amount_model] - metrics_model = {} # Metrics + metrics_model = {} # Metrics metrics_model['part_ref'] = 'testString' metrics_model['metric_id'] = 'testString' metrics_model['tier_model'] = 'testString' @@ -4972,7 +4722,8 @@ def test_pricing_get_serialization(self): pricing_get_model_json2 = pricing_get_model.to_dict() assert pricing_get_model_json2 == pricing_get_model_json -class TestPricingSet(): + +class TestPricingSet: """ Test Class for PricingSet """ @@ -4984,16 +4735,16 @@ def test_pricing_set_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] - starting_price_model = {} # StartingPrice + starting_price_model = {} # StartingPrice starting_price_model['plan_id'] = 'testString' starting_price_model['deployment_id'] = 'testString' starting_price_model['unit'] = 'testString' @@ -5020,7 +4771,8 @@ def test_pricing_set_serialization(self): pricing_set_model_json2 = pricing_set_model.to_dict() assert pricing_set_model_json2 == pricing_set_model_json -class TestProvider(): + +class TestProvider: """ Test Class for Provider """ @@ -5053,7 +4805,8 @@ def test_provider_serialization(self): provider_model_json2 = provider_model.to_dict() assert provider_model_json2 == provider_model_json -class TestSLAMetaData(): + +class TestSLAMetaData: """ Test Class for SLAMetaData """ @@ -5065,7 +4818,7 @@ def test_sla_meta_data_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - dr_meta_data_model = {} # DRMetaData + dr_meta_data_model = {} # DRMetaData dr_meta_data_model['dr'] = True dr_meta_data_model['description'] = 'testString' @@ -5092,7 +4845,8 @@ def test_sla_meta_data_serialization(self): sla_meta_data_model_json2 = sla_meta_data_model.to_dict() assert sla_meta_data_model_json2 == sla_meta_data_model_json -class TestSourceMetaData(): + +class TestSourceMetaData: """ Test Class for SourceMetaData """ @@ -5123,7 +4877,8 @@ def test_source_meta_data_serialization(self): source_meta_data_model_json2 = source_meta_data_model.to_dict() assert source_meta_data_model_json2 == source_meta_data_model_json -class TestStartingPrice(): + +class TestStartingPrice: """ Test Class for StartingPrice """ @@ -5135,11 +4890,11 @@ def test_starting_price_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - price_model = {} # Price + price_model = {} # Price price_model['quantity_tier'] = 38 price_model['Price'] = 72.5 - amount_model = {} # Amount + amount_model = {} # Amount amount_model['country'] = 'testString' amount_model['currency'] = 'testString' amount_model['prices'] = [price_model] @@ -5166,7 +4921,8 @@ def test_starting_price_serialization(self): starting_price_model_json2 = starting_price_model.to_dict() assert starting_price_model_json2 == starting_price_model_json -class TestStrings(): + +class TestStrings: """ Test Class for Strings """ @@ -5178,13 +4934,13 @@ def test_strings_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' @@ -5216,7 +4972,8 @@ def test_strings_serialization(self): strings_model_json2 = strings_model.to_dict() assert strings_model_json2 == strings_model_json -class TestTemplateMetaData(): + +class TestTemplateMetaData: """ Test Class for TemplateMetaData """ @@ -5228,7 +4985,7 @@ def test_template_meta_data_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - source_meta_data_model = {} # SourceMetaData + source_meta_data_model = {} # SourceMetaData source_meta_data_model['path'] = 'testString' source_meta_data_model['type'] = 'testString' source_meta_data_model['url'] = 'testString' @@ -5261,7 +5018,8 @@ def test_template_meta_data_serialization(self): template_meta_data_model_json2 = template_meta_data_model.to_dict() assert template_meta_data_model_json2 == template_meta_data_model_json -class TestUIMetaData(): + +class TestUIMetaData: """ Test Class for UIMetaData """ @@ -5273,20 +5031,20 @@ def test_ui_meta_data_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' bullets_model['quantity'] = 38 - ui_meta_media_model = {} # UIMetaMedia + ui_meta_media_model = {} # UIMetaMedia ui_meta_media_model['caption'] = 'testString' ui_meta_media_model['thumbnail_url'] = 'testString' ui_meta_media_model['type'] = 'testString' ui_meta_media_model['URL'] = 'testString' ui_meta_media_model['source'] = bullets_model - strings_model = {} # Strings + strings_model = {} # Strings strings_model['bullets'] = [bullets_model] strings_model['media'] = [ui_meta_media_model] strings_model['not_creatable_msg'] = 'testString' @@ -5295,7 +5053,7 @@ def test_ui_meta_data_serialization(self): strings_model['popup_warning_message'] = 'testString' strings_model['instruction'] = 'testString' - urls_model = {} # URLS + urls_model = {} # URLS urls_model['doc_url'] = 'testString' urls_model['instructions_url'] = 'testString' urls_model['api_url'] = 'testString' @@ -5340,7 +5098,8 @@ def test_ui_meta_data_serialization(self): ui_meta_data_model_json2 = ui_meta_data_model.to_dict() assert ui_meta_data_model_json2 == ui_meta_data_model_json -class TestUIMetaMedia(): + +class TestUIMetaMedia: """ Test Class for UIMetaMedia """ @@ -5352,7 +5111,7 @@ def test_ui_meta_media_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - bullets_model = {} # Bullets + bullets_model = {} # Bullets bullets_model['title'] = 'testString' bullets_model['description'] = 'testString' bullets_model['icon'] = 'testString' @@ -5381,7 +5140,8 @@ def test_ui_meta_media_serialization(self): ui_meta_media_model_json2 = ui_meta_media_model.to_dict() assert ui_meta_media_model_json2 == ui_meta_media_model_json -class TestURLS(): + +class TestURLS: """ Test Class for URLS """ @@ -5421,7 +5181,8 @@ def test_urls_serialization(self): urls_model_json2 = urls_model.to_dict() assert urls_model_json2 == urls_model_json -class TestVisibility(): + +class TestVisibility: """ Test Class for Visibility """ @@ -5433,10 +5194,10 @@ def test_visibility_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - visibility_detail_accounts_model = {} # VisibilityDetailAccounts + visibility_detail_accounts_model = {} # VisibilityDetailAccounts visibility_detail_accounts_model['_accountid_'] = 'testString' - visibility_detail_model = {} # VisibilityDetail + visibility_detail_model = {} # VisibilityDetail visibility_detail_model['accounts'] = visibility_detail_accounts_model # Construct a json representation of a Visibility model @@ -5463,7 +5224,8 @@ def test_visibility_serialization(self): visibility_model_json2 = visibility_model.to_dict() assert visibility_model_json2 == visibility_model_json -class TestVisibilityDetail(): + +class TestVisibilityDetail: """ Test Class for VisibilityDetail """ @@ -5475,7 +5237,7 @@ def test_visibility_detail_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - visibility_detail_accounts_model = {} # VisibilityDetailAccounts + visibility_detail_accounts_model = {} # VisibilityDetailAccounts visibility_detail_accounts_model['_accountid_'] = 'testString' # Construct a json representation of a VisibilityDetail model @@ -5497,7 +5259,8 @@ def test_visibility_detail_serialization(self): visibility_detail_model_json2 = visibility_detail_model.to_dict() assert visibility_detail_model_json2 == visibility_detail_model_json -class TestVisibilityDetailAccounts(): + +class TestVisibilityDetailAccounts: """ Test Class for VisibilityDetailAccounts """ @@ -5516,7 +5279,9 @@ def test_visibility_detail_accounts_serialization(self): assert visibility_detail_accounts_model != False # Construct a model instance of VisibilityDetailAccounts by calling from_dict on the json representation - visibility_detail_accounts_model_dict = VisibilityDetailAccounts.from_dict(visibility_detail_accounts_model_json).__dict__ + visibility_detail_accounts_model_dict = VisibilityDetailAccounts.from_dict( + visibility_detail_accounts_model_json + ).__dict__ visibility_detail_accounts_model2 = VisibilityDetailAccounts(**visibility_detail_accounts_model_dict) # Verify the model instances are equivalent diff --git a/test/unit/test_global_search_v2.py b/test/unit/test_global_search_v2.py index ac9dad5b..923a7f58 100644 --- a/test/unit/test_global_search_v2.py +++ b/test/unit/test_global_search_v2.py @@ -28,9 +28,7 @@ from ibm_platform_services.global_search_v2 import * -_service = GlobalSearchV2( - authenticator=NoAuthAuthenticator() - ) +_service = GlobalSearchV2(authenticator=NoAuthAuthenticator()) _base_url = 'https://api.global-search-tagging.cloud.ibm.com' _service.set_service_url(_base_url) @@ -40,7 +38,8 @@ ############################################################################## # region -class TestSearch(): + +class TestSearch: """ Test Class for search """ @@ -62,11 +61,7 @@ def test_search_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/resources/search') mock_response = '{"search_cursor": "search_cursor", "limit": 5, "items": [{"crn": "crn"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values query = 'testString' @@ -88,14 +83,14 @@ def test_search_all_params(self): limit=limit, timeout=timeout, sort=sort, - headers={} + 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 = 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 @@ -107,7 +102,6 @@ def test_search_all_params(self): assert req_body['fields'] == ['testString'] assert req_body['search_cursor'] == 'testString' - @responses.activate def test_search_required_params(self): """ @@ -116,11 +110,7 @@ def test_search_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/resources/search') mock_response = '{"search_cursor": "search_cursor", "limit": 5, "items": [{"crn": "crn"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values query = 'testString' @@ -128,12 +118,7 @@ def test_search_required_params(self): search_cursor = 'testString' # Invoke method - response = _service.search( - query=query, - fields=fields, - search_cursor=search_cursor, - headers={} - ) + response = _service.search(query=query, fields=fields, search_cursor=search_cursor, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -155,7 +140,8 @@ def test_search_required_params(self): ############################################################################## # region -class TestGetSupportedTypes(): + +class TestGetSupportedTypes: """ Test Class for get_supported_types """ @@ -177,16 +163,11 @@ def test_get_supported_types_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resources/supported_types') mock_response = '{"supported_types": ["supported_types"]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_supported_types() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -202,7 +183,7 @@ def test_get_supported_types_all_params(self): # Start of Model Tests ############################################################################## # region -class TestModel_ResultItem(): +class TestModel_ResultItem: """ Test Class for ResultItem """ @@ -215,7 +196,7 @@ def test_result_item_serialization(self): # Construct a json representation of a ResultItem model result_item_model_json = {} result_item_model_json['crn'] = 'testString' - result_item_model_json['foo'] = { 'foo': 'bar' } + result_item_model_json['foo'] = {'foo': 'bar'} # Construct a model instance of ResultItem by calling from_dict on the json representation result_item_model = ResultItem.from_dict(result_item_model_json) @@ -232,7 +213,8 @@ def test_result_item_serialization(self): result_item_model_json2 = result_item_model.to_dict() assert result_item_model_json2 == result_item_model_json -class TestModel_ScanResult(): + +class TestModel_ScanResult: """ Test Class for ScanResult """ @@ -244,9 +226,9 @@ def test_scan_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - result_item_model = {} # ResultItem + result_item_model = {} # ResultItem result_item_model['crn'] = 'testString' - result_item_model['foo'] = { 'foo': 'bar' } + result_item_model['foo'] = {'foo': 'bar'} # Construct a json representation of a ScanResult model scan_result_model_json = {} @@ -269,7 +251,8 @@ def test_scan_result_serialization(self): scan_result_model_json2 = scan_result_model.to_dict() assert scan_result_model_json2 == scan_result_model_json -class TestModel_SupportedTypesList(): + +class TestModel_SupportedTypesList: """ Test Class for SupportedTypesList """ diff --git a/test/unit/test_global_tagging_v1.py b/test/unit/test_global_tagging_v1.py index 1e52d63c..849a1c4d 100644 --- a/test/unit/test_global_tagging_v1.py +++ b/test/unit/test_global_tagging_v1.py @@ -28,9 +28,7 @@ from ibm_platform_services.global_tagging_v1 import * -_service = GlobalTaggingV1( - authenticator=NoAuthAuthenticator() - ) +_service = GlobalTaggingV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://tags.global-search-tagging.cloud.ibm.com' _service.set_service_url(_base_url) @@ -40,7 +38,8 @@ ############################################################################## # region -class TestListTags(): + +class TestListTags: """ Test Class for list_tags """ @@ -62,11 +61,7 @@ def test_list_tags_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"total_count": 0, "offset": 0, "limit": 1, "items": [{"name": "name"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values impersonate_user = 'testString' @@ -94,14 +89,14 @@ def test_list_tags_all_params(self): timeout=timeout, order_by_name=order_by_name, attached_only=attached_only, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string @@ -115,7 +110,6 @@ def test_list_tags_all_params(self): assert 'order_by_name={}'.format(order_by_name) in query_string assert 'attached_only={}'.format('true' if attached_only else 'false') in query_string - @responses.activate def test_list_tags_required_params(self): """ @@ -124,22 +118,17 @@ def test_list_tags_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"total_count": 0, "offset": 0, "limit": 1, "items": [{"name": "name"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_tags() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 -class TestCreateTag(): +class TestCreateTag: """ Test Class for create_tag """ @@ -161,11 +150,7 @@ def test_create_tag_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"results": [{"tag_name": "tag_name", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_names = ['testString'] @@ -175,18 +160,14 @@ def test_create_tag_all_params(self): # Invoke method response = _service.create_tag( - tag_names, - impersonate_user=impersonate_user, - account_id=account_id, - tag_type=tag_type, - headers={} + tag_names, impersonate_user=impersonate_user, account_id=account_id, tag_type=tag_type, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string @@ -195,7 +176,6 @@ def test_create_tag_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['tag_names'] == ['testString'] - @responses.activate def test_create_tag_required_params(self): """ @@ -204,20 +184,13 @@ def test_create_tag_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"results": [{"tag_name": "tag_name", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_names = ['testString'] # Invoke method - response = _service.create_tag( - tag_names, - headers={} - ) + response = _service.create_tag(tag_names, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -226,7 +199,6 @@ def test_create_tag_required_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['tag_names'] == ['testString'] - @responses.activate def test_create_tag_value_error(self): """ @@ -235,11 +207,7 @@ def test_create_tag_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"results": [{"tag_name": "tag_name", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_names = ['testString'] @@ -249,13 +217,12 @@ def test_create_tag_value_error(self): "tag_names": tag_names, } 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()} + 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_tag(**req_copy) - -class TestDeleteTagAll(): +class TestDeleteTagAll: """ Test Class for delete_tag_all """ @@ -277,11 +244,7 @@ def test_delete_tag_all_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"total_count": 11, "errors": true, "items": [{"tag_name": "tag_name", "is_error": true}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values providers = 'ghost' @@ -291,25 +254,20 @@ def test_delete_tag_all_all_params(self): # Invoke method response = _service.delete_tag_all( - providers=providers, - impersonate_user=impersonate_user, - account_id=account_id, - tag_type=tag_type, - headers={} + providers=providers, impersonate_user=impersonate_user, account_id=account_id, tag_type=tag_type, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'providers={}'.format(providers) in query_string assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string assert 'tag_type={}'.format(tag_type) in query_string - @responses.activate def test_delete_tag_all_required_params(self): """ @@ -318,22 +276,17 @@ def test_delete_tag_all_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags') mock_response = '{"total_count": 11, "errors": true, "items": [{"tag_name": "tag_name", "is_error": true}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.delete_tag_all() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 -class TestDeleteTag(): +class TestDeleteTag: """ Test Class for delete_tag """ @@ -355,11 +308,7 @@ def test_delete_tag_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/testString') mock_response = '{"results": [{"provider": "ghost", "is_error": true}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_name = 'testString' @@ -375,21 +324,20 @@ def test_delete_tag_all_params(self): impersonate_user=impersonate_user, account_id=account_id, tag_type=tag_type, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'providers={}'.format(','.join(providers)) in query_string assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string assert 'tag_type={}'.format(tag_type) in query_string - @responses.activate def test_delete_tag_required_params(self): """ @@ -398,26 +346,18 @@ def test_delete_tag_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/testString') mock_response = '{"results": [{"provider": "ghost", "is_error": true}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_name = 'testString' # Invoke method - response = _service.delete_tag( - tag_name, - headers={} - ) + response = _service.delete_tag(tag_name, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_delete_tag_value_error(self): """ @@ -426,11 +366,7 @@ def test_delete_tag_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/testString') mock_response = '{"results": [{"provider": "ghost", "is_error": true}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values tag_name = 'testString' @@ -440,13 +376,12 @@ def test_delete_tag_value_error(self): "tag_name": tag_name, } 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()} + 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_tag(**req_copy) - -class TestAttachTag(): +class TestAttachTag: """ Test Class for attach_tag """ @@ -468,11 +403,7 @@ def test_attach_tag_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/attach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -495,14 +426,14 @@ def test_attach_tag_all_params(self): impersonate_user=impersonate_user, account_id=account_id, tag_type=tag_type, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string @@ -513,7 +444,6 @@ def test_attach_tag_all_params(self): assert req_body['tag_name'] == 'testString' assert req_body['tag_names'] == ['testString'] - @responses.activate def test_attach_tag_required_params(self): """ @@ -522,11 +452,7 @@ def test_attach_tag_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/attach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -539,12 +465,7 @@ def test_attach_tag_required_params(self): tag_names = ['testString'] # Invoke method - response = _service.attach_tag( - resources, - tag_name=tag_name, - tag_names=tag_names, - headers={} - ) + response = _service.attach_tag(resources, tag_name=tag_name, tag_names=tag_names, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -555,7 +476,6 @@ def test_attach_tag_required_params(self): assert req_body['tag_name'] == 'testString' assert req_body['tag_names'] == ['testString'] - @responses.activate def test_attach_tag_value_error(self): """ @@ -564,11 +484,7 @@ def test_attach_tag_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/attach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -585,13 +501,12 @@ def test_attach_tag_value_error(self): "resources": resources, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.attach_tag(**req_copy) - -class TestDetachTag(): +class TestDetachTag: """ Test Class for detach_tag """ @@ -613,11 +528,7 @@ def test_detach_tag_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/detach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -640,14 +551,14 @@ def test_detach_tag_all_params(self): impersonate_user=impersonate_user, account_id=account_id, tag_type=tag_type, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'impersonate_user={}'.format(impersonate_user) in query_string assert 'account_id={}'.format(account_id) in query_string @@ -658,7 +569,6 @@ def test_detach_tag_all_params(self): assert req_body['tag_name'] == 'testString' assert req_body['tag_names'] == ['testString'] - @responses.activate def test_detach_tag_required_params(self): """ @@ -667,11 +577,7 @@ def test_detach_tag_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/detach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -684,12 +590,7 @@ def test_detach_tag_required_params(self): tag_names = ['testString'] # Invoke method - response = _service.detach_tag( - resources, - tag_name=tag_name, - tag_names=tag_names, - headers={} - ) + response = _service.detach_tag(resources, tag_name=tag_name, tag_names=tag_names, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -700,7 +601,6 @@ def test_detach_tag_required_params(self): assert req_body['tag_name'] == 'testString' assert req_body['tag_names'] == ['testString'] - @responses.activate def test_detach_tag_value_error(self): """ @@ -709,11 +609,7 @@ def test_detach_tag_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v3/tags/detach') mock_response = '{"results": [{"resource_id": "resource_id", "is_error": true}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Resource model resource_model = {} @@ -730,12 +626,11 @@ def test_detach_tag_value_error(self): "resources": resources, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.detach_tag(**req_copy) - # endregion ############################################################################## # End of Service: Tags @@ -746,7 +641,7 @@ def test_detach_tag_value_error(self): # Start of Model Tests ############################################################################## # region -class TestModel_CreateTagResults(): +class TestModel_CreateTagResults: """ Test Class for CreateTagResults """ @@ -758,7 +653,7 @@ def test_create_tag_results_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - create_tag_results_results_item_model = {} # CreateTagResultsResultsItem + create_tag_results_results_item_model = {} # CreateTagResultsResultsItem create_tag_results_results_item_model['tag_name'] = 'testString' create_tag_results_results_item_model['is_error'] = True @@ -781,7 +676,8 @@ def test_create_tag_results_serialization(self): create_tag_results_model_json2 = create_tag_results_model.to_dict() assert create_tag_results_model_json2 == create_tag_results_model_json -class TestModel_CreateTagResultsResultsItem(): + +class TestModel_CreateTagResultsResultsItem: """ Test Class for CreateTagResultsResultsItem """ @@ -797,12 +693,18 @@ def test_create_tag_results_results_item_serialization(self): create_tag_results_results_item_model_json['is_error'] = True # Construct a model instance of CreateTagResultsResultsItem by calling from_dict on the json representation - create_tag_results_results_item_model = CreateTagResultsResultsItem.from_dict(create_tag_results_results_item_model_json) + create_tag_results_results_item_model = CreateTagResultsResultsItem.from_dict( + create_tag_results_results_item_model_json + ) assert create_tag_results_results_item_model != False # Construct a model instance of CreateTagResultsResultsItem by calling from_dict on the json representation - create_tag_results_results_item_model_dict = CreateTagResultsResultsItem.from_dict(create_tag_results_results_item_model_json).__dict__ - create_tag_results_results_item_model2 = CreateTagResultsResultsItem(**create_tag_results_results_item_model_dict) + create_tag_results_results_item_model_dict = CreateTagResultsResultsItem.from_dict( + create_tag_results_results_item_model_json + ).__dict__ + create_tag_results_results_item_model2 = CreateTagResultsResultsItem( + **create_tag_results_results_item_model_dict + ) # Verify the model instances are equivalent assert create_tag_results_results_item_model == create_tag_results_results_item_model2 @@ -811,7 +713,8 @@ def test_create_tag_results_results_item_serialization(self): create_tag_results_results_item_model_json2 = create_tag_results_results_item_model.to_dict() assert create_tag_results_results_item_model_json2 == create_tag_results_results_item_model_json -class TestModel_DeleteTagResults(): + +class TestModel_DeleteTagResults: """ Test Class for DeleteTagResults """ @@ -823,10 +726,10 @@ def test_delete_tag_results_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - delete_tag_results_item_model = {} # DeleteTagResultsItem + delete_tag_results_item_model = {} # DeleteTagResultsItem delete_tag_results_item_model['provider'] = 'ghost' delete_tag_results_item_model['is_error'] = True - delete_tag_results_item_model['foo'] = { 'foo': 'bar' } + delete_tag_results_item_model['foo'] = {'foo': 'bar'} # Construct a json representation of a DeleteTagResults model delete_tag_results_model_json = {} @@ -847,7 +750,8 @@ def test_delete_tag_results_serialization(self): delete_tag_results_model_json2 = delete_tag_results_model.to_dict() assert delete_tag_results_model_json2 == delete_tag_results_model_json -class TestModel_DeleteTagResultsItem(): + +class TestModel_DeleteTagResultsItem: """ Test Class for DeleteTagResultsItem """ @@ -861,7 +765,7 @@ def test_delete_tag_results_item_serialization(self): delete_tag_results_item_model_json = {} delete_tag_results_item_model_json['provider'] = 'ghost' delete_tag_results_item_model_json['is_error'] = True - delete_tag_results_item_model_json['foo'] = { 'foo': 'bar' } + delete_tag_results_item_model_json['foo'] = {'foo': 'bar'} # Construct a model instance of DeleteTagResultsItem by calling from_dict on the json representation delete_tag_results_item_model = DeleteTagResultsItem.from_dict(delete_tag_results_item_model_json) @@ -878,7 +782,8 @@ def test_delete_tag_results_item_serialization(self): delete_tag_results_item_model_json2 = delete_tag_results_item_model.to_dict() assert delete_tag_results_item_model_json2 == delete_tag_results_item_model_json -class TestModel_DeleteTagsResult(): + +class TestModel_DeleteTagsResult: """ Test Class for DeleteTagsResult """ @@ -890,7 +795,7 @@ def test_delete_tags_result_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - delete_tags_result_item_model = {} # DeleteTagsResultItem + delete_tags_result_item_model = {} # DeleteTagsResultItem delete_tags_result_item_model['tag_name'] = 'testString' delete_tags_result_item_model['is_error'] = True @@ -915,7 +820,8 @@ def test_delete_tags_result_serialization(self): delete_tags_result_model_json2 = delete_tags_result_model.to_dict() assert delete_tags_result_model_json2 == delete_tags_result_model_json -class TestModel_DeleteTagsResultItem(): + +class TestModel_DeleteTagsResultItem: """ Test Class for DeleteTagsResultItem """ @@ -945,7 +851,8 @@ def test_delete_tags_result_item_serialization(self): delete_tags_result_item_model_json2 = delete_tags_result_item_model.to_dict() assert delete_tags_result_item_model_json2 == delete_tags_result_item_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -975,7 +882,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_Tag(): + +class TestModel_Tag: """ Test Class for Tag """ @@ -1004,7 +912,8 @@ def test_tag_serialization(self): tag_model_json2 = tag_model.to_dict() assert tag_model_json2 == tag_model_json -class TestModel_TagList(): + +class TestModel_TagList: """ Test Class for TagList """ @@ -1016,7 +925,7 @@ def test_tag_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - tag_model = {} # Tag + tag_model = {} # Tag tag_model['name'] = 'testString' # Construct a json representation of a TagList model @@ -1041,7 +950,8 @@ def test_tag_list_serialization(self): tag_list_model_json2 = tag_list_model.to_dict() assert tag_list_model_json2 == tag_list_model_json -class TestModel_TagResults(): + +class TestModel_TagResults: """ Test Class for TagResults """ @@ -1053,8 +963,10 @@ def test_tag_results_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - tag_results_item_model = {} # TagResultsItem - tag_results_item_model['resource_id'] = 'crn:v1:staging:public:resource-controller::a/5c2ac0d93c69e82c6c9c7c78dc4beda3::resource-group:1c061f4485b34360a8f8ee049880dc13' + tag_results_item_model = {} # TagResultsItem + tag_results_item_model[ + 'resource_id' + ] = 'crn:v1:staging:public:resource-controller::a/5c2ac0d93c69e82c6c9c7c78dc4beda3::resource-group:1c061f4485b34360a8f8ee049880dc13' tag_results_item_model['is_error'] = False # Construct a json representation of a TagResults model @@ -1076,7 +988,8 @@ def test_tag_results_serialization(self): tag_results_model_json2 = tag_results_model.to_dict() assert tag_results_model_json2 == tag_results_model_json -class TestModel_TagResultsItem(): + +class TestModel_TagResultsItem: """ Test Class for TagResultsItem """ diff --git a/test/unit/test_iam_access_groups_v2.py b/test/unit/test_iam_access_groups_v2.py index e061004e..ec01c463 100644 --- a/test/unit/test_iam_access_groups_v2.py +++ b/test/unit/test_iam_access_groups_v2.py @@ -31,9 +31,7 @@ from ibm_platform_services.iam_access_groups_v2 import * -_service = IamAccessGroupsV2( - authenticator=NoAuthAuthenticator() -) +_service = IamAccessGroupsV2(authenticator=NoAuthAuthenticator()) _base_url = 'https://iam.cloud.ibm.com' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateAccessGroup(): + +class TestCreateAccessGroup: """ Test Class for create_access_group """ @@ -110,11 +110,7 @@ def test_create_access_group_all_params(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values account_id = 'testString' @@ -124,18 +120,14 @@ def test_create_access_group_all_params(self): # Invoke method response = _service.create_access_group( - account_id, - name, - description=description, - transaction_id=transaction_id, - headers={} + account_id, name, description=description, transaction_id=transaction_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 # Validate body params @@ -160,11 +152,7 @@ def test_create_access_group_required_params(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values account_id = 'testString' @@ -172,18 +160,13 @@ def test_create_access_group_required_params(self): description = 'Group for managers' # Invoke method - response = _service.create_access_group( - account_id, - name, - description=description, - headers={} - ) + response = _service.create_access_group(account_id, name, description=description, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 # Validate body params @@ -208,11 +191,7 @@ def test_create_access_group_value_error(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values account_id = 'testString' @@ -225,7 +204,7 @@ def test_create_access_group_value_error(self): "name": name, } 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()} + 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_access_group(**req_copy) @@ -238,7 +217,8 @@ def test_create_access_group_value_error_with_retries(self): _service.disable_retries() self.test_create_access_group_value_error() -class TestListAccessGroups(): + +class TestListAccessGroups: """ Test Class for list_access_groups """ @@ -251,11 +231,7 @@ def test_list_access_groups_all_params(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "groups": [{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -279,14 +255,14 @@ def test_list_access_groups_all_params(self): sort=sort, show_federated=show_federated, hide_public_access=hide_public_access, - headers={} + 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 = 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 'iam_id={}'.format(iam_id) in query_string @@ -314,26 +290,19 @@ def test_list_access_groups_required_params(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "groups": [{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_access_groups( - account_id, - headers={} - ) + response = _service.list_access_groups(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 = 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 @@ -354,11 +323,7 @@ def test_list_access_groups_value_error(self): # Set up mock url = preprocess_url('/v2/groups') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "groups": [{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -368,7 +333,7 @@ def test_list_access_groups_value_error(self): "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()} + 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_access_groups(**req_copy) @@ -390,16 +355,8 @@ def test_list_access_groups_with_pager_get_next(self): url = preprocess_url('/v2/groups') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1,"groups":[{"id":"id","name":"name","description":"description","account_id":"account_id","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","href":"href","is_federated":true}]}' mock_response2 = '{"total_count":2,"limit":1,"groups":[{"id":"id","name":"name","description":"description","account_id":"account_id","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","href":"href","is_federated":true}]}' - 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) + 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 = [] @@ -429,16 +386,8 @@ def test_list_access_groups_with_pager_get_all(self): url = preprocess_url('/v2/groups') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"limit":1,"groups":[{"id":"id","name":"name","description":"description","account_id":"account_id","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","href":"href","is_federated":true}]}' mock_response2 = '{"total_count":2,"limit":1,"groups":[{"id":"id","name":"name","description":"description","account_id":"account_id","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id","last_modified_at":"2019-01-01T12:00:00.000Z","last_modified_by_id":"last_modified_by_id","href":"href","is_federated":true}]}' - 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) + 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 = AccessGroupsPager( @@ -456,7 +405,8 @@ def test_list_access_groups_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestGetAccessGroup(): + +class TestGetAccessGroup: """ Test Class for get_access_group """ @@ -469,11 +419,7 @@ def test_get_access_group_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -482,17 +428,14 @@ def test_get_access_group_all_params(self): # Invoke method response = _service.get_access_group( - access_group_id, - transaction_id=transaction_id, - show_federated=show_federated, - headers={} + access_group_id, transaction_id=transaction_id, show_federated=show_federated, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'show_federated={}'.format('true' if show_federated else 'false') in query_string @@ -513,20 +456,13 @@ def test_get_access_group_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' # Invoke method - response = _service.get_access_group( - access_group_id, - headers={} - ) + response = _service.get_access_group(access_group_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -549,11 +485,7 @@ def test_get_access_group_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -563,7 +495,7 @@ def test_get_access_group_value_error(self): "access_group_id": access_group_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()} + 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_access_group(**req_copy) @@ -576,7 +508,8 @@ def test_get_access_group_value_error_with_retries(self): _service.disable_retries() self.test_get_access_group_value_error() -class TestUpdateAccessGroup(): + +class TestUpdateAccessGroup: """ Test Class for update_access_group """ @@ -589,11 +522,7 @@ def test_update_access_group_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -604,12 +533,7 @@ def test_update_access_group_all_params(self): # Invoke method response = _service.update_access_group( - access_group_id, - if_match, - name=name, - description=description, - transaction_id=transaction_id, - headers={} + access_group_id, if_match, name=name, description=description, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -637,11 +561,7 @@ def test_update_access_group_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -651,11 +571,7 @@ def test_update_access_group_required_params(self): # Invoke method response = _service.update_access_group( - access_group_id, - if_match, - name=name, - description=description, - headers={} + access_group_id, if_match, name=name, description=description, headers={} ) # Check for correct operation @@ -683,11 +599,7 @@ def test_update_access_group_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString') mock_response = '{"id": "id", "name": "name", "description": "description", "account_id": "account_id", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "href": "href", "is_federated": true}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -701,7 +613,7 @@ def test_update_access_group_value_error(self): "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()} + 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_access_group(**req_copy) @@ -714,7 +626,8 @@ def test_update_access_group_value_error_with_retries(self): _service.disable_retries() self.test_update_access_group_value_error() -class TestDeleteAccessGroup(): + +class TestDeleteAccessGroup: """ Test Class for delete_access_group """ @@ -726,9 +639,7 @@ def test_delete_access_group_all_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -736,18 +647,13 @@ def test_delete_access_group_all_params(self): force = False # Invoke method - response = _service.delete_access_group( - access_group_id, - transaction_id=transaction_id, - force=force, - headers={} - ) + response = _service.delete_access_group(access_group_id, transaction_id=transaction_id, force=force, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'force={}'.format('true' if force else 'false') in query_string @@ -767,18 +673,13 @@ def test_delete_access_group_required_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' # Invoke method - response = _service.delete_access_group( - access_group_id, - headers={} - ) + response = _service.delete_access_group(access_group_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -800,9 +701,7 @@ def test_delete_access_group_value_error(self): """ # Set up mock url = preprocess_url('/v2/groups/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -812,7 +711,7 @@ def test_delete_access_group_value_error(self): "access_group_id": access_group_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()} + 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_access_group(**req_copy) @@ -825,6 +724,7 @@ def test_delete_access_group_value_error_with_retries(self): _service.disable_retries() self.test_delete_access_group_value_error() + # endregion ############################################################################## # End of Service: AccessGroupOperations @@ -835,7 +735,8 @@ def test_delete_access_group_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -862,7 +763,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestIsMemberOfAccessGroup(): + +class TestIsMemberOfAccessGroup: """ Test Class for is_member_of_access_group """ @@ -874,9 +776,7 @@ def test_is_member_of_access_group_all_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.HEAD, - url, - status=204) + responses.add(responses.HEAD, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -885,10 +785,7 @@ def test_is_member_of_access_group_all_params(self): # Invoke method response = _service.is_member_of_access_group( - access_group_id, - iam_id, - transaction_id=transaction_id, - headers={} + access_group_id, iam_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -911,20 +808,14 @@ def test_is_member_of_access_group_required_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.HEAD, - url, - status=204) + responses.add(responses.HEAD, url, status=204) # Set up parameter values access_group_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.is_member_of_access_group( - access_group_id, - iam_id, - headers={} - ) + response = _service.is_member_of_access_group(access_group_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -946,9 +837,7 @@ def test_is_member_of_access_group_value_error(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.HEAD, - url, - status=204) + responses.add(responses.HEAD, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -960,7 +849,7 @@ def test_is_member_of_access_group_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.is_member_of_access_group(**req_copy) @@ -973,7 +862,8 @@ def test_is_member_of_access_group_value_error_with_retries(self): _service.disable_retries() self.test_is_member_of_access_group_value_error() -class TestAddMembersToAccessGroup(): + +class TestAddMembersToAccessGroup: """ Test Class for add_members_to_access_group """ @@ -986,11 +876,7 @@ def test_add_members_to_access_group_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"members": [{"iam_id": "iam_id", "type": "type", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Construct a dict representation of a AddGroupMembersRequestMembersItem model add_group_members_request_members_item_model = {} @@ -1004,10 +890,7 @@ def test_add_members_to_access_group_all_params(self): # Invoke method response = _service.add_members_to_access_group( - access_group_id, - members=members, - transaction_id=transaction_id, - headers={} + access_group_id, members=members, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1034,11 +917,7 @@ def test_add_members_to_access_group_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"members": [{"iam_id": "iam_id", "type": "type", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Construct a dict representation of a AddGroupMembersRequestMembersItem model add_group_members_request_members_item_model = {} @@ -1050,11 +929,7 @@ def test_add_members_to_access_group_required_params(self): members = [add_group_members_request_members_item_model] # Invoke method - response = _service.add_members_to_access_group( - access_group_id, - members=members, - headers={} - ) + response = _service.add_members_to_access_group(access_group_id, members=members, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1080,11 +955,7 @@ def test_add_members_to_access_group_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"members": [{"iam_id": "iam_id", "type": "type", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Construct a dict representation of a AddGroupMembersRequestMembersItem model add_group_members_request_members_item_model = {} @@ -1100,7 +971,7 @@ def test_add_members_to_access_group_value_error(self): "access_group_id": access_group_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_members_to_access_group(**req_copy) @@ -1113,7 +984,8 @@ def test_add_members_to_access_group_value_error_with_retries(self): _service.disable_retries() self.test_add_members_to_access_group_value_error() -class TestListAccessGroupMembers(): + +class TestListAccessGroupMembers: """ Test Class for list_access_group_members """ @@ -1126,11 +998,7 @@ def test_list_access_group_members_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "members": [{"iam_id": "iam_id", "type": "type", "membership_type": "membership_type", "name": "name", "email": "email", "description": "description", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -1152,14 +1020,14 @@ def test_list_access_group_members_all_params(self): type=type, verbose=verbose, sort=sort, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'membership_type={}'.format(membership_type) in query_string assert 'limit={}'.format(limit) in query_string @@ -1185,20 +1053,13 @@ def test_list_access_group_members_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "members": [{"iam_id": "iam_id", "type": "type", "membership_type": "membership_type", "name": "name", "email": "email", "description": "description", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' # Invoke method - response = _service.list_access_group_members( - access_group_id, - headers={} - ) + response = _service.list_access_group_members(access_group_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1221,11 +1082,7 @@ def test_list_access_group_members_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/members') mock_response = '{"limit": 5, "offset": 6, "total_count": 11, "first": {"href": "href"}, "previous": {"href": "href"}, "next": {"href": "href"}, "last": {"href": "href"}, "members": [{"iam_id": "iam_id", "type": "type", "membership_type": "membership_type", "name": "name", "email": "email", "description": "description", "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -1235,7 +1092,7 @@ def test_list_access_group_members_value_error(self): "access_group_id": access_group_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()} + 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_access_group_members(**req_copy) @@ -1257,16 +1114,8 @@ def test_list_access_group_members_with_pager_get_next(self): url = preprocess_url('/v2/groups/testString/members') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"members":[{"iam_id":"iam_id","type":"type","membership_type":"membership_type","name":"name","email":"email","description":"description","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id"}],"limit":1}' mock_response2 = '{"total_count":2,"members":[{"iam_id":"iam_id","type":"type","membership_type":"membership_type","name":"name","email":"email","description":"description","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_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) + 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 = [] @@ -1295,16 +1144,8 @@ def test_list_access_group_members_with_pager_get_all(self): url = preprocess_url('/v2/groups/testString/members') mock_response1 = '{"next":{"href":"https://myhost.com/somePath?offset=1"},"total_count":2,"members":[{"iam_id":"iam_id","type":"type","membership_type":"membership_type","name":"name","email":"email","description":"description","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_by_id"}],"limit":1}' mock_response2 = '{"total_count":2,"members":[{"iam_id":"iam_id","type":"type","membership_type":"membership_type","name":"name","email":"email","description":"description","href":"href","created_at":"2019-01-01T12:00:00.000Z","created_by_id":"created_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) + 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 = AccessGroupMembersPager( @@ -1321,7 +1162,8 @@ def test_list_access_group_members_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestRemoveMemberFromAccessGroup(): + +class TestRemoveMemberFromAccessGroup: """ Test Class for remove_member_from_access_group """ @@ -1333,9 +1175,7 @@ def test_remove_member_from_access_group_all_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -1344,10 +1184,7 @@ def test_remove_member_from_access_group_all_params(self): # Invoke method response = _service.remove_member_from_access_group( - access_group_id, - iam_id, - transaction_id=transaction_id, - headers={} + access_group_id, iam_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1370,20 +1207,14 @@ def test_remove_member_from_access_group_required_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.remove_member_from_access_group( - access_group_id, - iam_id, - headers={} - ) + response = _service.remove_member_from_access_group(access_group_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1405,9 +1236,7 @@ def test_remove_member_from_access_group_value_error(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/members/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -1419,7 +1248,7 @@ def test_remove_member_from_access_group_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_member_from_access_group(**req_copy) @@ -1432,7 +1261,8 @@ def test_remove_member_from_access_group_value_error_with_retries(self): _service.disable_retries() self.test_remove_member_from_access_group_value_error() -class TestRemoveMembersFromAccessGroup(): + +class TestRemoveMembersFromAccessGroup: """ Test Class for remove_members_from_access_group """ @@ -1445,11 +1275,7 @@ def test_remove_members_from_access_group_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members/delete') mock_response = '{"access_group_id": "access_group_id", "members": [{"iam_id": "iam_id", "trace": "trace", "status_code": 11, "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values access_group_id = 'testString' @@ -1458,10 +1284,7 @@ def test_remove_members_from_access_group_all_params(self): # Invoke method response = _service.remove_members_from_access_group( - access_group_id, - members=members, - transaction_id=transaction_id, - headers={} + access_group_id, members=members, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1488,22 +1311,14 @@ def test_remove_members_from_access_group_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/members/delete') mock_response = '{"access_group_id": "access_group_id", "members": [{"iam_id": "iam_id", "trace": "trace", "status_code": 11, "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values access_group_id = 'testString' members = ['IBMId-user1', 'iam-ServiceId-123', 'iam-Profile-123'] # Invoke method - response = _service.remove_members_from_access_group( - access_group_id, - members=members, - headers={} - ) + response = _service.remove_members_from_access_group(access_group_id, members=members, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1529,11 +1344,7 @@ def test_remove_members_from_access_group_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/members/delete') mock_response = '{"access_group_id": "access_group_id", "members": [{"iam_id": "iam_id", "trace": "trace", "status_code": 11, "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values access_group_id = 'testString' @@ -1544,7 +1355,7 @@ def test_remove_members_from_access_group_value_error(self): "access_group_id": access_group_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_members_from_access_group(**req_copy) @@ -1557,7 +1368,8 @@ def test_remove_members_from_access_group_value_error_with_retries(self): _service.disable_retries() self.test_remove_members_from_access_group_value_error() -class TestRemoveMemberFromAllAccessGroups(): + +class TestRemoveMemberFromAllAccessGroups: """ Test Class for remove_member_from_all_access_groups """ @@ -1570,11 +1382,7 @@ def test_remove_member_from_all_access_groups_all_params(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' @@ -1583,17 +1391,14 @@ def test_remove_member_from_all_access_groups_all_params(self): # Invoke method response = _service.remove_member_from_all_access_groups( - account_id, - iam_id, - transaction_id=transaction_id, - headers={} + account_id, iam_id, transaction_id=transaction_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 207 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 @@ -1614,28 +1419,20 @@ def test_remove_member_from_all_access_groups_required_params(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.remove_member_from_all_access_groups( - account_id, - iam_id, - headers={} - ) + response = _service.remove_member_from_all_access_groups(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 207 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 @@ -1656,11 +1453,7 @@ def test_remove_member_from_all_access_groups_value_error(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' @@ -1672,7 +1465,7 @@ def test_remove_member_from_all_access_groups_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_member_from_all_access_groups(**req_copy) @@ -1685,7 +1478,8 @@ def test_remove_member_from_all_access_groups_value_error_with_retries(self): _service.disable_retries() self.test_remove_member_from_all_access_groups_value_error() -class TestAddMemberToMultipleAccessGroups(): + +class TestAddMemberToMultipleAccessGroups: """ Test Class for add_member_to_multiple_access_groups """ @@ -1698,11 +1492,7 @@ def test_add_member_to_multiple_access_groups_all_params(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' @@ -1713,19 +1503,14 @@ def test_add_member_to_multiple_access_groups_all_params(self): # Invoke method response = _service.add_member_to_multiple_access_groups( - account_id, - iam_id, - type=type, - groups=groups, - transaction_id=transaction_id, - headers={} + account_id, iam_id, type=type, groups=groups, transaction_id=transaction_id, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 207 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 # Validate body params @@ -1750,11 +1535,7 @@ def test_add_member_to_multiple_access_groups_required_params(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' @@ -1764,18 +1545,14 @@ def test_add_member_to_multiple_access_groups_required_params(self): # Invoke method response = _service.add_member_to_multiple_access_groups( - account_id, - iam_id, - type=type, - groups=groups, - headers={} + account_id, iam_id, type=type, groups=groups, headers={} ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 207 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + 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 # Validate body params @@ -1800,11 +1577,7 @@ def test_add_member_to_multiple_access_groups_value_error(self): # Set up mock url = preprocess_url('/v2/groups/_allgroups/members/testString') mock_response = '{"iam_id": "iam_id", "groups": [{"access_group_id": "access_group_id", "status_code": 11, "trace": "trace", "errors": [{"code": "code", "message": "message"}]}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=207) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=207) # Set up parameter values account_id = 'testString' @@ -1818,7 +1591,7 @@ def test_add_member_to_multiple_access_groups_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_member_to_multiple_access_groups(**req_copy) @@ -1831,6 +1604,7 @@ def test_add_member_to_multiple_access_groups_value_error_with_retries(self): _service.disable_retries() self.test_add_member_to_multiple_access_groups_value_error() + # endregion ############################################################################## # End of Service: MembershipOperations @@ -1841,7 +1615,8 @@ def test_add_member_to_multiple_access_groups_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1868,7 +1643,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestAddAccessGroupRule(): + +class TestAddAccessGroupRule: """ Test Class for add_access_group_rule """ @@ -1881,11 +1657,7 @@ def test_add_access_group_rule_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -1903,13 +1675,7 @@ def test_add_access_group_rule_all_params(self): # Invoke method response = _service.add_access_group_rule( - access_group_id, - expiration, - realm_name, - conditions, - name=name, - transaction_id=transaction_id, - headers={} + access_group_id, expiration, realm_name, conditions, name=name, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -1939,11 +1705,7 @@ def test_add_access_group_rule_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -1960,12 +1722,7 @@ def test_add_access_group_rule_required_params(self): # Invoke method response = _service.add_access_group_rule( - access_group_id, - expiration, - realm_name, - conditions, - name=name, - headers={} + access_group_id, expiration, realm_name, conditions, name=name, headers={} ) # Check for correct operation @@ -1995,11 +1752,7 @@ def test_add_access_group_rule_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -2022,7 +1775,7 @@ def test_add_access_group_rule_value_error(self): "conditions": conditions, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.add_access_group_rule(**req_copy) @@ -2035,7 +1788,8 @@ def test_add_access_group_rule_value_error_with_retries(self): _service.disable_retries() self.test_add_access_group_rule_value_error() -class TestListAccessGroupRules(): + +class TestListAccessGroupRules: """ Test Class for list_access_group_rules """ @@ -2048,22 +1802,14 @@ def test_list_access_group_rules_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"rules": [{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' transaction_id = 'testString' # Invoke method - response = _service.list_access_group_rules( - access_group_id, - transaction_id=transaction_id, - headers={} - ) + response = _service.list_access_group_rules(access_group_id, transaction_id=transaction_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2086,20 +1832,13 @@ def test_list_access_group_rules_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"rules": [{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' # Invoke method - response = _service.list_access_group_rules( - access_group_id, - headers={} - ) + response = _service.list_access_group_rules(access_group_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2122,11 +1861,7 @@ def test_list_access_group_rules_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules') mock_response = '{"rules": [{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -2136,7 +1871,7 @@ def test_list_access_group_rules_value_error(self): "access_group_id": access_group_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()} + 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_access_group_rules(**req_copy) @@ -2149,7 +1884,8 @@ def test_list_access_group_rules_value_error_with_retries(self): _service.disable_retries() self.test_list_access_group_rules_value_error() -class TestGetAccessGroupRule(): + +class TestGetAccessGroupRule: """ Test Class for get_access_group_rule """ @@ -2162,11 +1898,7 @@ def test_get_access_group_rule_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -2174,12 +1906,7 @@ def test_get_access_group_rule_all_params(self): transaction_id = 'testString' # Invoke method - response = _service.get_access_group_rule( - access_group_id, - rule_id, - transaction_id=transaction_id, - headers={} - ) + response = _service.get_access_group_rule(access_group_id, rule_id, transaction_id=transaction_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2202,22 +1929,14 @@ def test_get_access_group_rule_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' rule_id = 'testString' # Invoke method - response = _service.get_access_group_rule( - access_group_id, - rule_id, - headers={} - ) + response = _service.get_access_group_rule(access_group_id, rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2240,11 +1959,7 @@ def test_get_access_group_rule_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values access_group_id = 'testString' @@ -2256,7 +1971,7 @@ def test_get_access_group_rule_value_error(self): "rule_id": rule_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()} + 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_access_group_rule(**req_copy) @@ -2269,7 +1984,8 @@ def test_get_access_group_rule_value_error_with_retries(self): _service.disable_retries() self.test_get_access_group_rule_value_error() -class TestReplaceAccessGroupRule(): + +class TestReplaceAccessGroupRule: """ Test Class for replace_access_group_rule """ @@ -2282,11 +1998,7 @@ def test_replace_access_group_rule_all_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -2314,7 +2026,7 @@ def test_replace_access_group_rule_all_params(self): conditions, name=name, transaction_id=transaction_id, - headers={} + headers={}, ) # Check for correct operation @@ -2344,11 +2056,7 @@ def test_replace_access_group_rule_required_params(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -2367,14 +2075,7 @@ def test_replace_access_group_rule_required_params(self): # Invoke method response = _service.replace_access_group_rule( - access_group_id, - rule_id, - if_match, - expiration, - realm_name, - conditions, - name=name, - headers={} + access_group_id, rule_id, if_match, expiration, realm_name, conditions, name=name, headers={} ) # Check for correct operation @@ -2404,11 +2105,7 @@ def test_replace_access_group_rule_value_error(self): # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') mock_response = '{"id": "id", "name": "name", "expiration": 10, "realm_name": "realm_name", "access_group_id": "access_group_id", "account_id": "account_id", "conditions": [{"claim": "claim", "operator": "EQUALS", "value": "value"}], "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=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a RuleConditions model rule_conditions_model = {} @@ -2435,7 +2132,7 @@ def test_replace_access_group_rule_value_error(self): "conditions": conditions, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.replace_access_group_rule(**req_copy) @@ -2448,7 +2145,8 @@ def test_replace_access_group_rule_value_error_with_retries(self): _service.disable_retries() self.test_replace_access_group_rule_value_error() -class TestRemoveAccessGroupRule(): + +class TestRemoveAccessGroupRule: """ Test Class for remove_access_group_rule """ @@ -2460,9 +2158,7 @@ def test_remove_access_group_rule_all_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -2471,10 +2167,7 @@ def test_remove_access_group_rule_all_params(self): # Invoke method response = _service.remove_access_group_rule( - access_group_id, - rule_id, - transaction_id=transaction_id, - headers={} + access_group_id, rule_id, transaction_id=transaction_id, headers={} ) # Check for correct operation @@ -2497,20 +2190,14 @@ def test_remove_access_group_rule_required_params(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' rule_id = 'testString' # Invoke method - response = _service.remove_access_group_rule( - access_group_id, - rule_id, - headers={} - ) + response = _service.remove_access_group_rule(access_group_id, rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2532,9 +2219,7 @@ def test_remove_access_group_rule_value_error(self): """ # Set up mock url = preprocess_url('/v2/groups/testString/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values access_group_id = 'testString' @@ -2546,7 +2231,7 @@ def test_remove_access_group_rule_value_error(self): "rule_id": rule_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_access_group_rule(**req_copy) @@ -2559,6 +2244,7 @@ def test_remove_access_group_rule_value_error_with_retries(self): _service.disable_retries() self.test_remove_access_group_rule_value_error() + # endregion ############################################################################## # End of Service: RuleOperations @@ -2569,7 +2255,8 @@ def test_remove_access_group_rule_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -2596,7 +2283,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetAccountSettings(): + +class TestGetAccountSettings: """ Test Class for get_account_settings """ @@ -2609,28 +2297,20 @@ def test_get_account_settings_all_params(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' transaction_id = 'testString' # Invoke method - response = _service.get_account_settings( - account_id, - transaction_id=transaction_id, - headers={} - ) + response = _service.get_account_settings(account_id, 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 = 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 @@ -2651,26 +2331,19 @@ def test_get_account_settings_required_params(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.get_account_settings( - account_id, - headers={} - ) + response = _service.get_account_settings(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 = 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 @@ -2691,11 +2364,7 @@ def test_get_account_settings_value_error(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -2705,7 +2374,7 @@ def test_get_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) @@ -2718,7 +2387,8 @@ def test_get_account_settings_value_error_with_retries(self): _service.disable_retries() self.test_get_account_settings_value_error() -class TestUpdateAccountSettings(): + +class TestUpdateAccountSettings: """ Test Class for update_account_settings """ @@ -2731,11 +2401,7 @@ def test_update_account_settings_all_params(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -2744,17 +2410,14 @@ def test_update_account_settings_all_params(self): # Invoke method response = _service.update_account_settings( - account_id, - public_access_enabled=public_access_enabled, - transaction_id=transaction_id, - headers={} + account_id, public_access_enabled=public_access_enabled, 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 = 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 # Validate body params @@ -2778,28 +2441,20 @@ def test_update_account_settings_required_params(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' public_access_enabled = True # Invoke method - response = _service.update_account_settings( - account_id, - public_access_enabled=public_access_enabled, - headers={} - ) + response = _service.update_account_settings(account_id, public_access_enabled=public_access_enabled, 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 = 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 # Validate body params @@ -2823,11 +2478,7 @@ def test_update_account_settings_value_error(self): # Set up mock url = preprocess_url('/v2/groups/settings') mock_response = '{"account_id": "account_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "public_access_enabled": false}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -2838,7 +2489,7 @@ def test_update_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) @@ -2851,6 +2502,7 @@ def test_update_account_settings_value_error_with_retries(self): _service.disable_retries() self.test_update_account_settings_value_error() + # endregion ############################################################################## # End of Service: AccountSettings @@ -2861,7 +2513,7 @@ def test_update_account_settings_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_AccountSettings(): +class TestModel_AccountSettings: """ Test Class for AccountSettings """ @@ -2893,7 +2545,8 @@ def test_account_settings_serialization(self): account_settings_model_json2 = account_settings_model.to_dict() assert account_settings_model_json2 == account_settings_model_json -class TestModel_AddGroupMembersRequestMembersItem(): + +class TestModel_AddGroupMembersRequestMembersItem: """ Test Class for AddGroupMembersRequestMembersItem """ @@ -2909,12 +2562,18 @@ def test_add_group_members_request_members_item_serialization(self): 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) + 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) + 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 @@ -2923,7 +2582,8 @@ def test_add_group_members_request_members_item_serialization(self): 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(): + +class TestModel_AddGroupMembersResponse: """ Test Class for AddGroupMembersResponse """ @@ -2935,11 +2595,11 @@ def test_add_group_members_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + 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 = {} # 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' @@ -2957,7 +2617,9 @@ def test_add_group_members_response_serialization(self): 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_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 @@ -2967,7 +2629,8 @@ def test_add_group_members_response_serialization(self): 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(): + +class TestModel_AddGroupMembersResponseMembersItem: """ Test Class for AddGroupMembersResponseMembersItem """ @@ -2979,7 +2642,7 @@ def test_add_group_members_response_members_item_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' @@ -2994,12 +2657,18 @@ def test_add_group_members_response_members_item_serialization(self): 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) + 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) + 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 @@ -3008,7 +2677,8 @@ def test_add_group_members_response_members_item_serialization(self): 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(): + +class TestModel_AddMembershipMultipleGroupsResponse: """ Test Class for AddMembershipMultipleGroupsResponse """ @@ -3020,11 +2690,11 @@ def test_add_membership_multiple_groups_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + 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 = {} # 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' @@ -3033,15 +2703,23 @@ def test_add_membership_multiple_groups_response_serialization(self): # 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] + 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(add_membership_multiple_groups_response_model_json) + add_membership_multiple_groups_response_model = AddMembershipMultipleGroupsResponse.from_dict( + add_membership_multiple_groups_response_model_json + ) assert add_membership_multiple_groups_response_model != False # Construct a model instance of AddMembershipMultipleGroupsResponse by calling from_dict on the json representation - add_membership_multiple_groups_response_model_dict = AddMembershipMultipleGroupsResponse.from_dict(add_membership_multiple_groups_response_model_json).__dict__ - add_membership_multiple_groups_response_model2 = AddMembershipMultipleGroupsResponse(**add_membership_multiple_groups_response_model_dict) + add_membership_multiple_groups_response_model_dict = AddMembershipMultipleGroupsResponse.from_dict( + add_membership_multiple_groups_response_model_json + ).__dict__ + add_membership_multiple_groups_response_model2 = AddMembershipMultipleGroupsResponse( + **add_membership_multiple_groups_response_model_dict + ) # Verify the model instances are equivalent assert add_membership_multiple_groups_response_model == add_membership_multiple_groups_response_model2 @@ -3050,7 +2728,8 @@ def test_add_membership_multiple_groups_response_serialization(self): add_membership_multiple_groups_response_model_json2 = add_membership_multiple_groups_response_model.to_dict() assert add_membership_multiple_groups_response_model_json2 == add_membership_multiple_groups_response_model_json -class TestModel_AddMembershipMultipleGroupsResponseGroupsItem(): + +class TestModel_AddMembershipMultipleGroupsResponseGroupsItem: """ Test Class for AddMembershipMultipleGroupsResponseGroupsItem """ @@ -3062,7 +2741,7 @@ def test_add_membership_multiple_groups_response_groups_item_serialization(self) # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' @@ -3074,21 +2753,40 @@ def test_add_membership_multiple_groups_response_groups_item_serialization(self) add_membership_multiple_groups_response_groups_item_model_json['errors'] = [error_model] # Construct a model instance of AddMembershipMultipleGroupsResponseGroupsItem by calling from_dict on the json representation - add_membership_multiple_groups_response_groups_item_model = AddMembershipMultipleGroupsResponseGroupsItem.from_dict(add_membership_multiple_groups_response_groups_item_model_json) + add_membership_multiple_groups_response_groups_item_model = ( + AddMembershipMultipleGroupsResponseGroupsItem.from_dict( + add_membership_multiple_groups_response_groups_item_model_json + ) + ) assert add_membership_multiple_groups_response_groups_item_model != False # Construct a model instance of AddMembershipMultipleGroupsResponseGroupsItem by calling from_dict on the json representation - add_membership_multiple_groups_response_groups_item_model_dict = AddMembershipMultipleGroupsResponseGroupsItem.from_dict(add_membership_multiple_groups_response_groups_item_model_json).__dict__ - add_membership_multiple_groups_response_groups_item_model2 = AddMembershipMultipleGroupsResponseGroupsItem(**add_membership_multiple_groups_response_groups_item_model_dict) + add_membership_multiple_groups_response_groups_item_model_dict = ( + AddMembershipMultipleGroupsResponseGroupsItem.from_dict( + add_membership_multiple_groups_response_groups_item_model_json + ).__dict__ + ) + add_membership_multiple_groups_response_groups_item_model2 = AddMembershipMultipleGroupsResponseGroupsItem( + **add_membership_multiple_groups_response_groups_item_model_dict + ) # 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 + 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_DeleteFromAllGroupsResponse(): +class TestModel_DeleteFromAllGroupsResponse: """ Test Class for DeleteFromAllGroupsResponse """ @@ -3100,11 +2798,11 @@ def test_delete_from_all_groups_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' - delete_from_all_groups_response_groups_item_model = {} # DeleteFromAllGroupsResponseGroupsItem + delete_from_all_groups_response_groups_item_model = {} # DeleteFromAllGroupsResponseGroupsItem delete_from_all_groups_response_groups_item_model['access_group_id'] = 'testString' delete_from_all_groups_response_groups_item_model['status_code'] = 38 delete_from_all_groups_response_groups_item_model['trace'] = 'testString' @@ -3116,12 +2814,18 @@ def test_delete_from_all_groups_response_serialization(self): delete_from_all_groups_response_model_json['groups'] = [delete_from_all_groups_response_groups_item_model] # Construct a model instance of DeleteFromAllGroupsResponse by calling from_dict on the json representation - delete_from_all_groups_response_model = DeleteFromAllGroupsResponse.from_dict(delete_from_all_groups_response_model_json) + delete_from_all_groups_response_model = DeleteFromAllGroupsResponse.from_dict( + delete_from_all_groups_response_model_json + ) assert delete_from_all_groups_response_model != False # Construct a model instance of DeleteFromAllGroupsResponse by calling from_dict on the json representation - delete_from_all_groups_response_model_dict = DeleteFromAllGroupsResponse.from_dict(delete_from_all_groups_response_model_json).__dict__ - delete_from_all_groups_response_model2 = DeleteFromAllGroupsResponse(**delete_from_all_groups_response_model_dict) + delete_from_all_groups_response_model_dict = DeleteFromAllGroupsResponse.from_dict( + delete_from_all_groups_response_model_json + ).__dict__ + delete_from_all_groups_response_model2 = DeleteFromAllGroupsResponse( + **delete_from_all_groups_response_model_dict + ) # Verify the model instances are equivalent assert delete_from_all_groups_response_model == delete_from_all_groups_response_model2 @@ -3130,7 +2834,8 @@ def test_delete_from_all_groups_response_serialization(self): delete_from_all_groups_response_model_json2 = delete_from_all_groups_response_model.to_dict() assert delete_from_all_groups_response_model_json2 == delete_from_all_groups_response_model_json -class TestModel_DeleteFromAllGroupsResponseGroupsItem(): + +class TestModel_DeleteFromAllGroupsResponseGroupsItem: """ Test Class for DeleteFromAllGroupsResponseGroupsItem """ @@ -3142,7 +2847,7 @@ def test_delete_from_all_groups_response_groups_item_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' @@ -3154,21 +2859,33 @@ def test_delete_from_all_groups_response_groups_item_serialization(self): delete_from_all_groups_response_groups_item_model_json['errors'] = [error_model] # Construct a model instance of DeleteFromAllGroupsResponseGroupsItem by calling from_dict on the json representation - delete_from_all_groups_response_groups_item_model = DeleteFromAllGroupsResponseGroupsItem.from_dict(delete_from_all_groups_response_groups_item_model_json) + delete_from_all_groups_response_groups_item_model = DeleteFromAllGroupsResponseGroupsItem.from_dict( + delete_from_all_groups_response_groups_item_model_json + ) assert delete_from_all_groups_response_groups_item_model != False # Construct a model instance of DeleteFromAllGroupsResponseGroupsItem by calling from_dict on the json representation - delete_from_all_groups_response_groups_item_model_dict = DeleteFromAllGroupsResponseGroupsItem.from_dict(delete_from_all_groups_response_groups_item_model_json).__dict__ - delete_from_all_groups_response_groups_item_model2 = DeleteFromAllGroupsResponseGroupsItem(**delete_from_all_groups_response_groups_item_model_dict) + delete_from_all_groups_response_groups_item_model_dict = DeleteFromAllGroupsResponseGroupsItem.from_dict( + delete_from_all_groups_response_groups_item_model_json + ).__dict__ + delete_from_all_groups_response_groups_item_model2 = DeleteFromAllGroupsResponseGroupsItem( + **delete_from_all_groups_response_groups_item_model_dict + ) # Verify the model instances are equivalent assert delete_from_all_groups_response_groups_item_model == delete_from_all_groups_response_groups_item_model2 # Convert model instance back to dict and verify no loss of data - delete_from_all_groups_response_groups_item_model_json2 = delete_from_all_groups_response_groups_item_model.to_dict() - assert delete_from_all_groups_response_groups_item_model_json2 == delete_from_all_groups_response_groups_item_model_json + delete_from_all_groups_response_groups_item_model_json2 = ( + delete_from_all_groups_response_groups_item_model.to_dict() + ) + assert ( + delete_from_all_groups_response_groups_item_model_json2 + == delete_from_all_groups_response_groups_item_model_json + ) + -class TestModel_DeleteGroupBulkMembersResponse(): +class TestModel_DeleteGroupBulkMembersResponse: """ Test Class for DeleteGroupBulkMembersResponse """ @@ -3180,11 +2897,11 @@ def test_delete_group_bulk_members_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' - delete_group_bulk_members_response_members_item_model = {} # DeleteGroupBulkMembersResponseMembersItem + delete_group_bulk_members_response_members_item_model = {} # DeleteGroupBulkMembersResponseMembersItem delete_group_bulk_members_response_members_item_model['iam_id'] = 'testString' delete_group_bulk_members_response_members_item_model['trace'] = 'testString' delete_group_bulk_members_response_members_item_model['status_code'] = 38 @@ -3193,15 +2910,23 @@ def test_delete_group_bulk_members_response_serialization(self): # Construct a json representation of a DeleteGroupBulkMembersResponse model delete_group_bulk_members_response_model_json = {} delete_group_bulk_members_response_model_json['access_group_id'] = 'testString' - delete_group_bulk_members_response_model_json['members'] = [delete_group_bulk_members_response_members_item_model] + delete_group_bulk_members_response_model_json['members'] = [ + delete_group_bulk_members_response_members_item_model + ] # Construct a model instance of DeleteGroupBulkMembersResponse by calling from_dict on the json representation - delete_group_bulk_members_response_model = DeleteGroupBulkMembersResponse.from_dict(delete_group_bulk_members_response_model_json) + delete_group_bulk_members_response_model = DeleteGroupBulkMembersResponse.from_dict( + delete_group_bulk_members_response_model_json + ) assert delete_group_bulk_members_response_model != False # Construct a model instance of DeleteGroupBulkMembersResponse by calling from_dict on the json representation - delete_group_bulk_members_response_model_dict = DeleteGroupBulkMembersResponse.from_dict(delete_group_bulk_members_response_model_json).__dict__ - delete_group_bulk_members_response_model2 = DeleteGroupBulkMembersResponse(**delete_group_bulk_members_response_model_dict) + delete_group_bulk_members_response_model_dict = DeleteGroupBulkMembersResponse.from_dict( + delete_group_bulk_members_response_model_json + ).__dict__ + delete_group_bulk_members_response_model2 = DeleteGroupBulkMembersResponse( + **delete_group_bulk_members_response_model_dict + ) # Verify the model instances are equivalent assert delete_group_bulk_members_response_model == delete_group_bulk_members_response_model2 @@ -3210,7 +2935,8 @@ def test_delete_group_bulk_members_response_serialization(self): delete_group_bulk_members_response_model_json2 = delete_group_bulk_members_response_model.to_dict() assert delete_group_bulk_members_response_model_json2 == delete_group_bulk_members_response_model_json -class TestModel_DeleteGroupBulkMembersResponseMembersItem(): + +class TestModel_DeleteGroupBulkMembersResponseMembersItem: """ Test Class for DeleteGroupBulkMembersResponseMembersItem """ @@ -3222,7 +2948,7 @@ def test_delete_group_bulk_members_response_members_item_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - error_model = {} # Error + error_model = {} # Error error_model['code'] = 'testString' error_model['message'] = 'testString' @@ -3234,21 +2960,38 @@ def test_delete_group_bulk_members_response_members_item_serialization(self): delete_group_bulk_members_response_members_item_model_json['errors'] = [error_model] # Construct a model instance of DeleteGroupBulkMembersResponseMembersItem by calling from_dict on the json representation - delete_group_bulk_members_response_members_item_model = DeleteGroupBulkMembersResponseMembersItem.from_dict(delete_group_bulk_members_response_members_item_model_json) + delete_group_bulk_members_response_members_item_model = DeleteGroupBulkMembersResponseMembersItem.from_dict( + delete_group_bulk_members_response_members_item_model_json + ) assert delete_group_bulk_members_response_members_item_model != False # Construct a model instance of DeleteGroupBulkMembersResponseMembersItem by calling from_dict on the json representation - delete_group_bulk_members_response_members_item_model_dict = DeleteGroupBulkMembersResponseMembersItem.from_dict(delete_group_bulk_members_response_members_item_model_json).__dict__ - delete_group_bulk_members_response_members_item_model2 = DeleteGroupBulkMembersResponseMembersItem(**delete_group_bulk_members_response_members_item_model_dict) + delete_group_bulk_members_response_members_item_model_dict = ( + DeleteGroupBulkMembersResponseMembersItem.from_dict( + delete_group_bulk_members_response_members_item_model_json + ).__dict__ + ) + delete_group_bulk_members_response_members_item_model2 = DeleteGroupBulkMembersResponseMembersItem( + **delete_group_bulk_members_response_members_item_model_dict + ) # Verify the model instances are equivalent - assert delete_group_bulk_members_response_members_item_model == delete_group_bulk_members_response_members_item_model2 + assert ( + delete_group_bulk_members_response_members_item_model + == delete_group_bulk_members_response_members_item_model2 + ) # Convert model instance back to dict and verify no loss of data - delete_group_bulk_members_response_members_item_model_json2 = delete_group_bulk_members_response_members_item_model.to_dict() - assert delete_group_bulk_members_response_members_item_model_json2 == delete_group_bulk_members_response_members_item_model_json + delete_group_bulk_members_response_members_item_model_json2 = ( + delete_group_bulk_members_response_members_item_model.to_dict() + ) + assert ( + delete_group_bulk_members_response_members_item_model_json2 + == delete_group_bulk_members_response_members_item_model_json + ) -class TestModel_Error(): + +class TestModel_Error: """ Test Class for Error """ @@ -3278,7 +3021,8 @@ def test_error_serialization(self): error_model_json2 = error_model.to_dict() assert error_model_json2 == error_model_json -class TestModel_Group(): + +class TestModel_Group: """ Test Class for Group """ @@ -3312,7 +3056,8 @@ def test_group_serialization(self): group_model_json2 = group_model.to_dict() assert group_model_json2 == group_model_json -class TestModel_GroupMembersList(): + +class TestModel_GroupMembersList: """ Test Class for GroupMembersList """ @@ -3324,10 +3069,10 @@ def test_group_members_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - href_struct_model = {} # HrefStruct + href_struct_model = {} # HrefStruct href_struct_model['href'] = 'testString' - list_group_members_response_member_model = {} # ListGroupMembersResponseMember + list_group_members_response_member_model = {} # ListGroupMembersResponseMember list_group_members_response_member_model['iam_id'] = 'testString' list_group_members_response_member_model['type'] = 'testString' list_group_members_response_member_model['membership_type'] = 'testString' @@ -3364,7 +3109,8 @@ def test_group_members_list_serialization(self): group_members_list_model_json2 = group_members_list_model.to_dict() assert group_members_list_model_json2 == group_members_list_model_json -class TestModel_GroupsList(): + +class TestModel_GroupsList: """ Test Class for GroupsList """ @@ -3376,10 +3122,10 @@ def test_groups_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - href_struct_model = {} # HrefStruct + href_struct_model = {} # HrefStruct href_struct_model['href'] = 'testString' - group_model = {} # Group + group_model = {} # Group group_model['id'] = 'testString' group_model['name'] = 'testString' group_model['description'] = 'testString' @@ -3413,7 +3159,8 @@ def test_groups_list_serialization(self): groups_list_model_json2 = groups_list_model.to_dict() assert groups_list_model_json2 == groups_list_model_json -class TestModel_HrefStruct(): + +class TestModel_HrefStruct: """ Test Class for HrefStruct """ @@ -3442,7 +3189,8 @@ def test_href_struct_serialization(self): href_struct_model_json2 = href_struct_model.to_dict() assert href_struct_model_json2 == href_struct_model_json -class TestModel_ListGroupMembersResponseMember(): + +class TestModel_ListGroupMembersResponseMember: """ Test Class for ListGroupMembersResponseMember """ @@ -3465,12 +3213,18 @@ def test_list_group_members_response_member_serialization(self): list_group_members_response_member_model_json['created_by_id'] = 'testString' # Construct a model instance of ListGroupMembersResponseMember by calling from_dict on the json representation - list_group_members_response_member_model = ListGroupMembersResponseMember.from_dict(list_group_members_response_member_model_json) + list_group_members_response_member_model = ListGroupMembersResponseMember.from_dict( + list_group_members_response_member_model_json + ) assert list_group_members_response_member_model != False # Construct a model instance of ListGroupMembersResponseMember by calling from_dict on the json representation - list_group_members_response_member_model_dict = ListGroupMembersResponseMember.from_dict(list_group_members_response_member_model_json).__dict__ - list_group_members_response_member_model2 = ListGroupMembersResponseMember(**list_group_members_response_member_model_dict) + list_group_members_response_member_model_dict = ListGroupMembersResponseMember.from_dict( + list_group_members_response_member_model_json + ).__dict__ + list_group_members_response_member_model2 = ListGroupMembersResponseMember( + **list_group_members_response_member_model_dict + ) # Verify the model instances are equivalent assert list_group_members_response_member_model == list_group_members_response_member_model2 @@ -3479,7 +3233,8 @@ def test_list_group_members_response_member_serialization(self): list_group_members_response_member_model_json2 = list_group_members_response_member_model.to_dict() assert list_group_members_response_member_model_json2 == list_group_members_response_member_model_json -class TestModel_Rule(): + +class TestModel_Rule: """ Test Class for Rule """ @@ -3491,7 +3246,7 @@ def test_rule_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rule_conditions_model = {} # RuleConditions + rule_conditions_model = {} # RuleConditions rule_conditions_model['claim'] = 'testString' rule_conditions_model['operator'] = 'EQUALS' rule_conditions_model['value'] = 'testString' @@ -3525,7 +3280,8 @@ def test_rule_serialization(self): rule_model_json2 = rule_model.to_dict() assert rule_model_json2 == rule_model_json -class TestModel_RuleConditions(): + +class TestModel_RuleConditions: """ Test Class for RuleConditions """ @@ -3556,7 +3312,8 @@ def test_rule_conditions_serialization(self): rule_conditions_model_json2 = rule_conditions_model.to_dict() assert rule_conditions_model_json2 == rule_conditions_model_json -class TestModel_RulesList(): + +class TestModel_RulesList: """ Test Class for RulesList """ @@ -3568,12 +3325,12 @@ def test_rules_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - rule_conditions_model = {} # RuleConditions + rule_conditions_model = {} # RuleConditions rule_conditions_model['claim'] = 'testString' rule_conditions_model['operator'] = 'EQUALS' rule_conditions_model['value'] = 'testString' - rule_model = {} # Rule + rule_model = {} # Rule rule_model['id'] = 'testString' rule_model['name'] = 'testString' rule_model['expiration'] = 38 diff --git a/test/unit/test_iam_identity_v1.py b/test/unit/test_iam_identity_v1.py index b4fafbd4..ce3d74ef 100644 --- a/test/unit/test_iam_identity_v1.py +++ b/test/unit/test_iam_identity_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.iam_identity_v1 import * -_service = IamIdentityV1( - authenticator=NoAuthAuthenticator() -) +_service = IamIdentityV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://iam.cloud.ibm.com' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListApiKeys(): + +class TestListApiKeys: """ Test Class for list_api_keys """ @@ -110,11 +110,7 @@ def test_list_api_keys_all_params(self): # Set up mock url = preprocess_url('/v1/apikeys') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "apikeys": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -138,14 +134,14 @@ def test_list_api_keys_all_params(self): sort=sort, order=order, include_history=include_history, - headers={} + 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 = 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 'iam_id={}'.format(iam_id) in query_string @@ -174,16 +170,11 @@ def test_list_api_keys_required_params(self): # Set up mock url = preprocess_url('/v1/apikeys') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "apikeys": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_api_keys() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -197,7 +188,8 @@ def test_list_api_keys_required_params_with_retries(self): _service.disable_retries() self.test_list_api_keys_required_params() -class TestCreateApiKey(): + +class TestCreateApiKey: """ Test Class for create_api_key """ @@ -210,11 +202,7 @@ def test_create_api_key_all_params(self): # Set up mock url = preprocess_url('/v1/apikeys') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'testString' @@ -234,7 +222,7 @@ def test_create_api_key_all_params(self): apikey=apikey, store_value=store_value, entity_lock=entity_lock, - headers={} + headers={}, ) # Check for correct operation @@ -266,11 +254,7 @@ def test_create_api_key_required_params(self): # Set up mock url = preprocess_url('/v1/apikeys') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'testString' @@ -288,7 +272,7 @@ def test_create_api_key_required_params(self): account_id=account_id, apikey=apikey, store_value=store_value, - headers={} + headers={}, ) # Check for correct operation @@ -320,11 +304,7 @@ def test_create_api_key_value_error(self): # Set up mock url = preprocess_url('/v1/apikeys') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'testString' @@ -340,11 +320,10 @@ def test_create_api_key_value_error(self): "iam_id": iam_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()} + 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_api_key(**req_copy) - def test_create_api_key_value_error_with_retries(self): # Enable retries and run test_create_api_key_value_error. _service.enable_retries() @@ -354,7 +333,8 @@ def test_create_api_key_value_error_with_retries(self): _service.disable_retries() self.test_create_api_key_value_error() -class TestGetApiKeysDetails(): + +class TestGetApiKeysDetails: """ Test Class for get_api_keys_details """ @@ -367,28 +347,20 @@ def test_get_api_keys_details_all_params(self): # Set up mock url = preprocess_url('/v1/apikeys/details') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values iam_api_key = 'testString' include_history = False # Invoke method - response = _service.get_api_keys_details( - iam_api_key=iam_api_key, - include_history=include_history, - headers={} - ) + response = _service.get_api_keys_details(iam_api_key=iam_api_key, include_history=include_history, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_history={}'.format('true' if include_history else 'false') in query_string @@ -409,16 +381,11 @@ def test_get_api_keys_details_required_params(self): # Set up mock url = preprocess_url('/v1/apikeys/details') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.get_api_keys_details() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -432,7 +399,8 @@ def test_get_api_keys_details_required_params_with_retries(self): _service.disable_retries() self.test_get_api_keys_details_required_params() -class TestGetApiKey(): + +class TestGetApiKey: """ Test Class for get_api_key """ @@ -445,11 +413,7 @@ def test_get_api_key_all_params(self): # Set up mock url = preprocess_url('/v1/apikeys/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -458,17 +422,14 @@ def test_get_api_key_all_params(self): # Invoke method response = _service.get_api_key( - id, - include_history=include_history, - include_activity=include_activity, - headers={} + id, include_history=include_history, include_activity=include_activity, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_history={}'.format('true' if include_history else 'false') in query_string assert 'include_activity={}'.format('true' if include_activity else 'false') in query_string @@ -490,20 +451,13 @@ def test_get_api_key_required_params(self): # Set up mock url = preprocess_url('/v1/apikeys/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_api_key( - id, - headers={} - ) + response = _service.get_api_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -526,11 +480,7 @@ def test_get_api_key_value_error(self): # Set up mock url = preprocess_url('/v1/apikeys/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -540,11 +490,10 @@ def test_get_api_key_value_error(self): "id": 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()} + 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_api_key(**req_copy) - def test_get_api_key_value_error_with_retries(self): # Enable retries and run test_get_api_key_value_error. _service.enable_retries() @@ -554,7 +503,8 @@ def test_get_api_key_value_error_with_retries(self): _service.disable_retries() self.test_get_api_key_value_error() -class TestUpdateApiKey(): + +class TestUpdateApiKey: """ Test Class for update_api_key """ @@ -567,11 +517,7 @@ def test_update_api_key_all_params(self): # Set up mock url = preprocess_url('/v1/apikeys/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -580,13 +526,7 @@ def test_update_api_key_all_params(self): description = 'testString' # Invoke method - response = _service.update_api_key( - id, - if_match, - name=name, - description=description, - headers={} - ) + response = _service.update_api_key(id, if_match, name=name, description=description, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -613,11 +553,7 @@ def test_update_api_key_value_error(self): # Set up mock url = preprocess_url('/v1/apikeys/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -631,11 +567,10 @@ def test_update_api_key_value_error(self): "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()} + 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_api_key(**req_copy) - def test_update_api_key_value_error_with_retries(self): # Enable retries and run test_update_api_key_value_error. _service.enable_retries() @@ -645,7 +580,8 @@ def test_update_api_key_value_error_with_retries(self): _service.disable_retries() self.test_update_api_key_value_error() -class TestDeleteApiKey(): + +class TestDeleteApiKey: """ Test Class for delete_api_key """ @@ -657,18 +593,13 @@ def test_delete_api_key_all_params(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_api_key( - id, - headers={} - ) + response = _service.delete_api_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -690,9 +621,7 @@ def test_delete_api_key_value_error(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -702,11 +631,10 @@ def test_delete_api_key_value_error(self): "id": 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()} + 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_api_key(**req_copy) - def test_delete_api_key_value_error_with_retries(self): # Enable retries and run test_delete_api_key_value_error. _service.enable_retries() @@ -716,7 +644,8 @@ def test_delete_api_key_value_error_with_retries(self): _service.disable_retries() self.test_delete_api_key_value_error() -class TestLockApiKey(): + +class TestLockApiKey: """ Test Class for lock_api_key """ @@ -728,18 +657,13 @@ def test_lock_api_key_all_params(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString/lock') - responses.add(responses.POST, - url, - status=204) + responses.add(responses.POST, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.lock_api_key( - id, - headers={} - ) + response = _service.lock_api_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -761,9 +685,7 @@ def test_lock_api_key_value_error(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString/lock') - responses.add(responses.POST, - url, - status=204) + responses.add(responses.POST, url, status=204) # Set up parameter values id = 'testString' @@ -773,11 +695,10 @@ def test_lock_api_key_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.lock_api_key(**req_copy) - def test_lock_api_key_value_error_with_retries(self): # Enable retries and run test_lock_api_key_value_error. _service.enable_retries() @@ -787,7 +708,8 @@ def test_lock_api_key_value_error_with_retries(self): _service.disable_retries() self.test_lock_api_key_value_error() -class TestUnlockApiKey(): + +class TestUnlockApiKey: """ Test Class for unlock_api_key """ @@ -799,18 +721,13 @@ def test_unlock_api_key_all_params(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString/lock') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.unlock_api_key( - id, - headers={} - ) + response = _service.unlock_api_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -832,9 +749,7 @@ def test_unlock_api_key_value_error(self): """ # Set up mock url = preprocess_url('/v1/apikeys/testString/lock') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -844,11 +759,10 @@ def test_unlock_api_key_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.unlock_api_key(**req_copy) - def test_unlock_api_key_value_error_with_retries(self): # Enable retries and run test_unlock_api_key_value_error. _service.enable_retries() @@ -858,6 +772,7 @@ def test_unlock_api_key_value_error_with_retries(self): _service.disable_retries() self.test_unlock_api_key_value_error() + # endregion ############################################################################## # End of Service: APIKeyOperations @@ -868,7 +783,8 @@ def test_unlock_api_key_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -895,7 +811,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListServiceIds(): + +class TestListServiceIds: """ Test Class for list_service_ids """ @@ -908,11 +825,7 @@ def test_list_service_ids_all_params(self): # Set up mock url = preprocess_url('/v1/serviceids/') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "serviceids": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -932,14 +845,14 @@ def test_list_service_ids_all_params(self): sort=sort, order=order, include_history=include_history, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account_id={}'.format(account_id) in query_string assert 'name={}'.format(name) in query_string @@ -966,16 +879,11 @@ def test_list_service_ids_required_params(self): # Set up mock url = preprocess_url('/v1/serviceids/') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "serviceids": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_service_ids() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -989,7 +897,8 @@ def test_list_service_ids_required_params_with_retries(self): _service.disable_retries() self.test_list_service_ids_required_params() -class TestCreateServiceId(): + +class TestCreateServiceId: """ Test Class for create_service_id """ @@ -1002,11 +911,7 @@ def test_create_service_id_all_params(self): # Set up mock url = preprocess_url('/v1/serviceids/') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ApiKeyInsideCreateServiceIdRequest model api_key_inside_create_service_id_request_model = {} @@ -1031,7 +936,7 @@ def test_create_service_id_all_params(self): unique_instance_crns=unique_instance_crns, apikey=apikey, entity_lock=entity_lock, - headers={} + headers={}, ) # Check for correct operation @@ -1062,11 +967,7 @@ def test_create_service_id_required_params(self): # Set up mock url = preprocess_url('/v1/serviceids/') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ApiKeyInsideCreateServiceIdRequest model api_key_inside_create_service_id_request_model = {} @@ -1089,7 +990,7 @@ def test_create_service_id_required_params(self): description=description, unique_instance_crns=unique_instance_crns, apikey=apikey, - headers={} + headers={}, ) # Check for correct operation @@ -1120,11 +1021,7 @@ def test_create_service_id_value_error(self): # Set up mock url = preprocess_url('/v1/serviceids/') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ApiKeyInsideCreateServiceIdRequest model api_key_inside_create_service_id_request_model = {} @@ -1146,11 +1043,10 @@ def test_create_service_id_value_error(self): "name": name, } 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()} + 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_service_id(**req_copy) - def test_create_service_id_value_error_with_retries(self): # Enable retries and run test_create_service_id_value_error. _service.enable_retries() @@ -1160,7 +1056,8 @@ def test_create_service_id_value_error_with_retries(self): _service.disable_retries() self.test_create_service_id_value_error() -class TestGetServiceId(): + +class TestGetServiceId: """ Test Class for get_service_id """ @@ -1173,11 +1070,7 @@ def test_get_service_id_all_params(self): # Set up mock url = preprocess_url('/v1/serviceids/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1186,17 +1079,14 @@ def test_get_service_id_all_params(self): # Invoke method response = _service.get_service_id( - id, - include_history=include_history, - include_activity=include_activity, - headers={} + id, include_history=include_history, include_activity=include_activity, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_history={}'.format('true' if include_history else 'false') in query_string assert 'include_activity={}'.format('true' if include_activity else 'false') in query_string @@ -1218,20 +1108,13 @@ def test_get_service_id_required_params(self): # Set up mock url = preprocess_url('/v1/serviceids/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_service_id( - id, - headers={} - ) + response = _service.get_service_id(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1254,11 +1137,7 @@ def test_get_service_id_value_error(self): # Set up mock url = preprocess_url('/v1/serviceids/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1268,11 +1147,10 @@ def test_get_service_id_value_error(self): "id": 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()} + 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_service_id(**req_copy) - def test_get_service_id_value_error_with_retries(self): # Enable retries and run test_get_service_id_value_error. _service.enable_retries() @@ -1282,7 +1160,8 @@ def test_get_service_id_value_error_with_retries(self): _service.disable_retries() self.test_get_service_id_value_error() -class TestUpdateServiceId(): + +class TestUpdateServiceId: """ Test Class for update_service_id """ @@ -1295,11 +1174,7 @@ def test_update_service_id_all_params(self): # Set up mock url = preprocess_url('/v1/serviceids/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1310,12 +1185,7 @@ def test_update_service_id_all_params(self): # Invoke method response = _service.update_service_id( - id, - if_match, - name=name, - description=description, - unique_instance_crns=unique_instance_crns, - headers={} + id, if_match, name=name, description=description, unique_instance_crns=unique_instance_crns, headers={} ) # Check for correct operation @@ -1344,11 +1214,7 @@ def test_update_service_id_value_error(self): # Set up mock url = preprocess_url('/v1/serviceids/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "iam_id": "iam_id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "account_id": "account_id", "name": "name", "description": "description", "unique_instance_crns": ["unique_instance_crns"], "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "apikey": {"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "locked": true, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "description": "description", "iam_id": "iam_id", "account_id": "account_id", "apikey": "apikey", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}, "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1363,11 +1229,10 @@ def test_update_service_id_value_error(self): "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()} + 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_service_id(**req_copy) - def test_update_service_id_value_error_with_retries(self): # Enable retries and run test_update_service_id_value_error. _service.enable_retries() @@ -1377,7 +1242,8 @@ def test_update_service_id_value_error_with_retries(self): _service.disable_retries() self.test_update_service_id_value_error() -class TestDeleteServiceId(): + +class TestDeleteServiceId: """ Test Class for delete_service_id """ @@ -1389,18 +1255,13 @@ def test_delete_service_id_all_params(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_service_id( - id, - headers={} - ) + response = _service.delete_service_id(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1422,9 +1283,7 @@ def test_delete_service_id_value_error(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -1434,11 +1293,10 @@ def test_delete_service_id_value_error(self): "id": 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()} + 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_service_id(**req_copy) - def test_delete_service_id_value_error_with_retries(self): # Enable retries and run test_delete_service_id_value_error. _service.enable_retries() @@ -1448,7 +1306,8 @@ def test_delete_service_id_value_error_with_retries(self): _service.disable_retries() self.test_delete_service_id_value_error() -class TestLockServiceId(): + +class TestLockServiceId: """ Test Class for lock_service_id """ @@ -1460,18 +1319,13 @@ def test_lock_service_id_all_params(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString/lock') - responses.add(responses.POST, - url, - status=204) + responses.add(responses.POST, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.lock_service_id( - id, - headers={} - ) + response = _service.lock_service_id(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1493,9 +1347,7 @@ def test_lock_service_id_value_error(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString/lock') - responses.add(responses.POST, - url, - status=204) + responses.add(responses.POST, url, status=204) # Set up parameter values id = 'testString' @@ -1505,11 +1357,10 @@ def test_lock_service_id_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.lock_service_id(**req_copy) - def test_lock_service_id_value_error_with_retries(self): # Enable retries and run test_lock_service_id_value_error. _service.enable_retries() @@ -1519,7 +1370,8 @@ def test_lock_service_id_value_error_with_retries(self): _service.disable_retries() self.test_lock_service_id_value_error() -class TestUnlockServiceId(): + +class TestUnlockServiceId: """ Test Class for unlock_service_id """ @@ -1531,18 +1383,13 @@ def test_unlock_service_id_all_params(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString/lock') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.unlock_service_id( - id, - headers={} - ) + response = _service.unlock_service_id(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1564,9 +1411,7 @@ def test_unlock_service_id_value_error(self): """ # Set up mock url = preprocess_url('/v1/serviceids/testString/lock') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -1576,11 +1421,10 @@ def test_unlock_service_id_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.unlock_service_id(**req_copy) - def test_unlock_service_id_value_error_with_retries(self): # Enable retries and run test_unlock_service_id_value_error. _service.enable_retries() @@ -1590,6 +1434,7 @@ def test_unlock_service_id_value_error_with_retries(self): _service.disable_retries() self.test_unlock_service_id_value_error() + # endregion ############################################################################## # End of Service: ServiceIDOperations @@ -1600,7 +1445,8 @@ def test_unlock_service_id_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1627,7 +1473,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateProfile(): + +class TestCreateProfile: """ Test Class for create_profile """ @@ -1640,11 +1487,7 @@ def test_create_profile_all_params(self): # Set up mock url = preprocess_url('/v1/profiles') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'testString' @@ -1652,12 +1495,7 @@ def test_create_profile_all_params(self): description = 'testString' # Invoke method - response = _service.create_profile( - name, - account_id, - description=description, - headers={} - ) + response = _service.create_profile(name, account_id, description=description, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1685,11 +1523,7 @@ def test_create_profile_value_error(self): # Set up mock url = preprocess_url('/v1/profiles') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'testString' @@ -1702,11 +1536,10 @@ def test_create_profile_value_error(self): "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()} + 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_profile(**req_copy) - def test_create_profile_value_error_with_retries(self): # Enable retries and run test_create_profile_value_error. _service.enable_retries() @@ -1716,7 +1549,8 @@ def test_create_profile_value_error_with_retries(self): _service.disable_retries() self.test_create_profile_value_error() -class TestListProfiles(): + +class TestListProfiles: """ Test Class for list_profiles """ @@ -1729,11 +1563,7 @@ def test_list_profiles_all_params(self): # Set up mock url = preprocess_url('/v1/profiles') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "profiles": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1753,14 +1583,14 @@ def test_list_profiles_all_params(self): order=order, include_history=include_history, pagetoken=pagetoken, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'account_id={}'.format(account_id) in query_string assert 'name={}'.format(name) in query_string @@ -1787,26 +1617,19 @@ def test_list_profiles_required_params(self): # Set up mock url = preprocess_url('/v1/profiles') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "profiles": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_profiles( - account_id, - headers={} - ) + response = _service.list_profiles(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 = 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 @@ -1827,11 +1650,7 @@ def test_list_profiles_value_error(self): # Set up mock url = preprocess_url('/v1/profiles') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "offset": 6, "limit": 5, "first": "first", "previous": "previous", "next": "next", "profiles": [{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1841,11 +1660,10 @@ def test_list_profiles_value_error(self): "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()} + 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_profiles(**req_copy) - def test_list_profiles_value_error_with_retries(self): # Enable retries and run test_list_profiles_value_error. _service.enable_retries() @@ -1855,7 +1673,8 @@ def test_list_profiles_value_error_with_retries(self): _service.disable_retries() self.test_list_profiles_value_error() -class TestGetProfile(): + +class TestGetProfile: """ Test Class for get_profile """ @@ -1868,28 +1687,20 @@ def test_get_profile_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' include_activity = False # Invoke method - response = _service.get_profile( - profile_id, - include_activity=include_activity, - headers={} - ) + response = _service.get_profile(profile_id, include_activity=include_activity, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_activity={}'.format('true' if include_activity else 'false') in query_string @@ -1910,20 +1721,13 @@ def test_get_profile_required_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' # Invoke method - response = _service.get_profile( - profile_id, - headers={} - ) + response = _service.get_profile(profile_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1946,11 +1750,7 @@ def test_get_profile_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -1960,11 +1760,10 @@ def test_get_profile_value_error(self): "profile_id": profile_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()} + 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_profile(**req_copy) - def test_get_profile_value_error_with_retries(self): # Enable retries and run test_get_profile_value_error. _service.enable_retries() @@ -1974,7 +1773,8 @@ def test_get_profile_value_error_with_retries(self): _service.disable_retries() self.test_get_profile_value_error() -class TestUpdateProfile(): + +class TestUpdateProfile: """ Test Class for update_profile """ @@ -1987,11 +1787,7 @@ def test_update_profile_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2000,13 +1796,7 @@ def test_update_profile_all_params(self): description = 'testString' # Invoke method - response = _service.update_profile( - profile_id, - if_match, - name=name, - description=description, - headers={} - ) + response = _service.update_profile(profile_id, if_match, name=name, description=description, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2033,11 +1823,7 @@ def test_update_profile_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "id": "id", "entity_tag": "entity_tag", "crn": "crn", "name": "name", "description": "description", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "iam_id": "iam_id", "account_id": "account_id", "ims_account_id": 14, "ims_user_id": 11, "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "activity": {"last_authn": "last_authn", "authn_count": 11}}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2051,11 +1837,10 @@ def test_update_profile_value_error(self): "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()} + 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_profile(**req_copy) - def test_update_profile_value_error_with_retries(self): # Enable retries and run test_update_profile_value_error. _service.enable_retries() @@ -2065,7 +1850,8 @@ def test_update_profile_value_error_with_retries(self): _service.disable_retries() self.test_update_profile_value_error() -class TestDeleteProfile(): + +class TestDeleteProfile: """ Test Class for delete_profile """ @@ -2077,18 +1863,13 @@ def test_delete_profile_all_params(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' # Invoke method - response = _service.delete_profile( - profile_id, - headers={} - ) + response = _service.delete_profile(profile_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2110,9 +1891,7 @@ def test_delete_profile_value_error(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' @@ -2122,11 +1901,10 @@ def test_delete_profile_value_error(self): "profile_id": profile_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()} + 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_profile(**req_copy) - def test_delete_profile_value_error_with_retries(self): # Enable retries and run test_delete_profile_value_error. _service.enable_retries() @@ -2136,7 +1914,8 @@ def test_delete_profile_value_error_with_retries(self): _service.disable_retries() self.test_delete_profile_value_error() -class TestCreateClaimRule(): + +class TestCreateClaimRule: """ Test Class for create_claim_rule """ @@ -2149,11 +1928,7 @@ def test_create_claim_rule_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ProfileClaimRuleConditions model profile_claim_rule_conditions_model = {} @@ -2195,7 +1970,7 @@ def test_create_claim_rule_all_params(self): realm_name=realm_name, cr_type=cr_type, expiration=expiration, - headers={} + headers={}, ) # Check for correct operation @@ -2228,11 +2003,7 @@ def test_create_claim_rule_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ProfileClaimRuleConditions model profile_claim_rule_conditions_model = {} @@ -2271,11 +2042,10 @@ def test_create_claim_rule_value_error(self): "conditions": conditions, } 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()} + 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_claim_rule(**req_copy) - def test_create_claim_rule_value_error_with_retries(self): # Enable retries and run test_create_claim_rule_value_error. _service.enable_retries() @@ -2285,7 +2055,8 @@ def test_create_claim_rule_value_error_with_retries(self): _service.disable_retries() self.test_create_claim_rule_value_error() -class TestListClaimRules(): + +class TestListClaimRules: """ Test Class for list_claim_rules """ @@ -2298,20 +2069,13 @@ def test_list_claim_rules_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "rules": [{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' # Invoke method - response = _service.list_claim_rules( - profile_id, - headers={} - ) + response = _service.list_claim_rules(profile_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2334,11 +2098,7 @@ def test_list_claim_rules_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "rules": [{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2348,11 +2108,10 @@ def test_list_claim_rules_value_error(self): "profile_id": profile_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()} + 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_claim_rules(**req_copy) - def test_list_claim_rules_value_error_with_retries(self): # Enable retries and run test_list_claim_rules_value_error. _service.enable_retries() @@ -2362,7 +2121,8 @@ def test_list_claim_rules_value_error_with_retries(self): _service.disable_retries() self.test_list_claim_rules_value_error() -class TestGetClaimRule(): + +class TestGetClaimRule: """ Test Class for get_claim_rule """ @@ -2375,22 +2135,14 @@ def test_get_claim_rule_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' rule_id = 'testString' # Invoke method - response = _service.get_claim_rule( - profile_id, - rule_id, - headers={} - ) + response = _service.get_claim_rule(profile_id, rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2413,11 +2165,7 @@ def test_get_claim_rule_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2429,11 +2177,10 @@ def test_get_claim_rule_value_error(self): "rule_id": rule_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()} + 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_claim_rule(**req_copy) - def test_get_claim_rule_value_error_with_retries(self): # Enable retries and run test_get_claim_rule_value_error. _service.enable_retries() @@ -2443,7 +2190,8 @@ def test_get_claim_rule_value_error_with_retries(self): _service.disable_retries() self.test_get_claim_rule_value_error() -class TestUpdateClaimRule(): + +class TestUpdateClaimRule: """ Test Class for update_claim_rule """ @@ -2456,11 +2204,7 @@ def test_update_claim_rule_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a ProfileClaimRuleConditions model profile_claim_rule_conditions_model = {} @@ -2506,7 +2250,7 @@ def test_update_claim_rule_all_params(self): realm_name=realm_name, cr_type=cr_type, expiration=expiration, - headers={} + headers={}, ) # Check for correct operation @@ -2539,11 +2283,7 @@ def test_update_claim_rule_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "type": "type", "realm_name": "realm_name", "expiration": 10, "cr_type": "cr_type", "conditions": [{"claim": "claim", "operator": "operator", "value": "value"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a ProfileClaimRuleConditions model profile_claim_rule_conditions_model = {} @@ -2586,11 +2326,10 @@ def test_update_claim_rule_value_error(self): "conditions": conditions, } 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()} + 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_claim_rule(**req_copy) - def test_update_claim_rule_value_error_with_retries(self): # Enable retries and run test_update_claim_rule_value_error. _service.enable_retries() @@ -2600,7 +2339,8 @@ def test_update_claim_rule_value_error_with_retries(self): _service.disable_retries() self.test_update_claim_rule_value_error() -class TestDeleteClaimRule(): + +class TestDeleteClaimRule: """ Test Class for delete_claim_rule """ @@ -2612,20 +2352,14 @@ def test_delete_claim_rule_all_params(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' rule_id = 'testString' # Invoke method - response = _service.delete_claim_rule( - profile_id, - rule_id, - headers={} - ) + response = _service.delete_claim_rule(profile_id, rule_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2647,9 +2381,7 @@ def test_delete_claim_rule_value_error(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString/rules/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' @@ -2661,11 +2393,10 @@ def test_delete_claim_rule_value_error(self): "rule_id": rule_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()} + 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_claim_rule(**req_copy) - def test_delete_claim_rule_value_error_with_retries(self): # Enable retries and run test_delete_claim_rule_value_error. _service.enable_retries() @@ -2675,7 +2406,8 @@ def test_delete_claim_rule_value_error_with_retries(self): _service.disable_retries() self.test_delete_claim_rule_value_error() -class TestCreateLink(): + +class TestCreateLink: """ Test Class for create_link """ @@ -2688,11 +2420,7 @@ def test_create_link_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a CreateProfileLinkRequestLink model create_profile_link_request_link_model = {} @@ -2707,13 +2435,7 @@ def test_create_link_all_params(self): name = 'testString' # Invoke method - response = _service.create_link( - profile_id, - cr_type, - link, - name=name, - headers={} - ) + response = _service.create_link(profile_id, cr_type, link, name=name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2741,11 +2463,7 @@ def test_create_link_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a CreateProfileLinkRequestLink model create_profile_link_request_link_model = {} @@ -2766,11 +2484,10 @@ def test_create_link_value_error(self): "link": link, } 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()} + 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_link(**req_copy) - def test_create_link_value_error_with_retries(self): # Enable retries and run test_create_link_value_error. _service.enable_retries() @@ -2780,7 +2497,8 @@ def test_create_link_value_error_with_retries(self): _service.disable_retries() self.test_create_link_value_error() -class TestListLinks(): + +class TestListLinks: """ Test Class for list_links """ @@ -2793,20 +2511,13 @@ def test_list_links_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links') mock_response = '{"links": [{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' # Invoke method - response = _service.list_links( - profile_id, - headers={} - ) + response = _service.list_links(profile_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2829,11 +2540,7 @@ def test_list_links_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links') mock_response = '{"links": [{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2843,11 +2550,10 @@ def test_list_links_value_error(self): "profile_id": profile_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()} + 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_links(**req_copy) - def test_list_links_value_error_with_retries(self): # Enable retries and run test_list_links_value_error. _service.enable_retries() @@ -2857,7 +2563,8 @@ def test_list_links_value_error_with_retries(self): _service.disable_retries() self.test_list_links_value_error() -class TestGetLink(): + +class TestGetLink: """ Test Class for get_link """ @@ -2870,22 +2577,14 @@ def test_get_link_all_params(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' link_id = 'testString' # Invoke method - response = _service.get_link( - profile_id, - link_id, - headers={} - ) + response = _service.get_link(profile_id, link_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2908,11 +2607,7 @@ def test_get_link_value_error(self): # Set up mock url = preprocess_url('/v1/profiles/testString/links/testString') mock_response = '{"id": "id", "entity_tag": "entity_tag", "created_at": "2019-01-01T12:00:00.000Z", "modified_at": "2019-01-01T12:00:00.000Z", "name": "name", "cr_type": "cr_type", "link": {"crn": "crn", "namespace": "namespace", "name": "name"}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values profile_id = 'testString' @@ -2924,11 +2619,10 @@ def test_get_link_value_error(self): "link_id": link_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()} + 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_link(**req_copy) - def test_get_link_value_error_with_retries(self): # Enable retries and run test_get_link_value_error. _service.enable_retries() @@ -2938,7 +2632,8 @@ def test_get_link_value_error_with_retries(self): _service.disable_retries() self.test_get_link_value_error() -class TestDeleteLink(): + +class TestDeleteLink: """ Test Class for delete_link """ @@ -2950,20 +2645,14 @@ def test_delete_link_all_params(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString/links/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' link_id = 'testString' # Invoke method - response = _service.delete_link( - profile_id, - link_id, - headers={} - ) + response = _service.delete_link(profile_id, link_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2985,9 +2674,7 @@ def test_delete_link_value_error(self): """ # Set up mock url = preprocess_url('/v1/profiles/testString/links/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values profile_id = 'testString' @@ -2999,11 +2686,10 @@ def test_delete_link_value_error(self): "link_id": link_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()} + 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_link(**req_copy) - def test_delete_link_value_error_with_retries(self): # Enable retries and run test_delete_link_value_error. _service.enable_retries() @@ -3013,6 +2699,7 @@ def test_delete_link_value_error_with_retries(self): _service.disable_retries() self.test_delete_link_value_error() + # endregion ############################################################################## # End of Service: TrustedProfilesOperations @@ -3023,7 +2710,8 @@ def test_delete_link_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -3050,7 +2738,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetAccountSettings(): + +class TestGetAccountSettings: """ Test Class for get_account_settings """ @@ -3063,28 +2752,20 @@ def test_get_account_settings_all_params(self): # Set up mock url = preprocess_url('/v1/accounts/testString/settings/identity') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "account_id": "account_id", "restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "allowed_ip_addresses", "entity_tag": "entity_tag", "mfa": "NONE", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "max_sessions_per_identity"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' include_history = False # Invoke method - response = _service.get_account_settings( - account_id, - include_history=include_history, - headers={} - ) + response = _service.get_account_settings(account_id, include_history=include_history, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_history={}'.format('true' if include_history else 'false') in query_string @@ -3105,20 +2786,13 @@ def test_get_account_settings_required_params(self): # Set up mock url = preprocess_url('/v1/accounts/testString/settings/identity') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "account_id": "account_id", "restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "allowed_ip_addresses", "entity_tag": "entity_tag", "mfa": "NONE", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "max_sessions_per_identity"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.get_account_settings( - account_id, - headers={} - ) + response = _service.get_account_settings(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3141,11 +2815,7 @@ def test_get_account_settings_value_error(self): # Set up mock url = preprocess_url('/v1/accounts/testString/settings/identity') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "account_id": "account_id", "restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "allowed_ip_addresses", "entity_tag": "entity_tag", "mfa": "NONE", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "max_sessions_per_identity"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -3155,11 +2825,10 @@ def test_get_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) - def test_get_account_settings_value_error_with_retries(self): # Enable retries and run test_get_account_settings_value_error. _service.enable_retries() @@ -3169,7 +2838,8 @@ def test_get_account_settings_value_error_with_retries(self): _service.disable_retries() self.test_get_account_settings_value_error() -class TestUpdateAccountSettings(): + +class TestUpdateAccountSettings: """ Test Class for update_account_settings """ @@ -3182,11 +2852,7 @@ def test_update_account_settings_all_params(self): # Set up mock url = preprocess_url('/v1/accounts/testString/settings/identity') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "account_id": "account_id", "restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "allowed_ip_addresses", "entity_tag": "entity_tag", "mfa": "NONE", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "max_sessions_per_identity"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values if_match = 'testString' @@ -3210,7 +2876,7 @@ def test_update_account_settings_all_params(self): session_expiration_in_seconds=session_expiration_in_seconds, session_invalidation_in_seconds=session_invalidation_in_seconds, max_sessions_per_identity=max_sessions_per_identity, - headers={} + headers={}, ) # Check for correct operation @@ -3243,11 +2909,7 @@ def test_update_account_settings_value_error(self): # Set up mock url = preprocess_url('/v1/accounts/testString/settings/identity') mock_response = '{"context": {"transaction_id": "transaction_id", "operation": "operation", "user_agent": "user_agent", "url": "url", "instance_id": "instance_id", "thread_id": "thread_id", "host": "host", "start_time": "start_time", "end_time": "end_time", "elapsed_time": "elapsed_time", "cluster_name": "cluster_name"}, "account_id": "account_id", "restrict_create_service_id": "NOT_SET", "restrict_create_platform_apikey": "NOT_SET", "allowed_ip_addresses": "allowed_ip_addresses", "entity_tag": "entity_tag", "mfa": "NONE", "history": [{"timestamp": "timestamp", "iam_id": "iam_id", "iam_id_account": "iam_id_account", "action": "action", "params": ["params"], "message": "message"}], "session_expiration_in_seconds": "86400", "session_invalidation_in_seconds": "7200", "max_sessions_per_identity": "max_sessions_per_identity"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values if_match = 'testString' @@ -3266,11 +2928,10 @@ def test_update_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) - def test_update_account_settings_value_error_with_retries(self): # Enable retries and run test_update_account_settings_value_error. _service.enable_retries() @@ -3280,6 +2941,7 @@ def test_update_account_settings_value_error_with_retries(self): _service.disable_retries() self.test_update_account_settings_value_error() + # endregion ############################################################################## # End of Service: AccountSettings @@ -3290,7 +2952,8 @@ def test_update_account_settings_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -3317,7 +2980,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestCreateReport(): + +class TestCreateReport: """ Test Class for create_report """ @@ -3330,11 +2994,7 @@ def test_create_report_all_params(self): # Set up mock url = preprocess_url('/v1/activity/accounts/testString/report') mock_response = '{"reference": "reference"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values account_id = 'testString' @@ -3342,18 +3002,13 @@ def test_create_report_all_params(self): duration = '720' # Invoke method - response = _service.create_report( - account_id, - type=type, - duration=duration, - headers={} - ) + response = _service.create_report(account_id, type=type, duration=duration, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 202 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'type={}'.format(type) in query_string assert 'duration={}'.format(duration) in query_string @@ -3375,20 +3030,13 @@ def test_create_report_required_params(self): # Set up mock url = preprocess_url('/v1/activity/accounts/testString/report') mock_response = '{"reference": "reference"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.create_report( - account_id, - headers={} - ) + response = _service.create_report(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3411,11 +3059,7 @@ def test_create_report_value_error(self): # Set up mock url = preprocess_url('/v1/activity/accounts/testString/report') mock_response = '{"reference": "reference"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values account_id = 'testString' @@ -3425,11 +3069,10 @@ def test_create_report_value_error(self): "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()} + 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_report(**req_copy) - def test_create_report_value_error_with_retries(self): # Enable retries and run test_create_report_value_error. _service.enable_retries() @@ -3439,7 +3082,8 @@ def test_create_report_value_error_with_retries(self): _service.disable_retries() self.test_create_report_value_error() -class TestGetReport(): + +class TestGetReport: """ Test Class for get_report """ @@ -3452,22 +3096,14 @@ def test_get_report_all_params(self): # Set up mock url = preprocess_url('/v1/activity/accounts/testString/report/testString') mock_response = '{"created_by": "created_by", "reference": "reference", "report_duration": "report_duration", "report_start_time": "report_start_time", "report_end_time": "report_end_time", "users": [{"iam_id": "iam_id", "name": "name", "username": "username", "email": "email", "last_authn": "last_authn"}], "apikeys": [{"id": "id", "name": "name", "type": "type", "serviceid": {"id": "id", "name": "name"}, "user": {"iam_id": "iam_id", "name": "name", "username": "username", "email": "email"}, "last_authn": "last_authn"}], "serviceids": [{"id": "id", "name": "name", "last_authn": "last_authn"}], "profiles": [{"id": "id", "name": "name", "last_authn": "last_authn"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' reference = 'testString' # Invoke method - response = _service.get_report( - account_id, - reference, - headers={} - ) + response = _service.get_report(account_id, reference, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3490,11 +3126,7 @@ def test_get_report_value_error(self): # Set up mock url = preprocess_url('/v1/activity/accounts/testString/report/testString') mock_response = '{"created_by": "created_by", "reference": "reference", "report_duration": "report_duration", "report_start_time": "report_start_time", "report_end_time": "report_end_time", "users": [{"iam_id": "iam_id", "name": "name", "username": "username", "email": "email", "last_authn": "last_authn"}], "apikeys": [{"id": "id", "name": "name", "type": "type", "serviceid": {"id": "id", "name": "name"}, "user": {"iam_id": "iam_id", "name": "name", "username": "username", "email": "email"}, "last_authn": "last_authn"}], "serviceids": [{"id": "id", "name": "name", "last_authn": "last_authn"}], "profiles": [{"id": "id", "name": "name", "last_authn": "last_authn"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -3506,11 +3138,10 @@ def test_get_report_value_error(self): "reference": reference, } 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()} + 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_report(**req_copy) - def test_get_report_value_error_with_retries(self): # Enable retries and run test_get_report_value_error. _service.enable_retries() @@ -3520,6 +3151,7 @@ def test_get_report_value_error_with_retries(self): _service.disable_retries() self.test_get_report_value_error() + # endregion ############################################################################## # End of Service: ActivityOperations @@ -3530,7 +3162,7 @@ def test_get_report_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_AccountSettingsResponse(): +class TestModel_AccountSettingsResponse: """ Test Class for AccountSettingsResponse """ @@ -3542,7 +3174,7 @@ def test_account_settings_response_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -3555,7 +3187,7 @@ def test_account_settings_response_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -3582,7 +3214,9 @@ def test_account_settings_response_serialization(self): assert account_settings_response_model != False # Construct a model instance of AccountSettingsResponse by calling from_dict on the json representation - account_settings_response_model_dict = AccountSettingsResponse.from_dict(account_settings_response_model_json).__dict__ + account_settings_response_model_dict = AccountSettingsResponse.from_dict( + account_settings_response_model_json + ).__dict__ account_settings_response_model2 = AccountSettingsResponse(**account_settings_response_model_dict) # Verify the model instances are equivalent @@ -3592,7 +3226,8 @@ def test_account_settings_response_serialization(self): account_settings_response_model_json2 = account_settings_response_model.to_dict() assert account_settings_response_model_json2 == account_settings_response_model_json -class TestModel_Activity(): + +class TestModel_Activity: """ Test Class for Activity """ @@ -3622,7 +3257,8 @@ def test_activity_serialization(self): activity_model_json2 = activity_model.to_dict() assert activity_model_json2 == activity_model_json -class TestModel_ApiKey(): + +class TestModel_ApiKey: """ Test Class for ApiKey """ @@ -3634,7 +3270,7 @@ def test_api_key_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -3647,7 +3283,7 @@ def test_api_key_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -3655,7 +3291,7 @@ def test_api_key_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 @@ -3692,7 +3328,8 @@ def test_api_key_serialization(self): api_key_model_json2 = api_key_model.to_dict() assert api_key_model_json2 == api_key_model_json -class TestModel_ApiKeyInsideCreateServiceIdRequest(): + +class TestModel_ApiKeyInsideCreateServiceIdRequest: """ Test Class for ApiKeyInsideCreateServiceIdRequest """ @@ -3710,21 +3347,30 @@ def test_api_key_inside_create_service_id_request_serialization(self): api_key_inside_create_service_id_request_model_json['store_value'] = True # Construct a model instance of ApiKeyInsideCreateServiceIdRequest by calling from_dict on the json representation - api_key_inside_create_service_id_request_model = ApiKeyInsideCreateServiceIdRequest.from_dict(api_key_inside_create_service_id_request_model_json) + api_key_inside_create_service_id_request_model = ApiKeyInsideCreateServiceIdRequest.from_dict( + api_key_inside_create_service_id_request_model_json + ) assert api_key_inside_create_service_id_request_model != False # Construct a model instance of ApiKeyInsideCreateServiceIdRequest by calling from_dict on the json representation - api_key_inside_create_service_id_request_model_dict = ApiKeyInsideCreateServiceIdRequest.from_dict(api_key_inside_create_service_id_request_model_json).__dict__ - api_key_inside_create_service_id_request_model2 = ApiKeyInsideCreateServiceIdRequest(**api_key_inside_create_service_id_request_model_dict) + api_key_inside_create_service_id_request_model_dict = ApiKeyInsideCreateServiceIdRequest.from_dict( + api_key_inside_create_service_id_request_model_json + ).__dict__ + api_key_inside_create_service_id_request_model2 = ApiKeyInsideCreateServiceIdRequest( + **api_key_inside_create_service_id_request_model_dict + ) # Verify the model instances are equivalent assert api_key_inside_create_service_id_request_model == api_key_inside_create_service_id_request_model2 # Convert model instance back to dict and verify no loss of data api_key_inside_create_service_id_request_model_json2 = api_key_inside_create_service_id_request_model.to_dict() - assert api_key_inside_create_service_id_request_model_json2 == api_key_inside_create_service_id_request_model_json + assert ( + api_key_inside_create_service_id_request_model_json2 == api_key_inside_create_service_id_request_model_json + ) + -class TestModel_ApiKeyList(): +class TestModel_ApiKeyList: """ Test Class for ApiKeyList """ @@ -3736,7 +3382,7 @@ def test_api_key_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -3749,7 +3395,7 @@ def test_api_key_list_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -3757,11 +3403,11 @@ def test_api_key_list_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 - api_key_model = {} # ApiKey + api_key_model = {} # ApiKey api_key_model['context'] = response_context_model api_key_model['id'] = 'testString' api_key_model['entity_tag'] = 'testString' @@ -3803,7 +3449,8 @@ def test_api_key_list_serialization(self): api_key_list_model_json2 = api_key_list_model.to_dict() assert api_key_list_model_json2 == api_key_list_model_json -class TestModel_ApikeyActivity(): + +class TestModel_ApikeyActivity: """ Test Class for ApikeyActivity """ @@ -3815,11 +3462,11 @@ def test_apikey_activity_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - apikey_activity_serviceid_model = {} # ApikeyActivityServiceid + apikey_activity_serviceid_model = {} # ApikeyActivityServiceid apikey_activity_serviceid_model['id'] = 'testString' apikey_activity_serviceid_model['name'] = 'testString' - apikey_activity_user_model = {} # ApikeyActivityUser + apikey_activity_user_model = {} # ApikeyActivityUser apikey_activity_user_model['iam_id'] = 'testString' apikey_activity_user_model['name'] = 'testString' apikey_activity_user_model['username'] = 'testString' @@ -3849,7 +3496,8 @@ def test_apikey_activity_serialization(self): apikey_activity_model_json2 = apikey_activity_model.to_dict() assert apikey_activity_model_json2 == apikey_activity_model_json -class TestModel_ApikeyActivityServiceid(): + +class TestModel_ApikeyActivityServiceid: """ Test Class for ApikeyActivityServiceid """ @@ -3869,7 +3517,9 @@ def test_apikey_activity_serviceid_serialization(self): assert apikey_activity_serviceid_model != False # Construct a model instance of ApikeyActivityServiceid by calling from_dict on the json representation - apikey_activity_serviceid_model_dict = ApikeyActivityServiceid.from_dict(apikey_activity_serviceid_model_json).__dict__ + apikey_activity_serviceid_model_dict = ApikeyActivityServiceid.from_dict( + apikey_activity_serviceid_model_json + ).__dict__ apikey_activity_serviceid_model2 = ApikeyActivityServiceid(**apikey_activity_serviceid_model_dict) # Verify the model instances are equivalent @@ -3879,7 +3529,8 @@ def test_apikey_activity_serviceid_serialization(self): apikey_activity_serviceid_model_json2 = apikey_activity_serviceid_model.to_dict() assert apikey_activity_serviceid_model_json2 == apikey_activity_serviceid_model_json -class TestModel_ApikeyActivityUser(): + +class TestModel_ApikeyActivityUser: """ Test Class for ApikeyActivityUser """ @@ -3911,7 +3562,8 @@ def test_apikey_activity_user_serialization(self): apikey_activity_user_model_json2 = apikey_activity_user_model.to_dict() assert apikey_activity_user_model_json2 == apikey_activity_user_model_json -class TestModel_CreateProfileLinkRequestLink(): + +class TestModel_CreateProfileLinkRequestLink: """ Test Class for CreateProfileLinkRequestLink """ @@ -3928,12 +3580,18 @@ def test_create_profile_link_request_link_serialization(self): create_profile_link_request_link_model_json['name'] = 'testString' # Construct a model instance of CreateProfileLinkRequestLink by calling from_dict on the json representation - create_profile_link_request_link_model = CreateProfileLinkRequestLink.from_dict(create_profile_link_request_link_model_json) + create_profile_link_request_link_model = CreateProfileLinkRequestLink.from_dict( + create_profile_link_request_link_model_json + ) assert create_profile_link_request_link_model != False # Construct a model instance of CreateProfileLinkRequestLink by calling from_dict on the json representation - create_profile_link_request_link_model_dict = CreateProfileLinkRequestLink.from_dict(create_profile_link_request_link_model_json).__dict__ - create_profile_link_request_link_model2 = CreateProfileLinkRequestLink(**create_profile_link_request_link_model_dict) + create_profile_link_request_link_model_dict = CreateProfileLinkRequestLink.from_dict( + create_profile_link_request_link_model_json + ).__dict__ + create_profile_link_request_link_model2 = CreateProfileLinkRequestLink( + **create_profile_link_request_link_model_dict + ) # Verify the model instances are equivalent assert create_profile_link_request_link_model == create_profile_link_request_link_model2 @@ -3942,7 +3600,8 @@ def test_create_profile_link_request_link_serialization(self): create_profile_link_request_link_model_json2 = create_profile_link_request_link_model.to_dict() assert create_profile_link_request_link_model_json2 == create_profile_link_request_link_model_json -class TestModel_EnityHistoryRecord(): + +class TestModel_EnityHistoryRecord: """ Test Class for EnityHistoryRecord """ @@ -3976,7 +3635,8 @@ def test_enity_history_record_serialization(self): enity_history_record_model_json2 = enity_history_record_model.to_dict() assert enity_history_record_model_json2 == enity_history_record_model_json -class TestModel_EntityActivity(): + +class TestModel_EntityActivity: """ Test Class for EntityActivity """ @@ -4007,7 +3667,8 @@ def test_entity_activity_serialization(self): entity_activity_model_json2 = entity_activity_model.to_dict() assert entity_activity_model_json2 == entity_activity_model_json -class TestModel_ProfileClaimRule(): + +class TestModel_ProfileClaimRule: """ Test Class for ProfileClaimRule """ @@ -4019,7 +3680,7 @@ def test_profile_claim_rule_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - profile_claim_rule_conditions_model = {} # ProfileClaimRuleConditions + profile_claim_rule_conditions_model = {} # ProfileClaimRuleConditions profile_claim_rule_conditions_model['claim'] = 'testString' profile_claim_rule_conditions_model['operator'] = 'testString' profile_claim_rule_conditions_model['value'] = 'testString' @@ -4052,7 +3713,8 @@ def test_profile_claim_rule_serialization(self): profile_claim_rule_model_json2 = profile_claim_rule_model.to_dict() assert profile_claim_rule_model_json2 == profile_claim_rule_model_json -class TestModel_ProfileClaimRuleConditions(): + +class TestModel_ProfileClaimRuleConditions: """ Test Class for ProfileClaimRuleConditions """ @@ -4069,11 +3731,15 @@ def test_profile_claim_rule_conditions_serialization(self): profile_claim_rule_conditions_model_json['value'] = 'testString' # Construct a model instance of ProfileClaimRuleConditions by calling from_dict on the json representation - profile_claim_rule_conditions_model = ProfileClaimRuleConditions.from_dict(profile_claim_rule_conditions_model_json) + profile_claim_rule_conditions_model = ProfileClaimRuleConditions.from_dict( + profile_claim_rule_conditions_model_json + ) assert profile_claim_rule_conditions_model != False # Construct a model instance of ProfileClaimRuleConditions by calling from_dict on the json representation - profile_claim_rule_conditions_model_dict = ProfileClaimRuleConditions.from_dict(profile_claim_rule_conditions_model_json).__dict__ + profile_claim_rule_conditions_model_dict = ProfileClaimRuleConditions.from_dict( + profile_claim_rule_conditions_model_json + ).__dict__ profile_claim_rule_conditions_model2 = ProfileClaimRuleConditions(**profile_claim_rule_conditions_model_dict) # Verify the model instances are equivalent @@ -4083,7 +3749,8 @@ def test_profile_claim_rule_conditions_serialization(self): profile_claim_rule_conditions_model_json2 = profile_claim_rule_conditions_model.to_dict() assert profile_claim_rule_conditions_model_json2 == profile_claim_rule_conditions_model_json -class TestModel_ProfileClaimRuleList(): + +class TestModel_ProfileClaimRuleList: """ Test Class for ProfileClaimRuleList """ @@ -4095,7 +3762,7 @@ def test_profile_claim_rule_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -4108,12 +3775,12 @@ def test_profile_claim_rule_list_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - profile_claim_rule_conditions_model = {} # ProfileClaimRuleConditions + profile_claim_rule_conditions_model = {} # ProfileClaimRuleConditions profile_claim_rule_conditions_model['claim'] = 'testString' profile_claim_rule_conditions_model['operator'] = 'testString' profile_claim_rule_conditions_model['value'] = 'testString' - profile_claim_rule_model = {} # ProfileClaimRule + profile_claim_rule_model = {} # ProfileClaimRule profile_claim_rule_model['id'] = 'testString' profile_claim_rule_model['entity_tag'] = 'testString' profile_claim_rule_model['created_at'] = '2019-01-01T12:00:00Z' @@ -4145,7 +3812,8 @@ def test_profile_claim_rule_list_serialization(self): profile_claim_rule_list_model_json2 = profile_claim_rule_list_model.to_dict() assert profile_claim_rule_list_model_json2 == profile_claim_rule_list_model_json -class TestModel_ProfileLink(): + +class TestModel_ProfileLink: """ Test Class for ProfileLink """ @@ -4157,7 +3825,7 @@ def test_profile_link_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - profile_link_link_model = {} # ProfileLinkLink + profile_link_link_model = {} # ProfileLinkLink profile_link_link_model['crn'] = 'testString' profile_link_link_model['namespace'] = 'testString' profile_link_link_model['name'] = 'testString' @@ -4187,7 +3855,8 @@ def test_profile_link_serialization(self): profile_link_model_json2 = profile_link_model.to_dict() assert profile_link_model_json2 == profile_link_model_json -class TestModel_ProfileLinkLink(): + +class TestModel_ProfileLinkLink: """ Test Class for ProfileLinkLink """ @@ -4218,7 +3887,8 @@ def test_profile_link_link_serialization(self): profile_link_link_model_json2 = profile_link_link_model.to_dict() assert profile_link_link_model_json2 == profile_link_link_model_json -class TestModel_ProfileLinkList(): + +class TestModel_ProfileLinkList: """ Test Class for ProfileLinkList """ @@ -4230,12 +3900,12 @@ def test_profile_link_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - profile_link_link_model = {} # ProfileLinkLink + profile_link_link_model = {} # ProfileLinkLink profile_link_link_model['crn'] = 'testString' profile_link_link_model['namespace'] = 'testString' profile_link_link_model['name'] = 'testString' - profile_link_model = {} # ProfileLink + profile_link_model = {} # ProfileLink profile_link_model['id'] = 'testString' profile_link_model['entity_tag'] = 'testString' profile_link_model['created_at'] = '2019-01-01T12:00:00Z' @@ -4263,7 +3933,8 @@ def test_profile_link_list_serialization(self): profile_link_list_model_json2 = profile_link_list_model.to_dict() assert profile_link_list_model_json2 == profile_link_list_model_json -class TestModel_Report(): + +class TestModel_Report: """ Test Class for Report """ @@ -4275,24 +3946,24 @@ def test_report_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_activity_model = {} # UserActivity + user_activity_model = {} # UserActivity user_activity_model['iam_id'] = 'testString' user_activity_model['name'] = 'testString' user_activity_model['username'] = 'testString' user_activity_model['email'] = 'testString' user_activity_model['last_authn'] = 'testString' - apikey_activity_serviceid_model = {} # ApikeyActivityServiceid + apikey_activity_serviceid_model = {} # ApikeyActivityServiceid apikey_activity_serviceid_model['id'] = 'testString' apikey_activity_serviceid_model['name'] = 'testString' - apikey_activity_user_model = {} # ApikeyActivityUser + apikey_activity_user_model = {} # ApikeyActivityUser apikey_activity_user_model['iam_id'] = 'testString' apikey_activity_user_model['name'] = 'testString' apikey_activity_user_model['username'] = 'testString' apikey_activity_user_model['email'] = 'testString' - apikey_activity_model = {} # ApikeyActivity + apikey_activity_model = {} # ApikeyActivity apikey_activity_model['id'] = 'testString' apikey_activity_model['name'] = 'testString' apikey_activity_model['type'] = 'testString' @@ -4300,7 +3971,7 @@ def test_report_serialization(self): apikey_activity_model['user'] = apikey_activity_user_model apikey_activity_model['last_authn'] = 'testString' - entity_activity_model = {} # EntityActivity + entity_activity_model = {} # EntityActivity entity_activity_model['id'] = 'testString' entity_activity_model['name'] = 'testString' entity_activity_model['last_authn'] = 'testString' @@ -4332,7 +4003,8 @@ def test_report_serialization(self): report_model_json2 = report_model.to_dict() assert report_model_json2 == report_model_json -class TestModel_ReportReference(): + +class TestModel_ReportReference: """ Test Class for ReportReference """ @@ -4361,7 +4033,8 @@ def test_report_reference_serialization(self): report_reference_model_json2 = report_reference_model.to_dict() assert report_reference_model_json2 == report_reference_model_json -class TestModel_ResponseContext(): + +class TestModel_ResponseContext: """ Test Class for ResponseContext """ @@ -4400,7 +4073,8 @@ def test_response_context_serialization(self): response_context_model_json2 = response_context_model.to_dict() assert response_context_model_json2 == response_context_model_json -class TestModel_ServiceId(): + +class TestModel_ServiceId: """ Test Class for ServiceId """ @@ -4412,7 +4086,7 @@ def test_service_id_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -4425,7 +4099,7 @@ def test_service_id_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -4433,11 +4107,11 @@ def test_service_id_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 - api_key_model = {} # ApiKey + api_key_model = {} # ApiKey api_key_model['context'] = response_context_model api_key_model['id'] = 'testString' api_key_model['entity_tag'] = 'testString' @@ -4487,7 +4161,8 @@ def test_service_id_serialization(self): service_id_model_json2 = service_id_model.to_dict() assert service_id_model_json2 == service_id_model_json -class TestModel_ServiceIdList(): + +class TestModel_ServiceIdList: """ Test Class for ServiceIdList """ @@ -4499,7 +4174,7 @@ def test_service_id_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -4512,7 +4187,7 @@ def test_service_id_list_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -4520,11 +4195,11 @@ def test_service_id_list_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 - api_key_model = {} # ApiKey + api_key_model = {} # ApiKey api_key_model['context'] = response_context_model api_key_model['id'] = 'testString' api_key_model['entity_tag'] = 'testString' @@ -4541,7 +4216,7 @@ def test_service_id_list_serialization(self): api_key_model['history'] = [enity_history_record_model] api_key_model['activity'] = activity_model - service_id_model = {} # ServiceId + service_id_model = {} # ServiceId service_id_model['context'] = response_context_model service_id_model['id'] = 'testString' service_id_model['iam_id'] = 'testString' @@ -4583,7 +4258,8 @@ def test_service_id_list_serialization(self): service_id_list_model_json2 = service_id_list_model.to_dict() assert service_id_list_model_json2 == service_id_list_model_json -class TestModel_TrustedProfile(): + +class TestModel_TrustedProfile: """ Test Class for TrustedProfile """ @@ -4595,7 +4271,7 @@ def test_trusted_profile_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -4608,7 +4284,7 @@ def test_trusted_profile_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -4616,7 +4292,7 @@ def test_trusted_profile_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 @@ -4652,7 +4328,8 @@ def test_trusted_profile_serialization(self): trusted_profile_model_json2 = trusted_profile_model.to_dict() assert trusted_profile_model_json2 == trusted_profile_model_json -class TestModel_TrustedProfilesList(): + +class TestModel_TrustedProfilesList: """ Test Class for TrustedProfilesList """ @@ -4664,7 +4341,7 @@ def test_trusted_profiles_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - response_context_model = {} # ResponseContext + response_context_model = {} # ResponseContext response_context_model['transaction_id'] = 'testString' response_context_model['operation'] = 'testString' response_context_model['user_agent'] = 'testString' @@ -4677,7 +4354,7 @@ def test_trusted_profiles_list_serialization(self): response_context_model['elapsed_time'] = 'testString' response_context_model['cluster_name'] = 'testString' - enity_history_record_model = {} # EnityHistoryRecord + enity_history_record_model = {} # EnityHistoryRecord enity_history_record_model['timestamp'] = 'testString' enity_history_record_model['iam_id'] = 'testString' enity_history_record_model['iam_id_account'] = 'testString' @@ -4685,11 +4362,11 @@ def test_trusted_profiles_list_serialization(self): enity_history_record_model['params'] = ['testString'] enity_history_record_model['message'] = 'testString' - activity_model = {} # Activity + activity_model = {} # Activity activity_model['last_authn'] = 'testString' activity_model['authn_count'] = 26 - trusted_profile_model = {} # TrustedProfile + trusted_profile_model = {} # TrustedProfile trusted_profile_model['context'] = response_context_model trusted_profile_model['id'] = 'testString' trusted_profile_model['entity_tag'] = 'testString' @@ -4730,7 +4407,8 @@ def test_trusted_profiles_list_serialization(self): trusted_profiles_list_model_json2 = trusted_profiles_list_model.to_dict() assert trusted_profiles_list_model_json2 == trusted_profiles_list_model_json -class TestModel_UserActivity(): + +class TestModel_UserActivity: """ Test Class for UserActivity """ diff --git a/test/unit/test_iam_policy_management_v1.py b/test/unit/test_iam_policy_management_v1.py index 2ac67429..849eaa74 100644 --- a/test/unit/test_iam_policy_management_v1.py +++ b/test/unit/test_iam_policy_management_v1.py @@ -31,9 +31,7 @@ from ibm_platform_services.iam_policy_management_v1 import * -_service = IamPolicyManagementV1( - authenticator=NoAuthAuthenticator() -) +_service = IamPolicyManagementV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://iam.cloud.ibm.com' _service.set_service_url(_base_url) @@ -43,7 +41,8 @@ ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -66,10 +65,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = IamPolicyManagementV1.new_instance( - ) + service = IamPolicyManagementV1.new_instance() + -class TestListPolicies(): +class TestListPolicies: """ Test Class for list_policies """ @@ -78,7 +77,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -93,11 +92,7 @@ def test_list_policies_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -125,14 +120,14 @@ def test_list_policies_all_params(self): sort=sort, format=format, state=state, - headers={} + 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 = 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 'iam_id={}'.format(iam_id) in query_string @@ -146,13 +141,13 @@ def test_list_policies_all_params(self): assert 'state={}'.format(state) in query_string def test_list_policies_all_params_with_retries(self): - # Enable retries and run test_list_policies_all_params. - _service.enable_retries() - self.test_list_policies_all_params() + # Enable retries and run test_list_policies_all_params. + _service.enable_retries() + self.test_list_policies_all_params() - # Disable retries and run test_list_policies_all_params. - _service.disable_retries() - self.test_list_policies_all_params() + # Disable retries and run test_list_policies_all_params. + _service.disable_retries() + self.test_list_policies_all_params() @responses.activate def test_list_policies_required_params(self): @@ -162,37 +157,30 @@ def test_list_policies_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_policies( - account_id, - headers={} - ) + response = _service.list_policies(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 = 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_policies_required_params_with_retries(self): - # Enable retries and run test_list_policies_required_params. - _service.enable_retries() - self.test_list_policies_required_params() + # Enable retries and run test_list_policies_required_params. + _service.enable_retries() + self.test_list_policies_required_params() - # Disable retries and run test_list_policies_required_params. - _service.disable_retries() - self.test_list_policies_required_params() + # Disable retries and run test_list_policies_required_params. + _service.disable_retries() + self.test_list_policies_required_params() @responses.activate def test_list_policies_value_error(self): @@ -202,11 +190,7 @@ def test_list_policies_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"policies": [{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -216,21 +200,21 @@ def test_list_policies_value_error(self): "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()} + 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_policies(**req_copy) - def test_list_policies_value_error_with_retries(self): - # Enable retries and run test_list_policies_value_error. - _service.enable_retries() - self.test_list_policies_value_error() + # Enable retries and run test_list_policies_value_error. + _service.enable_retries() + self.test_list_policies_value_error() - # Disable retries and run test_list_policies_value_error. - _service.disable_retries() - self.test_list_policies_value_error() + # Disable retries and run test_list_policies_value_error. + _service.disable_retries() + self.test_list_policies_value_error() -class TestCreatePolicy(): + +class TestCreatePolicy: """ Test Class for create_policy """ @@ -239,7 +223,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -254,11 +238,7 @@ def test_create_policy_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a SubjectAttribute model subject_attribute_model = {} @@ -300,13 +280,7 @@ def test_create_policy_all_params(self): # Invoke method response = _service.create_policy( - type, - subjects, - roles, - resources, - description=description, - accept_language=accept_language, - headers={} + type, subjects, roles, resources, description=description, accept_language=accept_language, headers={} ) # Check for correct operation @@ -321,13 +295,13 @@ def test_create_policy_all_params(self): assert req_body['description'] == 'testString' def test_create_policy_all_params_with_retries(self): - # Enable retries and run test_create_policy_all_params. - _service.enable_retries() - self.test_create_policy_all_params() + # Enable retries and run test_create_policy_all_params. + _service.enable_retries() + self.test_create_policy_all_params() - # Disable retries and run test_create_policy_all_params. - _service.disable_retries() - self.test_create_policy_all_params() + # Disable retries and run test_create_policy_all_params. + _service.disable_retries() + self.test_create_policy_all_params() @responses.activate def test_create_policy_required_params(self): @@ -337,11 +311,7 @@ def test_create_policy_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a SubjectAttribute model subject_attribute_model = {} @@ -381,14 +351,7 @@ def test_create_policy_required_params(self): description = 'testString' # Invoke method - response = _service.create_policy( - type, - subjects, - roles, - resources, - description=description, - headers={} - ) + response = _service.create_policy(type, subjects, roles, resources, description=description, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -402,13 +365,13 @@ def test_create_policy_required_params(self): assert req_body['description'] == 'testString' def test_create_policy_required_params_with_retries(self): - # Enable retries and run test_create_policy_required_params. - _service.enable_retries() - self.test_create_policy_required_params() + # Enable retries and run test_create_policy_required_params. + _service.enable_retries() + self.test_create_policy_required_params() - # Disable retries and run test_create_policy_required_params. - _service.disable_retries() - self.test_create_policy_required_params() + # Disable retries and run test_create_policy_required_params. + _service.disable_retries() + self.test_create_policy_required_params() @responses.activate def test_create_policy_value_error(self): @@ -418,11 +381,7 @@ def test_create_policy_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a SubjectAttribute model subject_attribute_model = {} @@ -469,21 +428,21 @@ def test_create_policy_value_error(self): "resources": resources, } 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()} + 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_policy(**req_copy) - def test_create_policy_value_error_with_retries(self): - # Enable retries and run test_create_policy_value_error. - _service.enable_retries() - self.test_create_policy_value_error() + # Enable retries and run test_create_policy_value_error. + _service.enable_retries() + self.test_create_policy_value_error() + + # Disable retries and run test_create_policy_value_error. + _service.disable_retries() + self.test_create_policy_value_error() - # Disable retries and run test_create_policy_value_error. - _service.disable_retries() - self.test_create_policy_value_error() -class TestUpdatePolicy(): +class TestUpdatePolicy: """ Test Class for update_policy """ @@ -492,7 +451,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -507,11 +466,7 @@ def test_update_policy_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a SubjectAttribute model subject_attribute_model = {} @@ -554,14 +509,7 @@ def test_update_policy_all_params(self): # Invoke method response = _service.update_policy( - policy_id, - if_match, - type, - subjects, - roles, - resources, - description=description, - headers={} + policy_id, if_match, type, subjects, roles, resources, description=description, headers={} ) # Check for correct operation @@ -576,13 +524,13 @@ def test_update_policy_all_params(self): assert req_body['description'] == 'testString' def test_update_policy_all_params_with_retries(self): - # Enable retries and run test_update_policy_all_params. - _service.enable_retries() - self.test_update_policy_all_params() + # Enable retries and run test_update_policy_all_params. + _service.enable_retries() + self.test_update_policy_all_params() - # Disable retries and run test_update_policy_all_params. - _service.disable_retries() - self.test_update_policy_all_params() + # Disable retries and run test_update_policy_all_params. + _service.disable_retries() + self.test_update_policy_all_params() @responses.activate def test_update_policy_value_error(self): @@ -592,11 +540,7 @@ def test_update_policy_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a SubjectAttribute model subject_attribute_model = {} @@ -647,21 +591,21 @@ def test_update_policy_value_error(self): "resources": resources, } 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()} + 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_policy(**req_copy) - def test_update_policy_value_error_with_retries(self): - # Enable retries and run test_update_policy_value_error. - _service.enable_retries() - self.test_update_policy_value_error() + # Enable retries and run test_update_policy_value_error. + _service.enable_retries() + self.test_update_policy_value_error() + + # Disable retries and run test_update_policy_value_error. + _service.disable_retries() + self.test_update_policy_value_error() - # Disable retries and run test_update_policy_value_error. - _service.disable_retries() - self.test_update_policy_value_error() -class TestGetPolicy(): +class TestGetPolicy: """ Test Class for get_policy """ @@ -670,7 +614,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -685,33 +629,26 @@ def test_get_policy_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values policy_id = 'testString' # Invoke method - response = _service.get_policy( - policy_id, - headers={} - ) + response = _service.get_policy(policy_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 def test_get_policy_all_params_with_retries(self): - # Enable retries and run test_get_policy_all_params. - _service.enable_retries() - self.test_get_policy_all_params() + # Enable retries and run test_get_policy_all_params. + _service.enable_retries() + self.test_get_policy_all_params() - # Disable retries and run test_get_policy_all_params. - _service.disable_retries() - self.test_get_policy_all_params() + # Disable retries and run test_get_policy_all_params. + _service.disable_retries() + self.test_get_policy_all_params() @responses.activate def test_get_policy_value_error(self): @@ -721,11 +658,7 @@ def test_get_policy_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values policy_id = 'testString' @@ -735,21 +668,21 @@ def test_get_policy_value_error(self): "policy_id": policy_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()} + 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_policy(**req_copy) - def test_get_policy_value_error_with_retries(self): - # Enable retries and run test_get_policy_value_error. - _service.enable_retries() - self.test_get_policy_value_error() + # Enable retries and run test_get_policy_value_error. + _service.enable_retries() + self.test_get_policy_value_error() - # Disable retries and run test_get_policy_value_error. - _service.disable_retries() - self.test_get_policy_value_error() + # Disable retries and run test_get_policy_value_error. + _service.disable_retries() + self.test_get_policy_value_error() -class TestDeletePolicy(): + +class TestDeletePolicy: """ Test Class for delete_policy """ @@ -758,7 +691,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -772,31 +705,26 @@ def test_delete_policy_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values policy_id = 'testString' # Invoke method - response = _service.delete_policy( - policy_id, - headers={} - ) + response = _service.delete_policy(policy_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 def test_delete_policy_all_params_with_retries(self): - # Enable retries and run test_delete_policy_all_params. - _service.enable_retries() - self.test_delete_policy_all_params() + # Enable retries and run test_delete_policy_all_params. + _service.enable_retries() + self.test_delete_policy_all_params() - # Disable retries and run test_delete_policy_all_params. - _service.disable_retries() - self.test_delete_policy_all_params() + # Disable retries and run test_delete_policy_all_params. + _service.disable_retries() + self.test_delete_policy_all_params() @responses.activate def test_delete_policy_value_error(self): @@ -805,9 +733,7 @@ def test_delete_policy_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values policy_id = 'testString' @@ -817,21 +743,21 @@ def test_delete_policy_value_error(self): "policy_id": policy_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()} + 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_policy(**req_copy) - def test_delete_policy_value_error_with_retries(self): - # Enable retries and run test_delete_policy_value_error. - _service.enable_retries() - self.test_delete_policy_value_error() + # Enable retries and run test_delete_policy_value_error. + _service.enable_retries() + self.test_delete_policy_value_error() - # Disable retries and run test_delete_policy_value_error. - _service.disable_retries() - self.test_delete_policy_value_error() + # Disable retries and run test_delete_policy_value_error. + _service.disable_retries() + self.test_delete_policy_value_error() -class TestPatchPolicy(): + +class TestPatchPolicy: """ Test Class for patch_policy """ @@ -840,7 +766,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -855,11 +781,7 @@ def test_patch_policy_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values policy_id = 'testString' @@ -867,12 +789,7 @@ def test_patch_policy_all_params(self): state = 'active' # Invoke method - response = _service.patch_policy( - policy_id, - if_match, - state=state, - headers={} - ) + response = _service.patch_policy(policy_id, if_match, state=state, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -882,13 +799,13 @@ def test_patch_policy_all_params(self): assert req_body['state'] == 'active' def test_patch_policy_all_params_with_retries(self): - # Enable retries and run test_patch_policy_all_params. - _service.enable_retries() - self.test_patch_policy_all_params() + # Enable retries and run test_patch_policy_all_params. + _service.enable_retries() + self.test_patch_policy_all_params() - # Disable retries and run test_patch_policy_all_params. - _service.disable_retries() - self.test_patch_policy_all_params() + # Disable retries and run test_patch_policy_all_params. + _service.disable_retries() + self.test_patch_policy_all_params() @responses.activate def test_patch_policy_value_error(self): @@ -898,11 +815,7 @@ def test_patch_policy_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v1/policies/testString') mock_response = '{"id": "id", "type": "type", "description": "description", "subjects": [{"attributes": [{"name": "name", "value": "value"}]}], "roles": [{"role_id": "role_id", "display_name": "display_name", "description": "description"}], "resources": [{"attributes": [{"name": "name", "value": "value", "operator": "operator"}], "tags": [{"name": "name", "value": "value", "operator": "operator"}]}], "href": "href", "created_at": "2019-01-01T12:00:00.000Z", "created_by_id": "created_by_id", "last_modified_at": "2019-01-01T12:00:00.000Z", "last_modified_by_id": "last_modified_by_id", "state": "active"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values policy_id = 'testString' @@ -915,19 +828,19 @@ def test_patch_policy_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.patch_policy(**req_copy) - def test_patch_policy_value_error_with_retries(self): - # Enable retries and run test_patch_policy_value_error. - _service.enable_retries() - self.test_patch_policy_value_error() + # Enable retries and run test_patch_policy_value_error. + _service.enable_retries() + self.test_patch_policy_value_error() + + # Disable retries and run test_patch_policy_value_error. + _service.disable_retries() + self.test_patch_policy_value_error() - # Disable retries and run test_patch_policy_value_error. - _service.disable_retries() - self.test_patch_policy_value_error() # endregion ############################################################################## @@ -939,7 +852,8 @@ def test_patch_policy_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -962,10 +876,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = IamPolicyManagementV1.new_instance( - ) + service = IamPolicyManagementV1.new_instance() + -class TestListRoles(): +class TestListRoles: """ Test Class for list_roles """ @@ -974,7 +888,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -989,11 +903,7 @@ def test_list_roles_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles') mock_response = '{"custom_roles": [{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}], "service_roles": [{"display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn"}], "system_roles": [{"display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values accept_language = 'default' @@ -1009,14 +919,14 @@ def test_list_roles_all_params(self): service_name=service_name, source_service_name=source_service_name, policy_type=policy_type, - headers={} + 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 = 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 'service_name={}'.format(service_name) in query_string @@ -1024,13 +934,13 @@ def test_list_roles_all_params(self): assert 'policy_type={}'.format(policy_type) in query_string def test_list_roles_all_params_with_retries(self): - # Enable retries and run test_list_roles_all_params. - _service.enable_retries() - self.test_list_roles_all_params() + # Enable retries and run test_list_roles_all_params. + _service.enable_retries() + self.test_list_roles_all_params() - # Disable retries and run test_list_roles_all_params. - _service.disable_retries() - self.test_list_roles_all_params() + # Disable retries and run test_list_roles_all_params. + _service.disable_retries() + self.test_list_roles_all_params() @responses.activate def test_list_roles_required_params(self): @@ -1040,30 +950,26 @@ def test_list_roles_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles') mock_response = '{"custom_roles": [{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}], "service_roles": [{"display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn"}], "system_roles": [{"display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_roles() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 def test_list_roles_required_params_with_retries(self): - # Enable retries and run test_list_roles_required_params. - _service.enable_retries() - self.test_list_roles_required_params() + # Enable retries and run test_list_roles_required_params. + _service.enable_retries() + self.test_list_roles_required_params() + + # Disable retries and run test_list_roles_required_params. + _service.disable_retries() + self.test_list_roles_required_params() - # Disable retries and run test_list_roles_required_params. - _service.disable_retries() - self.test_list_roles_required_params() -class TestCreateRole(): +class TestCreateRole: """ Test Class for create_role """ @@ -1072,7 +978,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1087,11 +993,7 @@ def test_create_role_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values display_name = 'testString' @@ -1111,7 +1013,7 @@ def test_create_role_all_params(self): service_name, description=description, accept_language=accept_language, - headers={} + headers={}, ) # Check for correct operation @@ -1127,13 +1029,13 @@ def test_create_role_all_params(self): assert req_body['description'] == 'testString' def test_create_role_all_params_with_retries(self): - # Enable retries and run test_create_role_all_params. - _service.enable_retries() - self.test_create_role_all_params() + # Enable retries and run test_create_role_all_params. + _service.enable_retries() + self.test_create_role_all_params() - # Disable retries and run test_create_role_all_params. - _service.disable_retries() - self.test_create_role_all_params() + # Disable retries and run test_create_role_all_params. + _service.disable_retries() + self.test_create_role_all_params() @responses.activate def test_create_role_required_params(self): @@ -1143,11 +1045,7 @@ def test_create_role_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values display_name = 'testString' @@ -1159,13 +1057,7 @@ def test_create_role_required_params(self): # Invoke method response = _service.create_role( - display_name, - actions, - name, - account_id, - service_name, - description=description, - headers={} + display_name, actions, name, account_id, service_name, description=description, headers={} ) # Check for correct operation @@ -1181,13 +1073,13 @@ def test_create_role_required_params(self): assert req_body['description'] == 'testString' def test_create_role_required_params_with_retries(self): - # Enable retries and run test_create_role_required_params. - _service.enable_retries() - self.test_create_role_required_params() + # Enable retries and run test_create_role_required_params. + _service.enable_retries() + self.test_create_role_required_params() - # Disable retries and run test_create_role_required_params. - _service.disable_retries() - self.test_create_role_required_params() + # Disable retries and run test_create_role_required_params. + _service.disable_retries() + self.test_create_role_required_params() @responses.activate def test_create_role_value_error(self): @@ -1197,11 +1089,7 @@ def test_create_role_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values display_name = 'testString' @@ -1220,21 +1108,21 @@ def test_create_role_value_error(self): "service_name": service_name, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.create_role(**req_copy) - def test_create_role_value_error_with_retries(self): - # Enable retries and run test_create_role_value_error. - _service.enable_retries() - self.test_create_role_value_error() + # Enable retries and run test_create_role_value_error. + _service.enable_retries() + self.test_create_role_value_error() + + # Disable retries and run test_create_role_value_error. + _service.disable_retries() + self.test_create_role_value_error() - # Disable retries and run test_create_role_value_error. - _service.disable_retries() - self.test_create_role_value_error() -class TestUpdateRole(): +class TestUpdateRole: """ Test Class for update_role """ @@ -1243,7 +1131,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1258,11 +1146,7 @@ def test_update_role_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values role_id = 'testString' @@ -1273,12 +1157,7 @@ def test_update_role_all_params(self): # Invoke method response = _service.update_role( - role_id, - if_match, - display_name=display_name, - description=description, - actions=actions, - headers={} + role_id, if_match, display_name=display_name, description=description, actions=actions, headers={} ) # Check for correct operation @@ -1291,13 +1170,13 @@ def test_update_role_all_params(self): assert req_body['actions'] == ['testString'] def test_update_role_all_params_with_retries(self): - # Enable retries and run test_update_role_all_params. - _service.enable_retries() - self.test_update_role_all_params() + # Enable retries and run test_update_role_all_params. + _service.enable_retries() + self.test_update_role_all_params() - # Disable retries and run test_update_role_all_params. - _service.disable_retries() - self.test_update_role_all_params() + # Disable retries and run test_update_role_all_params. + _service.disable_retries() + self.test_update_role_all_params() @responses.activate def test_update_role_value_error(self): @@ -1307,11 +1186,7 @@ def test_update_role_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values role_id = 'testString' @@ -1326,21 +1201,21 @@ def test_update_role_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.update_role(**req_copy) - def test_update_role_value_error_with_retries(self): - # Enable retries and run test_update_role_value_error. - _service.enable_retries() - self.test_update_role_value_error() + # Enable retries and run test_update_role_value_error. + _service.enable_retries() + self.test_update_role_value_error() - # Disable retries and run test_update_role_value_error. - _service.disable_retries() - self.test_update_role_value_error() + # Disable retries and run test_update_role_value_error. + _service.disable_retries() + self.test_update_role_value_error() -class TestGetRole(): + +class TestGetRole: """ Test Class for get_role """ @@ -1349,7 +1224,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1364,33 +1239,26 @@ def test_get_role_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values role_id = 'testString' # Invoke method - response = _service.get_role( - role_id, - headers={} - ) + response = _service.get_role(role_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 def test_get_role_all_params_with_retries(self): - # Enable retries and run test_get_role_all_params. - _service.enable_retries() - self.test_get_role_all_params() + # Enable retries and run test_get_role_all_params. + _service.enable_retries() + self.test_get_role_all_params() - # Disable retries and run test_get_role_all_params. - _service.disable_retries() - self.test_get_role_all_params() + # Disable retries and run test_get_role_all_params. + _service.disable_retries() + self.test_get_role_all_params() @responses.activate def test_get_role_value_error(self): @@ -1400,11 +1268,7 @@ def test_get_role_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') mock_response = '{"id": "id", "display_name": "display_name", "description": "description", "actions": ["actions"], "crn": "crn", "name": "Developer", "account_id": "account_id", "service_name": "iam-groups", "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", "href": "href"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values role_id = 'testString' @@ -1414,21 +1278,21 @@ def test_get_role_value_error(self): "role_id": role_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.get_role(**req_copy) - def test_get_role_value_error_with_retries(self): - # Enable retries and run test_get_role_value_error. - _service.enable_retries() - self.test_get_role_value_error() + # Enable retries and run test_get_role_value_error. + _service.enable_retries() + self.test_get_role_value_error() - # Disable retries and run test_get_role_value_error. - _service.disable_retries() - self.test_get_role_value_error() + # Disable retries and run test_get_role_value_error. + _service.disable_retries() + self.test_get_role_value_error() -class TestDeleteRole(): + +class TestDeleteRole: """ Test Class for delete_role """ @@ -1437,7 +1301,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -1451,31 +1315,26 @@ def test_delete_role_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values role_id = 'testString' # Invoke method - response = _service.delete_role( - role_id, - headers={} - ) + response = _service.delete_role(role_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 def test_delete_role_all_params_with_retries(self): - # Enable retries and run test_delete_role_all_params. - _service.enable_retries() - self.test_delete_role_all_params() + # Enable retries and run test_delete_role_all_params. + _service.enable_retries() + self.test_delete_role_all_params() - # Disable retries and run test_delete_role_all_params. - _service.disable_retries() - self.test_delete_role_all_params() + # Disable retries and run test_delete_role_all_params. + _service.disable_retries() + self.test_delete_role_all_params() @responses.activate def test_delete_role_value_error(self): @@ -1484,9 +1343,7 @@ def test_delete_role_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v2/roles/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values role_id = 'testString' @@ -1496,19 +1353,19 @@ def test_delete_role_value_error(self): "role_id": role_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.delete_role(**req_copy) - def test_delete_role_value_error_with_retries(self): - # Enable retries and run test_delete_role_value_error. - _service.enable_retries() - self.test_delete_role_value_error() + # Enable retries and run test_delete_role_value_error. + _service.enable_retries() + self.test_delete_role_value_error() + + # Disable retries and run test_delete_role_value_error. + _service.disable_retries() + self.test_delete_role_value_error() - # Disable retries and run test_delete_role_value_error. - _service.disable_retries() - self.test_delete_role_value_error() # endregion ############################################################################## @@ -1520,7 +1377,7 @@ def test_delete_role_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_CustomRole(): +class TestModel_CustomRole: """ Test Class for CustomRole """ @@ -1561,7 +1418,8 @@ def test_custom_role_serialization(self): custom_role_model_json2 = custom_role_model.to_dict() assert custom_role_model_json2 == custom_role_model_json -class TestModel_Policy(): + +class TestModel_Policy: """ Test Class for Policy """ @@ -1573,29 +1431,29 @@ def test_policy_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subject_attribute_model = {} # SubjectAttribute + subject_attribute_model = {} # SubjectAttribute subject_attribute_model['name'] = 'testString' subject_attribute_model['value'] = 'testString' - policy_subject_model = {} # PolicySubject + policy_subject_model = {} # PolicySubject policy_subject_model['attributes'] = [subject_attribute_model] - policy_role_model = {} # PolicyRole + policy_role_model = {} # PolicyRole policy_role_model['role_id'] = 'testString' policy_role_model['display_name'] = 'testString' policy_role_model['description'] = 'testString' - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_model = {} # ResourceTag + resource_tag_model = {} # ResourceTag resource_tag_model['name'] = 'testString' resource_tag_model['value'] = 'testString' resource_tag_model['operator'] = 'testString' - policy_resource_model = {} # PolicyResource + policy_resource_model = {} # PolicyResource policy_resource_model['attributes'] = [resource_attribute_model] policy_resource_model['tags'] = [resource_tag_model] @@ -1629,7 +1487,8 @@ def test_policy_serialization(self): policy_model_json2 = policy_model.to_dict() assert policy_model_json2 == policy_model_json -class TestModel_PolicyList(): + +class TestModel_PolicyList: """ Test Class for PolicyList """ @@ -1641,33 +1500,33 @@ def test_policy_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subject_attribute_model = {} # SubjectAttribute + subject_attribute_model = {} # SubjectAttribute subject_attribute_model['name'] = 'testString' subject_attribute_model['value'] = 'testString' - policy_subject_model = {} # PolicySubject + policy_subject_model = {} # PolicySubject policy_subject_model['attributes'] = [subject_attribute_model] - policy_role_model = {} # PolicyRole + policy_role_model = {} # PolicyRole policy_role_model['role_id'] = 'testString' policy_role_model['display_name'] = 'testString' policy_role_model['description'] = 'testString' - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_model = {} # ResourceTag + resource_tag_model = {} # ResourceTag resource_tag_model['name'] = 'testString' resource_tag_model['value'] = 'testString' resource_tag_model['operator'] = 'testString' - policy_resource_model = {} # PolicyResource + policy_resource_model = {} # PolicyResource policy_resource_model['attributes'] = [resource_attribute_model] policy_resource_model['tags'] = [resource_tag_model] - policy_model = {} # Policy + policy_model = {} # Policy policy_model['id'] = 'testString' policy_model['type'] = 'testString' policy_model['description'] = 'testString' @@ -1700,7 +1559,8 @@ def test_policy_list_serialization(self): policy_list_model_json2 = policy_list_model.to_dict() assert policy_list_model_json2 == policy_list_model_json -class TestModel_PolicyResource(): + +class TestModel_PolicyResource: """ Test Class for PolicyResource """ @@ -1712,12 +1572,12 @@ def test_policy_resource_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_attribute_model = {} # ResourceAttribute + resource_attribute_model = {} # ResourceAttribute resource_attribute_model['name'] = 'testString' resource_attribute_model['value'] = 'testString' resource_attribute_model['operator'] = 'testString' - resource_tag_model = {} # ResourceTag + resource_tag_model = {} # ResourceTag resource_tag_model['name'] = 'testString' resource_tag_model['value'] = 'testString' resource_tag_model['operator'] = 'testString' @@ -1742,7 +1602,8 @@ def test_policy_resource_serialization(self): policy_resource_model_json2 = policy_resource_model.to_dict() assert policy_resource_model_json2 == policy_resource_model_json -class TestModel_PolicyRole(): + +class TestModel_PolicyRole: """ Test Class for PolicyRole """ @@ -1773,7 +1634,8 @@ def test_policy_role_serialization(self): policy_role_model_json2 = policy_role_model.to_dict() assert policy_role_model_json2 == policy_role_model_json -class TestModel_PolicySubject(): + +class TestModel_PolicySubject: """ Test Class for PolicySubject """ @@ -1785,7 +1647,7 @@ def test_policy_subject_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subject_attribute_model = {} # SubjectAttribute + subject_attribute_model = {} # SubjectAttribute subject_attribute_model['name'] = 'testString' subject_attribute_model['value'] = 'testString' @@ -1808,7 +1670,8 @@ def test_policy_subject_serialization(self): policy_subject_model_json2 = policy_subject_model.to_dict() assert policy_subject_model_json2 == policy_subject_model_json -class TestModel_ResourceAttribute(): + +class TestModel_ResourceAttribute: """ Test Class for ResourceAttribute """ @@ -1839,7 +1702,8 @@ def test_resource_attribute_serialization(self): resource_attribute_model_json2 = resource_attribute_model.to_dict() assert resource_attribute_model_json2 == resource_attribute_model_json -class TestModel_ResourceTag(): + +class TestModel_ResourceTag: """ Test Class for ResourceTag """ @@ -1870,7 +1734,8 @@ def test_resource_tag_serialization(self): resource_tag_model_json2 = resource_tag_model.to_dict() assert resource_tag_model_json2 == resource_tag_model_json -class TestModel_Role(): + +class TestModel_Role: """ Test Class for Role """ @@ -1902,7 +1767,8 @@ def test_role_serialization(self): role_model_json2 = role_model.to_dict() assert role_model_json2 == role_model_json -class TestModel_RoleList(): + +class TestModel_RoleList: """ Test Class for RoleList """ @@ -1914,7 +1780,7 @@ def test_role_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - custom_role_model = {} # CustomRole + custom_role_model = {} # CustomRole custom_role_model['id'] = 'testString' custom_role_model['display_name'] = 'testString' custom_role_model['description'] = 'testString' @@ -1929,7 +1795,7 @@ def test_role_list_serialization(self): custom_role_model['last_modified_by_id'] = 'testString' custom_role_model['href'] = 'testString' - role_model = {} # Role + role_model = {} # Role role_model['display_name'] = 'testString' role_model['description'] = 'testString' role_model['actions'] = ['testString'] @@ -1956,7 +1822,8 @@ def test_role_list_serialization(self): role_list_model_json2 = role_list_model.to_dict() assert role_list_model_json2 == role_list_model_json -class TestModel_SubjectAttribute(): + +class TestModel_SubjectAttribute: """ Test Class for SubjectAttribute """ diff --git a/test/unit/test_ibm_cloud_shell_v1.py b/test/unit/test_ibm_cloud_shell_v1.py index c569c3b6..a092c778 100644 --- a/test/unit/test_ibm_cloud_shell_v1.py +++ b/test/unit/test_ibm_cloud_shell_v1.py @@ -27,9 +27,7 @@ from ibm_platform_services.ibm_cloud_shell_v1 import * -_service = IbmCloudShellV1( - authenticator=NoAuthAuthenticator() - ) +_service = IbmCloudShellV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://api.shell.cloud.ibm.com' _service.set_service_url(_base_url) @@ -39,7 +37,8 @@ ############################################################################## # region -class TestGetAccountSettings(): + +class TestGetAccountSettings: """ Test Class for get_account_settings """ @@ -61,26 +60,18 @@ def test_get_account_settings_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings') mock_response = '{"_id": "id", "_rev": "rev", "account_id": "account_id", "created_at": 10, "created_by": "created_by", "default_enable_new_features": false, "default_enable_new_regions": true, "enabled": false, "features": [{"enabled": false, "key": "key"}], "regions": [{"enabled": false, "key": "key"}], "type": "type", "updated_at": 10, "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = '12345678-abcd-1a2b-a1b2-1234567890ab' # Invoke method - response = _service.get_account_settings( - account_id, - headers={} - ) + response = _service.get_account_settings(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_account_settings_value_error(self): """ @@ -89,11 +80,7 @@ def test_get_account_settings_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings') mock_response = '{"_id": "id", "_rev": "rev", "account_id": "account_id", "created_at": 10, "created_by": "created_by", "default_enable_new_features": false, "default_enable_new_regions": true, "enabled": false, "features": [{"enabled": false, "key": "key"}], "regions": [{"enabled": false, "key": "key"}], "type": "type", "updated_at": 10, "updated_by": "updated_by"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = '12345678-abcd-1a2b-a1b2-1234567890ab' @@ -103,13 +90,12 @@ def test_get_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) - -class TestUpdateAccountSettings(): +class TestUpdateAccountSettings: """ Test Class for update_account_settings """ @@ -131,35 +117,35 @@ def test_update_account_settings_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings') mock_response = '{"_id": "id", "_rev": "rev", "account_id": "account_id", "created_at": 10, "created_by": "created_by", "default_enable_new_features": false, "default_enable_new_regions": true, "enabled": false, "features": [{"enabled": false, "key": "key"}], "regions": [{"enabled": false, "key": "key"}], "type": "type", "updated_at": 10, "updated_by": "updated_by"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Feature model - feature_model = [{ - 'enabled': True, - 'key': 'server.file_manager', - }, - { - 'enabled': True, - 'key': 'server.web_preview', - }] + feature_model = [ + { + 'enabled': True, + 'key': 'server.file_manager', + }, + { + 'enabled': True, + 'key': 'server.web_preview', + }, + ] # Construct a dict representation of a RegionSetting model - region_setting_model = [{ - 'enabled': True, - 'key': 'eu-de', - }, - { - 'enabled': True, - 'key': 'jp-tok', - }, - { - 'enabled': True, - 'key': 'us-south', - }] + region_setting_model = [ + { + 'enabled': True, + 'key': 'eu-de', + }, + { + 'enabled': True, + 'key': 'jp-tok', + }, + { + 'enabled': True, + 'key': 'us-south', + }, + ] # Set up parameter values account_id = '12345678-abcd-1a2b-a1b2-1234567890ab' @@ -179,7 +165,7 @@ def test_update_account_settings_all_params(self): enabled=enabled, features=features, regions=regions, - headers={} + headers={}, ) # Check for correct operation @@ -194,7 +180,6 @@ def test_update_account_settings_all_params(self): assert req_body['features'] == feature_model assert req_body['regions'] == region_setting_model - @responses.activate def test_update_account_settings_value_error(self): """ @@ -203,35 +188,35 @@ def test_update_account_settings_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/api/v1/user/accounts/12345678-abcd-1a2b-a1b2-1234567890ab/settings') mock_response = '{"_id": "id", "_rev": "rev", "account_id": "account_id", "created_at": 10, "created_by": "created_by", "default_enable_new_features": false, "default_enable_new_regions": true, "enabled": false, "features": [{"enabled": false, "key": "key"}], "regions": [{"enabled": false, "key": "key"}], "type": "type", "updated_at": 10, "updated_by": "updated_by"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Feature model - feature_model = [{ - 'enabled': True, - 'key': 'server.file_manager', - }, - { - 'enabled': True, - 'key': 'server.web_preview', - }] + feature_model = [ + { + 'enabled': True, + 'key': 'server.file_manager', + }, + { + 'enabled': True, + 'key': 'server.web_preview', + }, + ] # Construct a dict representation of a RegionSetting model - region_setting_model = [{ - 'enabled': True, - 'key': 'eu-de', - }, - { - 'enabled': True, - 'key': 'jp-tok', - }, - { - 'enabled': True, - 'key': 'us-south', - }] + region_setting_model = [ + { + 'enabled': True, + 'key': 'eu-de', + }, + { + 'enabled': True, + 'key': 'jp-tok', + }, + { + 'enabled': True, + 'key': 'us-south', + }, + ] # Set up parameter values account_id = '12345678-abcd-1a2b-a1b2-1234567890ab' @@ -247,12 +232,11 @@ def test_update_account_settings_value_error(self): "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()} + 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_account_settings(**req_copy) - # endregion ############################################################################## # End of Service: AccountSettings @@ -263,7 +247,7 @@ def test_update_account_settings_value_error(self): # Start of Model Tests ############################################################################## # region -class AccountSettingsUnitTests(): +class AccountSettingsUnitTests: """ Test Class for AccountSettings """ @@ -274,27 +258,31 @@ def test_account_settings_serialization(self): """ # Construct dict forms of any model objects needed in order to build this model. - feature_model = [{ - 'enabled': True, - 'key': 'server.file_manager', - }, - { - 'enabled': True, - 'key': 'server.web_preview', - }] - - region_setting_model = [{ - 'enabled': True, - 'key': 'eu-de', - }, - { - 'enabled': True, - 'key': 'jp-tok', - }, - { - 'enabled': True, - 'key': 'us-south', - }] + feature_model = [ + { + 'enabled': True, + 'key': 'server.file_manager', + }, + { + 'enabled': True, + 'key': 'server.web_preview', + }, + ] + + region_setting_model = [ + { + 'enabled': True, + 'key': 'eu-de', + }, + { + 'enabled': True, + 'key': 'jp-tok', + }, + { + 'enabled': True, + 'key': 'us-south', + }, + ] # Construct a json representation of a AccountSettings model account_settings_model_json = {} @@ -327,7 +315,8 @@ def test_account_settings_serialization(self): account_settings_model_json2 = account_settings_model.to_dict() assert account_settings_model_json2 == account_settings_model_json -class FeatureUnitTests(): + +class FeatureUnitTests: """ Test Class for Feature """ @@ -357,7 +346,8 @@ def test_feature_serialization(self): feature_model_json2 = feature_model.to_dict() assert feature_model_json2 == feature_model_json -class RegionSettingUnitTests(): + +class RegionSettingUnitTests: """ Test Class for RegionSetting """ diff --git a/test/unit/test_open_service_broker_v1.py b/test/unit/test_open_service_broker_v1.py index 0fd382de..9b9af40d 100644 --- a/test/unit/test_open_service_broker_v1.py +++ b/test/unit/test_open_service_broker_v1.py @@ -28,9 +28,7 @@ from ibm_platform_services.open_service_broker_v1 import * -service = OpenServiceBrokerV1( - authenticator=NoAuthAuthenticator() - ) +service = OpenServiceBrokerV1(authenticator=NoAuthAuthenticator()) base_url = 'https://fake' service.set_service_url(base_url) @@ -40,7 +38,8 @@ ############################################################################## # region -class TestGetServiceInstanceState(): + +class TestGetServiceInstanceState: """ Test Class for get_service_instance_state """ @@ -62,26 +61,18 @@ def test_get_service_instance_state_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/bluemix_v1/service_instances/testString') mock_response = '{"active": true, "enabled": false, "last_active": 11}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' # Invoke method - response = service.get_service_instance_state( - instance_id, - headers={} - ) + response = service.get_service_instance_state(instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_service_instance_state_value_error(self): """ @@ -90,11 +81,7 @@ def test_get_service_instance_state_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/bluemix_v1/service_instances/testString') mock_response = '{"active": true, "enabled": false, "last_active": 11}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -104,13 +91,12 @@ def test_get_service_instance_state_value_error(self): "instance_id": instance_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()} + 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_service_instance_state(**req_copy) - -class TestReplaceServiceInstanceState(): +class TestReplaceServiceInstanceState: """ Test Class for replace_service_instance_state """ @@ -132,11 +118,7 @@ def test_replace_service_instance_state_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/bluemix_v1/service_instances/testString') mock_response = '{"active": true, "enabled": false, "last_active": 11}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -146,11 +128,7 @@ def test_replace_service_instance_state_all_params(self): # Invoke method response = service.replace_service_instance_state( - instance_id, - enabled=enabled, - initiator_id=initiator_id, - reason_code=reason_code, - headers={} + instance_id, enabled=enabled, initiator_id=initiator_id, reason_code=reason_code, headers={} ) # Check for correct operation @@ -162,7 +140,6 @@ def test_replace_service_instance_state_all_params(self): assert req_body['initiator_id'] == 'null' assert req_body['reason_code'] == 'null' - @responses.activate def test_replace_service_instance_state_required_params(self): """ @@ -171,26 +148,18 @@ def test_replace_service_instance_state_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/bluemix_v1/service_instances/testString') mock_response = '{"active": true, "enabled": false, "last_active": 11}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' # Invoke method - response = service.replace_service_instance_state( - instance_id, - headers={} - ) + response = service.replace_service_instance_state(instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_replace_service_instance_state_value_error(self): """ @@ -199,11 +168,7 @@ def test_replace_service_instance_state_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/bluemix_v1/service_instances/testString') mock_response = '{"active": true, "enabled": false, "last_active": 11}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -213,12 +178,11 @@ def test_replace_service_instance_state_value_error(self): "instance_id": instance_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.replace_service_instance_state(**req_copy) - # endregion ############################################################################## # End of Service: EnableAndDisableInstances @@ -229,7 +193,8 @@ def test_replace_service_instance_state_value_error(self): ############################################################################## # region -class TestReplaceServiceInstance(): + +class TestReplaceServiceInstance: """ Test Class for replace_service_instance """ @@ -251,11 +216,7 @@ def test_replace_service_instance_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"dashboard_url": "dashboard_url", "operation": "operation"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Context model context_model = {} @@ -283,14 +244,14 @@ def test_replace_service_instance_all_params(self): context=context, parameters=parameters, accepts_incomplete=accepts_incomplete, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'accepts_incomplete={}'.format('true' if accepts_incomplete else 'false') in query_string # Validate body params @@ -302,7 +263,6 @@ def test_replace_service_instance_all_params(self): assert req_body['context'] == context_model assert req_body['parameters'] == {} - @responses.activate def test_replace_service_instance_required_params(self): """ @@ -311,26 +271,18 @@ def test_replace_service_instance_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"dashboard_url": "dashboard_url", "operation": "operation"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' # Invoke method - response = service.replace_service_instance( - instance_id, - headers={} - ) + response = service.replace_service_instance(instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_replace_service_instance_value_error(self): """ @@ -339,11 +291,7 @@ def test_replace_service_instance_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"dashboard_url": "dashboard_url", "operation": "operation"}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -353,13 +301,12 @@ def test_replace_service_instance_value_error(self): "instance_id": instance_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.replace_service_instance(**req_copy) - -class TestUpdateServiceInstance(): +class TestUpdateServiceInstance: """ Test Class for update_service_instance """ @@ -381,11 +328,7 @@ def test_update_service_instance_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a Context model context_model = {} @@ -411,14 +354,14 @@ def test_update_service_instance_all_params(self): plan_id=plan_id, previous_values=previous_values, accepts_incomplete=accepts_incomplete, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'accepts_incomplete={}'.format('true' if accepts_incomplete else 'false') in query_string # Validate body params @@ -429,7 +372,6 @@ def test_update_service_instance_all_params(self): assert req_body['plan_id'] == 'null' assert req_body['previous_values'] == {} - @responses.activate def test_update_service_instance_required_params(self): """ @@ -438,26 +380,18 @@ def test_update_service_instance_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' # Invoke method - response = service.update_service_instance( - instance_id, - headers={} - ) + response = service.update_service_instance(instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_update_service_instance_value_error(self): """ @@ -466,11 +400,7 @@ def test_update_service_instance_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -480,13 +410,12 @@ def test_update_service_instance_value_error(self): "instance_id": instance_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()} + 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_service_instance(**req_copy) - -class TestDeleteServiceInstance(): +class TestDeleteServiceInstance: """ Test Class for delete_service_instance """ @@ -508,11 +437,7 @@ def test_delete_service_instance_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_id = 'testString' @@ -522,24 +447,19 @@ def test_delete_service_instance_all_params(self): # Invoke method response = service.delete_service_instance( - service_id, - plan_id, - instance_id, - accepts_incomplete=accepts_incomplete, - headers={} + service_id, plan_id, instance_id, accepts_incomplete=accepts_incomplete, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'service_id={}'.format(service_id) in query_string assert 'plan_id={}'.format(plan_id) in query_string assert 'accepts_incomplete={}'.format('true' if accepts_incomplete else 'false') in query_string - @responses.activate def test_delete_service_instance_required_params(self): """ @@ -548,11 +468,7 @@ def test_delete_service_instance_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_id = 'testString' @@ -560,23 +476,17 @@ def test_delete_service_instance_required_params(self): instance_id = 'testString' # Invoke method - response = service.delete_service_instance( - service_id, - plan_id, - instance_id, - headers={} - ) + response = service.delete_service_instance(service_id, plan_id, instance_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'service_id={}'.format(service_id) in query_string assert 'plan_id={}'.format(plan_id) in query_string - @responses.activate def test_delete_service_instance_value_error(self): """ @@ -585,11 +495,7 @@ def test_delete_service_instance_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString') mock_response = '{"operation": "operation"}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values service_id = 'testString' @@ -603,12 +509,11 @@ def test_delete_service_instance_value_error(self): "instance_id": instance_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()} + 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_service_instance(**req_copy) - # endregion ############################################################################## # End of Service: ResourceInstances @@ -619,7 +524,8 @@ def test_delete_service_instance_value_error(self): ############################################################################## # region -class TestListCatalog(): + +class TestListCatalog: """ Test Class for list_catalog """ @@ -641,16 +547,11 @@ def test_list_catalog_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/catalog') mock_response = '{"services": [{"bindable": true, "description": "description", "id": "id", "name": "name", "plan_updateable": false, "plans": [{"description": "description", "free": true, "id": "id", "name": "name"}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = service.list_catalog() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -666,7 +567,8 @@ def test_list_catalog_all_params(self): ############################################################################## # region -class TestGetLastOperation(): + +class TestGetLastOperation: """ Test Class for get_last_operation """ @@ -688,11 +590,7 @@ def test_get_last_operation_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/last_operation') mock_response = '{"description": "description", "state": "state"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -702,24 +600,19 @@ def test_get_last_operation_all_params(self): # Invoke method response = service.get_last_operation( - instance_id, - operation=operation, - plan_id=plan_id, - service_id=service_id, - headers={} + instance_id, operation=operation, plan_id=plan_id, service_id=service_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'operation={}'.format(operation) in query_string assert 'plan_id={}'.format(plan_id) in query_string assert 'service_id={}'.format(service_id) in query_string - @responses.activate def test_get_last_operation_required_params(self): """ @@ -728,26 +621,18 @@ def test_get_last_operation_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/last_operation') mock_response = '{"description": "description", "state": "state"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' # Invoke method - response = service.get_last_operation( - instance_id, - headers={} - ) + response = service.get_last_operation(instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_last_operation_value_error(self): """ @@ -756,11 +641,7 @@ def test_get_last_operation_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/last_operation') mock_response = '{"description": "description", "state": "state"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values instance_id = 'testString' @@ -770,12 +651,11 @@ def test_get_last_operation_value_error(self): "instance_id": instance_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()} + 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_last_operation(**req_copy) - # endregion ############################################################################## # End of Service: LastOperationAsync @@ -786,7 +666,8 @@ def test_get_last_operation_value_error(self): ############################################################################## # region -class TestReplaceServiceBinding(): + +class TestReplaceServiceBinding: """ Test Class for replace_service_binding """ @@ -808,11 +689,7 @@ def test_replace_service_binding_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/service_bindings/testString') mock_response = '{"credentials": {"anyKey": "anyValue"}, "syslog_drain_url": "syslog_drain_url", "route_service_url": "route_service_url", "volume_mounts": [{"driver": "driver", "container_dir": "container_dir", "mode": "mode", "device_type": "device_type", "device": "device"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Construct a dict representation of a BindResource model bind_resource_model = {} @@ -838,7 +715,7 @@ def test_replace_service_binding_all_params(self): service_id=service_id, bind_resource=bind_resource, parameters=parameters, - headers={} + headers={}, ) # Check for correct operation @@ -851,7 +728,6 @@ def test_replace_service_binding_all_params(self): assert req_body['bind_resource'] == bind_resource_model assert req_body['parameters'] == {} - @responses.activate def test_replace_service_binding_required_params(self): """ @@ -860,28 +736,19 @@ def test_replace_service_binding_required_params(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/service_bindings/testString') mock_response = '{"credentials": {"anyKey": "anyValue"}, "syslog_drain_url": "syslog_drain_url", "route_service_url": "route_service_url", "volume_mounts": [{"driver": "driver", "container_dir": "container_dir", "mode": "mode", "device_type": "device_type", "device": "device"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values binding_id = 'testString' instance_id = 'testString' # Invoke method - response = service.replace_service_binding( - binding_id, - instance_id, - headers={} - ) + response = service.replace_service_binding(binding_id, instance_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_replace_service_binding_value_error(self): """ @@ -890,11 +757,7 @@ def test_replace_service_binding_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/service_bindings/testString') mock_response = '{"credentials": {"anyKey": "anyValue"}, "syslog_drain_url": "syslog_drain_url", "route_service_url": "route_service_url", "volume_mounts": [{"driver": "driver", "container_dir": "container_dir", "mode": "mode", "device_type": "device_type", "device": "device"}]}' - responses.add(responses.PUT, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PUT, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values binding_id = 'testString' @@ -906,13 +769,12 @@ def test_replace_service_binding_value_error(self): "instance_id": instance_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.replace_service_binding(**req_copy) - -class TestDeleteServiceBinding(): +class TestDeleteServiceBinding: """ Test Class for delete_service_binding """ @@ -933,9 +795,7 @@ def test_delete_service_binding_all_params(self): """ # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/service_bindings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values binding_id = 'testString' @@ -944,24 +804,17 @@ def test_delete_service_binding_all_params(self): service_id = 'testString' # Invoke method - response = service.delete_service_binding( - binding_id, - instance_id, - plan_id, - service_id, - headers={} - ) + response = service.delete_service_binding(binding_id, instance_id, plan_id, service_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'plan_id={}'.format(plan_id) in query_string assert 'service_id={}'.format(service_id) in query_string - @responses.activate def test_delete_service_binding_value_error(self): """ @@ -969,9 +822,7 @@ def test_delete_service_binding_value_error(self): """ # Set up mock url = self.preprocess_url(base_url + '/v2/service_instances/testString/service_bindings/testString') - responses.add(responses.DELETE, - url, - status=200) + responses.add(responses.DELETE, url, status=200) # Set up parameter values binding_id = 'testString' @@ -987,12 +838,11 @@ def test_delete_service_binding_value_error(self): "service_id": service_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()} + 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_service_binding(**req_copy) - # endregion ############################################################################## # End of Service: BindingsAndCredentials @@ -1003,7 +853,7 @@ def test_delete_service_binding_value_error(self): # Start of Model Tests ############################################################################## # region -class TestResp1874644Root(): +class TestResp1874644Root: """ Test Class for Resp1874644Root """ @@ -1034,7 +884,8 @@ def test_resp1874644_root_serialization(self): resp1874644_root_model_json2 = resp1874644_root_model.to_dict() assert resp1874644_root_model_json2 == resp1874644_root_model_json -class TestResp1874650Root(): + +class TestResp1874650Root: """ Test Class for Resp1874650Root """ @@ -1046,13 +897,13 @@ def test_resp1874650_root_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - plans_model = {} # Plans + plans_model = {} # Plans plans_model['description'] = 'testString' plans_model['free'] = True plans_model['id'] = 'testString' plans_model['name'] = 'testString' - services_model = {} # Services + services_model = {} # Services services_model['bindable'] = True services_model['description'] = 'testString' services_model['id'] = 'testString' @@ -1079,7 +930,8 @@ def test_resp1874650_root_serialization(self): resp1874650_root_model_json2 = resp1874650_root_model.to_dict() assert resp1874650_root_model_json2 == resp1874650_root_model_json -class TestResp2079872Root(): + +class TestResp2079872Root: """ Test Class for Resp2079872Root """ @@ -1109,7 +961,8 @@ def test_resp2079872_root_serialization(self): resp2079872_root_model_json2 = resp2079872_root_model.to_dict() assert resp2079872_root_model_json2 == resp2079872_root_model_json -class TestResp2079874Root(): + +class TestResp2079874Root: """ Test Class for Resp2079874Root """ @@ -1138,7 +991,8 @@ def test_resp2079874_root_serialization(self): resp2079874_root_model_json2 = resp2079874_root_model.to_dict() assert resp2079874_root_model_json2 == resp2079874_root_model_json -class TestResp2079876Root(): + +class TestResp2079876Root: """ Test Class for Resp2079876Root """ @@ -1150,7 +1004,7 @@ def test_resp2079876_root_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - volume_mount_model = {} # VolumeMount + volume_mount_model = {} # VolumeMount volume_mount_model['driver'] = 'testString' volume_mount_model['container_dir'] = 'testString' volume_mount_model['mode'] = 'testString' @@ -1159,7 +1013,7 @@ def test_resp2079876_root_serialization(self): # Construct a json representation of a Resp2079876Root model resp2079876_root_model_json = {} - resp2079876_root_model_json['credentials'] = { 'foo': 'bar' } + resp2079876_root_model_json['credentials'] = {'foo': 'bar'} resp2079876_root_model_json['syslog_drain_url'] = 'testString' resp2079876_root_model_json['route_service_url'] = 'testString' resp2079876_root_model_json['volume_mounts'] = [volume_mount_model] @@ -1179,7 +1033,8 @@ def test_resp2079876_root_serialization(self): resp2079876_root_model_json2 = resp2079876_root_model.to_dict() assert resp2079876_root_model_json2 == resp2079876_root_model_json -class TestResp2079894Root(): + +class TestResp2079894Root: """ Test Class for Resp2079894Root """ @@ -1209,7 +1064,8 @@ def test_resp2079894_root_serialization(self): resp2079894_root_model_json2 = resp2079894_root_model.to_dict() assert resp2079894_root_model_json2 == resp2079894_root_model_json -class TestResp2448145Root(): + +class TestResp2448145Root: """ Test Class for Resp2448145Root """ @@ -1240,7 +1096,8 @@ def test_resp2448145_root_serialization(self): resp2448145_root_model_json2 = resp2448145_root_model.to_dict() assert resp2448145_root_model_json2 == resp2448145_root_model_json -class TestBindResource(): + +class TestBindResource: """ Test Class for BindResource """ @@ -1273,7 +1130,8 @@ def test_bind_resource_serialization(self): bind_resource_model_json2 = bind_resource_model.to_dict() assert bind_resource_model_json2 == bind_resource_model_json -class TestContext(): + +class TestContext: """ Test Class for Context """ @@ -1304,7 +1162,8 @@ def test_context_serialization(self): context_model_json2 = context_model.to_dict() assert context_model_json2 == context_model_json -class TestPlans(): + +class TestPlans: """ Test Class for Plans """ @@ -1336,7 +1195,8 @@ def test_plans_serialization(self): plans_model_json2 = plans_model.to_dict() assert plans_model_json2 == plans_model_json -class TestServices(): + +class TestServices: """ Test Class for Services """ @@ -1348,7 +1208,7 @@ def test_services_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - plans_model = {} # Plans + plans_model = {} # Plans plans_model['description'] = 'testString' plans_model['free'] = True plans_model['id'] = 'testString' @@ -1378,7 +1238,8 @@ def test_services_serialization(self): services_model_json2 = services_model.to_dict() assert services_model_json2 == services_model_json -class TestVolumeMount(): + +class TestVolumeMount: """ Test Class for VolumeMount """ diff --git a/test/unit/test_resource_controller_v2.py b/test/unit/test_resource_controller_v2.py index 02d2fe1b..ceff0701 100644 --- a/test/unit/test_resource_controller_v2.py +++ b/test/unit/test_resource_controller_v2.py @@ -31,9 +31,7 @@ from ibm_platform_services.resource_controller_v2 import * -_service = ResourceControllerV2( - authenticator=NoAuthAuthenticator() -) +_service = ResourceControllerV2(authenticator=NoAuthAuthenticator()) _base_url = 'https://resource-controller.cloud.ibm.com' _service.set_service_url(_base_url) @@ -70,7 +68,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -97,7 +96,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListResourceInstances(): + +class TestListResourceInstances: """ Test Class for list_resource_instances """ @@ -110,11 +110,7 @@ def test_list_resource_instances_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values guid = 'testString' @@ -144,14 +140,14 @@ def test_list_resource_instances_all_params(self): state=state, updated_from=updated_from, updated_to=updated_to, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'guid={}'.format(guid) in query_string assert 'name={}'.format(name) in query_string @@ -183,16 +179,11 @@ def test_list_resource_instances_required_params(self): # Set up mock url = preprocess_url('/v2/resource_instances') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_resource_instances() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -215,16 +206,8 @@ def test_list_resource_instances_with_pager_get_next(self): url = preprocess_url('/v2/resource_instances') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","scheduled_reclaim_at":"2019-01-01T12:00:00.000Z","restored_at":"2019-01-01T12:00:00.000Z","restored_by":"restored_by","scheduled_reclaim_by":"scheduled_reclaim_by","name":"name","region_id":"region_id","account_id":"account_id","reseller_channel_id":"reseller_channel_id","resource_plan_id":"resource_plan_id","resource_group_id":"resource_group_id","resource_group_crn":"resource_group_crn","target_crn":"target_crn","parameters":{"anyKey":"anyValue"},"allow_cleanup":false,"crn":"crn","state":"active","type":"type","sub_type":"sub_type","resource_id":"resource_id","dashboard_url":"dashboard_url","last_operation":{"type":"type","state":"in progress","sub_type":"sub_type","async":true,"description":"description","reason_code":"reason_code","poll_after":10,"cancelable":true,"poll":true},"resource_aliases_url":"resource_aliases_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url","plan_history":[{"resource_plan_id":"resource_plan_id","start_date":"2019-01-01T12:00:00.000Z","requestor_id":"requestor_id"}],"migrated":true,"extensions":{"anyKey":"anyValue"},"controlled_by":"controlled_by","locked":true}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","scheduled_reclaim_at":"2019-01-01T12:00:00.000Z","restored_at":"2019-01-01T12:00:00.000Z","restored_by":"restored_by","scheduled_reclaim_by":"scheduled_reclaim_by","name":"name","region_id":"region_id","account_id":"account_id","reseller_channel_id":"reseller_channel_id","resource_plan_id":"resource_plan_id","resource_group_id":"resource_group_id","resource_group_crn":"resource_group_crn","target_crn":"target_crn","parameters":{"anyKey":"anyValue"},"allow_cleanup":false,"crn":"crn","state":"active","type":"type","sub_type":"sub_type","resource_id":"resource_id","dashboard_url":"dashboard_url","last_operation":{"type":"type","state":"in progress","sub_type":"sub_type","async":true,"description":"description","reason_code":"reason_code","poll_after":10,"cancelable":true,"poll":true},"resource_aliases_url":"resource_aliases_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url","plan_history":[{"resource_plan_id":"resource_plan_id","start_date":"2019-01-01T12:00:00.000Z","requestor_id":"requestor_id"}],"migrated":true,"extensions":{"anyKey":"anyValue"},"controlled_by":"controlled_by","locked":true}]}' - 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) + 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 = [] @@ -257,16 +240,8 @@ def test_list_resource_instances_with_pager_get_all(self): url = preprocess_url('/v2/resource_instances') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","scheduled_reclaim_at":"2019-01-01T12:00:00.000Z","restored_at":"2019-01-01T12:00:00.000Z","restored_by":"restored_by","scheduled_reclaim_by":"scheduled_reclaim_by","name":"name","region_id":"region_id","account_id":"account_id","reseller_channel_id":"reseller_channel_id","resource_plan_id":"resource_plan_id","resource_group_id":"resource_group_id","resource_group_crn":"resource_group_crn","target_crn":"target_crn","parameters":{"anyKey":"anyValue"},"allow_cleanup":false,"crn":"crn","state":"active","type":"type","sub_type":"sub_type","resource_id":"resource_id","dashboard_url":"dashboard_url","last_operation":{"type":"type","state":"in progress","sub_type":"sub_type","async":true,"description":"description","reason_code":"reason_code","poll_after":10,"cancelable":true,"poll":true},"resource_aliases_url":"resource_aliases_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url","plan_history":[{"resource_plan_id":"resource_plan_id","start_date":"2019-01-01T12:00:00.000Z","requestor_id":"requestor_id"}],"migrated":true,"extensions":{"anyKey":"anyValue"},"controlled_by":"controlled_by","locked":true}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","scheduled_reclaim_at":"2019-01-01T12:00:00.000Z","restored_at":"2019-01-01T12:00:00.000Z","restored_by":"restored_by","scheduled_reclaim_by":"scheduled_reclaim_by","name":"name","region_id":"region_id","account_id":"account_id","reseller_channel_id":"reseller_channel_id","resource_plan_id":"resource_plan_id","resource_group_id":"resource_group_id","resource_group_crn":"resource_group_crn","target_crn":"target_crn","parameters":{"anyKey":"anyValue"},"allow_cleanup":false,"crn":"crn","state":"active","type":"type","sub_type":"sub_type","resource_id":"resource_id","dashboard_url":"dashboard_url","last_operation":{"type":"type","state":"in progress","sub_type":"sub_type","async":true,"description":"description","reason_code":"reason_code","poll_after":10,"cancelable":true,"poll":true},"resource_aliases_url":"resource_aliases_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url","plan_history":[{"resource_plan_id":"resource_plan_id","start_date":"2019-01-01T12:00:00.000Z","requestor_id":"requestor_id"}],"migrated":true,"extensions":{"anyKey":"anyValue"},"controlled_by":"controlled_by","locked":true}]}' - 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) + 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 = ResourceInstancesPager( @@ -287,7 +262,8 @@ def test_list_resource_instances_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestCreateResourceInstance(): + +class TestCreateResourceInstance: """ Test Class for create_resource_instance """ @@ -300,11 +276,7 @@ def test_create_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'ExampleResourceInstance' @@ -326,7 +298,7 @@ def test_create_resource_instance_all_params(self): allow_cleanup=allow_cleanup, parameters=parameters, entity_lock=entity_lock, - headers={} + headers={}, ) # Check for correct operation @@ -359,11 +331,7 @@ def test_create_resource_instance_required_params(self): # Set up mock url = preprocess_url('/v2/resource_instances') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'ExampleResourceInstance' @@ -383,7 +351,7 @@ def test_create_resource_instance_required_params(self): tags=tags, allow_cleanup=allow_cleanup, parameters=parameters, - headers={} + headers={}, ) # Check for correct operation @@ -416,11 +384,7 @@ def test_create_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'ExampleResourceInstance' @@ -439,7 +403,7 @@ def test_create_resource_instance_value_error(self): "resource_plan_id": resource_plan_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()} + 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_resource_instance(**req_copy) @@ -452,7 +416,8 @@ def test_create_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_create_resource_instance_value_error() -class TestGetResourceInstance(): + +class TestGetResourceInstance: """ Test Class for get_resource_instance """ @@ -465,20 +430,13 @@ def test_get_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_resource_instance( - id, - headers={} - ) + response = _service.get_resource_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -501,11 +459,7 @@ def test_get_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -515,7 +469,7 @@ def test_get_resource_instance_value_error(self): "id": 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()} + 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_resource_instance(**req_copy) @@ -528,7 +482,8 @@ def test_get_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_get_resource_instance_value_error() -class TestDeleteResourceInstance(): + +class TestDeleteResourceInstance: """ Test Class for delete_resource_instance """ @@ -540,26 +495,20 @@ def test_delete_resource_instance_all_params(self): """ # Set up mock url = preprocess_url('/v2/resource_instances/testString') - responses.add(responses.DELETE, - url, - status=202) + responses.add(responses.DELETE, url, status=202) # Set up parameter values id = 'testString' recursive = False # Invoke method - response = _service.delete_resource_instance( - id, - recursive=recursive, - headers={} - ) + response = _service.delete_resource_instance(id, recursive=recursive, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 202 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'recursive={}'.format('true' if recursive else 'false') in query_string @@ -579,18 +528,13 @@ def test_delete_resource_instance_required_params(self): """ # Set up mock url = preprocess_url('/v2/resource_instances/testString') - responses.add(responses.DELETE, - url, - status=202) + responses.add(responses.DELETE, url, status=202) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_resource_instance( - id, - headers={} - ) + response = _service.delete_resource_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -612,9 +556,7 @@ def test_delete_resource_instance_value_error(self): """ # Set up mock url = preprocess_url('/v2/resource_instances/testString') - responses.add(responses.DELETE, - url, - status=202) + responses.add(responses.DELETE, url, status=202) # Set up parameter values id = 'testString' @@ -624,7 +566,7 @@ def test_delete_resource_instance_value_error(self): "id": 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()} + 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_resource_instance(**req_copy) @@ -637,7 +579,8 @@ def test_delete_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_delete_resource_instance_value_error() -class TestUpdateResourceInstance(): + +class TestUpdateResourceInstance: """ Test Class for update_resource_instance """ @@ -650,11 +593,7 @@ def test_update_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -670,7 +609,7 @@ def test_update_resource_instance_all_params(self): parameters=parameters, resource_plan_id=resource_plan_id, allow_cleanup=allow_cleanup, - headers={} + headers={}, ) # Check for correct operation @@ -700,11 +639,7 @@ def test_update_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -718,7 +653,7 @@ def test_update_resource_instance_value_error(self): "id": 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()} + 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_resource_instance(**req_copy) @@ -731,7 +666,8 @@ def test_update_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_update_resource_instance_value_error() -class TestListResourceAliasesForInstance(): + +class TestListResourceAliasesForInstance: """ Test Class for list_resource_aliases_for_instance """ @@ -744,11 +680,7 @@ def test_list_resource_aliases_for_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_aliases') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -756,18 +688,13 @@ def test_list_resource_aliases_for_instance_all_params(self): start = 'testString' # Invoke method - response = _service.list_resource_aliases_for_instance( - id, - limit=limit, - start=start, - headers={} - ) + response = _service.list_resource_aliases_for_instance(id, limit=limit, start=start, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'limit={}'.format(limit) in query_string assert 'start={}'.format(start) in query_string @@ -789,20 +716,13 @@ def test_list_resource_aliases_for_instance_required_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_aliases') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.list_resource_aliases_for_instance( - id, - headers={} - ) + response = _service.list_resource_aliases_for_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -825,11 +745,7 @@ def test_list_resource_aliases_for_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_aliases') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -839,7 +755,7 @@ def test_list_resource_aliases_for_instance_value_error(self): "id": 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()} + 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_resource_aliases_for_instance(**req_copy) @@ -861,16 +777,8 @@ def test_list_resource_aliases_for_instance_with_pager_get_next(self): url = preprocess_url('/v2/resource_instances/testString/resource_aliases') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' - 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) + 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 = [] @@ -894,16 +802,8 @@ def test_list_resource_aliases_for_instance_with_pager_get_all(self): url = preprocess_url('/v2/resource_instances/testString/resource_aliases') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' - 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) + 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 = ResourceAliasesForInstancePager( @@ -915,7 +815,8 @@ def test_list_resource_aliases_for_instance_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestListResourceKeysForInstance(): + +class TestListResourceKeysForInstance: """ Test Class for list_resource_keys_for_instance """ @@ -928,11 +829,7 @@ def test_list_resource_keys_for_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_keys') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -940,18 +837,13 @@ def test_list_resource_keys_for_instance_all_params(self): start = 'testString' # Invoke method - response = _service.list_resource_keys_for_instance( - id, - limit=limit, - start=start, - headers={} - ) + response = _service.list_resource_keys_for_instance(id, limit=limit, start=start, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'limit={}'.format(limit) in query_string assert 'start={}'.format(start) in query_string @@ -973,20 +865,13 @@ def test_list_resource_keys_for_instance_required_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_keys') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.list_resource_keys_for_instance( - id, - headers={} - ) + response = _service.list_resource_keys_for_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1009,11 +894,7 @@ def test_list_resource_keys_for_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/resource_keys') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1023,7 +904,7 @@ def test_list_resource_keys_for_instance_value_error(self): "id": 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()} + 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_resource_keys_for_instance(**req_copy) @@ -1045,16 +926,8 @@ def test_list_resource_keys_for_instance_with_pager_get_next(self): url = preprocess_url('/v2/resource_instances/testString/resource_keys') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = [] @@ -1078,16 +951,8 @@ def test_list_resource_keys_for_instance_with_pager_get_all(self): url = preprocess_url('/v2/resource_instances/testString/resource_keys') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = ResourceKeysForInstancePager( @@ -1099,7 +964,8 @@ def test_list_resource_keys_for_instance_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestLockResourceInstance(): + +class TestLockResourceInstance: """ Test Class for lock_resource_instance """ @@ -1112,20 +978,13 @@ def test_lock_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/lock') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.lock_resource_instance( - id, - headers={} - ) + response = _service.lock_resource_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1148,11 +1007,7 @@ def test_lock_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/lock') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1162,7 +1017,7 @@ def test_lock_resource_instance_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.lock_resource_instance(**req_copy) @@ -1175,7 +1030,8 @@ def test_lock_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_lock_resource_instance_value_error() -class TestUnlockResourceInstance(): + +class TestUnlockResourceInstance: """ Test Class for unlock_resource_instance """ @@ -1188,20 +1044,13 @@ def test_unlock_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/lock') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.unlock_resource_instance( - id, - headers={} - ) + response = _service.unlock_resource_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1224,11 +1073,7 @@ def test_unlock_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/lock') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1238,7 +1083,7 @@ def test_unlock_resource_instance_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.unlock_resource_instance(**req_copy) @@ -1251,7 +1096,8 @@ def test_unlock_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_unlock_resource_instance_value_error() -class TestCancelLastopResourceInstance(): + +class TestCancelLastopResourceInstance: """ Test Class for cancel_lastop_resource_instance """ @@ -1264,20 +1110,13 @@ def test_cancel_lastop_resource_instance_all_params(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/last_operation') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.cancel_lastop_resource_instance( - id, - headers={} - ) + response = _service.cancel_lastop_resource_instance(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1300,11 +1139,7 @@ def test_cancel_lastop_resource_instance_value_error(self): # Set up mock url = preprocess_url('/v2/resource_instances/testString/last_operation') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "scheduled_reclaim_at": "2019-01-01T12:00:00.000Z", "restored_at": "2019-01-01T12:00:00.000Z", "restored_by": "restored_by", "scheduled_reclaim_by": "scheduled_reclaim_by", "name": "name", "region_id": "region_id", "account_id": "account_id", "reseller_channel_id": "reseller_channel_id", "resource_plan_id": "resource_plan_id", "resource_group_id": "resource_group_id", "resource_group_crn": "resource_group_crn", "target_crn": "target_crn", "parameters": {"anyKey": "anyValue"}, "allow_cleanup": false, "crn": "crn", "state": "active", "type": "type", "sub_type": "sub_type", "resource_id": "resource_id", "dashboard_url": "dashboard_url", "last_operation": {"type": "type", "state": "in progress", "sub_type": "sub_type", "async": true, "description": "description", "reason_code": "reason_code", "poll_after": 10, "cancelable": true, "poll": true}, "resource_aliases_url": "resource_aliases_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url", "plan_history": [{"resource_plan_id": "resource_plan_id", "start_date": "2019-01-01T12:00:00.000Z", "requestor_id": "requestor_id"}], "migrated": true, "extensions": {"anyKey": "anyValue"}, "controlled_by": "controlled_by", "locked": true}' - responses.add(responses.DELETE, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.DELETE, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1314,7 +1149,7 @@ def test_cancel_lastop_resource_instance_value_error(self): "id": 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.cancel_lastop_resource_instance(**req_copy) @@ -1327,6 +1162,7 @@ def test_cancel_lastop_resource_instance_value_error_with_retries(self): _service.disable_retries() self.test_cancel_lastop_resource_instance_value_error() + # endregion ############################################################################## # End of Service: ResourceInstances @@ -1337,7 +1173,8 @@ def test_cancel_lastop_resource_instance_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1364,7 +1201,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListResourceKeys(): + +class TestListResourceKeys: """ Test Class for list_resource_keys """ @@ -1377,11 +1215,7 @@ def test_list_resource_keys_all_params(self): # Set up mock url = preprocess_url('/v2/resource_keys') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values guid = 'testString' @@ -1403,14 +1237,14 @@ def test_list_resource_keys_all_params(self): start=start, updated_from=updated_from, updated_to=updated_to, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'guid={}'.format(guid) in query_string assert 'name={}'.format(name) in query_string @@ -1438,16 +1272,11 @@ def test_list_resource_keys_required_params(self): # Set up mock url = preprocess_url('/v2/resource_keys') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_resource_keys() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -1470,16 +1299,8 @@ def test_list_resource_keys_with_pager_get_next(self): url = preprocess_url('/v2/resource_keys') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = [] @@ -1508,16 +1329,8 @@ def test_list_resource_keys_with_pager_get_all(self): url = preprocess_url('/v2/resource_keys') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","name":"name","crn":"crn","state":"state","account_id":"account_id","resource_group_id":"resource_group_id","resource_id":"resource_id","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"migrated":true,"resource_instance_url":"resource_instance_url","resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = ResourceKeysPager( @@ -1534,7 +1347,8 @@ def test_list_resource_keys_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestCreateResourceKey(): + +class TestCreateResourceKey: """ Test Class for create_resource_key """ @@ -1547,15 +1361,13 @@ def test_create_resource_key_all_params(self): # Set up mock url = preprocess_url('/v2/resource_keys') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ResourceKeyPostParameters model resource_key_post_parameters_model = {} - resource_key_post_parameters_model['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_key_post_parameters_model[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_key_post_parameters_model['exampleParameter'] = 'exampleValue' # Set up parameter values @@ -1565,13 +1377,7 @@ def test_create_resource_key_all_params(self): role = 'Writer' # Invoke method - response = _service.create_resource_key( - name, - source, - parameters=parameters, - role=role, - headers={} - ) + response = _service.create_resource_key(name, source, parameters=parameters, role=role, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1600,15 +1406,13 @@ def test_create_resource_key_value_error(self): # Set up mock url = preprocess_url('/v2/resource_keys') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ResourceKeyPostParameters model resource_key_post_parameters_model = {} - resource_key_post_parameters_model['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_key_post_parameters_model[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_key_post_parameters_model['exampleParameter'] = 'exampleValue' # Set up parameter values @@ -1623,7 +1427,7 @@ def test_create_resource_key_value_error(self): "source": source, } 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()} + 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_resource_key(**req_copy) @@ -1636,7 +1440,8 @@ def test_create_resource_key_value_error_with_retries(self): _service.disable_retries() self.test_create_resource_key_value_error() -class TestGetResourceKey(): + +class TestGetResourceKey: """ Test Class for get_resource_key """ @@ -1649,20 +1454,13 @@ def test_get_resource_key_all_params(self): # Set up mock url = preprocess_url('/v2/resource_keys/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_resource_key( - id, - headers={} - ) + response = _service.get_resource_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1685,11 +1483,7 @@ def test_get_resource_key_value_error(self): # Set up mock url = preprocess_url('/v2/resource_keys/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1699,7 +1493,7 @@ def test_get_resource_key_value_error(self): "id": 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()} + 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_resource_key(**req_copy) @@ -1712,7 +1506,8 @@ def test_get_resource_key_value_error_with_retries(self): _service.disable_retries() self.test_get_resource_key_value_error() -class TestDeleteResourceKey(): + +class TestDeleteResourceKey: """ Test Class for delete_resource_key """ @@ -1724,18 +1519,13 @@ def test_delete_resource_key_all_params(self): """ # Set up mock url = preprocess_url('/v2/resource_keys/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_resource_key( - id, - headers={} - ) + response = _service.delete_resource_key(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1757,9 +1547,7 @@ def test_delete_resource_key_value_error(self): """ # Set up mock url = preprocess_url('/v2/resource_keys/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -1769,7 +1557,7 @@ def test_delete_resource_key_value_error(self): "id": 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()} + 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_resource_key(**req_copy) @@ -1782,7 +1570,8 @@ def test_delete_resource_key_value_error_with_retries(self): _service.disable_retries() self.test_delete_resource_key_value_error() -class TestUpdateResourceKey(): + +class TestUpdateResourceKey: """ Test Class for update_resource_key """ @@ -1795,22 +1584,14 @@ def test_update_resource_key_all_params(self): # Set up mock url = preprocess_url('/v2/resource_keys/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' name = 'UpdatedExampleResourceKey' # Invoke method - response = _service.update_resource_key( - id, - name, - headers={} - ) + response = _service.update_resource_key(id, name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1836,11 +1617,7 @@ def test_update_resource_key_value_error(self): # Set up mock url = preprocess_url('/v2/resource_keys/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "name": "name", "crn": "crn", "state": "state", "account_id": "account_id", "resource_group_id": "resource_group_id", "resource_id": "resource_id", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "migrated": true, "resource_instance_url": "resource_instance_url", "resource_alias_url": "resource_alias_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -1852,7 +1629,7 @@ def test_update_resource_key_value_error(self): "name": name, } 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()} + 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_resource_key(**req_copy) @@ -1865,6 +1642,7 @@ def test_update_resource_key_value_error_with_retries(self): _service.disable_retries() self.test_update_resource_key_value_error() + # endregion ############################################################################## # End of Service: ResourceKeys @@ -1875,7 +1653,8 @@ def test_update_resource_key_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -1902,7 +1681,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListResourceBindings(): + +class TestListResourceBindings: """ Test Class for list_resource_bindings """ @@ -1915,11 +1695,7 @@ def test_list_resource_bindings_all_params(self): # Set up mock url = preprocess_url('/v2/resource_bindings') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values guid = 'testString' @@ -1943,14 +1719,14 @@ def test_list_resource_bindings_all_params(self): start=start, updated_from=updated_from, updated_to=updated_to, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'guid={}'.format(guid) in query_string assert 'name={}'.format(name) in query_string @@ -1979,16 +1755,11 @@ def test_list_resource_bindings_required_params(self): # Set up mock url = preprocess_url('/v2/resource_bindings') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_resource_bindings() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -2011,16 +1782,8 @@ def test_list_resource_bindings_with_pager_get_next(self): url = preprocess_url('/v2/resource_bindings') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = [] @@ -2050,16 +1813,8 @@ def test_list_resource_bindings_with_pager_get_all(self): url = preprocess_url('/v2/resource_bindings') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = ResourceBindingsPager( @@ -2077,7 +1832,8 @@ def test_list_resource_bindings_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestCreateResourceBinding(): + +class TestCreateResourceBinding: """ Test Class for create_resource_binding """ @@ -2090,15 +1846,13 @@ def test_create_resource_binding_all_params(self): # Set up mock url = preprocess_url('/v2/resource_bindings') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ResourceBindingPostParameters model resource_binding_post_parameters_model = {} - resource_binding_post_parameters_model['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_binding_post_parameters_model[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_binding_post_parameters_model['exampleParameter'] = 'exampleValue' # Set up parameter values @@ -2110,12 +1864,7 @@ def test_create_resource_binding_all_params(self): # Invoke method response = _service.create_resource_binding( - source, - target, - name=name, - parameters=parameters, - role=role, - headers={} + source, target, name=name, parameters=parameters, role=role, headers={} ) # Check for correct operation @@ -2124,7 +1873,10 @@ def test_create_resource_binding_all_params(self): # Validate body params req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['source'] == 'faaec9d8-ec64-44d8-ab83-868632fac6a2' - assert req_body['target'] == 'crn:v1:staging:public:bluemix:us-south:s/e1773b6e-17b4-40c8-b5ed-d2a1c4b620d7::cf-application:8d9457e0-1303-4f32-b4b3-5525575f6205' + assert ( + req_body['target'] + == 'crn:v1:staging:public:bluemix:us-south:s/e1773b6e-17b4-40c8-b5ed-d2a1c4b620d7::cf-application:8d9457e0-1303-4f32-b4b3-5525575f6205' + ) assert req_body['name'] == 'ExampleResourceBinding' assert req_body['parameters'] == resource_binding_post_parameters_model assert req_body['role'] == 'Writer' @@ -2146,15 +1898,13 @@ def test_create_resource_binding_value_error(self): # Set up mock url = preprocess_url('/v2/resource_bindings') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Construct a dict representation of a ResourceBindingPostParameters model resource_binding_post_parameters_model = {} - resource_binding_post_parameters_model['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_binding_post_parameters_model[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_binding_post_parameters_model['exampleParameter'] = 'exampleValue' # Set up parameter values @@ -2170,7 +1920,7 @@ def test_create_resource_binding_value_error(self): "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()} + 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_resource_binding(**req_copy) @@ -2183,7 +1933,8 @@ def test_create_resource_binding_value_error_with_retries(self): _service.disable_retries() self.test_create_resource_binding_value_error() -class TestGetResourceBinding(): + +class TestGetResourceBinding: """ Test Class for get_resource_binding """ @@ -2196,20 +1947,13 @@ def test_get_resource_binding_all_params(self): # Set up mock url = preprocess_url('/v2/resource_bindings/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_resource_binding( - id, - headers={} - ) + response = _service.get_resource_binding(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2232,11 +1976,7 @@ def test_get_resource_binding_value_error(self): # Set up mock url = preprocess_url('/v2/resource_bindings/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2246,7 +1986,7 @@ def test_get_resource_binding_value_error(self): "id": 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()} + 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_resource_binding(**req_copy) @@ -2259,7 +1999,8 @@ def test_get_resource_binding_value_error_with_retries(self): _service.disable_retries() self.test_get_resource_binding_value_error() -class TestDeleteResourceBinding(): + +class TestDeleteResourceBinding: """ Test Class for delete_resource_binding """ @@ -2271,18 +2012,13 @@ def test_delete_resource_binding_all_params(self): """ # Set up mock url = preprocess_url('/v2/resource_bindings/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_resource_binding( - id, - headers={} - ) + response = _service.delete_resource_binding(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2304,9 +2040,7 @@ def test_delete_resource_binding_value_error(self): """ # Set up mock url = preprocess_url('/v2/resource_bindings/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -2316,7 +2050,7 @@ def test_delete_resource_binding_value_error(self): "id": 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()} + 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_resource_binding(**req_copy) @@ -2329,7 +2063,8 @@ def test_delete_resource_binding_value_error_with_retries(self): _service.disable_retries() self.test_delete_resource_binding_value_error() -class TestUpdateResourceBinding(): + +class TestUpdateResourceBinding: """ Test Class for update_resource_binding """ @@ -2342,22 +2077,14 @@ def test_update_resource_binding_all_params(self): # Set up mock url = preprocess_url('/v2/resource_bindings/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' name = 'UpdatedExampleResourceBinding' # Invoke method - response = _service.update_resource_binding( - id, - name, - headers={} - ) + response = _service.update_resource_binding(id, name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2383,11 +2110,7 @@ def test_update_resource_binding_value_error(self): # Set up mock url = preprocess_url('/v2/resource_bindings/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2399,7 +2122,7 @@ def test_update_resource_binding_value_error(self): "name": name, } 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()} + 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_resource_binding(**req_copy) @@ -2412,6 +2135,7 @@ def test_update_resource_binding_value_error_with_retries(self): _service.disable_retries() self.test_update_resource_binding_value_error() + # endregion ############################################################################## # End of Service: ResourceBindings @@ -2422,7 +2146,8 @@ def test_update_resource_binding_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -2449,7 +2174,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListResourceAliases(): + +class TestListResourceAliases: """ Test Class for list_resource_aliases """ @@ -2462,11 +2188,7 @@ def test_list_resource_aliases_all_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values guid = 'testString' @@ -2492,14 +2214,14 @@ def test_list_resource_aliases_all_params(self): start=start, updated_from=updated_from, updated_to=updated_to, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'guid={}'.format(guid) in query_string assert 'name={}'.format(name) in query_string @@ -2529,16 +2251,11 @@ def test_list_resource_aliases_required_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_resource_aliases() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -2561,16 +2278,8 @@ def test_list_resource_aliases_with_pager_get_next(self): url = preprocess_url('/v2/resource_aliases') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' - 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) + 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 = [] @@ -2601,16 +2310,8 @@ def test_list_resource_aliases_with_pager_get_all(self): url = preprocess_url('/v2/resource_aliases') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","name":"name","resource_instance_id":"resource_instance_id","target_crn":"target_crn","account_id":"account_id","resource_id":"resource_id","resource_group_id":"resource_group_id","crn":"crn","region_instance_id":"region_instance_id","region_instance_crn":"region_instance_crn","state":"state","migrated":true,"resource_instance_url":"resource_instance_url","resource_bindings_url":"resource_bindings_url","resource_keys_url":"resource_keys_url"}]}' - 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) + 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 = ResourceAliasesPager( @@ -2629,7 +2330,8 @@ def test_list_resource_aliases_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestCreateResourceAlias(): + +class TestCreateResourceAlias: """ Test Class for create_resource_alias """ @@ -2642,11 +2344,7 @@ def test_create_resource_alias_all_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'ExampleResourceAlias' @@ -2654,12 +2352,7 @@ def test_create_resource_alias_all_params(self): target = 'crn:v1:bluemix:public:bluemix:us-south:o/d35d4f0e-5076-4c89-9361-2522894b6548::cf-space:e1773b6e-17b4-40c8-b5ed-d2a1c4b620d7' # Invoke method - response = _service.create_resource_alias( - name, - source, - target, - headers={} - ) + response = _service.create_resource_alias(name, source, target, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2668,7 +2361,10 @@ def test_create_resource_alias_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body['name'] == 'ExampleResourceAlias' assert req_body['source'] == '381fd51a-f251-4f95-aff4-2b03fa8caa63' - assert req_body['target'] == 'crn:v1:bluemix:public:bluemix:us-south:o/d35d4f0e-5076-4c89-9361-2522894b6548::cf-space:e1773b6e-17b4-40c8-b5ed-d2a1c4b620d7' + assert ( + req_body['target'] + == 'crn:v1:bluemix:public:bluemix:us-south:o/d35d4f0e-5076-4c89-9361-2522894b6548::cf-space:e1773b6e-17b4-40c8-b5ed-d2a1c4b620d7' + ) def test_create_resource_alias_all_params_with_retries(self): # Enable retries and run test_create_resource_alias_all_params. @@ -2687,11 +2383,7 @@ def test_create_resource_alias_value_error(self): # Set up mock url = preprocess_url('/v2/resource_aliases') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'ExampleResourceAlias' @@ -2705,7 +2397,7 @@ def test_create_resource_alias_value_error(self): "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()} + 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_resource_alias(**req_copy) @@ -2718,7 +2410,8 @@ def test_create_resource_alias_value_error_with_retries(self): _service.disable_retries() self.test_create_resource_alias_value_error() -class TestGetResourceAlias(): + +class TestGetResourceAlias: """ Test Class for get_resource_alias """ @@ -2731,20 +2424,13 @@ def test_get_resource_alias_all_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_resource_alias( - id, - headers={} - ) + response = _service.get_resource_alias(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2767,11 +2453,7 @@ def test_get_resource_alias_value_error(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2781,7 +2463,7 @@ def test_get_resource_alias_value_error(self): "id": 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()} + 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_resource_alias(**req_copy) @@ -2794,7 +2476,8 @@ def test_get_resource_alias_value_error_with_retries(self): _service.disable_retries() self.test_get_resource_alias_value_error() -class TestDeleteResourceAlias(): + +class TestDeleteResourceAlias: """ Test Class for delete_resource_alias """ @@ -2806,26 +2489,20 @@ def test_delete_resource_alias_all_params(self): """ # Set up mock url = preprocess_url('/v2/resource_aliases/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' recursive = False # Invoke method - response = _service.delete_resource_alias( - id, - recursive=recursive, - headers={} - ) + response = _service.delete_resource_alias(id, recursive=recursive, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'recursive={}'.format('true' if recursive else 'false') in query_string @@ -2845,18 +2522,13 @@ def test_delete_resource_alias_required_params(self): """ # Set up mock url = preprocess_url('/v2/resource_aliases/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_resource_alias( - id, - headers={} - ) + response = _service.delete_resource_alias(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2878,9 +2550,7 @@ def test_delete_resource_alias_value_error(self): """ # Set up mock url = preprocess_url('/v2/resource_aliases/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -2890,7 +2560,7 @@ def test_delete_resource_alias_value_error(self): "id": 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()} + 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_resource_alias(**req_copy) @@ -2903,7 +2573,8 @@ def test_delete_resource_alias_value_error_with_retries(self): _service.disable_retries() self.test_delete_resource_alias_value_error() -class TestUpdateResourceAlias(): + +class TestUpdateResourceAlias: """ Test Class for update_resource_alias """ @@ -2916,22 +2587,14 @@ def test_update_resource_alias_all_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' name = 'UpdatedExampleResourceAlias' # Invoke method - response = _service.update_resource_alias( - id, - name, - headers={} - ) + response = _service.update_resource_alias(id, name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -2957,11 +2620,7 @@ def test_update_resource_alias_value_error(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString') mock_response = '{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "name": "name", "resource_instance_id": "resource_instance_id", "target_crn": "target_crn", "account_id": "account_id", "resource_id": "resource_id", "resource_group_id": "resource_group_id", "crn": "crn", "region_instance_id": "region_instance_id", "region_instance_crn": "region_instance_crn", "state": "state", "migrated": true, "resource_instance_url": "resource_instance_url", "resource_bindings_url": "resource_bindings_url", "resource_keys_url": "resource_keys_url"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -2973,7 +2632,7 @@ def test_update_resource_alias_value_error(self): "name": name, } 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()} + 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_resource_alias(**req_copy) @@ -2986,7 +2645,8 @@ def test_update_resource_alias_value_error_with_retries(self): _service.disable_retries() self.test_update_resource_alias_value_error() -class TestListResourceBindingsForAlias(): + +class TestListResourceBindingsForAlias: """ Test Class for list_resource_bindings_for_alias """ @@ -2999,11 +2659,7 @@ def test_list_resource_bindings_for_alias_all_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString/resource_bindings') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -3011,18 +2667,13 @@ def test_list_resource_bindings_for_alias_all_params(self): start = 'testString' # Invoke method - response = _service.list_resource_bindings_for_alias( - id, - limit=limit, - start=start, - headers={} - ) + response = _service.list_resource_bindings_for_alias(id, limit=limit, start=start, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'limit={}'.format(limit) in query_string assert 'start={}'.format(start) in query_string @@ -3044,20 +2695,13 @@ def test_list_resource_bindings_for_alias_required_params(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString/resource_bindings') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.list_resource_bindings_for_alias( - id, - headers={} - ) + response = _service.list_resource_bindings_for_alias(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3080,11 +2724,7 @@ def test_list_resource_bindings_for_alias_value_error(self): # Set up mock url = preprocess_url('/v2/resource_aliases/testString/resource_bindings') mock_response = '{"rows_count": 10, "next_url": "next_url", "resources": [{"id": "id", "guid": "guid", "url": "url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z", "deleted_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_by": "updated_by", "deleted_by": "deleted_by", "source_crn": "source_crn", "target_crn": "target_crn", "crn": "crn", "region_binding_id": "region_binding_id", "region_binding_crn": "region_binding_crn", "name": "name", "account_id": "account_id", "resource_group_id": "resource_group_id", "state": "state", "credentials": {"REDACTED": "REDACTED", "apikey": "apikey", "iam_apikey_description": "iam_apikey_description", "iam_apikey_name": "iam_apikey_name", "iam_role_crn": "iam_role_crn", "iam_serviceid_crn": "iam_serviceid_crn"}, "iam_compatible": true, "resource_id": "resource_id", "migrated": true, "resource_alias_url": "resource_alias_url"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -3094,7 +2734,7 @@ def test_list_resource_bindings_for_alias_value_error(self): "id": 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()} + 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_resource_bindings_for_alias(**req_copy) @@ -3116,16 +2756,8 @@ def test_list_resource_bindings_for_alias_with_pager_get_next(self): url = preprocess_url('/v2/resource_aliases/testString/resource_bindings') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = [] @@ -3149,16 +2781,8 @@ def test_list_resource_bindings_for_alias_with_pager_get_all(self): url = preprocess_url('/v2/resource_aliases/testString/resource_bindings') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?start=1","resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","guid":"guid","url":"url","created_at":"2019-01-01T12:00:00.000Z","updated_at":"2019-01-01T12:00:00.000Z","deleted_at":"2019-01-01T12:00:00.000Z","created_by":"created_by","updated_by":"updated_by","deleted_by":"deleted_by","source_crn":"source_crn","target_crn":"target_crn","crn":"crn","region_binding_id":"region_binding_id","region_binding_crn":"region_binding_crn","name":"name","account_id":"account_id","resource_group_id":"resource_group_id","state":"state","credentials":{"REDACTED":"REDACTED","apikey":"apikey","iam_apikey_description":"iam_apikey_description","iam_apikey_name":"iam_apikey_name","iam_role_crn":"iam_role_crn","iam_serviceid_crn":"iam_serviceid_crn"},"iam_compatible":true,"resource_id":"resource_id","migrated":true,"resource_alias_url":"resource_alias_url"}]}' - 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) + 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 = ResourceBindingsForAliasPager( @@ -3170,6 +2794,7 @@ def test_list_resource_bindings_for_alias_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 + # endregion ############################################################################## # End of Service: ResourceAliases @@ -3180,7 +2805,8 @@ def test_list_resource_bindings_for_alias_with_pager_get_all(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -3207,7 +2833,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListReclamations(): + +class TestListReclamations: """ Test Class for list_reclamations """ @@ -3220,11 +2847,7 @@ def test_list_reclamations_all_params(self): # Set up mock url = preprocess_url('/v1/reclamations') mock_response = '{"resources": [{"id": "id", "entity_id": "entity_id", "entity_type_id": "entity_type_id", "entity_crn": "entity_crn", "resource_instance_id": "resource_instance_id", "resource_group_id": "resource_group_id", "account_id": "account_id", "policy_id": "policy_id", "state": "state", "target_time": "target_time", "custom_properties": {"anyKey": "anyValue"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -3232,16 +2855,14 @@ def test_list_reclamations_all_params(self): # Invoke method response = _service.list_reclamations( - account_id=account_id, - resource_instance_id=resource_instance_id, - headers={} + account_id=account_id, resource_instance_id=resource_instance_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 = 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 'resource_instance_id={}'.format(resource_instance_id) in query_string @@ -3263,16 +2884,11 @@ def test_list_reclamations_required_params(self): # Set up mock url = preprocess_url('/v1/reclamations') mock_response = '{"resources": [{"id": "id", "entity_id": "entity_id", "entity_type_id": "entity_type_id", "entity_crn": "entity_crn", "resource_instance_id": "resource_instance_id", "resource_group_id": "resource_group_id", "account_id": "account_id", "policy_id": "policy_id", "state": "state", "target_time": "target_time", "custom_properties": {"anyKey": "anyValue"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_reclamations() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -3286,7 +2902,8 @@ def test_list_reclamations_required_params_with_retries(self): _service.disable_retries() self.test_list_reclamations_required_params() -class TestRunReclamationAction(): + +class TestRunReclamationAction: """ Test Class for run_reclamation_action """ @@ -3299,11 +2916,7 @@ def test_run_reclamation_action_all_params(self): # Set up mock url = preprocess_url('/v1/reclamations/testString/actions/testString') mock_response = '{"id": "id", "entity_id": "entity_id", "entity_type_id": "entity_type_id", "entity_crn": "entity_crn", "resource_instance_id": "resource_instance_id", "resource_group_id": "resource_group_id", "account_id": "account_id", "policy_id": "policy_id", "state": "state", "target_time": "target_time", "custom_properties": {"anyKey": "anyValue"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -3312,13 +2925,7 @@ def test_run_reclamation_action_all_params(self): comment = 'testString' # Invoke method - response = _service.run_reclamation_action( - id, - action_name, - request_by=request_by, - comment=comment, - headers={} - ) + response = _service.run_reclamation_action(id, action_name, request_by=request_by, comment=comment, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3345,22 +2952,14 @@ def test_run_reclamation_action_required_params(self): # Set up mock url = preprocess_url('/v1/reclamations/testString/actions/testString') mock_response = '{"id": "id", "entity_id": "entity_id", "entity_type_id": "entity_type_id", "entity_crn": "entity_crn", "resource_instance_id": "resource_instance_id", "resource_group_id": "resource_group_id", "account_id": "account_id", "policy_id": "policy_id", "state": "state", "target_time": "target_time", "custom_properties": {"anyKey": "anyValue"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' action_name = 'testString' # Invoke method - response = _service.run_reclamation_action( - id, - action_name, - headers={} - ) + response = _service.run_reclamation_action(id, action_name, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -3383,11 +2982,7 @@ def test_run_reclamation_action_value_error(self): # Set up mock url = preprocess_url('/v1/reclamations/testString/actions/testString') mock_response = '{"id": "id", "entity_id": "entity_id", "entity_type_id": "entity_type_id", "entity_crn": "entity_crn", "resource_instance_id": "resource_instance_id", "resource_group_id": "resource_group_id", "account_id": "account_id", "policy_id": "policy_id", "state": "state", "target_time": "target_time", "custom_properties": {"anyKey": "anyValue"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "created_by", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "updated_by"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -3399,7 +2994,7 @@ def test_run_reclamation_action_value_error(self): "action_name": action_name, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.run_reclamation_action(**req_copy) @@ -3412,6 +3007,7 @@ def test_run_reclamation_action_value_error_with_retries(self): _service.disable_retries() self.test_run_reclamation_action_value_error() + # endregion ############################################################################## # End of Service: ResourceReclamations @@ -3422,7 +3018,7 @@ def test_run_reclamation_action_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_Credentials(): +class TestModel_Credentials: """ Test Class for Credentials """ @@ -3467,7 +3063,8 @@ def test_credentials_serialization(self): actual_dict = credentials_model.get_properties() assert actual_dict == expected_dict -class TestModel_PlanHistoryItem(): + +class TestModel_PlanHistoryItem: """ Test Class for PlanHistoryItem """ @@ -3498,7 +3095,8 @@ def test_plan_history_item_serialization(self): plan_history_item_model_json2 = plan_history_item_model.to_dict() assert plan_history_item_model_json2 == plan_history_item_model_json -class TestModel_Reclamation(): + +class TestModel_Reclamation: """ Test Class for Reclamation """ @@ -3541,7 +3139,8 @@ def test_reclamation_serialization(self): reclamation_model_json2 = reclamation_model.to_dict() assert reclamation_model_json2 == reclamation_model_json -class TestModel_ReclamationsList(): + +class TestModel_ReclamationsList: """ Test Class for ReclamationsList """ @@ -3553,7 +3152,7 @@ def test_reclamations_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - reclamation_model = {} # Reclamation + reclamation_model = {} # Reclamation reclamation_model['id'] = 'testString' reclamation_model['entity_id'] = 'testString' reclamation_model['entity_type_id'] = 'testString' @@ -3589,7 +3188,8 @@ def test_reclamations_list_serialization(self): reclamations_list_model_json2 = reclamations_list_model.to_dict() assert reclamations_list_model_json2 == reclamations_list_model_json -class TestModel_ResourceAlias(): + +class TestModel_ResourceAlias: """ Test Class for ResourceAlias """ @@ -3640,7 +3240,8 @@ def test_resource_alias_serialization(self): resource_alias_model_json2 = resource_alias_model.to_dict() assert resource_alias_model_json2 == resource_alias_model_json -class TestModel_ResourceAliasesList(): + +class TestModel_ResourceAliasesList: """ Test Class for ResourceAliasesList """ @@ -3652,7 +3253,7 @@ def test_resource_aliases_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_alias_model = {} # ResourceAlias + resource_alias_model = {} # ResourceAlias resource_alias_model['id'] = 'testString' resource_alias_model['guid'] = 'testString' resource_alias_model['url'] = 'testString' @@ -3698,7 +3299,8 @@ def test_resource_aliases_list_serialization(self): resource_aliases_list_model_json2 = resource_aliases_list_model.to_dict() assert resource_aliases_list_model_json2 == resource_aliases_list_model_json -class TestModel_ResourceBinding(): + +class TestModel_ResourceBinding: """ Test Class for ResourceBinding """ @@ -3710,7 +3312,7 @@ def test_resource_binding_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - credentials_model = {} # Credentials + credentials_model = {} # Credentials credentials_model['REDACTED'] = 'REDACTED' credentials_model['apikey'] = 'testString' credentials_model['iam_apikey_description'] = 'testString' @@ -3760,7 +3362,8 @@ def test_resource_binding_serialization(self): resource_binding_model_json2 = resource_binding_model.to_dict() assert resource_binding_model_json2 == resource_binding_model_json -class TestModel_ResourceBindingPostParameters(): + +class TestModel_ResourceBindingPostParameters: """ Test Class for ResourceBindingPostParameters """ @@ -3772,16 +3375,24 @@ def test_resource_binding_post_parameters_serialization(self): # Construct a json representation of a ResourceBindingPostParameters model resource_binding_post_parameters_model_json = {} - resource_binding_post_parameters_model_json['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_binding_post_parameters_model_json[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_binding_post_parameters_model_json['foo'] = 'testString' # Construct a model instance of ResourceBindingPostParameters by calling from_dict on the json representation - resource_binding_post_parameters_model = ResourceBindingPostParameters.from_dict(resource_binding_post_parameters_model_json) + resource_binding_post_parameters_model = ResourceBindingPostParameters.from_dict( + resource_binding_post_parameters_model_json + ) assert resource_binding_post_parameters_model != False # Construct a model instance of ResourceBindingPostParameters by calling from_dict on the json representation - resource_binding_post_parameters_model_dict = ResourceBindingPostParameters.from_dict(resource_binding_post_parameters_model_json).__dict__ - resource_binding_post_parameters_model2 = ResourceBindingPostParameters(**resource_binding_post_parameters_model_dict) + resource_binding_post_parameters_model_dict = ResourceBindingPostParameters.from_dict( + resource_binding_post_parameters_model_json + ).__dict__ + resource_binding_post_parameters_model2 = ResourceBindingPostParameters( + **resource_binding_post_parameters_model_dict + ) # Verify the model instances are equivalent assert resource_binding_post_parameters_model == resource_binding_post_parameters_model2 @@ -3800,7 +3411,8 @@ def test_resource_binding_post_parameters_serialization(self): actual_dict = resource_binding_post_parameters_model.get_properties() assert actual_dict == expected_dict -class TestModel_ResourceBindingsList(): + +class TestModel_ResourceBindingsList: """ Test Class for ResourceBindingsList """ @@ -3812,7 +3424,7 @@ def test_resource_bindings_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - credentials_model = {} # Credentials + credentials_model = {} # Credentials credentials_model['REDACTED'] = 'REDACTED' credentials_model['apikey'] = 'testString' credentials_model['iam_apikey_description'] = 'testString' @@ -3821,7 +3433,7 @@ def test_resource_bindings_list_serialization(self): credentials_model['iam_serviceid_crn'] = 'testString' credentials_model['foo'] = 'testString' - resource_binding_model = {} # ResourceBinding + resource_binding_model = {} # ResourceBinding resource_binding_model['id'] = 'testString' resource_binding_model['guid'] = 'testString' resource_binding_model['url'] = 'testString' @@ -3867,7 +3479,8 @@ def test_resource_bindings_list_serialization(self): resource_bindings_list_model_json2 = resource_bindings_list_model.to_dict() assert resource_bindings_list_model_json2 == resource_bindings_list_model_json -class TestModel_ResourceInstance(): + +class TestModel_ResourceInstance: """ Test Class for ResourceInstance """ @@ -3879,7 +3492,7 @@ def test_resource_instance_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_instance_last_operation_model = {} # ResourceInstanceLastOperation + resource_instance_last_operation_model = {} # ResourceInstanceLastOperation resource_instance_last_operation_model['type'] = 'testString' resource_instance_last_operation_model['state'] = 'in progress' resource_instance_last_operation_model['sub_type'] = 'testString' @@ -3891,7 +3504,7 @@ def test_resource_instance_serialization(self): resource_instance_last_operation_model['poll'] = True resource_instance_last_operation_model['foo'] = 'testString' - plan_history_item_model = {} # PlanHistoryItem + plan_history_item_model = {} # PlanHistoryItem plan_history_item_model['resource_plan_id'] = 'testString' plan_history_item_model['start_date'] = '2019-01-01T12:00:00Z' plan_history_item_model['requestor_id'] = 'testString' @@ -3952,7 +3565,8 @@ def test_resource_instance_serialization(self): resource_instance_model_json2 = resource_instance_model.to_dict() assert resource_instance_model_json2 == resource_instance_model_json -class TestModel_ResourceInstanceLastOperation(): + +class TestModel_ResourceInstanceLastOperation: """ Test Class for ResourceInstanceLastOperation """ @@ -3976,12 +3590,18 @@ def test_resource_instance_last_operation_serialization(self): resource_instance_last_operation_model_json['foo'] = 'testString' # Construct a model instance of ResourceInstanceLastOperation by calling from_dict on the json representation - resource_instance_last_operation_model = ResourceInstanceLastOperation.from_dict(resource_instance_last_operation_model_json) + resource_instance_last_operation_model = ResourceInstanceLastOperation.from_dict( + resource_instance_last_operation_model_json + ) assert resource_instance_last_operation_model != False # Construct a model instance of ResourceInstanceLastOperation by calling from_dict on the json representation - resource_instance_last_operation_model_dict = ResourceInstanceLastOperation.from_dict(resource_instance_last_operation_model_json).__dict__ - resource_instance_last_operation_model2 = ResourceInstanceLastOperation(**resource_instance_last_operation_model_dict) + resource_instance_last_operation_model_dict = ResourceInstanceLastOperation.from_dict( + resource_instance_last_operation_model_json + ).__dict__ + resource_instance_last_operation_model2 = ResourceInstanceLastOperation( + **resource_instance_last_operation_model_dict + ) # Verify the model instances are equivalent assert resource_instance_last_operation_model == resource_instance_last_operation_model2 @@ -4000,7 +3620,8 @@ def test_resource_instance_last_operation_serialization(self): actual_dict = resource_instance_last_operation_model.get_properties() assert actual_dict == expected_dict -class TestModel_ResourceInstancesList(): + +class TestModel_ResourceInstancesList: """ Test Class for ResourceInstancesList """ @@ -4012,7 +3633,7 @@ def test_resource_instances_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_instance_last_operation_model = {} # ResourceInstanceLastOperation + resource_instance_last_operation_model = {} # ResourceInstanceLastOperation resource_instance_last_operation_model['type'] = 'testString' resource_instance_last_operation_model['state'] = 'in progress' resource_instance_last_operation_model['sub_type'] = 'testString' @@ -4024,12 +3645,12 @@ def test_resource_instances_list_serialization(self): resource_instance_last_operation_model['poll'] = True resource_instance_last_operation_model['foo'] = 'testString' - plan_history_item_model = {} # PlanHistoryItem + plan_history_item_model = {} # PlanHistoryItem plan_history_item_model['resource_plan_id'] = 'testString' plan_history_item_model['start_date'] = '2019-01-01T12:00:00Z' plan_history_item_model['requestor_id'] = 'testString' - resource_instance_model = {} # ResourceInstance + resource_instance_model = {} # ResourceInstance resource_instance_model['id'] = 'testString' resource_instance_model['guid'] = 'testString' resource_instance_model['url'] = 'testString' @@ -4080,7 +3701,9 @@ def test_resource_instances_list_serialization(self): assert resource_instances_list_model != False # Construct a model instance of ResourceInstancesList by calling from_dict on the json representation - resource_instances_list_model_dict = ResourceInstancesList.from_dict(resource_instances_list_model_json).__dict__ + resource_instances_list_model_dict = ResourceInstancesList.from_dict( + resource_instances_list_model_json + ).__dict__ resource_instances_list_model2 = ResourceInstancesList(**resource_instances_list_model_dict) # Verify the model instances are equivalent @@ -4090,7 +3713,8 @@ def test_resource_instances_list_serialization(self): resource_instances_list_model_json2 = resource_instances_list_model.to_dict() assert resource_instances_list_model_json2 == resource_instances_list_model_json -class TestModel_ResourceKey(): + +class TestModel_ResourceKey: """ Test Class for ResourceKey """ @@ -4102,7 +3726,7 @@ def test_resource_key_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - credentials_model = {} # Credentials + credentials_model = {} # Credentials credentials_model['REDACTED'] = 'REDACTED' credentials_model['apikey'] = 'testString' credentials_model['iam_apikey_description'] = 'testString' @@ -4150,7 +3774,8 @@ def test_resource_key_serialization(self): resource_key_model_json2 = resource_key_model.to_dict() assert resource_key_model_json2 == resource_key_model_json -class TestModel_ResourceKeyPostParameters(): + +class TestModel_ResourceKeyPostParameters: """ Test Class for ResourceKeyPostParameters """ @@ -4162,15 +3787,21 @@ def test_resource_key_post_parameters_serialization(self): # Construct a json representation of a ResourceKeyPostParameters model resource_key_post_parameters_model_json = {} - resource_key_post_parameters_model_json['serviceid_crn'] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' + resource_key_post_parameters_model_json[ + 'serviceid_crn' + ] = 'crn:v1:bluemix:public:iam-identity::a/9fceaa56d1ab84893af6b9eec5ab81bb::serviceid:ServiceId-fe4c29b5-db13-410a-bacc-b5779a03d393' resource_key_post_parameters_model_json['foo'] = 'testString' # Construct a model instance of ResourceKeyPostParameters by calling from_dict on the json representation - resource_key_post_parameters_model = ResourceKeyPostParameters.from_dict(resource_key_post_parameters_model_json) + resource_key_post_parameters_model = ResourceKeyPostParameters.from_dict( + resource_key_post_parameters_model_json + ) assert resource_key_post_parameters_model != False # Construct a model instance of ResourceKeyPostParameters by calling from_dict on the json representation - resource_key_post_parameters_model_dict = ResourceKeyPostParameters.from_dict(resource_key_post_parameters_model_json).__dict__ + resource_key_post_parameters_model_dict = ResourceKeyPostParameters.from_dict( + resource_key_post_parameters_model_json + ).__dict__ resource_key_post_parameters_model2 = ResourceKeyPostParameters(**resource_key_post_parameters_model_dict) # Verify the model instances are equivalent @@ -4190,7 +3821,8 @@ def test_resource_key_post_parameters_serialization(self): actual_dict = resource_key_post_parameters_model.get_properties() assert actual_dict == expected_dict -class TestModel_ResourceKeysList(): + +class TestModel_ResourceKeysList: """ Test Class for ResourceKeysList """ @@ -4202,7 +3834,7 @@ def test_resource_keys_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - credentials_model = {} # Credentials + credentials_model = {} # Credentials credentials_model['REDACTED'] = 'REDACTED' credentials_model['apikey'] = 'testString' credentials_model['iam_apikey_description'] = 'testString' @@ -4211,7 +3843,7 @@ def test_resource_keys_list_serialization(self): credentials_model['iam_serviceid_crn'] = 'testString' credentials_model['foo'] = 'testString' - resource_key_model = {} # ResourceKey + resource_key_model = {} # ResourceKey resource_key_model['id'] = 'testString' resource_key_model['guid'] = 'testString' resource_key_model['url'] = 'testString' diff --git a/test/unit/test_resource_manager_v2.py b/test/unit/test_resource_manager_v2.py index 7209d314..f3226ffa 100644 --- a/test/unit/test_resource_manager_v2.py +++ b/test/unit/test_resource_manager_v2.py @@ -31,9 +31,7 @@ from ibm_platform_services.resource_manager_v2 import * -_service = ResourceManagerV2( - authenticator=NoAuthAuthenticator() -) +_service = ResourceManagerV2(authenticator=NoAuthAuthenticator()) _base_url = 'https://resource-controller.cloud.ibm.com' _service.set_service_url(_base_url) @@ -43,7 +41,8 @@ ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -66,10 +65,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = ResourceManagerV2.new_instance( - ) + service = ResourceManagerV2.new_instance() + -class TestListResourceGroups(): +class TestListResourceGroups: """ Test Class for list_resource_groups """ @@ -78,7 +77,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -93,11 +92,7 @@ def test_list_resource_groups_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups') mock_response = '{"resources": [{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -108,19 +103,14 @@ def test_list_resource_groups_all_params(self): # Invoke method response = _service.list_resource_groups( - account_id=account_id, - date=date, - name=name, - default=default, - include_deleted=include_deleted, - headers={} + account_id=account_id, date=date, name=name, default=default, include_deleted=include_deleted, 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 = 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 'date={}'.format(date) in query_string @@ -145,16 +135,11 @@ def test_list_resource_groups_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups') mock_response = '{"resources": [{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_resource_groups() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -168,7 +153,8 @@ def test_list_resource_groups_required_params_with_retries(self): _service.disable_retries() self.test_list_resource_groups_required_params() -class TestCreateResourceGroup(): + +class TestCreateResourceGroup: """ Test Class for create_resource_group """ @@ -177,7 +163,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -192,22 +178,14 @@ def test_create_resource_group_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups') mock_response = '{"id": "id", "crn": "crn"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Set up parameter values name = 'test1' account_id = '25eba2a9-beef-450b-82cf-f5ad5e36c6dd' # Invoke method - response = _service.create_resource_group( - name=name, - account_id=account_id, - headers={} - ) + response = _service.create_resource_group(name=name, account_id=account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -234,16 +212,11 @@ def test_create_resource_group_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups') mock_response = '{"id": "id", "crn": "crn"}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=201) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=201) # Invoke method response = _service.create_resource_group() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 201 @@ -257,7 +230,8 @@ def test_create_resource_group_required_params_with_retries(self): _service.disable_retries() self.test_create_resource_group_required_params() -class TestGetResourceGroup(): + +class TestGetResourceGroup: """ Test Class for get_resource_group """ @@ -266,7 +240,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -281,20 +255,13 @@ def test_get_resource_group_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') mock_response = '{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_resource_group( - id, - headers={} - ) + response = _service.get_resource_group(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -317,11 +284,7 @@ def test_get_resource_group_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') mock_response = '{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -331,11 +294,10 @@ def test_get_resource_group_value_error(self): "id": 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()} + 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_resource_group(**req_copy) - def test_get_resource_group_value_error_with_retries(self): # Enable retries and run test_get_resource_group_value_error. _service.enable_retries() @@ -345,7 +307,8 @@ def test_get_resource_group_value_error_with_retries(self): _service.disable_retries() self.test_get_resource_group_value_error() -class TestUpdateResourceGroup(): + +class TestUpdateResourceGroup: """ Test Class for update_resource_group """ @@ -354,7 +317,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -369,11 +332,7 @@ def test_update_resource_group_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') mock_response = '{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -381,12 +340,7 @@ def test_update_resource_group_all_params(self): state = 'testString' # Invoke method - response = _service.update_resource_group( - id, - name=name, - state=state, - headers={} - ) + response = _service.update_resource_group(id, name=name, state=state, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -413,20 +367,13 @@ def test_update_resource_group_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') mock_response = '{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.update_resource_group( - id, - headers={} - ) + response = _service.update_resource_group(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -449,11 +396,7 @@ def test_update_resource_group_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') mock_response = '{"id": "id", "crn": "crn", "account_id": "account_id", "name": "name", "state": "state", "default": false, "quota_id": "quota_id", "quota_url": "quota_url", "payment_methods_url": "payment_methods_url", "resource_linkages": [{"anyKey": "anyValue"}], "teams_url": "teams_url", "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.PATCH, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.PATCH, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -463,11 +406,10 @@ def test_update_resource_group_value_error(self): "id": 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()} + 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_resource_group(**req_copy) - def test_update_resource_group_value_error_with_retries(self): # Enable retries and run test_update_resource_group_value_error. _service.enable_retries() @@ -477,7 +419,8 @@ def test_update_resource_group_value_error_with_retries(self): _service.disable_retries() self.test_update_resource_group_value_error() -class TestDeleteResourceGroup(): + +class TestDeleteResourceGroup: """ Test Class for delete_resource_group """ @@ -486,7 +429,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -500,18 +443,13 @@ def test_delete_resource_group_all_params(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' # Invoke method - response = _service.delete_resource_group( - id, - headers={} - ) + response = _service.delete_resource_group(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -533,9 +471,7 @@ def test_delete_resource_group_value_error(self): """ # Set up mock url = self.preprocess_url(_base_url + '/v2/resource_groups/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values id = 'testString' @@ -545,11 +481,10 @@ def test_delete_resource_group_value_error(self): "id": 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()} + 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_resource_group(**req_copy) - def test_delete_resource_group_value_error_with_retries(self): # Enable retries and run test_delete_resource_group_value_error. _service.enable_retries() @@ -559,6 +494,7 @@ def test_delete_resource_group_value_error_with_retries(self): _service.disable_retries() self.test_delete_resource_group_value_error() + # endregion ############################################################################## # End of Service: ResourceGroup @@ -569,7 +505,8 @@ def test_delete_resource_group_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -592,10 +529,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = ResourceManagerV2.new_instance( - ) + service = ResourceManagerV2.new_instance() + -class TestListQuotaDefinitions(): +class TestListQuotaDefinitions: """ Test Class for list_quota_definitions """ @@ -604,7 +541,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -619,16 +556,11 @@ def test_list_quota_definitions_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/quota_definitions') mock_response = '{"resources": [{"id": "id", "name": "name", "type": "type", "number_of_apps": 14, "number_of_service_instances": 27, "default_number_of_instances_per_lite_plan": 41, "instances_per_app": 17, "instance_memory": "instance_memory", "total_app_memory": "total_app_memory", "vsi_limit": 9, "resource_quotas": [{"_id": "id", "resource_id": "resource_id", "crn": "crn", "limit": 5}], "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Invoke method response = _service.list_quota_definitions() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 @@ -642,7 +574,8 @@ def test_list_quota_definitions_all_params_with_retries(self): _service.disable_retries() self.test_list_quota_definitions_all_params() -class TestGetQuotaDefinition(): + +class TestGetQuotaDefinition: """ Test Class for get_quota_definition """ @@ -651,7 +584,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -666,20 +599,13 @@ def test_get_quota_definition_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/quota_definitions/testString') mock_response = '{"id": "id", "name": "name", "type": "type", "number_of_apps": 14, "number_of_service_instances": 27, "default_number_of_instances_per_lite_plan": 41, "instances_per_app": 17, "instance_memory": "instance_memory", "total_app_memory": "total_app_memory", "vsi_limit": 9, "resource_quotas": [{"_id": "id", "resource_id": "resource_id", "crn": "crn", "limit": 5}], "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' # Invoke method - response = _service.get_quota_definition( - id, - headers={} - ) + response = _service.get_quota_definition(id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -702,11 +628,7 @@ def test_get_quota_definition_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v2/quota_definitions/testString') mock_response = '{"id": "id", "name": "name", "type": "type", "number_of_apps": 14, "number_of_service_instances": 27, "default_number_of_instances_per_lite_plan": 41, "instances_per_app": 17, "instance_memory": "instance_memory", "total_app_memory": "total_app_memory", "vsi_limit": 9, "resource_quotas": [{"_id": "id", "resource_id": "resource_id", "crn": "crn", "limit": 5}], "created_at": "2019-01-01T12:00:00.000Z", "updated_at": "2019-01-01T12:00:00.000Z"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values id = 'testString' @@ -716,11 +638,10 @@ def test_get_quota_definition_value_error(self): "id": 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()} + 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_quota_definition(**req_copy) - def test_get_quota_definition_value_error_with_retries(self): # Enable retries and run test_get_quota_definition_value_error. _service.enable_retries() @@ -730,6 +651,7 @@ def test_get_quota_definition_value_error_with_retries(self): _service.disable_retries() self.test_get_quota_definition_value_error() + # endregion ############################################################################## # End of Service: QuotaDefinition @@ -740,7 +662,7 @@ def test_get_quota_definition_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_QuotaDefinition(): +class TestModel_QuotaDefinition: """ Test Class for QuotaDefinition """ @@ -752,7 +674,7 @@ def test_quota_definition_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_quota_model = {} # ResourceQuota + resource_quota_model = {} # ResourceQuota resource_quota_model['_id'] = 'testString' resource_quota_model['resource_id'] = 'testString' resource_quota_model['crn'] = 'testString' @@ -789,7 +711,8 @@ def test_quota_definition_serialization(self): quota_definition_model_json2 = quota_definition_model.to_dict() assert quota_definition_model_json2 == quota_definition_model_json -class TestModel_QuotaDefinitionList(): + +class TestModel_QuotaDefinitionList: """ Test Class for QuotaDefinitionList """ @@ -801,13 +724,13 @@ def test_quota_definition_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_quota_model = {} # ResourceQuota + resource_quota_model = {} # ResourceQuota resource_quota_model['_id'] = 'testString' resource_quota_model['resource_id'] = 'testString' resource_quota_model['crn'] = 'testString' resource_quota_model['limit'] = 72.5 - quota_definition_model = {} # QuotaDefinition + quota_definition_model = {} # QuotaDefinition quota_definition_model['id'] = 'testString' quota_definition_model['name'] = 'testString' quota_definition_model['type'] = 'testString' @@ -841,7 +764,8 @@ def test_quota_definition_list_serialization(self): quota_definition_list_model_json2 = quota_definition_list_model.to_dict() assert quota_definition_list_model_json2 == quota_definition_list_model_json -class TestModel_ResCreateResourceGroup(): + +class TestModel_ResCreateResourceGroup: """ Test Class for ResCreateResourceGroup """ @@ -861,7 +785,9 @@ def test_res_create_resource_group_serialization(self): assert res_create_resource_group_model != False # Construct a model instance of ResCreateResourceGroup by calling from_dict on the json representation - res_create_resource_group_model_dict = ResCreateResourceGroup.from_dict(res_create_resource_group_model_json).__dict__ + res_create_resource_group_model_dict = ResCreateResourceGroup.from_dict( + res_create_resource_group_model_json + ).__dict__ res_create_resource_group_model2 = ResCreateResourceGroup(**res_create_resource_group_model_dict) # Verify the model instances are equivalent @@ -871,7 +797,8 @@ def test_res_create_resource_group_serialization(self): res_create_resource_group_model_json2 = res_create_resource_group_model.to_dict() assert res_create_resource_group_model_json2 == res_create_resource_group_model_json -class TestModel_ResourceGroup(): + +class TestModel_ResourceGroup: """ Test Class for ResourceGroup """ @@ -892,7 +819,7 @@ def test_resource_group_serialization(self): resource_group_model_json['quota_id'] = 'testString' resource_group_model_json['quota_url'] = 'testString' resource_group_model_json['payment_methods_url'] = 'testString' - resource_group_model_json['resource_linkages'] = [{ 'foo': 'bar' }] + resource_group_model_json['resource_linkages'] = [{'foo': 'bar'}] resource_group_model_json['teams_url'] = 'testString' resource_group_model_json['created_at'] = "2019-01-01T12:00:00Z" resource_group_model_json['updated_at'] = "2019-01-01T12:00:00Z" @@ -912,7 +839,8 @@ def test_resource_group_serialization(self): resource_group_model_json2 = resource_group_model.to_dict() assert resource_group_model_json2 == resource_group_model_json -class TestModel_ResourceGroupList(): + +class TestModel_ResourceGroupList: """ Test Class for ResourceGroupList """ @@ -924,7 +852,7 @@ def test_resource_group_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_group_model = {} # ResourceGroup + resource_group_model = {} # ResourceGroup resource_group_model['id'] = 'testString' resource_group_model['crn'] = 'testString' resource_group_model['account_id'] = 'testString' @@ -934,7 +862,7 @@ def test_resource_group_list_serialization(self): resource_group_model['quota_id'] = 'testString' resource_group_model['quota_url'] = 'testString' resource_group_model['payment_methods_url'] = 'testString' - resource_group_model['resource_linkages'] = [{ 'foo': 'bar' }] + resource_group_model['resource_linkages'] = [{'foo': 'bar'}] resource_group_model['teams_url'] = 'testString' resource_group_model['created_at'] = "2019-01-01T12:00:00Z" resource_group_model['updated_at'] = "2019-01-01T12:00:00Z" @@ -958,7 +886,8 @@ def test_resource_group_list_serialization(self): resource_group_list_model_json2 = resource_group_list_model.to_dict() assert resource_group_list_model_json2 == resource_group_list_model_json -class TestModel_ResourceQuota(): + +class TestModel_ResourceQuota: """ Test Class for ResourceQuota """ diff --git a/test/unit/test_usage_metering_v4.py b/test/unit/test_usage_metering_v4.py index 21425cf9..1b241a3f 100644 --- a/test/unit/test_usage_metering_v4.py +++ b/test/unit/test_usage_metering_v4.py @@ -27,9 +27,7 @@ from ibm_platform_services.usage_metering_v4 import * -service = UsageMeteringV4( - authenticator=NoAuthAuthenticator() - ) +service = UsageMeteringV4(authenticator=NoAuthAuthenticator()) base_url = 'https://billing.cloud.ibm.com' service.set_service_url(base_url) @@ -39,7 +37,8 @@ ############################################################################## # region -class TestReportResourceUsage(): + +class TestReportResourceUsage: """ Test Class for report_resource_usage """ @@ -61,20 +60,18 @@ def test_report_resource_usage_all_params(self): # Set up mock url = self.preprocess_url(base_url + '/v4/metering/resources/testString/usage') mock_response = '{"resources": [{"status": 6, "location": "location", "code": "code", "message": "message"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Construct a dict representation of a MeasureAndQuantity model measure_and_quantity_model = {} measure_and_quantity_model['measure'] = 'STORAGE' - measure_and_quantity_model['quantity'] = { 'foo': 'bar' } + measure_and_quantity_model['quantity'] = {'foo': 'bar'} # Construct a dict representation of a ResourceInstanceUsage model resource_instance_usage_model = {} - resource_instance_usage_model['resource_instance_id'] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' + resource_instance_usage_model[ + 'resource_instance_id' + ] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' resource_instance_usage_model['plan_id'] = 'database-lite' resource_instance_usage_model['region'] = 'us-south' resource_instance_usage_model['start'] = 1485907200000 @@ -87,11 +84,7 @@ def test_report_resource_usage_all_params(self): resource_usage = [resource_instance_usage_model] # Invoke method - response = service.report_resource_usage( - resource_id, - resource_usage, - headers={} - ) + response = service.report_resource_usage(resource_id, resource_usage, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -100,7 +93,6 @@ def test_report_resource_usage_all_params(self): req_body = json.loads(str(responses.calls[0].request.body, 'utf-8')) assert req_body == resource_usage - @responses.activate def test_report_resource_usage_value_error(self): """ @@ -109,20 +101,18 @@ def test_report_resource_usage_value_error(self): # Set up mock url = self.preprocess_url(base_url + '/v4/metering/resources/testString/usage') mock_response = '{"resources": [{"status": 6, "location": "location", "code": "code", "message": "message"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Construct a dict representation of a MeasureAndQuantity model measure_and_quantity_model = {} measure_and_quantity_model['measure'] = 'STORAGE' - measure_and_quantity_model['quantity'] = { 'foo': 'bar' } + measure_and_quantity_model['quantity'] = {'foo': 'bar'} # Construct a dict representation of a ResourceInstanceUsage model resource_instance_usage_model = {} - resource_instance_usage_model['resource_instance_id'] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' + resource_instance_usage_model[ + 'resource_instance_id' + ] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' resource_instance_usage_model['plan_id'] = 'database-lite' resource_instance_usage_model['region'] = 'us-south' resource_instance_usage_model['start'] = 1485907200000 @@ -140,12 +130,11 @@ def test_report_resource_usage_value_error(self): "resource_usage": resource_usage, } 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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): service.report_resource_usage(**req_copy) - # endregion ############################################################################## # End of Service: ResourceUsage @@ -156,7 +145,7 @@ def test_report_resource_usage_value_error(self): # Start of Model Tests ############################################################################## # region -class TestMeasureAndQuantity(): +class TestMeasureAndQuantity: """ Test Class for MeasureAndQuantity """ @@ -169,7 +158,7 @@ def test_measure_and_quantity_serialization(self): # Construct a json representation of a MeasureAndQuantity model measure_and_quantity_model_json = {} measure_and_quantity_model_json['measure'] = 'STORAGE' - measure_and_quantity_model_json['quantity'] = { 'foo': 'bar' } + measure_and_quantity_model_json['quantity'] = {'foo': 'bar'} # Construct a model instance of MeasureAndQuantity by calling from_dict on the json representation measure_and_quantity_model = MeasureAndQuantity.from_dict(measure_and_quantity_model_json) @@ -186,7 +175,8 @@ def test_measure_and_quantity_serialization(self): measure_and_quantity_model_json2 = measure_and_quantity_model.to_dict() assert measure_and_quantity_model_json2 == measure_and_quantity_model_json -class TestResourceInstanceUsage(): + +class TestResourceInstanceUsage: """ Test Class for ResourceInstanceUsage """ @@ -198,13 +188,15 @@ def test_resource_instance_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - measure_and_quantity_model = {} # MeasureAndQuantity + measure_and_quantity_model = {} # MeasureAndQuantity measure_and_quantity_model['measure'] = 'STORAGE' - measure_and_quantity_model['quantity'] = { 'foo': 'bar' } + measure_and_quantity_model['quantity'] = {'foo': 'bar'} # Construct a json representation of a ResourceInstanceUsage model resource_instance_usage_model_json = {} - resource_instance_usage_model_json['resource_instance_id'] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' + resource_instance_usage_model_json[ + 'resource_instance_id' + ] = 'crn:v1:bluemix:staging:database-service:us-south:a/1c8ae972c35e470d994b6faff9494ce1:793ff3d3-9fe3-4329-9ea0-404703a3c371::' resource_instance_usage_model_json['plan_id'] = 'database-lite' resource_instance_usage_model_json['region'] = 'us-south' resource_instance_usage_model_json['start'] = 1485907200000 @@ -217,7 +209,9 @@ def test_resource_instance_usage_serialization(self): assert resource_instance_usage_model != False # Construct a model instance of ResourceInstanceUsage by calling from_dict on the json representation - resource_instance_usage_model_dict = ResourceInstanceUsage.from_dict(resource_instance_usage_model_json).__dict__ + resource_instance_usage_model_dict = ResourceInstanceUsage.from_dict( + resource_instance_usage_model_json + ).__dict__ resource_instance_usage_model2 = ResourceInstanceUsage(**resource_instance_usage_model_dict) # Verify the model instances are equivalent @@ -227,7 +221,8 @@ def test_resource_instance_usage_serialization(self): resource_instance_usage_model_json2 = resource_instance_usage_model.to_dict() assert resource_instance_usage_model_json2 == resource_instance_usage_model_json -class TestResourceUsageDetails(): + +class TestResourceUsageDetails: """ Test Class for ResourceUsageDetails """ @@ -259,7 +254,8 @@ def test_resource_usage_details_serialization(self): resource_usage_details_model_json2 = resource_usage_details_model.to_dict() assert resource_usage_details_model_json2 == resource_usage_details_model_json -class TestResponseAccepted(): + +class TestResponseAccepted: """ Test Class for ResponseAccepted """ @@ -271,7 +267,7 @@ def test_response_accepted_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resource_usage_details_model = {} # ResourceUsageDetails + resource_usage_details_model = {} # ResourceUsageDetails resource_usage_details_model['status'] = 38 resource_usage_details_model['location'] = 'testString' resource_usage_details_model['code'] = 'testString' diff --git a/test/unit/test_usage_reports_v4.py b/test/unit/test_usage_reports_v4.py index ec14b3b5..d6fa598e 100644 --- a/test/unit/test_usage_reports_v4.py +++ b/test/unit/test_usage_reports_v4.py @@ -31,9 +31,7 @@ from ibm_platform_services.usage_reports_v4 import * -_service = UsageReportsV4( - authenticator=NoAuthAuthenticator() - ) +_service = UsageReportsV4(authenticator=NoAuthAuthenticator()) _base_url = 'https://billing.cloud.ibm.com' _service.set_service_url(_base_url) @@ -43,7 +41,8 @@ ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -66,10 +65,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = UsageReportsV4.new_instance( - ) + service = UsageReportsV4.new_instance() + -class TestGetAccountSummary(): +class TestGetAccountSummary: """ Test Class for get_account_summary """ @@ -78,7 +77,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -93,28 +92,19 @@ def test_get_account_summary_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/summary/testString') mock_response = '{"account_id": "account_id", "billing_month": "billing_month", "billing_country_code": "billing_country_code", "billing_currency_code": "billing_currency_code", "resources": {"billable_cost": 13, "non_billable_cost": 17}, "offers": [{"offer_id": "offer_id", "credits_total": 13, "offer_template": "offer_template", "valid_from": "2019-01-01T12:00:00.000Z", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 16, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "type", "overage": 7}], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "subscription_id", "charge_agreement_number": "charge_agreement_number", "type": "type", "subscription_amount": 19, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 13, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 16, "used": 4, "balance": 7}}]}]}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' billingmonth = 'testString' # Invoke method - response = _service.get_account_summary( - account_id, - billingmonth, - headers={} - ) + response = _service.get_account_summary(account_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_account_summary_value_error(self): """ @@ -123,11 +113,7 @@ def test_get_account_summary_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/summary/testString') mock_response = '{"account_id": "account_id", "billing_month": "billing_month", "billing_country_code": "billing_country_code", "billing_currency_code": "billing_currency_code", "resources": {"billable_cost": 13, "non_billable_cost": 17}, "offers": [{"offer_id": "offer_id", "credits_total": 13, "offer_template": "offer_template", "valid_from": "2019-01-01T12:00:00.000Z", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 16, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "type", "overage": 7}], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "subscription_id", "charge_agreement_number": "charge_agreement_number", "type": "type", "subscription_amount": 19, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 13, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 16, "used": 4, "balance": 7}}]}]}}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -139,13 +125,12 @@ def test_get_account_summary_value_error(self): "billingmonth": billingmonth, } 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()} + 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_account_summary(**req_copy) - -class TestGetAccountUsage(): +class TestGetAccountUsage: """ Test Class for get_account_usage """ @@ -154,7 +139,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -169,11 +154,7 @@ def test_get_account_usage_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/usage/testString') mock_response = '{"account_id": "account_id", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -183,22 +164,17 @@ def test_get_account_usage_all_params(self): # Invoke method response = _service.get_account_usage( - account_id, - billingmonth, - names=names, - accept_language=accept_language, - headers={} + account_id, billingmonth, names=names, accept_language=accept_language, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string - @responses.activate def test_get_account_usage_required_params(self): """ @@ -207,28 +183,19 @@ def test_get_account_usage_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/usage/testString') mock_response = '{"account_id": "account_id", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' billingmonth = 'testString' # Invoke method - response = _service.get_account_usage( - account_id, - billingmonth, - headers={} - ) + response = _service.get_account_usage(account_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_account_usage_value_error(self): """ @@ -237,11 +204,7 @@ def test_get_account_usage_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/usage/testString') mock_response = '{"account_id": "account_id", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -253,12 +216,11 @@ def test_get_account_usage_value_error(self): "billingmonth": billingmonth, } 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()} + 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_account_usage(**req_copy) - # endregion ############################################################################## # End of Service: AccountOperations @@ -269,7 +231,8 @@ def test_get_account_usage_value_error(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -292,10 +255,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = UsageReportsV4.new_instance( - ) + service = UsageReportsV4.new_instance() + -class TestGetResourceGroupUsage(): +class TestGetResourceGroupUsage: """ Test Class for get_resource_group_usage """ @@ -304,7 +267,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -319,11 +282,7 @@ def test_get_resource_group_usage_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/usage/testString') mock_response = '{"account_id": "account_id", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -334,23 +293,17 @@ def test_get_resource_group_usage_all_params(self): # Invoke method response = _service.get_resource_group_usage( - account_id, - resource_group_id, - billingmonth, - names=names, - accept_language=accept_language, - headers={} + account_id, resource_group_id, billingmonth, names=names, accept_language=accept_language, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string - @responses.activate def test_get_resource_group_usage_required_params(self): """ @@ -359,11 +312,7 @@ def test_get_resource_group_usage_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/usage/testString') mock_response = '{"account_id": "account_id", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -371,18 +320,12 @@ def test_get_resource_group_usage_required_params(self): billingmonth = 'testString' # Invoke method - response = _service.get_resource_group_usage( - account_id, - resource_group_id, - billingmonth, - headers={} - ) + response = _service.get_resource_group_usage(account_id, resource_group_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_resource_group_usage_value_error(self): """ @@ -391,11 +334,7 @@ def test_get_resource_group_usage_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/usage/testString') mock_response = '{"account_id": "account_id", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -409,13 +348,12 @@ def test_get_resource_group_usage_value_error(self): "billingmonth": billingmonth, } 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()} + 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_resource_group_usage(**req_copy) - -class TestGetResourceUsageAccount(): +class TestGetResourceUsageAccount: """ Test Class for get_resource_usage_account """ @@ -424,7 +362,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -439,11 +377,7 @@ def test_get_resource_usage_account_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_instances/usage/testString') mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -473,14 +407,14 @@ def test_get_resource_usage_account_all_params(self): resource_id=resource_id, plan_id=plan_id, region=region, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string assert '_limit={}'.format(limit) in query_string @@ -492,7 +426,6 @@ def test_get_resource_usage_account_all_params(self): assert 'plan_id={}'.format(plan_id) in query_string assert 'region={}'.format(region) in query_string - @responses.activate def test_get_resource_usage_account_required_params(self): """ @@ -501,28 +434,19 @@ def test_get_resource_usage_account_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_instances/usage/testString') mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' billingmonth = 'testString' # Invoke method - response = _service.get_resource_usage_account( - account_id, - billingmonth, - headers={} - ) + response = _service.get_resource_usage_account(account_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_resource_usage_account_value_error(self): """ @@ -531,11 +455,7 @@ def test_get_resource_usage_account_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_instances/usage/testString') mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -547,13 +467,12 @@ def test_get_resource_usage_account_value_error(self): "billingmonth": billingmonth, } 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()} + 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_resource_usage_account(**req_copy) - -class TestGetResourceUsageResourceGroup(): +class TestGetResourceUsageResourceGroup: """ Test Class for get_resource_usage_resource_group """ @@ -562,7 +481,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -575,13 +494,11 @@ def test_get_resource_usage_resource_group_all_params(self): get_resource_usage_resource_group() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -609,14 +526,14 @@ def test_get_resource_usage_resource_group_all_params(self): resource_id=resource_id, plan_id=plan_id, region=region, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string assert '_limit={}'.format(limit) in query_string @@ -626,20 +543,17 @@ def test_get_resource_usage_resource_group_all_params(self): assert 'plan_id={}'.format(plan_id) in query_string assert 'region={}'.format(region) in query_string - @responses.activate def test_get_resource_usage_resource_group_required_params(self): """ test_get_resource_usage_resource_group_required_params() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -647,31 +561,23 @@ def test_get_resource_usage_resource_group_required_params(self): billingmonth = 'testString' # Invoke method - response = _service.get_resource_usage_resource_group( - account_id, - resource_group_id, - billingmonth, - headers={} - ) + response = _service.get_resource_usage_resource_group(account_id, resource_group_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_resource_usage_resource_group_value_error(self): """ test_get_resource_usage_resource_group_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/resource_groups/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -685,13 +591,12 @@ def test_get_resource_usage_resource_group_value_error(self): "billingmonth": billingmonth, } 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()} + 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_resource_usage_resource_group(**req_copy) - -class TestGetResourceUsageOrg(): +class TestGetResourceUsageOrg: """ Test Class for get_resource_usage_org """ @@ -700,7 +605,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -713,13 +618,11 @@ def test_get_resource_usage_org_all_params(self): get_resource_usage_org() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -747,14 +650,14 @@ def test_get_resource_usage_org_all_params(self): resource_id=resource_id, plan_id=plan_id, region=region, - headers={} + 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string assert '_limit={}'.format(limit) in query_string @@ -764,20 +667,17 @@ def test_get_resource_usage_org_all_params(self): assert 'plan_id={}'.format(plan_id) in query_string assert 'region={}'.format(region) in query_string - @responses.activate def test_get_resource_usage_org_required_params(self): """ test_get_resource_usage_org_required_params() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -785,31 +685,23 @@ def test_get_resource_usage_org_required_params(self): billingmonth = 'testString' # Invoke method - response = _service.get_resource_usage_org( - account_id, - organization_id, - billingmonth, - headers={} - ) + response = _service.get_resource_usage_org(account_id, organization_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_resource_usage_org_value_error(self): """ test_get_resource_usage_org_value_error() """ # Set up mock - url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString') + url = self.preprocess_url( + _base_url + '/v4/accounts/testString/organizations/testString/resource_instances/usage/testString' + ) mock_response = '{"limit": 5, "count": 5, "first": {"href": "href"}, "next": {"href": "href", "offset": "offset"}, "resources": [{"account_id": "account_id", "resource_instance_id": "resource_instance_id", "resource_instance_name": "resource_instance_name", "resource_id": "resource_id", "resource_name": "resource_name", "resource_group_id": "resource_group_id", "resource_group_name": "resource_group_name", "organization_id": "organization_id", "organization_name": "organization_name", "space_id": "space_id", "space_name": "space_name", "consumer_id": "consumer_id", "region": "region", "pricing_region": "pricing_region", "pricing_country": "USA", "currency_code": "USD", "billable": true, "plan_id": "plan_id", "plan_name": "plan_name", "month": "2017-08", "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -823,12 +715,11 @@ def test_get_resource_usage_org_value_error(self): "billingmonth": billingmonth, } 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()} + 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_resource_usage_org(**req_copy) - # endregion ############################################################################## # End of Service: ResourceOperations @@ -839,7 +730,8 @@ def test_get_resource_usage_org_value_error(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -862,10 +754,10 @@ def test_new_instance_without_authenticator(self): new_instance_without_authenticator() """ with pytest.raises(ValueError, match='authenticator must be provided'): - service = UsageReportsV4.new_instance( - ) + service = UsageReportsV4.new_instance() -class TestGetOrgUsage(): + +class TestGetOrgUsage: """ Test Class for get_org_usage """ @@ -874,7 +766,7 @@ def preprocess_url(self, request_url: str): """ Preprocess the request URL to ensure the mock response will be found. """ - request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded + request_url = urllib.parse.unquote(request_url) # don't double-encode if already encoded request_url = urllib.parse.quote(request_url, safe=':/') if re.fullmatch('.*/+', request_url) is None: return request_url @@ -889,11 +781,7 @@ def test_get_org_usage_all_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/usage/testString') mock_response = '{"account_id": "account_id", "organization_id": "organization_id", "organization_name": "organization_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -904,23 +792,17 @@ def test_get_org_usage_all_params(self): # Invoke method response = _service.get_org_usage( - account_id, - organization_id, - billingmonth, - names=names, - accept_language=accept_language, - headers={} + account_id, organization_id, billingmonth, names=names, accept_language=accept_language, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert '_names={}'.format('true' if names else 'false') in query_string - @responses.activate def test_get_org_usage_required_params(self): """ @@ -929,11 +811,7 @@ def test_get_org_usage_required_params(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/usage/testString') mock_response = '{"account_id": "account_id", "organization_id": "organization_id", "organization_name": "organization_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -941,18 +819,12 @@ def test_get_org_usage_required_params(self): billingmonth = 'testString' # Invoke method - response = _service.get_org_usage( - account_id, - organization_id, - billingmonth, - headers={} - ) + response = _service.get_org_usage(account_id, organization_id, billingmonth, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 200 - @responses.activate def test_get_org_usage_value_error(self): """ @@ -961,11 +833,7 @@ def test_get_org_usage_value_error(self): # Set up mock url = self.preprocess_url(_base_url + '/v4/accounts/testString/organizations/testString/usage/testString') mock_response = '{"account_id": "account_id", "organization_id": "organization_id", "organization_name": "organization_name", "pricing_country": "USA", "currency_code": "USD", "month": "2017-08", "resources": [{"resource_id": "resource_id", "resource_name": "resource_name", "billable_cost": 13, "billable_rated_cost": 19, "non_billable_cost": 17, "non_billable_rated_cost": 23, "plans": [{"plan_id": "plan_id", "plan_name": "plan_name", "pricing_region": "pricing_region", "billable": true, "cost": 4, "rated_cost": 10, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -979,12 +847,11 @@ def test_get_org_usage_value_error(self): "billingmonth": billingmonth, } 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()} + 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_org_usage(**req_copy) - # endregion ############################################################################## # End of Service: OrganizationOperations @@ -995,7 +862,7 @@ def test_get_org_usage_value_error(self): # Start of Model Tests ############################################################################## # region -class TestModel_AccountSummary(): +class TestModel_AccountSummary: """ Test Class for AccountSummary """ @@ -1007,16 +874,16 @@ def test_account_summary_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - resources_summary_model = {} # ResourcesSummary + resources_summary_model = {} # ResourcesSummary resources_summary_model['billable_cost'] = 72.5 resources_summary_model['non_billable_cost'] = 72.5 - offer_credits_model = {} # OfferCredits + offer_credits_model = {} # OfferCredits offer_credits_model['starting_balance'] = 72.5 offer_credits_model['used'] = 72.5 offer_credits_model['balance'] = 72.5 - offer_model = {} # Offer + offer_model = {} # Offer offer_model['offer_id'] = 'testString' offer_model['credits_total'] = 72.5 offer_model['offer_template'] = 'testString' @@ -1024,23 +891,23 @@ def test_account_summary_serialization(self): offer_model['expires_on'] = "2019-01-01T12:00:00Z" offer_model['credits'] = offer_credits_model - support_summary_model = {} # SupportSummary + support_summary_model = {} # SupportSummary support_summary_model['cost'] = 72.5 support_summary_model['type'] = 'testString' support_summary_model['overage'] = 72.5 - subscription_term_credits_model = {} # SubscriptionTermCredits + subscription_term_credits_model = {} # SubscriptionTermCredits subscription_term_credits_model['total'] = 72.5 subscription_term_credits_model['starting_balance'] = 72.5 subscription_term_credits_model['used'] = 72.5 subscription_term_credits_model['balance'] = 72.5 - subscription_term_model = {} # SubscriptionTerm + subscription_term_model = {} # SubscriptionTerm subscription_term_model['start'] = "2019-01-01T12:00:00Z" subscription_term_model['end'] = "2019-01-01T12:00:00Z" subscription_term_model['credits'] = subscription_term_credits_model - subscription_model = {} # Subscription + subscription_model = {} # Subscription subscription_model['subscription_id'] = 'testString' subscription_model['charge_agreement_number'] = 'testString' subscription_model['type'] = 'testString' @@ -1050,7 +917,7 @@ def test_account_summary_serialization(self): subscription_model['credits_total'] = 72.5 subscription_model['terms'] = [subscription_term_model] - subscription_summary_model = {} # SubscriptionSummary + subscription_summary_model = {} # SubscriptionSummary subscription_summary_model['overage'] = 72.5 subscription_summary_model['subscriptions'] = [subscription_model] @@ -1080,7 +947,8 @@ def test_account_summary_serialization(self): account_summary_model_json2 = account_summary_model.to_dict() assert account_summary_model_json2 == account_summary_model_json -class TestModel_AccountUsage(): + +class TestModel_AccountUsage: """ Test Class for AccountUsage """ @@ -1092,13 +960,13 @@ def test_account_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1111,7 +979,7 @@ def test_account_usage_serialization(self): metric_model['non_chargeable'] = True metric_model['discounts'] = [discount_model] - plan_model = {} # Plan + plan_model = {} # Plan plan_model['plan_id'] = 'testString' plan_model['plan_name'] = 'testString' plan_model['pricing_region'] = 'testString' @@ -1121,7 +989,7 @@ def test_account_usage_serialization(self): plan_model['usage'] = [metric_model] plan_model['discounts'] = [discount_model] - resource_model = {} # Resource + resource_model = {} # Resource resource_model['resource_id'] = 'testString' resource_model['resource_name'] = 'testString' resource_model['billable_cost'] = 72.5 @@ -1154,7 +1022,8 @@ def test_account_usage_serialization(self): account_usage_model_json2 = account_usage_model.to_dict() assert account_usage_model_json2 == account_usage_model_json -class TestModel_Discount(): + +class TestModel_Discount: """ Test Class for Discount """ @@ -1186,7 +1055,8 @@ def test_discount_serialization(self): discount_model_json2 = discount_model.to_dict() assert discount_model_json2 == discount_model_json -class TestModel_InstanceUsage(): + +class TestModel_InstanceUsage: """ Test Class for InstanceUsage """ @@ -1198,13 +1068,13 @@ def test_instance_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1256,7 +1126,8 @@ def test_instance_usage_serialization(self): instance_usage_model_json2 = instance_usage_model.to_dict() assert instance_usage_model_json2 == instance_usage_model_json -class TestModel_InstancesUsageFirst(): + +class TestModel_InstancesUsageFirst: """ Test Class for InstancesUsageFirst """ @@ -1285,7 +1156,8 @@ def test_instances_usage_first_serialization(self): instances_usage_first_model_json2 = instances_usage_first_model.to_dict() assert instances_usage_first_model_json2 == instances_usage_first_model_json -class TestModel_InstancesUsageNext(): + +class TestModel_InstancesUsageNext: """ Test Class for InstancesUsageNext """ @@ -1315,7 +1187,8 @@ def test_instances_usage_next_serialization(self): instances_usage_next_model_json2 = instances_usage_next_model.to_dict() assert instances_usage_next_model_json2 == instances_usage_next_model_json -class TestModel_InstancesUsage(): + +class TestModel_InstancesUsage: """ Test Class for InstancesUsage """ @@ -1327,20 +1200,20 @@ def test_instances_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - instances_usage_first_model = {} # InstancesUsageFirst + instances_usage_first_model = {} # InstancesUsageFirst instances_usage_first_model['href'] = 'testString' - instances_usage_next_model = {} # InstancesUsageNext + instances_usage_next_model = {} # InstancesUsageNext instances_usage_next_model['href'] = 'testString' instances_usage_next_model['offset'] = 'testString' - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1353,7 +1226,7 @@ def test_instances_usage_serialization(self): metric_model['non_chargeable'] = True metric_model['discounts'] = [discount_model] - instance_usage_model = {} # InstanceUsage + instance_usage_model = {} # InstanceUsage instance_usage_model['account_id'] = 'testString' instance_usage_model['resource_instance_id'] = 'testString' instance_usage_model['resource_instance_name'] = 'testString' @@ -1399,7 +1272,8 @@ def test_instances_usage_serialization(self): instances_usage_model_json2 = instances_usage_model.to_dict() assert instances_usage_model_json2 == instances_usage_model_json -class TestModel_Metric(): + +class TestModel_Metric: """ Test Class for Metric """ @@ -1411,7 +1285,7 @@ def test_metric_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' @@ -1446,7 +1320,8 @@ def test_metric_serialization(self): metric_model_json2 = metric_model.to_dict() assert metric_model_json2 == metric_model_json -class TestModel_Offer(): + +class TestModel_Offer: """ Test Class for Offer """ @@ -1458,7 +1333,7 @@ def test_offer_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - offer_credits_model = {} # OfferCredits + offer_credits_model = {} # OfferCredits offer_credits_model['starting_balance'] = 72.5 offer_credits_model['used'] = 72.5 offer_credits_model['balance'] = 72.5 @@ -1487,7 +1362,8 @@ def test_offer_serialization(self): offer_model_json2 = offer_model.to_dict() assert offer_model_json2 == offer_model_json -class TestModel_OfferCredits(): + +class TestModel_OfferCredits: """ Test Class for OfferCredits """ @@ -1518,7 +1394,8 @@ def test_offer_credits_serialization(self): offer_credits_model_json2 = offer_credits_model.to_dict() assert offer_credits_model_json2 == offer_credits_model_json -class TestModel_OrgUsage(): + +class TestModel_OrgUsage: """ Test Class for OrgUsage """ @@ -1530,13 +1407,13 @@ def test_org_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1549,7 +1426,7 @@ def test_org_usage_serialization(self): metric_model['non_chargeable'] = True metric_model['discounts'] = [discount_model] - plan_model = {} # Plan + plan_model = {} # Plan plan_model['plan_id'] = 'testString' plan_model['plan_name'] = 'testString' plan_model['pricing_region'] = 'testString' @@ -1559,7 +1436,7 @@ def test_org_usage_serialization(self): plan_model['usage'] = [metric_model] plan_model['discounts'] = [discount_model] - resource_model = {} # Resource + resource_model = {} # Resource resource_model['resource_id'] = 'testString' resource_model['resource_name'] = 'testString' resource_model['billable_cost'] = 72.5 @@ -1594,7 +1471,8 @@ def test_org_usage_serialization(self): org_usage_model_json2 = org_usage_model.to_dict() assert org_usage_model_json2 == org_usage_model_json -class TestModel_Plan(): + +class TestModel_Plan: """ Test Class for Plan """ @@ -1606,13 +1484,13 @@ def test_plan_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1651,7 +1529,8 @@ def test_plan_serialization(self): plan_model_json2 = plan_model.to_dict() assert plan_model_json2 == plan_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -1663,13 +1542,13 @@ def test_resource_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1682,7 +1561,7 @@ def test_resource_serialization(self): metric_model['non_chargeable'] = True metric_model['discounts'] = [discount_model] - plan_model = {} # Plan + plan_model = {} # Plan plan_model['plan_id'] = 'testString' plan_model['plan_name'] = 'testString' plan_model['pricing_region'] = 'testString' @@ -1718,7 +1597,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_ResourceGroupUsage(): + +class TestModel_ResourceGroupUsage: """ Test Class for ResourceGroupUsage """ @@ -1730,13 +1610,13 @@ def test_resource_group_usage_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - discount_model = {} # Discount + discount_model = {} # Discount discount_model['ref'] = 'Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9' discount_model['name'] = 'platform-discount' discount_model['display_name'] = 'Platform Service Discount' discount_model['discount'] = 5 - metric_model = {} # Metric + metric_model = {} # Metric metric_model['metric'] = 'UP-TIME' metric_model['metric_name'] = 'UP-TIME' metric_model['quantity'] = 711.11 @@ -1749,7 +1629,7 @@ def test_resource_group_usage_serialization(self): metric_model['non_chargeable'] = True metric_model['discounts'] = [discount_model] - plan_model = {} # Plan + plan_model = {} # Plan plan_model['plan_id'] = 'testString' plan_model['plan_name'] = 'testString' plan_model['pricing_region'] = 'testString' @@ -1759,7 +1639,7 @@ def test_resource_group_usage_serialization(self): plan_model['usage'] = [metric_model] plan_model['discounts'] = [discount_model] - resource_model = {} # Resource + resource_model = {} # Resource resource_model['resource_id'] = 'testString' resource_model['resource_name'] = 'testString' resource_model['billable_cost'] = 72.5 @@ -1794,7 +1674,8 @@ def test_resource_group_usage_serialization(self): resource_group_usage_model_json2 = resource_group_usage_model.to_dict() assert resource_group_usage_model_json2 == resource_group_usage_model_json -class TestModel_ResourcesSummary(): + +class TestModel_ResourcesSummary: """ Test Class for ResourcesSummary """ @@ -1824,7 +1705,8 @@ def test_resources_summary_serialization(self): resources_summary_model_json2 = resources_summary_model.to_dict() assert resources_summary_model_json2 == resources_summary_model_json -class TestModel_Subscription(): + +class TestModel_Subscription: """ Test Class for Subscription """ @@ -1836,13 +1718,13 @@ def test_subscription_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subscription_term_credits_model = {} # SubscriptionTermCredits + subscription_term_credits_model = {} # SubscriptionTermCredits subscription_term_credits_model['total'] = 72.5 subscription_term_credits_model['starting_balance'] = 72.5 subscription_term_credits_model['used'] = 72.5 subscription_term_credits_model['balance'] = 72.5 - subscription_term_model = {} # SubscriptionTerm + subscription_term_model = {} # SubscriptionTerm subscription_term_model['start'] = "2019-01-01T12:00:00Z" subscription_term_model['end'] = "2019-01-01T12:00:00Z" subscription_term_model['credits'] = subscription_term_credits_model @@ -1873,7 +1755,8 @@ def test_subscription_serialization(self): subscription_model_json2 = subscription_model.to_dict() assert subscription_model_json2 == subscription_model_json -class TestModel_SubscriptionSummary(): + +class TestModel_SubscriptionSummary: """ Test Class for SubscriptionSummary """ @@ -1885,18 +1768,18 @@ def test_subscription_summary_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subscription_term_credits_model = {} # SubscriptionTermCredits + subscription_term_credits_model = {} # SubscriptionTermCredits subscription_term_credits_model['total'] = 72.5 subscription_term_credits_model['starting_balance'] = 72.5 subscription_term_credits_model['used'] = 72.5 subscription_term_credits_model['balance'] = 72.5 - subscription_term_model = {} # SubscriptionTerm + subscription_term_model = {} # SubscriptionTerm subscription_term_model['start'] = "2019-01-01T12:00:00Z" subscription_term_model['end'] = "2019-01-01T12:00:00Z" subscription_term_model['credits'] = subscription_term_credits_model - subscription_model = {} # Subscription + subscription_model = {} # Subscription subscription_model['subscription_id'] = 'testString' subscription_model['charge_agreement_number'] = 'testString' subscription_model['type'] = 'testString' @@ -1926,7 +1809,8 @@ def test_subscription_summary_serialization(self): subscription_summary_model_json2 = subscription_summary_model.to_dict() assert subscription_summary_model_json2 == subscription_summary_model_json -class TestModel_SubscriptionTerm(): + +class TestModel_SubscriptionTerm: """ Test Class for SubscriptionTerm """ @@ -1938,7 +1822,7 @@ def test_subscription_term_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - subscription_term_credits_model = {} # SubscriptionTermCredits + subscription_term_credits_model = {} # SubscriptionTermCredits subscription_term_credits_model['total'] = 72.5 subscription_term_credits_model['starting_balance'] = 72.5 subscription_term_credits_model['used'] = 72.5 @@ -1965,7 +1849,8 @@ def test_subscription_term_serialization(self): subscription_term_model_json2 = subscription_term_model.to_dict() assert subscription_term_model_json2 == subscription_term_model_json -class TestModel_SubscriptionTermCredits(): + +class TestModel_SubscriptionTermCredits: """ Test Class for SubscriptionTermCredits """ @@ -1987,7 +1872,9 @@ def test_subscription_term_credits_serialization(self): assert subscription_term_credits_model != False # Construct a model instance of SubscriptionTermCredits by calling from_dict on the json representation - subscription_term_credits_model_dict = SubscriptionTermCredits.from_dict(subscription_term_credits_model_json).__dict__ + subscription_term_credits_model_dict = SubscriptionTermCredits.from_dict( + subscription_term_credits_model_json + ).__dict__ subscription_term_credits_model2 = SubscriptionTermCredits(**subscription_term_credits_model_dict) # Verify the model instances are equivalent @@ -1997,7 +1884,8 @@ def test_subscription_term_credits_serialization(self): subscription_term_credits_model_json2 = subscription_term_credits_model.to_dict() assert subscription_term_credits_model_json2 == subscription_term_credits_model_json -class TestModel_SupportSummary(): + +class TestModel_SupportSummary: """ Test Class for SupportSummary """ diff --git a/test/unit/test_user_management_v1.py b/test/unit/test_user_management_v1.py index 98fb9487..8ef16621 100644 --- a/test/unit/test_user_management_v1.py +++ b/test/unit/test_user_management_v1.py @@ -29,9 +29,7 @@ from ibm_platform_services.user_management_v1 import * -_service = UserManagementV1( - authenticator=NoAuthAuthenticator() -) +_service = UserManagementV1(authenticator=NoAuthAuthenticator()) _base_url = 'https://user-management.cloud.ibm.com' _service.set_service_url(_base_url) @@ -68,7 +66,8 @@ def preprocess_url(operation_path: str): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -95,7 +94,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestListUsers(): + +class TestListUsers: """ Test Class for list_users """ @@ -108,11 +108,7 @@ def test_list_users_all_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"total_results": 13, "limit": 5, "first_url": "first_url", "next_url": "next_url", "resources": [{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -121,19 +117,13 @@ def test_list_users_all_params(self): user_id = 'testString' # Invoke method - response = _service.list_users( - account_id, - limit=limit, - start=start, - user_id=user_id, - headers={} - ) + response = _service.list_users(account_id, limit=limit, start=start, user_id=user_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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'limit={}'.format(limit) in query_string assert '_start={}'.format(start) in query_string @@ -156,20 +146,13 @@ def test_list_users_required_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"total_results": 13, "limit": 5, "first_url": "first_url", "next_url": "next_url", "resources": [{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.list_users( - account_id, - headers={} - ) + response = _service.list_users(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -192,11 +175,7 @@ def test_list_users_value_error(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"total_results": 13, "limit": 5, "first_url": "first_url", "next_url": "next_url", "resources": [{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}]}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -206,7 +185,7 @@ def test_list_users_value_error(self): "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()} + 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_users(**req_copy) @@ -228,16 +207,8 @@ def test_list_users_with_pager_get_next(self): url = preprocess_url('/v2/accounts/testString/users') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?_start=1","resources":[{"id":"id","iam_id":"iam_id","realm":"realm","user_id":"user_id","firstname":"firstname","lastname":"lastname","state":"state","email":"email","phonenumber":"phonenumber","altphonenumber":"altphonenumber","photo":"photo","account_id":"account_id","added_on":"added_on"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","iam_id":"iam_id","realm":"realm","user_id":"user_id","firstname":"firstname","lastname":"lastname","state":"state","email":"email","phonenumber":"phonenumber","altphonenumber":"altphonenumber","photo":"photo","account_id":"account_id","added_on":"added_on"}]}' - 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) + 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 = [] @@ -262,16 +233,8 @@ def test_list_users_with_pager_get_all(self): url = preprocess_url('/v2/accounts/testString/users') mock_response1 = '{"total_count":2,"limit":1,"next_url":"https://myhost.com/somePath?_start=1","resources":[{"id":"id","iam_id":"iam_id","realm":"realm","user_id":"user_id","firstname":"firstname","lastname":"lastname","state":"state","email":"email","phonenumber":"phonenumber","altphonenumber":"altphonenumber","photo":"photo","account_id":"account_id","added_on":"added_on"}]}' mock_response2 = '{"total_count":2,"limit":1,"resources":[{"id":"id","iam_id":"iam_id","realm":"realm","user_id":"user_id","firstname":"firstname","lastname":"lastname","state":"state","email":"email","phonenumber":"phonenumber","altphonenumber":"altphonenumber","photo":"photo","account_id":"account_id","added_on":"added_on"}]}' - 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) + 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 = UsersPager( @@ -284,7 +247,8 @@ def test_list_users_with_pager_get_all(self): assert all_results is not None assert len(all_results) == 2 -class TestInviteUsers(): + +class TestInviteUsers: """ Test Class for invite_users """ @@ -297,11 +261,7 @@ def test_invite_users_all_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"resources": [{"email": "email", "id": "id", "state": "state"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Construct a dict representation of a InviteUser model invite_user_model = {} @@ -335,11 +295,7 @@ def test_invite_users_all_params(self): # Invoke method response = _service.invite_users( - account_id, - users=users, - iam_policy=iam_policy, - access_groups=access_groups, - headers={} + account_id, users=users, iam_policy=iam_policy, access_groups=access_groups, headers={} ) # Check for correct operation @@ -368,20 +324,13 @@ def test_invite_users_required_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"resources": [{"email": "email", "id": "id", "state": "state"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.invite_users( - account_id, - headers={} - ) + response = _service.invite_users(account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -404,11 +353,7 @@ def test_invite_users_value_error(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users') mock_response = '{"resources": [{"email": "email", "id": "id", "state": "state"}]}' - responses.add(responses.POST, - url, - body=mock_response, - content_type='application/json', - status=202) + responses.add(responses.POST, url, body=mock_response, content_type='application/json', status=202) # Set up parameter values account_id = 'testString' @@ -418,7 +363,7 @@ def test_invite_users_value_error(self): "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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.invite_users(**req_copy) @@ -431,7 +376,8 @@ def test_invite_users_value_error_with_retries(self): _service.disable_retries() self.test_invite_users_value_error() -class TestGetUserProfile(): + +class TestGetUserProfile: """ Test Class for get_user_profile """ @@ -444,11 +390,7 @@ def test_get_user_profile_all_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') mock_response = '{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -456,18 +398,13 @@ def test_get_user_profile_all_params(self): include_activity = 'testString' # Invoke method - response = _service.get_user_profile( - account_id, - iam_id, - include_activity=include_activity, - headers={} - ) + response = _service.get_user_profile(account_id, iam_id, include_activity=include_activity, 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 = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_activity={}'.format(include_activity) in query_string @@ -488,22 +425,14 @@ def test_get_user_profile_required_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') mock_response = '{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.get_user_profile( - account_id, - iam_id, - headers={} - ) + response = _service.get_user_profile(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -526,11 +455,7 @@ def test_get_user_profile_value_error(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') mock_response = '{"id": "id", "iam_id": "iam_id", "realm": "realm", "user_id": "user_id", "firstname": "firstname", "lastname": "lastname", "state": "state", "email": "email", "phonenumber": "phonenumber", "altphonenumber": "altphonenumber", "photo": "photo", "account_id": "account_id", "added_on": "added_on"}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -542,7 +467,7 @@ def test_get_user_profile_value_error(self): "iam_id": iam_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()} + 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_user_profile(**req_copy) @@ -555,7 +480,8 @@ def test_get_user_profile_value_error_with_retries(self): _service.disable_retries() self.test_get_user_profile_value_error() -class TestUpdateUserProfile(): + +class TestUpdateUserProfile: """ Test Class for update_user_profile """ @@ -567,9 +493,7 @@ def test_update_user_profile_all_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' @@ -595,14 +519,14 @@ def test_update_user_profile_all_params(self): altphonenumber=altphonenumber, photo=photo, include_activity=include_activity, - headers={} + headers={}, ) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_activity={}'.format(include_activity) in query_string # Validate body params @@ -631,20 +555,14 @@ def test_update_user_profile_required_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.update_user_profile( - account_id, - iam_id, - headers={} - ) + response = _service.update_user_profile(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -666,9 +584,7 @@ def test_update_user_profile_value_error(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' @@ -680,7 +596,7 @@ def test_update_user_profile_value_error(self): "iam_id": iam_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()} + 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_user_profile(**req_copy) @@ -693,7 +609,8 @@ def test_update_user_profile_value_error_with_retries(self): _service.disable_retries() self.test_update_user_profile_value_error() -class TestRemoveUser(): + +class TestRemoveUser: """ Test Class for remove_user """ @@ -705,9 +622,7 @@ def test_remove_user_all_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values account_id = 'testString' @@ -715,18 +630,13 @@ def test_remove_user_all_params(self): include_activity = 'testString' # Invoke method - response = _service.remove_user( - account_id, - iam_id, - include_activity=include_activity, - headers={} - ) + response = _service.remove_user(account_id, iam_id, include_activity=include_activity, headers={}) # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 204 # Validate query params - query_string = responses.calls[0].request.url.split('?',1)[1] + query_string = responses.calls[0].request.url.split('?', 1)[1] query_string = urllib.parse.unquote_plus(query_string) assert 'include_activity={}'.format(include_activity) in query_string @@ -746,20 +656,14 @@ def test_remove_user_required_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.remove_user( - account_id, - iam_id, - headers={} - ) + response = _service.remove_user(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -781,9 +685,7 @@ def test_remove_user_value_error(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString') - responses.add(responses.DELETE, - url, - status=204) + responses.add(responses.DELETE, url, status=204) # Set up parameter values account_id = 'testString' @@ -795,7 +697,7 @@ def test_remove_user_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.remove_user(**req_copy) @@ -808,7 +710,8 @@ def test_remove_user_value_error_with_retries(self): _service.disable_retries() self.test_remove_user_value_error() -class TestAccept(): + +class TestAccept: """ Test Class for accept """ @@ -820,18 +723,13 @@ def test_accept_all_params(self): """ # Set up mock url = preprocess_url('/v2/users/accept') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Set up parameter values account_id = 'testString' # Invoke method - response = _service.accept( - account_id=account_id, - headers={} - ) + response = _service.accept(account_id=account_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -856,14 +754,11 @@ def test_accept_required_params(self): """ # Set up mock url = preprocess_url('/v2/users/accept') - responses.add(responses.POST, - url, - status=202) + responses.add(responses.POST, url, status=202) # Invoke method response = _service.accept() - # Check for correct operation assert len(responses.calls) == 1 assert response.status_code == 202 @@ -877,7 +772,8 @@ def test_accept_required_params_with_retries(self): _service.disable_retries() self.test_accept_required_params() -class TestV3RemoveUser(): + +class TestV3RemoveUser: """ Test Class for v3_remove_user """ @@ -889,20 +785,14 @@ def test_v3_remove_user_all_params(self): """ # Set up mock url = preprocess_url('/v3/accounts/testString/users/testString') - responses.add(responses.DELETE, - url, - status=202) + responses.add(responses.DELETE, url, status=202) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.v3_remove_user( - account_id, - iam_id, - headers={} - ) + response = _service.v3_remove_user(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -924,9 +814,7 @@ def test_v3_remove_user_value_error(self): """ # Set up mock url = preprocess_url('/v3/accounts/testString/users/testString') - responses.add(responses.DELETE, - url, - status=202) + responses.add(responses.DELETE, url, status=202) # Set up parameter values account_id = 'testString' @@ -938,7 +826,7 @@ def test_v3_remove_user_value_error(self): "iam_id": iam_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()} + req_copy = {key: val if key is not param else None for (key, val) in req_param_dict.items()} with pytest.raises(ValueError): _service.v3_remove_user(**req_copy) @@ -951,6 +839,7 @@ def test_v3_remove_user_value_error_with_retries(self): _service.disable_retries() self.test_v3_remove_user_value_error() + # endregion ############################################################################## # End of Service: Users @@ -961,7 +850,8 @@ def test_v3_remove_user_value_error_with_retries(self): ############################################################################## # region -class TestNewInstance(): + +class TestNewInstance: """ Test Class for new_instance """ @@ -988,7 +878,8 @@ def test_new_instance_without_authenticator(self): service_name='TEST_SERVICE_NOT_FOUND', ) -class TestGetUserSettings(): + +class TestGetUserSettings: """ Test Class for get_user_settings """ @@ -1001,22 +892,14 @@ def test_get_user_settings_all_params(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString/settings') mock_response = '{"language": "language", "notification_language": "notification_language", "allowed_ip_addresses": "32.96.110.50,172.16.254.1", "self_manage": false}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.get_user_settings( - account_id, - iam_id, - headers={} - ) + response = _service.get_user_settings(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1039,11 +922,7 @@ def test_get_user_settings_value_error(self): # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString/settings') mock_response = '{"language": "language", "notification_language": "notification_language", "allowed_ip_addresses": "32.96.110.50,172.16.254.1", "self_manage": false}' - responses.add(responses.GET, - url, - body=mock_response, - content_type='application/json', - status=200) + responses.add(responses.GET, url, body=mock_response, content_type='application/json', status=200) # Set up parameter values account_id = 'testString' @@ -1055,7 +934,7 @@ def test_get_user_settings_value_error(self): "iam_id": iam_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()} + 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_user_settings(**req_copy) @@ -1068,7 +947,8 @@ def test_get_user_settings_value_error_with_retries(self): _service.disable_retries() self.test_get_user_settings_value_error() -class TestUpdateUserSettings(): + +class TestUpdateUserSettings: """ Test Class for update_user_settings """ @@ -1080,9 +960,7 @@ def test_update_user_settings_all_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString/settings') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' @@ -1100,7 +978,7 @@ def test_update_user_settings_all_params(self): notification_language=notification_language, allowed_ip_addresses=allowed_ip_addresses, self_manage=self_manage, - headers={} + headers={}, ) # Check for correct operation @@ -1129,20 +1007,14 @@ def test_update_user_settings_required_params(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString/settings') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' iam_id = 'testString' # Invoke method - response = _service.update_user_settings( - account_id, - iam_id, - headers={} - ) + response = _service.update_user_settings(account_id, iam_id, headers={}) # Check for correct operation assert len(responses.calls) == 1 @@ -1164,9 +1036,7 @@ def test_update_user_settings_value_error(self): """ # Set up mock url = preprocess_url('/v2/accounts/testString/users/testString/settings') - responses.add(responses.PATCH, - url, - status=204) + responses.add(responses.PATCH, url, status=204) # Set up parameter values account_id = 'testString' @@ -1178,7 +1048,7 @@ def test_update_user_settings_value_error(self): "iam_id": iam_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()} + 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_user_settings(**req_copy) @@ -1191,6 +1061,7 @@ def test_update_user_settings_value_error_with_retries(self): _service.disable_retries() self.test_update_user_settings_value_error() + # endregion ############################################################################## # End of Service: UserSettings @@ -1201,7 +1072,7 @@ def test_update_user_settings_value_error_with_retries(self): # Start of Model Tests ############################################################################## # region -class TestModel_InvitedUser(): +class TestModel_InvitedUser: """ Test Class for InvitedUser """ @@ -1232,7 +1103,8 @@ def test_invited_user_serialization(self): invited_user_model_json2 = invited_user_model.to_dict() assert invited_user_model_json2 == invited_user_model_json -class TestModel_InvitedUserList(): + +class TestModel_InvitedUserList: """ Test Class for InvitedUserList """ @@ -1244,7 +1116,7 @@ def test_invited_user_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - invited_user_model = {} # InvitedUser + invited_user_model = {} # InvitedUser invited_user_model['email'] = 'testString' invited_user_model['id'] = 'testString' invited_user_model['state'] = 'testString' @@ -1268,7 +1140,8 @@ def test_invited_user_list_serialization(self): invited_user_list_model_json2 = invited_user_list_model.to_dict() assert invited_user_list_model_json2 == invited_user_list_model_json -class TestModel_UserList(): + +class TestModel_UserList: """ Test Class for UserList """ @@ -1280,7 +1153,7 @@ def test_user_list_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - user_profile_model = {} # UserProfile + user_profile_model = {} # UserProfile user_profile_model['id'] = 'testString' user_profile_model['iam_id'] = 'testString' user_profile_model['realm'] = 'testString' @@ -1318,7 +1191,8 @@ def test_user_list_serialization(self): user_list_model_json2 = user_list_model.to_dict() assert user_list_model_json2 == user_list_model_json -class TestModel_UserProfile(): + +class TestModel_UserProfile: """ Test Class for UserProfile """ @@ -1359,7 +1233,8 @@ def test_user_profile_serialization(self): user_profile_model_json2 = user_profile_model.to_dict() assert user_profile_model_json2 == user_profile_model_json -class TestModel_UserSettings(): + +class TestModel_UserSettings: """ Test Class for UserSettings """ @@ -1391,7 +1266,8 @@ def test_user_settings_serialization(self): user_settings_model_json2 = user_settings_model.to_dict() assert user_settings_model_json2 == user_settings_model_json -class TestModel_Attribute(): + +class TestModel_Attribute: """ Test Class for Attribute """ @@ -1421,7 +1297,8 @@ def test_attribute_serialization(self): attribute_model_json2 = attribute_model.to_dict() assert attribute_model_json2 == attribute_model_json -class TestModel_InviteUser(): + +class TestModel_InviteUser: """ Test Class for InviteUser """ @@ -1451,7 +1328,8 @@ def test_invite_user_serialization(self): invite_user_model_json2 = invite_user_model.to_dict() assert invite_user_model_json2 == invite_user_model_json -class TestModel_InviteUserIamPolicy(): + +class TestModel_InviteUserIamPolicy: """ Test Class for InviteUserIamPolicy """ @@ -1463,14 +1341,14 @@ def test_invite_user_iam_policy_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - role_model = {} # Role + role_model = {} # Role role_model['role_id'] = 'testString' - attribute_model = {} # Attribute + attribute_model = {} # Attribute attribute_model['name'] = 'testString' attribute_model['value'] = 'testString' - resource_model = {} # Resource + resource_model = {} # Resource resource_model['attributes'] = [attribute_model] # Construct a json representation of a InviteUserIamPolicy model @@ -1494,7 +1372,8 @@ def test_invite_user_iam_policy_serialization(self): invite_user_iam_policy_model_json2 = invite_user_iam_policy_model.to_dict() assert invite_user_iam_policy_model_json2 == invite_user_iam_policy_model_json -class TestModel_Resource(): + +class TestModel_Resource: """ Test Class for Resource """ @@ -1506,7 +1385,7 @@ def test_resource_serialization(self): # Construct dict forms of any model objects needed in order to build this model. - attribute_model = {} # Attribute + attribute_model = {} # Attribute attribute_model['name'] = 'testString' attribute_model['value'] = 'testString' @@ -1529,7 +1408,8 @@ def test_resource_serialization(self): resource_model_json2 = resource_model.to_dict() assert resource_model_json2 == resource_model_json -class TestModel_Role(): + +class TestModel_Role: """ Test Class for Role """