
    gj+                     P   d Z ddlZddlZddlmZmZmZmZmZ 	 ddl	Z	n# e
$ rZ e
d          edZ[ww xY wddlmZ ddlmZ ddlmZ ddlmZ erddl	mZ n	 ddl	mZ n# e
ef$ r dZY nw xY w ej        e          Z G d	 d
ej                  Z G d dej                  ZdS )zBTransport adapter for Asynchronous HTTP Requests based on aiohttp.    N)AsyncGeneratorMappingOptionalTYPE_CHECKINGUnionzjThe aiohttp library is not installed from please install the aiohttp package to use the aiohttp transport.)_helpers)
exceptions)	transport)ClientTimeoutc                      e Zd ZdZdej        fdZe ej	        e
j                  defd                        Ze ej	        e
j                  deeef         fd                        Z ej	        e
j                  ddedeed	f         fd
            Z ej	        e
j                  defd            Z ej	        e
j                  d             Zd	S )Responseaz  
    Represents an HTTP response and its data. It is returned by ``google.auth.aio.transport.sessions.AsyncAuthorizedSession``.

    Args:
        response (aiohttp.ClientResponse): An instance of aiohttp.ClientResponse.

    Attributes:
        status_code (int): The HTTP status code of the response.
        headers (Mapping[str, str]): The HTTP headers of the response.
    responsec                     || _         d S N)	_response)selfr   s     e/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/google/auth/aio/transport/aiohttp.py__init__zResponse.__init__9   s    !    returnc                     | j         j        S r   )r   statusr   s    r   status_codezResponse.status_code<   s     ~$$r   c                 R    d | j         j                                        D             S )Nc                     i | ]\  }}||	S  r   ).0keyvalues      r   
<dictcomp>z$Response.headers.<locals>.<dictcomp>D   s    LLLzsEULLLr   )r   headersitemsr   s    r   r"   zResponse.headersA   s*     MLT^-C-I-I-K-KLLLLr      
chunk_sizeNc                   K   	 | j         j                            |          2 3 d {V }|W V  6 d S # t          j        $ r}t          j        d          |d }~ww xY w)Nz'Failed to read from the payload stream.)r   contentiter_chunkedaiohttpClientPayloadErrorr	   ResponseError)r   r%   chunkexcs       r   r'   zResponse.contentF   s      	#~5BB          e       ) 	 	 	*9 	s   3 03 AAAc                    K   	 | j                                          d {V S # t          j        $ r}t	          j        d          |d }~ww xY w)Nz!Failed to read the response body.)r   readr)   ClientResponseErrorr	   r+   )r   r-   s     r   r/   zResponse.readR   sm      	Y,,.........* 	Y 	Y 	Y*+NOOUXX	Ys   # AAAc                 <   K   | j                                          d S r   )r   closer   s    r   r2   zResponse.closeY   s       r   )r$   )__name__
__module____qualname____doc__r)   ClientResponser   propertyr   copy_docstringr
   r   intr   r   strr"   r   bytesr'   r/   r2   r   r   r   r   r   -   s       	 	"!7 " " " " XY/00%S % % % 10 X% XY/00Mc* M M M 10 XM XY/00	 	 	~eTk7R 	 	 	 10	 XY/00YE Y Y Y 10Y XY/00  10  r   r   c                       e Zd ZdZddeej                 fdZdddej	        fde
de
dee         d	eee
e
f                  d
eeef         dej        fdZddZddZdS )Requesta  Asynchronous Requests request adapter.

    This class is used internally for making requests using aiohttp
    in a consistent way. If you use :class:`google.auth.aio.transport.sessions.AsyncAuthorizedSession`
    you do not need to construct or use this class directly.

    This class can be useful if you want to configure a Request callable
    with a custom ``aiohttp.ClientSession`` in :class:`AuthorizedSession` or if
    you want to manually refresh a :class:`~google.auth.aio.credentials.Credentials` instance::

        import aiohttp
        import google.auth.aio.transport.aiohttp

        # Default example:
        request = google.auth.aio.transport.aiohttp.Request()
        await credentials.refresh(request)

        # Custom aiohttp Session Example:
        session = session=aiohttp.ClientSession(auto_decompress=False)
        request = google.auth.aio.transport.aiohttp.Request(session=session)
        auth_session = google.auth.aio.transport.sessions.AsyncAuthorizedSession(auth_request=request)

    Args:
        session (aiohttp.ClientSession): An instance :class:`aiohttp.ClientSession` used
            to make HTTP requests. If not specified, a session will be created.

    .. automethod:: __call__
    Nsessionc                 "    || _         d| _        d S )NF)_session_closed)r   r?   s     r   r   zRequest.__init__|   s    r   GETurlmethodbodyr"   timeoutr   c                   K   	 | j         rt          j        d          | j        st	          j                    | _        t          |t          j                  r|}nt	          j        |          }t          j	        t          ||||            | j        j        ||f|||d| d{V }t          j        t          |           d{V  t          |          S # t          j        $ r }	t          j        d| d          }
|
|	d}	~	wt           j        $ rD}	t          |t          j                  r|j        }n|}t          j        d| d          }||	d}	~	ww xY w)	a  
        Make an HTTP request using aiohttp.

        Args:
            url (str): The URL to be requested.
            method (Optional[str]):
                The HTTP method to use for the request. Defaults to 'GET'.
            body (Optional[bytes]):
                The payload or body in HTTP request.
            headers (Optional[Mapping[str, str]]):
                Request headers.
            timeout (float): The number of seconds to wait for a
                response from the server. If not specified or if None, the
                requests default timeout will be used.
            kwargs: Additional arguments passed through to the underlying
                aiohttp :meth:`aiohttp.Session.request` method.

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

        Raises:
            - google.auth.exceptions.TransportError: If the request fails or if the session is closed.
            - google.auth.exceptions.TimeoutError: If the request times out.
        zsession is closed.)total)datar"   rG   NzFailed to send request to .zRequest timed out after z	 seconds.)rB   r	   TransportErrorrA   r)   ClientSession
isinstancer   r   request_log_LOGGERrequest_helpers_asyncresponse_log_asyncr   ClientErrorasyncioTimeoutErrorrI   )r   rD   rE   rF   r"   rG   kwargsclient_timeoutr   
caught_exc
client_exctimeout_secondstimeout_excs                r   __call__zRequest.__call__   s     D#	.| F /0DEEE= 8 ' 5 7 7'7#899 F!(!(!6W!E!E!E &#tWEEE2T]2 &         H !3GXFFFFFFFFFH%%%" 	- 	- 	-#23VPS3V3V3VWWJ*,# 	. 	. 	.'7#899 *")-")$1E?EEE K :-	.s$   CC E)DE?EEc                 r   K   | j         s&| j        r| j                                         d{V  d| _         dS )zY
        Close the underlying aiohttp session to release the acquired resources.
        NT)rB   rA   r2   r   s    r   r2   zRequest.close   sL       | 	( 	(-%%'''''''''r   c                 8   | j         rt          j        d          | j        s&t	          j        dd          }t          |          S dt          | j        dd          d}t          | j        dd          }|r3|j        s+t          |t          j
                  rht	          j
        t          |d	d          t          |d
d          t          |dd          t          |dd          t          |dd                    |d<   nt          t          dd          rot          |t          t          d                    rLt          |dd          }|r8t	          j        |t          |d
d          t          |dd                    |d<   n$t          j        dt          |                     t          | j        dd          }|rt          |          |d<   dD ]"\  }}t          | j        |d          }||||<   #t          t	          j        di |          S )a  Creates an independent copy of this request adapter.

        Clones the connection settings, trace configurations, and session defaults
        (headers, cookies, basic auth, and timeouts).

        Only standard `aiohttp.TCPConnector` and `aiohttp.UnixConnector` connectors
        are supported. The DNS resolver is not copied to avoid closing shared resolver
        resources.

        Returns:
            google.auth.aio.transport.aiohttp.Request: A new request adapter.

        Raises:
            google.auth.exceptions.TransportError: If the transport is closed, or if the
                session uses an unsupported connector.
        z Cannot clone a closed transport.FT)auto_decompress	trust_env)r?   
_trust_env
_connectorN_ssl_limitd   _limit_per_hostr   _force_close_local_addr)ssllimitlimit_per_hostforce_close
local_addr	connectorUnixConnector_path)pathrk   rm   z(Unsupported connector type for cloning: _trace_configstrace_configs))_default_headersr"   )_cookie_jar
cookie_jar)_default_authauth)_timeoutrG   )_json_serializejson_serializer   )rB   r	   rL   rA   r)   rM   r>   getattrclosedrN   TCPConnectorrp   typelist)	r   new_sessionsession_kwargsorig_connectorrr   rt   	attr_name
kwarg_namevals	            r   _clonezRequest._clone   sm   " < 	P+,NOOO} 	0!/ %  K ;////  % dCC 
  
 !dCC 	."7 	.'*>??  /6.B==!.(C@@#*>;La#P#P ' N N&~}dKK/ / /{++ /488 Z A A> >  ~w== 292G!%nhDD$+NNE$R$R3 3 3N;/ !/UtN?S?SUU  
  /?FF 	B.2=.A.AN?+&
 		1 		1!Iz $-D99C-0z*w4FF~FFGGGGr   r   )r   N)r   r>   )r3   r4   r5   r6   r   r)   rM   r   r
   _DEFAULT_TIMEOUT_SECONDSr;   r<   r   r   floatr   r   r]   r2   r   r   r   r   r>   r>   ^   s	        : )> ?      $/3/8/QE. E.E. E. uo	E.
 '#s(+,E. um+,E. 
	E. E. E. E.N   NH NH NH NH NH NHr   r>   )r6   rU   loggingtypingr   r   r   r   r   r)   ImportErrorrY   google.authr   r	   google.auth.aiorR   r
   r   AttributeError	getLoggerr3   rP   r   r>   r   r   r   <module>r      s   I H   J J J J J J J J J J J J J JNNNN   
+t 
 !           " " " " " " 6 6 6 6 6 6 % % % % % % %%%%%%%)))))))(    '
H
%
%. . . . .y! . . .bH H H H Hi H H H H Hs"    505A! !	A-,A-