o
    'h                     @  s,   d Z ddlmZ ddlmZ ddddZdS )zGCP helpers.    )annotations)Any   resourcestrtimeoutfloatreturndict[str, Any]c              
   C  s   ddl m}m} d}|d|  7 }ddi}|||d}z"|||d}|j}| d	}	W d    n1 s7w   Y  W n tyR }
 z	d
|
 }t|d d }
~
ww |dkr]d}t|t|	dS )Nr   )RequesturlopenzMhttp://metadata/computeMetadata/v1/instance/service-accounts/default/identityz
?audience=zMetadata-FlavorGoogle)headers)r   utf8z'Failed to acquire IMDS access token: %s   z$Failed to acquire IMDS access token.)access_token)	urllib.requestr   r   statusreaddecode	Exception
ValueErrordict)r   r   r   r   urlr   requestresponser   bodyemsg r   P/var/www/html/olx_land/venv/lib/python3.10/site-packages/pymongo/_gcp_helpers.py_get_gcp_response   s(   

r!   N)r   )r   r   r   r   r	   r
   )__doc__
__future__r   typingr   r!   r   r   r   r    <module>   s   