
    Oj                         S r SSKrSSKJrJrJrJrJrJrJ	r	J
r
Jr  SSKJr  SSKJr  \
" S5      r\	S   r " S	 S
\\   5      r " S S\\   5      r " S S\\   5      rg)zPagers for the GenAI List APIs.    N)	AnyAsyncIterator	AwaitableCallableGenericIteratorLiteralTypeVarUnion   )_common)typesT)
batch_jobsmodelstuning_jobsfilescached_contentsfile_search_stores	documentsc            
       F   \ rS rSrSrS\S\S\4   S\S\SS	4
S
 jrS\S\S\4   S\S\4S jr	\
S\\   4S j5       r\
S\4S j5       r\
S\4S j5       r\
S\\R&                  S	4   4S j5       r\
S\R,                  4S j5       rS\4S jrS\S\4S jrS\SS	4S jrSrg	)
_BasePager&   z9Base pager class for iterating through paginated results.namerequest.responseconfigreturnNc                    Xl         X l        [        X0R                   5      =(       d    / U l        SU l        [        USS 5      U l        U(       d  0 nO7[        U[        5      (       a  [        R                  " U5      nO[        U5      n[        US5      US'   XPl
        UR                  S[        U R                  5      5      U l        g )Nr   sdk_http_responsenext_page_token
page_token	page_size)_name_requestgetattr_page_idx_sdk_http_response
isinstancedictcopydeepcopy_configgetlen
_page_size)selfr   r   r   r   request_configs         U/var/www/html/leaf-doctor-v1/venv/lib/python3.13/site-packages/google/genai/pagers.py
_init_page_BasePager._init_page)   s     JM::.4"DJDI%h0CTJDn	FD	!	!}}V,nF|n#*85F#GN< !L)--k3tzz?KDO    c                 (    U R                  XX45        g N)r5   )r2   r   r   r   r   s        r4   __init___BasePager.__init__C   s     	OOD84r7   c                     U R                   $ )aC  Returns a subset of the entire list of items.

For the number of items returned, see `pageSize()`.

Usage:

.. code-block:: python

  batch_jobs_pager = client.batches.list(config={'page_size': 5})
  print(f"first page: {batch_jobs_pager.page}")
  # first page: [BatchJob(name='projects/./locations/./batchPredictionJobs/1
)r'   r2   s    r4   page_BasePager.pageL   s     ::r7   c                     U R                   $ )zReturns the type of paged item (for example, ``batch_jobs``).

Usage:

.. code-block:: python

  batch_jobs_pager = client.batches.list(config={'page_size': 5})
  print(f"name: {batch_jobs_pager.name}")
  # name: batch_jobs
)r$   r=   s    r4   r   _BasePager.name]   s     ::r7   c                     U R                   $ )zReturns the maximum number of items fetched by the pager at one time.

Usage:

.. code-block:: python

  batch_jobs_pager = client.batches.list(config={'page_size': 5})
  print(f"page_size: {batch_jobs_pager.page_size}")
  # page_size: 5
)r1   r=   s    r4   r#   _BasePager.page_sizel   s     ??r7   c                     U R                   $ )z.Returns the http response of the API response.)r)   r=   s    r4   r    _BasePager.sdk_http_response{   s     """r7   c                     U R                   $ )a  Returns the configuration when making the API request for the next page.

A configuration is a set of optional parameters and arguments that can be
used to customize the API request. For example, the ``page_token`` parameter
contains the token to request the next page.

Usage:

.. code-block:: python

  batch_jobs_pager = client.batches.list(config={'page_size': 5})
  print(f"config: {batch_jobs_pager.config}")
  # config: {'page_size': 5, 'page_token': 'AMEw9yO5jnsGnZJLHSKDFHJJu'}
)r.   r=   s    r4   r   _BasePager.config   s    " <<r7   c                 ,    [        U R                  5      $ )z6Returns the total number of items in the current page.)r0   r>   r=   s    r4   __len___BasePager.__len__   s    tyy>r7   indexc                      U R                   U   $ )z$Returns the item at the given index.)r>   )r2   rK   s     r4   __getitem___BasePager.__getitem__   s    99Ur7   c                 f    U R                  U R                  U R                  XR                  5        g)zInitializes the next page from the response.

This is an internal method that should be called by subclasses after
fetching the next page.

Args:
  response: The response object from the API request.
N)r5   r   r%   r   r2   r   s     r4   _init_next_page_BasePager._init_next_page   s      	OODIIt}}hDr7   )r.   r(   r$   r'   r1   r%   r)   )__name__
__module____qualname____firstlineno____doc__	PagedItemr   r   r5   r:   propertylistr   r>   r   intr#   r   r   HttpResponser    r   
StringDictr   rI   rM   rQ   __static_attributes__ r7   r4   r   r   &   sS   ALL S!L 	L
 L L455 S!5 	5
 5 DG    I      #u'9'94'?!@ # #
 g((  $s s q 	Ec 	Ed 	Er7   r   c                   N    \ rS rSrSrS\4S jrS\\   4S jrS\	\   4S jr
Srg)	Pager   z4Pager class for iterating through paginated results.r   c                     U R                   [        U 5      :  a   U R                  5         U R
                  U R                      nU =R                   S-  sl         U$ ! [         a    [        ef = f)zReturns the next item.r   )r(   r0   	next_page
IndexErrorStopIterationr>   r2   items     r4   __next__Pager.__next__   s^    yyCI 99TYYDIINIK  s   A A,c                     SU l         U $ )z#Returns an iterator over the items.r   r(   r=   s    r4   __iter__Pager.__iter__       DIKr7   c                     U R                   R                  S5      (       d  [        S5      eU R                  U R                   S9nU R	                  U5        U R
                  $ )a  Fetches the next page of items. This makes a new API request.

Usage:

.. code-block:: python

  batch_jobs_pager = client.batches.list(config={'page_size': 5})
  print(f"current page: {batch_jobs_pager.page}")
  batch_jobs_pager.next_page()
  print(f"next page: {batch_jobs_pager.page}")
  # current page: [BatchJob(name='projects/.../batchPredictionJobs/1
  # next page: [BatchJob(name='projects/.../batchPredictionJobs/6
r"   No more pages to fetch.r   r   r/   re   r%   rQ   r>   rP   s     r4   rd   Pager.next_page   sO     ;;??<((011}}DKK}0H"99r7   rl   N)rS   rT   rU   rV   rW   r   ri   r   rm   rZ   rd   r^   r_   r7   r4   ra   ra      s1    <
 
 
a r7   ra   c                      ^  \ rS rSrSrS\S\S\\   4   S\S\4U 4S jjr	S	\
\   4S
 jrS	\4S jrS	\\   4S jrSrU =r$ )
AsyncPager   z9AsyncPager class for iterating through paginated results.r   r   .r   r   c                 &   > [         TU ]  XX45        g r9   )superr:   )r2   r   r   r   r   	__class__s        r4   r:   AsyncPager.__init__   s     
GTH5r7   r   c                     SU l         U $ )z)Returns an async iterator over the items.r   rl   r=   s    r4   	__aiter__AsyncPager.__aiter__   ro   r7   c                    #    U R                   [        U 5      :  a   U R                  5       I Sh  vN   U R
                  U R                      nU =R                   S-  sl         U$  N4! [         a    [        ef = f7f)z%Returns the next item asynchronously.Nr   )r(   r0   rd   re   StopAsyncIterationr>   rg   s     r4   	__anext__AsyncPager.__anext__   si     yyCI!nn 99TYYDIINIK 	 !  !s+   A;A' A%A' 0A;%A' 'A88A;c                    #    U R                   R                  S5      (       d  [        S5      eU R                  U R                   S9I Sh  vN nU R	                  U5        U R
                  $  N!7f)a  Fetches the next page of items asynchronously.

This makes a new API request.

Returns:
  The next page of items.

Raises:
  IndexError: No more pages to fetch.

Usage:

.. code-block:: python

  batch_jobs_pager = await client.aio.batches.list(config={'page_size': 5})
  print(f"current page: {batch_jobs_pager.page}")
  await batch_jobs_pager.next_page()
  print(f"next page: {batch_jobs_pager.page}")
  # current page: [BatchJob(name='projects/.../batchPredictionJobs/1
  # next page: [BatchJob(name='projects/.../batchPredictionJobs/6
r"   rq   rr   Nrs   rP   s     r4   rd   AsyncPager.next_page   sZ     . ;;??<((011]]$++]66H"99 7s   AA.
A,"A.rl   )rS   rT   rU   rV   rW   rX   r   r   r   r:   r   r   r}   r   rZ   rd   r^   __classcell__)rz   s   @r4   rv   rv      sq    A66 Ys^+,6 	6
 6q) 

q 
tAw  r7   rv   )rW   r,   typingr   r   r   r   r   r   r	   r
   r    r   r   r   rX   r   ra   rv   r_   r7   r4   <module>r      sl     &  f f f  CL	E ED(JqM (V9A 9r7   