U
    Wi                     @  sd   d dl mZ d dlmZmZ d dlmZmZmZ d dl	m
Z
mZ ddlmZmZ G dd deZd	S )
    )annotations)ABCabstractmethod)DictOptionalUnion)	BasicAuthTimeout   )AsyncClient
SyncClientc                   @  sr   e Zd ZdZddddddddd	d
dZedddddddddZdddddddddZddddZdS )BasePostgrestClientzBase PostgREST client.T)verifystrzDict[str, str]zUnion[int, float, Timeout]boolNone)base_urlschemaheaderstimeoutr   returnc                C  s$   |||d}|  ||||| _d S )NzAccept-ProfilezContent-Profile)create_sessionsession)selfr   r   r   r   r    r   [/home/afrizal/public_html/fastapi/venv/lib/python3.8/site-packages/postgrest/base_client.py__init__   s
    
zBasePostgrestClient.__init__zUnion[SyncClient, AsyncClient])r   r   r   r   r   c                 C  s
   t  d S )N)NotImplementedError)r   r   r   r   r   r   r   r   r      s    z"BasePostgrestClient.create_sessionN )usernamepasswordzOptional[str]zUnion[str, bytes, None]zUnion[str, bytes])tokenr    r!   c                C  s8   |rd| | j jd< n|r,t||| j _ntd| S )a  
        Authenticate the client with either bearer token or basic authentication.

        Raises:
            `ValueError`: If neither authentication scheme is provided.

        .. note::
            Bearer token is preferred if both ones are provided.
        zBearer Authorizationz?Neither bearer token or basic authentication scheme is provided)r   r   r   auth
ValueError)r   r"   r    r!   r   r   r   r$   (   s    zBasePostgrestClient.auth)r   c                 C  s   | j j||d | S )zSwitch to another schema.r   )r   r   update)r   r   r   r   r   r   B   s    zBasePostgrestClient.schema)T)	__name__
__module____qualname____doc__r   r   r   r$   r   r   r   r   r   r      s   	 r   N)
__future__r   abcr   r   typingr   r   r   Zhttpxr   r	   utilsr   r   r   r   r   r   r   <module>   s
   