
    (ph<2                     b   S r SSKrSSKJr  SSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SS	KJr  \R$                  " \5      r\R*                  " \R,                  S5      r\(       d  \R*                  " \R0                  S
5      rSR3                  \5      rSR3                  \R*                  " \R6                  S5      5      rSrSr\\0r \ " \R*                  " SS5      5      r!Sr#Sr$S r%S r&\!S4S jr'\SSSSS\!4S jr(S r)S r*SS jr+SS jr,g! \" a    Sr! N8f = f)zProvides helper methods for talking to the Compute Engine metadata server.

See https://cloud.google.com/compute/docs/metadata for more details.
    N)urljoin)_helpers)environment_vars)
exceptions)metrics)	transport)ExponentialBackoffzmetadata.google.internalzhttp://{}/computeMetadata/v1/z	http://{}z169.254.169.254zmetadata-flavorGoogleGCE_METADATA_TIMEOUT   z/sys/class/dmi/id/product_namec                 b    [        U 5      (       a  g[        R                  S:X  a  g[        5       $ )zChecks to see if the code runs on Google Compute Engine

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.

Returns:
    bool: True if the code runs on Google Compute Engine, False otherwise.
TntF)pingosnamedetect_gce_residency_linuxrequests    W/var/www/html/venv/lib/python3.13/site-packages/google/auth/compute_engine/_metadata.py	is_on_gcer   D   s)     G}}	ww$ &''    c                       [        [        S5       n U R                  5       R                  5       nSSS5        WR                  [        5      $ ! , (       d  f       N#= f! [         a     gf = f)zDetect Google Compute Engine residency by smbios check on Linux

Returns:
    bool: True if the GCE product name file is detected, False otherwise.
rNF)open_GCE_PRODUCT_NAME_FILEreadstrip	Exception
startswith_GOOGLE)file_objcontents     r   r   r   Y   s\    (#.(mmo++-G / g&& /.  s-   A AA 
AA A 
A,+A,c                    [         R                  5       n[        R                  " 5       U[        R                  '   [        US9nU H\  n U " [        SX1S9nUR                  R                  [        5      nUR                  [        R                  :H  =(       a	    U[        :H  s  $    g! [        R                   a#  n[         R#                  SUUU5         SnAM  SnAff = f)a  Checks to see if the metadata server is available.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.
    timeout (int): How long to wait for the metadata server to respond.
    retry_count (int): How many times to attempt connecting to metadata
        server using above timeout.

Returns:
    bool: True if the metadata server is reachable, False otherwise.
total_attemptsGETurlmethodheaderstimeoutJCompute Engine Metadata server unavailable on attempt %s of %s. Reason: %sNF)_METADATA_HEADERScopyr   mds_pingAPI_CLIENT_HEADERr	   _METADATA_IP_ROOTr*   get_METADATA_FLAVOR_HEADERstatushttp_clientOK_METADATA_FLAVOR_VALUEr   TransportError_LOGGERwarning)	r   r+   retry_countr*   backoffattemptresponsemetadata_flavores	            r   r   r   i   s    &  $$&G)0)9)9);GG%%& <G	%eWH '..223JKO;>>1 >#'== *  (( 	OO/ 	s   
AB''C;CCF   c	                    [        X!5      n	Uc  0 OUn
[        R                  5       nU(       a  UR                  U5        U(       a  SU
S'   [        R
                  " X5      n[        US9nSnU H  n U " USXS9nUR                  [        R                  ;   af  [        R                  SUUUR                  5        [        UR                  S5      (       a  UR                  R                  S	5      OUR                  nM    O'   [        R                   " SR#                  X5      5      e[        R$                  " UR                  5      nUR                  [&        R(                  :X  a  U(       a  gUR                  [&        R*                  :X  a@  [        R,                  " UR.                  S   5      S:X  a   [0        R2                  " U5      $ U$ [        R                   " SR#                  UUR                  UR                  5      U5      e! [        R                    a&  n[        R                  S
UUU5        Un SnAGM  SnAff = f! [4         a-  n[        R                   " SR#                  U5      5      nUUeSnAff = f)a  Fetch a resource from the metadata server.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.
    path (str): The resource to retrieve. For example,
        ``'instance/service-accounts/default'``.
    root (str): The full path to the metadata server root.
    params (Optional[Mapping[str, str]]): A mapping of query parameter
        keys to values.
    recursive (bool): Whether to do a recursive query of metadata. See
        https://cloud.google.com/compute/docs/metadata#aggcontents for more
        details.
    retry_count (int): How many times to attempt connecting to metadata
        server using above timeout.
    headers (Optional[Mapping[str, str]]): Headers for the request.
    return_none_for_not_found_error (Optional[bool]): If True, returns None
        for 404 error instead of throwing an exception.
    timeout (int): How long to wait, in seconds for the metadata server to respond.

Returns:
    Union[Mapping, str]: If the metadata server returns JSON, a mapping of
        the decoded JSON is returned. Otherwise, the response content is
        returned as a string.

Raises:
    google.auth.exceptions.TransportError: if an error occurred while
        retrieving metadata.
Ntrue	recursiver$   r&   r'   zSCompute Engine Metadata server unavailable on attempt %s of %s. Response status: %sdecodezutf-8r,   z{Failed to retrieve {} from the Google Compute Engine metadata service. Compute Engine Metadata server unavailable due to {}zcontent-typezapplication/jsonzMReceived invalid JSON from the Google Compute Engine metadata service: {:.20}z^Failed to retrieve {} from the Google Compute Engine metadata service. Status: {} Response:
{})r   r-   r.   updater   update_queryr	   r4   r   DEFAULT_RETRYABLE_STATUS_CODESr9   r:   hasattrdatarE   r   r8   format
from_bytesr5   	NOT_FOUNDr6   parse_content_typer*   jsonloads
ValueError)r   pathrootparamsrD   r;   r*   return_none_for_not_found_errorr+   base_urlquery_paramsheaders_to_user(   r<   failure_reasonr=   r>   r@   r"   
caught_excnew_excs                        r   r2   r2      s@   P t"H2VL&++-Ng&$*[!



7C <GN	~H )"J"JJ<OO x}}h77 MM((1! 
 ) @ ''UU[U[V
 	
 !!(--0G+///4S+..(''(8(8(HI!".zz'** N

#
#	55;V(--6
 	 M (( 	OO/ N	:  .$33//5vg :-.s1   2B
H3I IH<<I
I;(I66I;c                     [        U S5      $ )a+  Get the Google Cloud Project ID from the metadata server.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.

Returns:
    str: The project ID

Raises:
    google.auth.exceptions.TransportError: if an error occurred while
        retrieving metadata.
zproject/project-idr2   r   s    r   get_project_idr^     s     w,--r   c                 ,    [        U SSS9nU(       d  gU$ )a  Get the universe domain value from the metadata server.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.

Returns:
    str: The universe domain value. If the universe domain endpoint is not
    not found, return the default value, which is googleapis.com

Raises:
    google.auth.exceptions.TransportError: if an error other than
        404 occurs while retrieving metadata.
zuniverse/universe-domainT)rU   zgoogleapis.comr]   )r   universe_domains     r   get_universe_domainra   %  s$     +TO r   c                 <    SR                  U5      n[        XSS0S9$ )a  Get information about a service account from the metadata server.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.
    service_account (str): The string 'default' or a service account email
        address. The determines which service account for which to acquire
        information.

Returns:
    Mapping: The service account's information, for example::

        {
            'email': '...',
            'scopes': ['scope', ...],
            'aliases': ['default', '...']
        }

Raises:
    google.auth.exceptions.TransportError: if an error occurred while
        retrieving metadata.
zinstance/service-accounts/{0}/rD   rC   )rT   )rK   r2   )r   service_accountrR   s      r   get_service_account_inford   <  s(    . ,22?CD wk6%:;;r   c                 R   U(       a+  [        U[        5      (       d  SR                  U5      nSU0nOSn[        R                  [        R
                  " 5       0nSR                  U5      n[        XX4S9n[        R                  " 5       [        R                  " US   S9-   nUS   U4$ )	ag  Get the OAuth 2.0 access token for a service account.

Args:
    request (google.auth.transport.Request): A callable used to make
        HTTP requests.
    service_account (str): The string 'default' or a service account email
        address. The determines which service account for which to acquire
        an access token.
    scopes (Optional[Union[str, List[str]]]): Optional string or list of
        strings with auth scopes.
Returns:
    Tuple[str, datetime]: The access token and its expiration.

Raises:
    google.auth.exceptions.TransportError: if an error occurred while
        retrieving metadata.
,scopesNz#instance/service-accounts/{0}/token)rT   r*   
expires_in)secondsaccess_token)
isinstancestrjoinr   r0   token_request_access_token_mdsrK   r2   r   utcnowdatetime	timedelta)r   rc   rg   rT   metrics_headerrR   
token_jsontoken_expirys           r   get_service_account_tokenru   Y  s    $ &#&&XXf%FF# 	!!7#I#I#KN 177HDW6JJ??$x'9'9<(( L n%|33r   )default)rv   N)-__doc__rp   http.clientclientr5   rO   loggingr   urllib.parser   google.authr   r   r   r   r    google.auth._exponential_backoffr	   	getLogger__name__r9   getenvGCE_METADATA_HOST_GCE_METADATA_HOSTGCE_METADATA_ROOTrK   _METADATA_ROOTGCE_METADATA_IPr1   r3   r7   r-   int_METADATA_DEFAULT_TIMEOUTrQ   r    r   r   r   r   r2   r^   ra   rd   ru    r   r   <module>r      sX  
  !   	     ( "  ! ?


H
% YY/AA4H **,F 1778JK  &&II..0AB  , ! ,.DE " #BII.Da$H I
 9 (*'  4 -f 
$)%xv.".<:"4{  " !"s   D# #D.-D.