U
    ¯ªh$  ã                   @   sr   d dl Z d dlmZmZ d dlmZmZmZmZm	Z	 e  
e¡ZG dd„ dƒZG dd„ deeƒZG dd	„ d	eƒZdS )
é    N)ÚABCÚabstractmethod)ÚAnyÚCallableÚOptionalÚTupleÚUnionc                   @   sT   e Zd ZdZeee eeef f dœdd„Zeee eeef f dœdd„ZdS )ÚCredentialProviderz
    Credentials Provider.
    ©Úreturnc                 C   s   t dƒ‚d S )Nz#get_credentials must be implemented)ÚNotImplementedError©Úself© r   ú5/tmp/pip-unpacked-wheel-4avdqdik/redis/credentials.pyÚget_credentials   s    z"CredentialProvider.get_credentialsc                 Ã   s   t  d¡ |  ¡ S )Nz[This method is added for backward compatability. Please override it in your implementation.)ÚloggerÚwarningr   r   r   r   r   Úget_credentials_async   s    ÿz(CredentialProvider.get_credentials_asyncN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   r   r   r   r   r   r	      s   "r	   c                   @   sZ   e Zd ZdZeeegdf dœdd„ƒZeeegdf dœdd„ƒZ	ee
dœd	d
„ƒZdS )ÚStreamingCredentialProviderzI
    Credential provider that streams credentials in the background.
    N)Úcallbackc                 C   s   dS )z­
        Specifies the callback that should be invoked
        when the next credentials will be retrieved.

        :param callback: Callback with
        :return:
        Nr   ©r   r   r   r   r   Úon_next   s    	z#StreamingCredentialProvider.on_nextc                 C   s   d S ©Nr   r   r   r   r   Úon_error(   s    z$StreamingCredentialProvider.on_errorr
   c                 C   s   d S r   r   r   r   r   r   Úis_streaming,   s    z(StreamingCredentialProvider.is_streaming)r   r   r   r   r   r   r   r   Ú	Exceptionr   Úboolr    r   r   r   r   r      s   
r   c                   @   sT   e Zd ZdZdee ee dœdd„Zdd„ Zee	e e	eef f dœd	d
„Z
dS )Ú"UsernamePasswordCredentialProviderzg
    Simple implementation of CredentialProvider that just wraps static
    username and password.
    N©ÚusernameÚpasswordc                 C   s   |pd| _ |pd| _d S )NÚ r$   )r   r%   r&   r   r   r   Ú__init__7   s    
z+UsernamePasswordCredentialProvider.__init__c                 C   s   | j r| j | jfS | jfS r   r$   r   r   r   r   r   ;   s    z2UsernamePasswordCredentialProvider.get_credentialsr
   c                 Ã   s   |   ¡ S r   )r   r   r   r   r   r   @   s    z8UsernamePasswordCredentialProvider.get_credentials_async)NN)r   r   r   r   r   r   r(   r   r   r   r   r   r   r   r   r#   1   s   r#   )ÚloggingÚabcr   r   Útypingr   r   r   r   r   Ú	getLoggerr   r   r	   r   r#   r   r   r   r   Ú<module>   s   
