o
    ɶd>                     @   sL   d dl mZmZ d dl mZ d dlmZ dd Zdd Zdd	 Zd
d Z	dS )   )dnsobject_storage)retry)Responsec                 O   sB  d}g }d}d}d}	t  }
t| ||dg|R i |D ]R}|}t|jtjjs/t|jtjjr=d}|jj}|	|jj
 qt|jtjjrZd}	|	|jj |jjrY|
|jj qt|jtrf|	|jn|	|jj
 q|rt|j|j||d|j}|S |	rt|j|jtjj|t|
d|j}|S t|j|j||j}|S )ag  
    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`
    NFresponseTitemsobjectsprefixes)set#list_call_get_up_to_limit_generator
isinstancedatar   modelsRecordCollectionRRSet	__class__extendr   r   ListObjectsr
   r   updatelistr   statusheadersrequest)list_func_refrecord_limit	page_sizelist_func_argslist_func_kwargscall_resultaggregated_resultsis_dns_record_collectiondns_record_collection_classis_list_objects_responselist_objects_prefixesr   final_response r'   Cusr/lib/python3.10/site-packages/oci/pagination/pagination_utils.pylist_call_get_up_to_limit
   sT     r)   c                 o   sd   |s	|s	t d|du rX||d< tjj| g|R i |}|dkr'|V  dS g }t|jtjjs9t|jtjj	r>|jj
}nt|jtjjrK|jj}n|j}|D ]}|V  qPdS d}	|}
d}|	r,|
dkr.t||
|d< tjj| g|R i |}|dkr|V  n9g }t|jtjjst|jtjj	r|jj
}nt|jtjjr|jj}nt|jtr|jn|jj
}|D ]}|V  qt|jtjjst|jtjj	r|
t|jj
8 }
n$t|jtjjr|
t|jj8 }
n|
t|jtrt|jnt|jj
8 }
t|jtjjr|jjdur|jj|d< |jjdu}	n|jdur |j|d< |j}	|	r0|
dksfdS dS dS dS )	a  
    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)
    z>You must provide one, or both, of a record_limit and page_sizeNlimitr   T    startpage)
ValueErrorr   DEFAULT_RETRY_STRATEGYmake_retrying_callr   r   r   r   r   r   r   r   r   r
   minr   lennext_start_with	next_pagehas_next_page)r   r   r   
yield_moder   r   Zsingle_call_resultitems_to_yielditemkeep_paginatingZremaining_items_to_fetchr    r'   r'   r(   r   P   s^   $ 

 

 &
r   c                 O   s>  g }d}d}d}d}t  }t| dg|R i |D ]R}	|	}t|jtjjs-t|jtjjr;d}|jj}|	|jj
 qt|jtjjrXd}|	|jj |jjrW||jj qt|jtrd|	|jn|	|jj
 q|r}t|j|j||d|j}
|
S |rt|j|jtjj|t|d|j}
|
S t|j|j||j}
|
S )a<  
    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`
    NFr   Tr   r	   )r   #list_call_get_all_results_generatorr   r   r   r   r   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   )r   r   r   r!   r    r"   r#   r$   r%   r   r&   r'   r'   r(   list_call_get_all_results   sT    r;   c                 o   s   d}d}|rt jj| g|R i |}|dkr|V  n9g }t|jtjjs.t|jtjjr3|jj	}nt|jt
jjr@|jj}nt|jtrI|jn|jj	}|D ]}|V  qOt|jt
jjrp|jjduri|jj|d< |jjdu}n|jdurz|j|d< |j}|sdS dS )a  
    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)
    TNr   r,   r-   )r   r/   r0   r   r   r   r   r   r   r   r   r   r
   r   r3   r4   r5   )r   r6   r   r   r9   r    r7   r8   r'   r'   r(   r:      s.    



r:   N)
 r   r   r   r   r   r)   r   r;   r:   r'   r'   r'   r(   <module>   s   Fd>