
    (ph(                         S SK r S SKJr  S SKrS SKrS SKJrJr  S SKJ	r	J
r
  S SKJr  S SKJr  S SKJr   S SKJr  S	r\S 5       r " S S5      rg! \ a    S
r Nf = f)    N)asynccontextmanager)MappingOptional)_exponential_backoff
exceptions)	transport)Credentials)TimeoutError)RequestTFc                   ^^^#    [         R                  " 5       mU mUU4S jmUU4S jn U7v   T" 5         g! T" 5         f = f7f)a  
timeout_guard is an asynchronous context manager to apply a timeout to an asynchronous block of code.

Args:
    timeout (float): The time in seconds before the context manager times out.

Raises:
    google.auth.exceptions.TimeoutError: If the code within the context exceeds the provided timeout.

Usage:
    async with timeout_guard(10) as with_timeout:
        await with_timeout(async_function())
c                  l   > [         R                  " 5       T-
  n TU -
  nUS::  a  [        ST S35      eU$ )Nr   z3Context manager exceeded the configured timeout of s.)time	monotonicr
   )elapsed	remainingstarttotal_timeouts     U/var/www/html/venv/lib/python3.13/site-packages/google/auth/aio/transport/sessions.py_remaining_time&timeout_guard.<locals>._remaining_time4   sG    .."U*!G+	>Em_TVW      c                    >#     T" 5       n[         R                  " X5      I S h  vN nU$  N! [         R                  [        4 a  n[        SU  ST S35      UeS nAff = f7f)NzThe operation z$ exceeded the configured timeout of r   )asynciowait_forr
   )coror   responseer   r   s       r   with_timeout#timeout_guard.<locals>.with_timeout=   sn     	')I$--d>>HO ?$$l3 	 &J=/Y[\	s1   A# . ,. A#. A AA  A#N)r   r   )timeoutr   r   r   r   s     @@@r   timeout_guardr"   "   s<      NNEM 	s   &A9 A	AAc                   *   \ rS rSrSr SS\S\\R                     4S jjr	SS\R                  \R                  4S\S\S	\\   S
\\\\4      S\S\S\R                  4S jjr\R$                  " \5      SS\R                  \R                  4S\S	\\   S
\\\\4      S\S\S\R                  4S jj5       r\R$                  " \5      SS\R                  \R                  4S\S	\\   S
\\\\4      S\S\S\R                  4S jj5       r\R$                  " \5      SS\R                  \R                  4S\S	\\   S
\\\\4      S\S\S\R                  4S jj5       r\R$                  " \5      SS\R                  \R                  4S\S	\\   S
\\\\4      S\S\S\R                  4S jj5       r\R$                  " \5      SS\R                  \R                  4S\S	\\   S
\\\\4      S\S\S\R                  4S jj5       rSS jrSrg)AsyncAuthorizedSessionN   a;  This is an asynchronous implementation of :class:`google.auth.requests.AuthorizedSession` class.
We utilize an instance of a class that implements :class:`google.auth.aio.transport.Request` configured
by the caller or otherwise default to `google.auth.aio.transport.aiohttp.Request` if the external aiohttp
package is installed.

A Requests Session class with credentials.

This class is used to perform asynchronous requests to API endpoints that require
authorization::

    import aiohttp
    from google.auth.aio.transport import sessions

    async with sessions.AsyncAuthorizedSession(credentials) as authed_session:
        response = await authed_session.request(
            'GET', 'https://www.googleapis.com/storage/v1/b')

The underlying :meth:`request` implementation handles adding the
credentials' headers to the request and refreshing credentials as needed.

Args:
    credentials (google.auth.aio.credentials.Credentials):
        The credentials to add to the request.
    auth_request (Optional[google.auth.aio.transport.Request]):
        An instance of a class that implements
        :class:`~google.auth.aio.transport.Request` used to make requests
        and refresh credentials. If not passed,
        an instance of :class:`~google.auth.aio.transport.aiohttp.Request`
        is created.

Raises:
    - google.auth.exceptions.TransportError: If `auth_request` is `None`
        and the external package `aiohttp` is not installed.
    - google.auth.exceptions.InvalidType: If the provided credentials are
        not of type `google.auth.aio.credentials.Credentials`.
Ncredentialsauth_requestc                     [        U[        5      (       d#  [        R                  " S[	        U5       S35      eXl        UnU(       d  [        (       a
  [        5       nUc  [        R                  " S5      eX0l	        g )Nz#The configured credentials of type zJ are invalid and must be of type `google.auth.aio.credentials.Credentials`zv`auth_request` must either be configured or the external package `aiohttp` must be installed to use the default value.)

isinstancer	   r   InvalidTypetype_credentialsAIOHTTP_INSTALLEDAiohttpRequestTransportError_auth_request)selfr&   r'   r0   s       r   __init__AsyncAuthorizedSession.__init__t   s     +{33((5d;6G5H  IS  T  ($!2!2*,M ++ I  +r   methodurldataheadersmax_allowed_timer!   returnc                   #    [         R                  " [        R                  S9n[	        U5       ISh  vN n	U	" U R
                  R                  U R                  XU5      5      I Sh  vN   U  Sh  vN n
U	" U R                  " X!X4U40 UD65      I Sh  vN nUR                  [        R                  ;  d  ML    SSS5      ISh  vN   W$  N Ng N^ N=
 N N! , ISh  vN  (       d  f       W$ = f7f)a  
Args:
        method (str): The http method used to make the request.
        url (str): The URI to be requested.
        data (Optional[bytes]): The payload or body in HTTP request.
        headers (Optional[Mapping[str, str]]): Request headers.
        timeout (float):
        The amount of time in seconds to wait for the server response
        with each individual request.
        max_allowed_time (float):
        If the method runs longer than this, a ``Timeout`` exception is
        automatically raised. Unlike the ``timeout`` parameter, this
        value applies to the total method execution time, even if
        multiple requests are made under the hood.

        Mind that it is not guaranteed that the timeout error is raised
        at ``max_allowed_time``. It might take longer, for example, if
        an underlying request takes a lot of time, but the request
        itself does not timeout, e.g. if a large file is being
        transmitted. The timout error will be raised after such
        request completes.

Returns:
        google.auth.aio.transport.Response: The HTTP response.

Raises:
        google.auth.exceptions.TimeoutError: If the method does not complete within
        the configured `max_allowed_time` or the request exceeds the configured
        `timeout`.
)total_attemptsN)
r   AsyncExponentialBackoffr   DEFAULT_MAX_RETRY_ATTEMPTSr"   r,   before_requestr0   status_codeDEFAULT_RETRYABLE_STATUS_CODES)r1   r4   r5   r6   r7   r8   r!   kwargsretriesr   _r   s               r   requestAsyncAuthorizedSession.request   s     R '>>$??
 !!122l!!00&&W   # a!-&&sD7UfU"  ''y/W/WW 32  3 # 322 s   2C6CC61C)C*C0C4C5C8CC C<C=C6C	C6CCCCC6C3!C$"C3.C6c                 J   #    U R                   " SXX4U40 UD6I S h  vN $  N7f)NGETrD   r1   r5   r6   r7   r8   r!   rA   s          r   getAsyncAuthorizedSession.get   3      \\3g
DJ
 
 	
 
   #!#c                 J   #    U R                   " SXX4U40 UD6I S h  vN $  N7f)NPOSTrH   rI   s          r   postAsyncAuthorizedSession.post   s3      \\Cw'
EK
 
 	
 
rM   c                 J   #    U R                   " SXX4U40 UD6I S h  vN $  N7f)NPUTrH   rI   s          r   putAsyncAuthorizedSession.put   rL   rM   c                 J   #    U R                   " SXX4U40 UD6I S h  vN $  N7f)NPATCHrH   rI   s          r   patchAsyncAuthorizedSession.patch   s3      \\S7
FL
 
 	
 
rM   c                 J   #    U R                   " SXX4U40 UD6I S h  vN $  N7f)NDELETErH   rI   s          r   deleteAsyncAuthorizedSession.delete   s3      \\cG
GM
 
 	
 
rM   c                 T   #    U R                   R                  5       I Sh  vN   g N7f)z,
Close the underlying auth request session.
N)r0   close)r1   s    r   r_   AsyncAuthorizedSession.close  s        &&(((s   (&()r0   r,   )N)r9   N)__name__
__module____qualname____firstlineno____doc__r	   r   r   r   r2   _DEFAULT_TIMEOUT_SECONDSstrbytesr   floatResponserD   	functoolswrapsrJ   rP   rT   rX   r\   r_   __static_attributes__ r   r   r$   r$   N   s]   #L UY+&+6>y?P?P6Q+* !%/3"+"D"D";;;; ; uo	;
 '#s(+,;  ; ; 
		;z __W !%/3"+"D"D";;

 uo
 '#s(+,	

  
 
 
		
 
 __W !%/3"+"D"D";;

 uo
 '#s(+,	

  
 
 
		
 
 __W !%/3"+"D"D";;

 uo
 '#s(+,	

  
 
 
		
 
 __W !%/3"+"D"D";;

 uo
 '#s(+,	

  
 
 
		
 
 __W !%/3"+"D"D";;

 uo
 '#s(+,	

  
 
 
		
 
)r   r$   )r   
contextlibr   rk   r   typingr   r   google.authr   r   google.auth.aior   google.auth.aio.credentialsr	   google.auth.exceptionsr
   !google.auth.aio.transport.aiohttpr   r.   r-   ImportErrorr"   r$   rn   r   r   <module>rw      si     *   $ 8 % 3 /K
 ( (V~) ~)a  s   A AA