
    j}                         d dl Z d dlZd dlmZmZ d dlmZ ddlmZ ddl	m
Z
  G d de
      Zd	ee   fd
Zdededed	efdZded	dfdZy)    N)OptionalDict)HttpRequest   )EnvironmentVariables)MsalManagedIdentityClientc                       e Zd ZddedefdZy)AzureMLCredentialdescreturnc                     d| S )NzBAzure ML managed identity configuration not found in environment.  )selfr   s     e/root/aria/tools/markitdown-venv/lib/python3.12/site-packages/azure/identity/_credentials/azure_ml.pyget_unavailable_messagez)AzureMLCredential.get_unavailable_message   s    STXSYZZ    N) )__name__
__module____qualname__strr   r   r   r   r
   r
      s    [C [ [r   r
   r   c            
         | j                  dd       xs i }t        j                  j                  t        j
                        }t        j                  j                  t        j                        }|r|sy | j                  d      r| j                  d      |d<   t        | t        |d|it        j                  t        |            S )Nidentity_config	client_idclientidsecret)_content_callbackr   base_headersrequest_factory)poposenvirongetr   MSI_ENDPOINT
MSI_SECRETdict_parse_expires_on	functoolspartial_get_request)kwargsr   urlr   s       r   _get_client_argsr-      s    jj!2D9?RO
**..-::
;CZZ^^0;;<FFzz+&,jj&=
#+''!)),< r   r,   scoper   c           	      8    t        d| t        d|dfi |      S )NGETz
2017-09-01)zapi-versionresource)params)r   r&   )r,   r.   r   s      r   r*   r*   )   s"    uc$|Y^/_*scr*sttr   contentc                 P   	 t        | d         | d<   y# t        $ r Y nw xY wddl}ddl}| d   }|j	                  d      rM|dt        d        }dD ]9  }	 |j                  ||      }|j                  |      | d<    y# t        $ r Y 7w xY w t        dj                  |            )a  Parse an App Service MSI version 2017-09-01 expires_on value to epoch seconds.

    This version of the API returns expires_on as a UTC datetime string rather than epoch seconds. The string's
    format depends on the OS. Responses on Windows include AM/PM, for example "1/16/2020 5:24:12 AM +00:00".
    Responses on Linux do not, for example "06/20/2019 02:57:58 +00:00".

    :param dict content: a deserialized response from an App Service MSI.
    :raises ValueError: ``expires_on`` didn't match an expected format
    
expires_onNr   z +00:00)z%m/%d/%Y %H:%M:%Sz%m/%d/%Y %I:%M:%S %pz&'{}' doesn't match the expected format)	int
ValueErrorcalendartimeendswithlenstrptimetimegmformat)r3   r8   r9   r5   date_stringformat_stringts          r   r'   r'   -   s     #GL$9 :  &J9% !2C	N?3J 	MMM+}=(0(:% 	 =DDZP
QQs    	  &A>>	B
	B
)r(   r!   typingr   r   azure.core.restr   
_constantsr   &_internal.msal_managed_identity_clientr   r
   r-   r   r*   r'   r   r   r   <module>rF      st   
  	 ! ' - N[1 [
(4. *uc u# u u u!Rt !R !Rr   