Server IP : 103.119.228.120 / Your IP : 3.144.90.108 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/mysqlsh/lib/python3.9/site-packages/oci/pagination/ |
Upload File : |
# coding: utf-8 # Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. # This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. from .. import dns, object_storage from .. import retry from ..response import Response def list_call_get_up_to_limit(list_func_ref, record_limit, page_size, *list_func_args, **list_func_kwargs): """ Calls a list operation and automatically fetches more data from the service (automatically following pagination tokens) until the desired number of records is reached (or there are no more records left, if the total number of records is less than the desired number of records). Apart from the formally listed parameters for this function, any additional positional (``*list_func_args``) and keyword (``**list_func_kwargs``) arguments will be passed to the list operation. Results are eagerly loaded and the response returned by this function will contain all the data up to the desired number of records (or there are no more records left, whichever is first). If you wish to lazy load results, then use the version of this method which produces a generator: :py:func:`~oci.pagination.list_call_get_up_to_limit_generator` :param function list_func_ref: A reference to the list operation which we will call :param int record_limit: The maximum number of records to fetch. We may fetch less records than this if the total number of records is less than this value. If a record_limit is not provided then we will only fetch a single page of data :param int page_size: The number of records to retrieve per list operation call :return: A :class:`~oci.response.Response` whose data attribute contains all the records we retrieved. The other attributes of the :class:`~oci.response.Response` object will be sourced from the last response we received from calling the list operation on the service. :rtype: :class:`~oci.response.Response` """ call_result = None aggregated_results = [] is_dns_record_collection = False dns_record_collection_class = None is_list_objects_response = False list_objects_prefixes = set() for response in list_call_get_up_to_limit_generator(list_func_ref, record_limit, page_size, 'response', *list_func_args, **list_func_kwargs): call_result = response if isinstance(call_result.data, dns.models.RecordCollection) or isinstance(call_result.data, dns.models.RRSet): is_dns_record_collection = True dns_record_collection_class = call_result.data.__class__ aggregated_results.extend(call_result.data.items) elif isinstance(call_result.data, object_storage.models.ListObjects): is_list_objects_response = True aggregated_results.extend(call_result.data.objects) if call_result.data.prefixes: list_objects_prefixes.update(call_result.data.prefixes) else: aggregated_results.extend(call_result.data) if isinstance(call_result.data, list) \ else aggregated_results.extend(call_result.data.items) if is_dns_record_collection: final_response = Response( call_result.status, call_result.headers, dns_record_collection_class(items=aggregated_results), call_result.request ) elif is_list_objects_response: final_response = Response( call_result.status, call_result.headers, object_storage.models.ListObjects( objects=aggregated_results, prefixes=list(list_objects_prefixes) ), call_result.request ) else: final_response = Response(call_result.status, call_result.headers, aggregated_results, call_result.request) return final_response def list_call_get_up_to_limit_generator(list_func_ref, record_limit, page_size, yield_mode, *list_func_args, **list_func_kwargs): """ Calls a list operation and automatically fetches more data from the service (automatically following pagination tokens) until the desired number of records is reached (or there are no more records left, if the total number of records is less than the desired number of records). Apart from the formally listed parameters for this function, any additional positional (``*list_func_args``) and keyword (``**list_func_kwargs``) arguments will be passed to the list operation. This function produces a generator and lazily loads results. That is, service calls will only be made to fetch more data when needed as we iterate through results produced by the generator; this contrasts with the eagarily loaded :py:func:`~oci.pagination.list_call_get_up_to_limit` function, which makes all the required service calls when it is called. The generator also supports vending two types of objects - either the raw responses received from calling the list operation, or the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects). :param function list_func_ref: A reference to the list operation which we will call :param int record_limit: The maximum number of records to fetch. We may fetch less records than this if the total number of records is less than this value. If a record_limit is not provided then we will only fetch a single page of data :param int page_size: The number of records to retrieve per list operation call :param str yield_mode: Either ``response`` or ``record``. This will control whether the generator returned by this function yields either :class:`~oci.response.Response` objects (if the value is ``response``), or whether it yields the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects) :return: A generator that, depending on the ``yield_mode``, will yield either :class:`~oci.response.Response` objects or the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects) """ if not record_limit and not page_size: raise ValueError('You must provide one, or both, of a record_limit and page_size') # If no limit was provided, make a single call if record_limit is None: list_func_kwargs['limit'] = page_size single_call_result = retry.DEFAULT_RETRY_STRATEGY.make_retrying_call(list_func_ref, *list_func_args, **list_func_kwargs) if yield_mode == 'response': yield single_call_result else: items_to_yield = [] if isinstance(single_call_result.data, dns.models.RecordCollection) or isinstance(single_call_result.data, dns.models.RRSet): items_to_yield = single_call_result.data.items elif isinstance(single_call_result.data, object_storage.models.ListObjects): items_to_yield = single_call_result.data.objects else: items_to_yield = single_call_result.data for item in items_to_yield: yield item return # This will terminate after we yield everything we can from the single result # If we have a limit, make calls until we get that amount of data keep_paginating = True remaining_items_to_fetch = record_limit call_result = None while keep_paginating and remaining_items_to_fetch > 0: list_func_kwargs['limit'] = min(page_size, remaining_items_to_fetch) call_result = retry.DEFAULT_RETRY_STRATEGY.make_retrying_call(list_func_ref, *list_func_args, **list_func_kwargs) if yield_mode == 'response': yield call_result else: items_to_yield = [] if isinstance(call_result.data, dns.models.RecordCollection) or isinstance(call_result.data, dns.models.RRSet): items_to_yield = call_result.data.items elif isinstance(call_result.data, object_storage.models.ListObjects): items_to_yield = call_result.data.objects else: items_to_yield = call_result.data if isinstance(call_result.data, list) else call_result.data.items for item in items_to_yield: yield item if isinstance(call_result.data, dns.models.RecordCollection) or isinstance(call_result.data, dns.models.RRSet): remaining_items_to_fetch -= len(call_result.data.items) elif isinstance(call_result.data, object_storage.models.ListObjects): remaining_items_to_fetch -= len(call_result.data.objects) else: remaining_items_to_fetch -= len(call_result.data) if isinstance(call_result.data, list) else len(call_result.data.items) if isinstance(call_result.data, object_storage.models.ListObjects): if call_result.data.next_start_with is not None: list_func_kwargs['start'] = call_result.data.next_start_with keep_paginating = (call_result.data.next_start_with is not None) else: if call_result.next_page is not None: list_func_kwargs['page'] = call_result.next_page keep_paginating = call_result.has_next_page def list_call_get_all_results(list_func_ref, *list_func_args, **list_func_kwargs): """ Calls a list operation and automatically fetches more data from the service (automatically following pagination tokens) until the no more records are available. Apart from the formally listed parameters for this function, any additional positional (``*list_func_args``) and keyword (``**list_func_kwargs``) arguments will be passed to the list operation. Results are eagerly loaded and the response returned by this function will contain all the available data. If you wish to lazy load results, then use the version of this method which produces a generator: :py:func:`~oci.pagination.list_call_get_all_results_generator` :param function list_func_ref: A reference to the list operation which we will call :return: A :class:`~oci.response.Response` whose data attribute contains all the records we retrieved. The other attributes of the :class:`~oci.response.Response` object will be sourced from the last response we received from calling the list operation on the service. :rtype: :class:`~oci.response.Response` """ aggregated_results = [] call_result = None is_dns_record_collection = False dns_record_collection_class = None is_list_objects_response = False list_objects_prefixes = set() for response in list_call_get_all_results_generator(list_func_ref, 'response', *list_func_args, **list_func_kwargs): call_result = response if isinstance(call_result.data, dns.models.RecordCollection) or isinstance(call_result.data, dns.models.RRSet): is_dns_record_collection = True dns_record_collection_class = call_result.data.__class__ aggregated_results.extend(call_result.data.items) elif isinstance(call_result.data, object_storage.models.ListObjects): is_list_objects_response = True aggregated_results.extend(call_result.data.objects) if call_result.data.prefixes: list_objects_prefixes.update(call_result.data.prefixes) else: aggregated_results.extend(call_result.data) if isinstance(call_result.data, list) \ else aggregated_results.extend(call_result.data.items) if is_dns_record_collection: final_response = Response( call_result.status, call_result.headers, dns_record_collection_class(items=aggregated_results), call_result.request ) elif is_list_objects_response: final_response = Response( call_result.status, call_result.headers, object_storage.models.ListObjects( objects=aggregated_results, prefixes=list(list_objects_prefixes) ), call_result.request ) else: final_response = Response(call_result.status, call_result.headers, aggregated_results, call_result.request) return final_response def list_call_get_all_results_generator(list_func_ref, yield_mode, *list_func_args, **list_func_kwargs): """ Calls a list operation and automatically fetches more data from the service (automatically following pagination tokens) until the no more records are available. Apart from the formally listed parameters for this function, any additional positional (``*list_func_args``) and keyword (``**list_func_kwargs``) arguments will be passed to the list operation. This function produces a generator and lazily loads results. That is, service calls will only be made to fetch more data when needed as we iterate through results produced by the generator; this contrasts with the eagarily loaded :py:func:`~oci.pagination.list_call_get_all_results` function, which makes all the required service calls when it is called. The generator also supports vending two types of objects - either the raw responses received from calling the list operation, or the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects). :param function list_func_ref: A reference to the list operation which we will call :param str yield_mode: Either ``response`` or ``record``. This will control whether the generator returned by this function yields either :class:`~oci.response.Response` objects (if the value is ``response``), or whether it yields the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects) :return: A generator that, depending on the ``yield_mode``, will yield either :class:`~oci.response.Response` objects or the individual model objects which are contained within the response's ``data`` attribute (which should be a list of model objects) """ keep_paginating = True call_result = None while keep_paginating: call_result = retry.DEFAULT_RETRY_STRATEGY.make_retrying_call(list_func_ref, *list_func_args, **list_func_kwargs) if yield_mode == 'response': yield call_result else: items_to_yield = [] if isinstance(call_result.data, dns.models.RecordCollection) or isinstance(call_result.data, dns.models.RRSet): items_to_yield = call_result.data.items elif isinstance(call_result.data, object_storage.models.ListObjects): items_to_yield = call_result.data.objects else: items_to_yield = call_result.data if isinstance(call_result.data, list) else call_result.data.items for item in items_to_yield: yield item if isinstance(call_result.data, object_storage.models.ListObjects): if call_result.data.next_start_with is not None: list_func_kwargs['start'] = call_result.data.next_start_with keep_paginating = (call_result.data.next_start_with is not None) else: if call_result.next_page is not None: list_func_kwargs['page'] = call_result.next_page keep_paginating = call_result.has_next_page