
    df                    :    d Z ddlmZ ddlmZ ddlmZmZ dddZy)	zGCP helpers.    )annotations)Any)Requesturlopenc                T   d}|d|  z  }ddi}t        ||      }	 t        ||      5 }|j                  }|j                         j	                  d      }d d d        d	k7  rd
}	t        |	      t              S # 1 sw Y   'xY w# t
        $ r}d|z  }	t        |	      d d }~ww xY w)NzMhttp://metadata/computeMetadata/v1/instance/service-accounts/default/identityz
?audience=zMetadata-FlavorGoogle)headers)timeoututf8z'Failed to acquire IMDS access token: %s   z$Failed to acquire IMDS access token.)access_token)r   r   statusreaddecode	Exception
ValueErrordict)
resourcer
   urlr	   requestresponser   bodyemsgs
             M/home/api-vastappli/venv/lib/python3.12/site-packages/pymongo/_gcp_helpers.py_get_gcp_responser      s    
YCZz""C (+Gc7+G(Wg. 	2(__F==?))&1D	2 }4oT""	2 	2  (7!;o4'(s.   B ,A<B <BB 	B'B""B'N)   )r   strr
   floatreturnzdict[str, Any])	__doc__
__future__r   typingr   urllib.requestr   r   r        r   <module>r'      s     "  +#r&   