o
    i#                     @   s   d dl mZmZmZmZmZmZ d dlmZm	Z	 G dd deZ
G dd dZG dd ded	d
Ze	G dd deZe	G dd deed Zeeef ZG dd deZg dZG dd dZG dd dZG dd dZdS )    )Any
NamedTupleOptional	TypedDictUnionContextManager)Protocolruntime_checkablec                   @   s$   e Zd ZU dZeed< 	 eed< dS )AccessTokenz!Represents an OAuth access token.token
expires_onN)__name__
__module____qualname____doc__str__annotations__int r   r   M/home/app/Keep/.python/lib/python3.10/site-packages/azure/core/credentials.pyr
   
   s   
 r
   c                   @   sv   e Zd ZU dZeed< 	 eed< 	 eed< 	 ee ed< 	 ddddedededee d	df
d
dZd	efddZ	dS )AccessTokenInfoa  Information about an OAuth access token.

    This class is an alternative to `AccessToken` which provides additional information about the token.

    :param str token: The token string.
    :param int expires_on: The token's expiration time in Unix time.
    :keyword str token_type: The type of access token. Defaults to 'Bearer'.
    :keyword int refresh_on: Specifies the time, in Unix time, when the cached token should be proactively
        refreshed. Optional.
    r   r   
token_type
refresh_onZBearerN)r   r   returnc                C   s   || _ || _|| _|| _d S )N)r   r   r   r   )selfr   r   r   r   r   r   r   __init__(   s   
zAccessTokenInfo.__init__c                 C   s   d | j| j| j| jS )NzJAccessTokenInfo(token='{}', expires_on={}, token_type='{}', refresh_on={}))formatr   r   r   r   r   r   r   r   __repr__5   s   zAccessTokenInfo.__repr__)
r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s0   
 
r   c                   @   s.   e Zd ZU dZeed< 	 eed< 	 eed< dS )TokenRequestOptionszFOptions to use for access token requests. All parameters are optional.claims	tenant_id
enable_caeN)r   r   r   r   r   r   boolr   r   r   r   r   ;   s   
 r   F)totalc                   @   sD   e Zd ZdZdddddedee dee ded	ed
efddZ	dS )TokenCredentialz2Protocol for classes able to provide OAuth tokens.NF)r    r!   r"   scopesr    r!   r"   kwargsr   c                O      dS )a  Request an access token for `scopes`.

        :param str scopes: The type of access needed.

        :keyword str claims: Additional claims required in the token, such as those returned in a resource
            provider's claims challenge following an authorization failure.
        :keyword str tenant_id: Optional tenant to include in the token request.
        :keyword bool enable_cae: Indicates whether to enable Continuous Access Evaluation (CAE) for the requested
            token. Defaults to False.

        :rtype: AccessToken
        :return: An AccessToken instance containing the token string and its expiration time in Unix time.
        Nr   )r   r    r!   r"   r&   r'   r   r   r   	get_tokenK   s   zTokenCredential.get_token)
r   r   r   r   r   r   r#   r   r
   r)   r   r   r   r   r%   G   s$    r%   c                   @   s:   e Zd ZdZdddedee defddZdd	d
Z	dS )SupportsTokenInfozTProtocol for classes able to provide OAuth access tokens with additional properties.N)optionsr&   r+   r   c                G   r(   )a  Request an access token for `scopes`.

        This is an alternative to `get_token` to enable certain scenarios that require additional properties
        on the token.

        :param str scopes: The type of access needed.
        :keyword options: A dictionary of options for the token request. Unknown options will be ignored. Optional.
        :paramtype options: TokenRequestOptions

        :rtype: AccessTokenInfo
        :return: An AccessTokenInfo instance containing information about the token.
        Nr   )r   r+   r&   r   r   r   get_token_infog   s   z SupportsTokenInfo.get_token_infoc                 C   r(   )zlClose the credential, releasing any resources it holds.

        :return: None
        :rtype: None
        Nr   r   r   r   r   closev   s    zSupportsTokenInfo.close)r   N)
r   r   r   r   r   r   r   r   r,   r-   r   r   r   r   r*   c   s     r*   c                   @   s"   e Zd ZU dZeed< eed< dS )AzureNamedKeyzRepresents a name and key pair.namekeyN)r   r   r   r   r   r   r   r   r   r   r.      s   
 r.   )	AzureKeyCredentialAzureSasCredentialr
   r   r*   AzureNamedKeyCredentialr%   r   TokenProviderc                   @   F   e Zd ZdZdeddfddZedefddZdeddfd	d
ZdS )r1   a  Credential type used for authenticating to an Azure service.
    It provides the ability to update the key without creating a new client.

    :param str key: The key used to authenticate to an Azure service
    :raises TypeError: If the key is not a string.
    r0   r   Nc                 C      t |ts	td|| _d S )Nzkey must be a string.)
isinstancer   	TypeError_keyr   r0   r   r   r   r         

zAzureKeyCredential.__init__c                 C      | j S )zpThe value of the configured key.

        :rtype: str
        :return: The value of the configured key.
        )r9   r   r   r   r   r0         zAzureKeyCredential.keyc                 C   (   |st dt|tstd|| _dS )a)  Update the key.

        This can be used when you've regenerated your service key and want
        to update long-lived clients.

        :param str key: The key used to authenticate to an Azure service
        :raises ValueError or TypeError: If the key is None, empty, or not a string.
        z2The key used for updating can not be None or emptyz+The key used for updating must be a string.N)
ValueErrorr7   r   r8   r9   r:   r   r   r   update   s
   	

zAzureKeyCredential.update)	r   r   r   r   r   r   propertyr0   r@   r   r   r   r   r1          r1   c                   @   r5   )r2   a;  Credential type used for authenticating to an Azure service.
    It provides the ability to update the shared access signature without creating a new client.

    :param str signature: The shared access signature used to authenticate to an Azure service
    :raises TypeError: If the signature is not a string.
    	signaturer   Nc                 C   r6   )Nzsignature must be a string.)r7   r   r8   
_signaturer   rC   r   r   r   r      r;   zAzureSasCredential.__init__c                 C   r<   )zThe value of the configured shared access signature.

        :rtype: str
        :return: The value of the configured shared access signature.
        )rD   r   r   r   r   rC      r=   zAzureSasCredential.signaturec                 C   r>   )a  Update the shared access signature.

        This can be used when you've regenerated your shared access signature and want
        to update long-lived clients.

        :param str signature: The shared access signature used to authenticate to an Azure service
        :raises ValueError: If the signature is None or empty.
        :raises TypeError: If the signature is not a string.
        z8The signature used for updating can not be None or emptyz1The signature used for updating must be a string.N)r?   r7   r   r8   rD   rE   r   r   r   r@      s
   


zAzureSasCredential.update)	r   r   r   r   r   r   rA   rC   r@   r   r   r   r   r2      rB   r2   c                   @   sN   e Zd ZdZdededdfddZedefdd	Zdededdfd
dZ	dS )r3   ak  Credential type used for working with any service needing a named key that follows patterns
    established by the other credential types.

    :param str name: The name of the credential used to authenticate to an Azure service.
    :param str key: The key used to authenticate to an Azure service.
    :raises TypeError: If the name or key is not a string.
    r/   r0   r   Nc                 C   s,   t |tr
t |tstdt||| _d S )N"Both name and key must be strings.r7   r   r8   r.   _credentialr   r/   r0   r   r   r   r      s   z AzureNamedKeyCredential.__init__c                 C   r<   )z|The value of the configured name.

        :rtype: AzureNamedKey
        :return: The value of the configured name.
        )rH   r   r   r   r   	named_key   r=   z!AzureNamedKeyCredential.named_keyc                 C   s,   t |tr
t |tstdt||| _dS )a\  Update the named key credential.

        Both name and key must be provided in order to update the named key credential.
        Individual attributes cannot be updated.

        :param str name: The name of the credential used to authenticate to an Azure service.
        :param str key: The key used to authenticate to an Azure service.
        rF   NrG   rI   r   r   r   r@      s   	zAzureNamedKeyCredential.update)
r   r   r   r   r   r   rA   r.   rJ   r@   r   r   r   r   r3      s    r3   N)typingr   r   r   r   r   r   Ztyping_extensionsr   r	   r
   r   r   r%   r*   r4   r.   __all__r1   r2   r3   r   r   r   r   <module>   s    	(&'