Open pastyGRB opened 7 months ago
Until it fixed, you can use below functions I wrote in showoci to deal with paginations:
##########################################################################
# Pagination main call
##########################################################################
def list_call_get_all_results(list_func_ref, *list_func_args, **list_func_kwargs):
aggregated_results = []
for call_result in list_call_get_all_results_generator_domains(list_func_ref, *list_func_args, **list_func_kwargs):
aggregated_results.extend(call_result.data.resources)
final_response = oci.Response(call_result.status, call_result.headers, aggregated_results, call_result.request)
return final_response
##########################################################################
# Pagination result generator
##########################################################################
def list_call_get_all_results_generator_domains(list_func_ref, *list_func_args, **list_func_kwargs):
keep_paginating = True
while keep_paginating:
call_result = oci.retry.DEFAULT_RETRY_STRATEGY.make_retrying_call(list_func_ref, *list_func_args, **list_func_kwargs)
yield call_result
start_index = call_result.data.start_index
total_results = call_result.data.total_results
items_per_page = call_result.data.items_per_page
next_index = start_index + items_per_page
if next_index < total_results:
list_func_kwargs['start_index'] = next_index
else:
keep_paginating = False
Also opened Oracle SR: [3-35893215011]
SDK version 2.123.0 Python version 3.11.4
When attempting to use oci.pagination.list_call_get_all_results with the list_groups method of oci.identity.IdentityClient, the call fails with the following error:
Traceback (most recent call last):
File "/Users/cpasternak/repos/oci_helpers/groups.py", line 48, in get_all_groups_idd
group_list=oci.pagination.list_call_get_all_results(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cpasternak/Library/Python/3.11/lib/python/site-packages/oci/pagination/pagination_utils.py", line 218, in list_call_get_all_results
else aggregated_results.extend(call_result.data.items)
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Groups' object has no attribute 'items'
CODE:
config=valid OCI config
url="https://idcs-c2ee2b3360e24cea83df0f956fb007d5.identity.oraclecloud.com:443"
identity_domain_client = oci.identity_domains.IdentityDomainsClient(config, url)
group_list=oci.pagination.list_call_get_all_results(
identity_domain_client.list_groups,
retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY
).data
It would appear that the aggregated_results.extend function is looking for .items, but with the identity domain client, it uses the terminology .resources (not .items)