diff --git a/examples/test_iam_identity_v1_examples.py b/examples/test_iam_identity_v1_examples.py index 4490e7c..444d13d 100644 --- a/examples/test_iam_identity_v1_examples.py +++ b/examples/test_iam_identity_v1_examples.py @@ -1794,7 +1794,11 @@ def test_update_preference_on_scope_account(self): # begin-update_preference_on_scope_account preference = iam_identity_service.update_preference_on_scope_account( - iam_id=iam_id_for_preferences, service=service, preference_id=preference_id1, value_string=value_string + iam_id=iam_id_for_preferences, + account_id=account_id, + service=service, + preference_id=preference_id1, + value_string=value_string, ).get_result() print(json.dumps(preference, indent=2)) @@ -1813,7 +1817,7 @@ def test_get_preferences_on_scope_account(self): # begin-get_preferences_on_scope_account preference = iam_identity_service.get_preferences_on_scope_account( - iam_id=iam_id_for_preferences, service=service, preference_id=preference_id1 + iam_id=iam_id_for_preferences, account_id=account_id, service=service, preference_id=preference_id1 ).get_result() print(json.dumps(preference, indent=2)) @@ -1832,7 +1836,7 @@ def test_get_all_preferences_on_scope_account(self): # begin-get_all_preferences_on_scope_account preference = iam_identity_service.get_all_preferences_on_scope_account( - iam_id=iam_id_for_preferences + iam_id=iam_id_for_preferences, account_id=account_id ).get_result() print(json.dumps(preference, indent=2)) @@ -1850,7 +1854,7 @@ def test_delete_preferences_on_scope_account(self): # begin-delete_preferences_on_scope_account response = iam_identity_service.delete_preferences_on_scope_account( - iam_id=iam_id_for_preferences, service=service, preference_id=preference_id1 + iam_id=iam_id_for_preferences, account_id=account_id, service=service, preference_id=preference_id1 ) # end-delete_preferences_on_scope_account diff --git a/ibm_platform_services/iam_identity_v1.py b/ibm_platform_services/iam_identity_v1.py index 22241e8..4361ad8 100644 --- a/ibm_platform_services/iam_identity_v1.py +++ b/ibm_platform_services/iam_identity_v1.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# IBM OpenAPI SDK Code Generator Version: 3.98.0-8be2046a-20241205-162752 +# IBM OpenAPI SDK Code Generator Version: 3.103.0-e8b84313-20250402-201816 """ The IAM Identity Service API allows for the management of Account Settings and Identities @@ -89,6 +89,7 @@ def list_api_keys( sort: Optional[str] = None, order: Optional[str] = None, include_history: Optional[bool] = None, + filter: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -120,6 +121,9 @@ def list_api_keys( desc. Default: asc. :param bool include_history: (optional) Defines if the entity history is included in the response. + :param str filter: (optional) An optional filter query parameter used to + refine the results of the search operation. For more information see + [Filtering list results](#filter-list-results) section. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ApiKeyList` object @@ -143,6 +147,7 @@ def list_api_keys( 'sort': sort, 'order': order, 'include_history': include_history, + 'filter': filter, } if 'headers' in kwargs: @@ -691,6 +696,7 @@ def list_service_ids( sort: Optional[str] = None, order: Optional[str] = None, include_history: Optional[bool] = None, + filter: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -715,6 +721,9 @@ def list_service_ids( desc. Default: asc. :param bool include_history: (optional) Defines if the entity history is included in the response. + :param str filter: (optional) An optional filter query parameter used to + refine the results of the search operation. For more information see + [Filtering list results](#filter-list-results) section. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `ServiceIdList` object @@ -736,6 +745,7 @@ def list_service_ids( 'sort': sort, 'order': order, 'include_history': include_history, + 'filter': filter, } if 'headers' in kwargs: @@ -1187,6 +1197,7 @@ def list_profiles( order: Optional[str] = None, include_history: Optional[bool] = None, pagetoken: Optional[str] = None, + filter: Optional[str] = None, **kwargs, ) -> DetailedResponse: """ @@ -1208,6 +1219,9 @@ def list_profiles( included in the response. :param str pagetoken: (optional) Optional Prev or Next page token returned from a previous query execution. Default is start with first page. + :param str filter: (optional) An optional filter query parameter used to + refine the results of the search operation. For more information see + [Filtering list results](#filter-list-results) section. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. :rtype: DetailedResponse with `dict` result representing a `TrustedProfilesList` object @@ -1231,6 +1245,7 @@ def list_profiles( 'order': order, 'include_history': include_history, 'pagetoken': pagetoken, + 'filter': filter, } if 'headers' in kwargs: @@ -2090,7 +2105,10 @@ def set_profile_identity( """ Add a specific identity that can assume the trusted profile. - Add a specific identity that can assume the trusted profile. + Add a specific identity that can assume the trusted profile. This API will update + the trusted profile itself, thus calling it repeatedly for the same profile can + lead to conflicts responded with HTTP code 409. Make sure to call this API only + once in a few seconds for the same trusted profile. :param str profile_id: ID of the trusted profile. :param str identity_type: Type of the identity. @@ -2219,7 +2237,7 @@ def delete_profile_identity( **kwargs, ) -> DetailedResponse: """ - Delete the identity that can assume the trusted profile. + Delete the identity that can assume the trusted profile. This API will update the trusted profile itself, thus calling it repeatedly for the same profile can lead to conflicts responded with HTTP code 409. Make sure to call this API only once in a few seconds for the same trusted profile. Delete the identity that can assume the trusted profile. @@ -3825,7 +3843,7 @@ def delete_preferences_on_scope_account( :param str preference_id: Identifier of preference to be deleted. :param dict headers: A `dict` containing the request headers :return: A `DetailedResponse` containing the result, headers and HTTP status code. - :rtype: DetailedResponse + :rtype: DetailedResponse with `dict` result representing a `ExceptionResponse` object """ if not account_id: @@ -3847,6 +3865,7 @@ def delete_preferences_on_scope_account( if 'headers' in kwargs: headers.update(kwargs.get('headers')) del kwargs['headers'] + headers['Accept'] = 'application/json' path_param_keys = ['account_id', 'iam_id', 'service', 'preference_id'] path_param_values = self.encode_path_vars(account_id, iam_id, service, preference_id) diff --git a/test/integration/test_iam_identity_v1.py b/test/integration/test_iam_identity_v1.py index 2aceb1d..88b4008 100644 --- a/test/integration/test_iam_identity_v1.py +++ b/test/integration/test_iam_identity_v1.py @@ -428,6 +428,35 @@ def test_list_api_keys(self): # make sure we retrieved the two apikeys that we created previously. assert len(apikeys) == 2 + @needscredentials + def test_list_api_keys_with_filter(self): + apikeys = [] + + # Retrieve one apikey at a time to test the pagination. + pagetoken = None + pagetoken_present = True + filter = "name co \"Python\"" + 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, filter=filter + ) + 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)) + + if len(api_key_list['apikeys']) > 0: + for apikey in api_key_list['apikeys']: + if apikey['name'] == self.apikey_name: + apikeys.append(apikey) + + # fetch pagetoken value + pagetoken = self.get_page_token(api_key_list.get('next')) + pagetoken_present = pagetoken is not None + + # make sure we retrieved the two apikeys that we created previously. + assert len(apikeys) == 2 + @needscredentials def test_update_api_key(self): assert apikey_id1 is not None @@ -570,6 +599,20 @@ def test_list_service_ids(self): assert service_id_list is not None assert len(service_id_list['serviceids']) == 1 + @needscredentials + def test_list_service_ids_with_filter(self): + filter = "name co \"Python\"" + list_service_ids_response = self.iam_identity_service.list_service_ids( + account_id=self.account_id, name=self.serviceid_name, pagesize=100, filter=filter + ) + + 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)) + + assert service_id_list is not None + assert len(service_id_list['serviceids']) == 1 + @needscredentials def test_update_service_id(self): assert serviceid_id1 is not None @@ -704,6 +747,32 @@ def test_list_profiles(self): assert len(profiles) == 2 + @needscredentials + def test_list_profiles_with_filter(self): + profiles = [] + + pagetoken = None + pagetoken_present = True + filter = "name co \"Python\"" + while pagetoken_present: + list_profiles_response = self.iam_identity_service.list_profiles( + account_id=self.account_id, pagesize=1, pagetoken=pagetoken, include_history=False, filter=filter + ) + 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)) + + if len(profile_list['profiles']) > 0: + for profile in profile_list['profiles']: + if profile['name'] == self.profile_name1 or profile['name'] == self.profile_name2: + profiles.append(profile) + + pagetoken = self.get_page_token(profile_list.get('next')) + pagetoken_present = pagetoken is not None + + assert len(profiles) == 2 + @needscredentials def test_update_profile(self): assert profile_id1 is not None @@ -1844,11 +1913,12 @@ def test_update_api_key(self): @needscredentials def test_update_preference_on_scope_account(self): - assert iam_id_for_preferences is not None + assert self.iam_id_for_preferences is not None assert self.preference_id1 is not None preference = self.iam_identity_service.update_preference_on_scope_account( - iam_id=iam_id_for_preferences, + iam_id=self.iam_id_for_preferences, + account_id=self.account_id, service=self.service, preference_id=self.preference_id1, value_string=self.value_string, @@ -1858,29 +1928,35 @@ def test_update_preference_on_scope_account(self): @needscredentials def test_get_preferences_on_scope_account(self): - assert iam_id_for_preferences is not None + assert self.iam_id_for_preferences is not None assert self.preference_id1 is not None preference = self.iam_identity_service.get_preferences_on_scope_account( - iam_id=iam_id_for_preferences, service=self.service, preference_id=self.preference_id1 + iam_id=self.iam_id_for_preferences, + account_id=self.account_id, + service=self.service, + preference_id=self.preference_id1, ).get_result() print('\nget_preference_on_scope_account() response: ', json.dumps(preference, indent=2)) preference is not None @needscredentials def test_get_all_preferences_on_scope_account(self): - assert iam_id_for_preferences is not None + assert self.iam_id_for_preferences is not None assert self.preference_id1 is not None preference = self.iam_identity_service.get_all_preferences_on_scope_account( - iam_id=iam_id_for_preferences + account_id=self.account_id, iam_id=self.iam_id_for_preferences ).get_result() print('\nget_all_preference_on_scope_account() response: ', json.dumps(preference, indent=2)) preference is not None @needscredentials def test_delete_preferences_on_scope_account(self): - assert iam_id_for_preferences is not None + assert self.iam_id_for_preferences is not None assert self.preference_id1 is not None preference = self.iam_identity_service.delete_preferences_on_scope_account( - iam_id=iam_id_for_preferences, service=self.service, preference_id=self.preference_id1 + iam_id=self.iam_id_for_preferences, + account_id=self.account_id, + service=self.service, + preference_id=self.preference_id1, ) assert preference.get_status_code() == 204 diff --git a/test/unit/test_iam_identity_v1.py b/test/unit/test_iam_identity_v1.py index 457e5cc..375aa6b 100644 --- a/test/unit/test_iam_identity_v1.py +++ b/test/unit/test_iam_identity_v1.py @@ -120,6 +120,7 @@ def test_list_api_keys_all_params(self): sort = 'testString' order = 'asc' include_history = False + filter = 'testString' # Invoke method response = _service.list_api_keys( @@ -132,6 +133,7 @@ def test_list_api_keys_all_params(self): sort=sort, order=order, include_history=include_history, + filter=filter, headers={}, ) @@ -150,6 +152,7 @@ def test_list_api_keys_all_params(self): assert 'sort={}'.format(sort) in query_string assert 'order={}'.format(order) in query_string assert 'include_history={}'.format('true' if include_history else 'false') in query_string + assert 'filter={}'.format(filter) in query_string def test_list_api_keys_all_params_with_retries(self): # Enable retries and run test_list_api_keys_all_params. @@ -1128,6 +1131,7 @@ def test_list_service_ids_all_params(self): sort = 'testString' order = 'asc' include_history = False + filter = 'testString' # Invoke method response = _service.list_service_ids( @@ -1138,6 +1142,7 @@ def test_list_service_ids_all_params(self): sort=sort, order=order, include_history=include_history, + filter=filter, headers={}, ) @@ -1154,6 +1159,7 @@ def test_list_service_ids_all_params(self): assert 'sort={}'.format(sort) in query_string assert 'order={}'.format(order) in query_string assert 'include_history={}'.format('true' if include_history else 'false') in query_string + assert 'filter={}'.format(filter) in query_string def test_list_service_ids_all_params_with_retries(self): # Enable retries and run test_list_service_ids_all_params. @@ -1987,6 +1993,7 @@ def test_list_profiles_all_params(self): order = 'asc' include_history = False pagetoken = 'testString' + filter = 'testString' # Invoke method response = _service.list_profiles( @@ -1997,6 +2004,7 @@ def test_list_profiles_all_params(self): order=order, include_history=include_history, pagetoken=pagetoken, + filter=filter, headers={}, ) @@ -2013,6 +2021,7 @@ def test_list_profiles_all_params(self): assert 'order={}'.format(order) in query_string assert 'include_history={}'.format('true' if include_history else 'false') in query_string assert 'pagetoken={}'.format(pagetoken) in query_string + assert 'filter={}'.format(filter) in query_string def test_list_profiles_all_params_with_retries(self): # Enable retries and run test_list_profiles_all_params.