
    _i                    ,    d Z ddlmZ ddlmZ dddZdS )zGCP helpers.    )annotations)Any   resourcestrtimeoutfloatreturndict[str, Any]c                   ddl m}m} d}|d|  z  }ddi} |||          }	  |||          5 }|j        }|                                                    d	          }	d d d            n# 1 swxY w Y   n'# t          $ r}
d
|
z  }t          |          d d }
~
ww xY w|dk    rd}t          |          t          |	          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msgs               7D:\Nbitz\venv\Lib\site-packages\pymongo/_gcp_helpers.py_get_gcp_responser"      sE   ////////
YC""""C (+Ggc7+++G(WWg... 	2(_F==??))&11D	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2  ( ( (7!;oo4'( }}4ooT""""s:   A9 /A-!A9 -A11A9 4A15A9 9
BBBN)r   )r   r   r   r	   r
   r   )__doc__
__future__r   typingr   r"        r!   <module>r(      sT      " " " " " "      # # # # # # #r'   