
    &g                    J    S r SSKJr  SSKrSSKJrJr   S       SS jjrg)zAzure helpers.    )annotationsN)AnyOptionalc                2   SSK JnJn  SnUS-  nUSU  3-  nU(       a  USU 3-  nSSS	.nU" XVS
9n U" XrS9 nUR                  n	UR	                  5       R                  S5      n
S S S 5        W	S:w  a  Sn[        U5      e [        R                  " W
5      nS H,  nUR                  U5      (       a  M  SnXU
4-  n[        U5      e   U$ ! , (       d  f       Nl= f! [         a  nSU-  n[        U5      S eS nAff = f! [         a    [        S5      S ef = f)Nr   )Requesturlopenz5http://169.254.169.254/metadata/identity/oauth2/tokenz?api-version=2018-02-01z
&resource=z&client_id=truezapplication/json)MetadataAccept)headers)timeoututf8z'Failed to acquire IMDS access token: %s   z$Failed to acquire IMDS access token.z*Azure IMDS response must be in JSON format)access_token
expires_inz0Azure IMDS response must contain %s, but was %s.)urllib.requestr   r   statusreaddecode	Exception
ValueErrorjsonloadsget)resource	client_idr   r   r   urlr   requestresponser   bodyemsgdatakeys                  [C:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/_azure_helpers.py_get_azure_responser&      s;    0
AC$$CZz""CYK((!-?@Gc+G(W.(__F==?))&1D / }4oQzz$ .xx}}DCd#CS/!	 . K+ /.  (7!;o4'(  QEFDPQs@   C ,C%C C? 
CC C 
C<&C77C<?D)N   )r   strr   zOptional[str]r   floatreturnzdict[str, Any])__doc__
__future__r   r   typingr   r   r&        r%   <module>r0      s?     "    FG##+#=B##r/   