o
    zsg		                     @  sl   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mZmZ G dd deZd	S )
    )annotations)ABCabstractmethod)DictOptionalUnion)	BasicAuthTimeout   )AsyncClient
SyncClientis_http_urlis_valid_jwtc                   @  sR   e Zd ZdZdddd"ddZe		d#d$ddZdddd%ddZd&d d!ZdS )'BasePostgrestClientzBase PostgREST client.TN)verifyproxybase_urlstrschemaheadersDict[str, str]timeoutUnion[int, float, Timeout]r   boolr   Optional[str]returnNonec                C  s:   t |std i |||d}| |||||| _d S )Nz(base_url must be a valid HTTP URL stringzAccept-ProfilezContent-Profile)r   
ValueErrorcreate_sessionsession)selfr   r   r   r   r   r    r"   Q/var/www/html/minecraft/env/lib/python3.10/site-packages/postgrest/base_client.py__init__   s   
zBasePostgrestClient.__init__Union[SyncClient, AsyncClient]c                 C  s   t  )N)NotImplementedError)r!   r   r   r   r   r   r"   r"   r#   r   !   s   	z"BasePostgrestClient.create_session )usernamepasswordtokenr(   Union[str, bytes, None]r)   Union[str, bytes]c                C  sH   |rt |s
td d| | jjd< | S |r t||| j_| S td)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-token must be a valid JWT authorization tokenzBearer Authorizationz?Neither bearer token or basic authentication scheme is provided)r   r   r    r   r   auth)r!   r*   r(   r)   r"   r"   r#   r.   ,   s   zBasePostgrestClient.authc                 C  s   | j j||d | S )zSwitch to another schema.r   )r    r   update)r!   r   r"   r"   r#   r   H   s   zBasePostgrestClient.schema)r   r   r   r   r   r   r   r   r   r   r   r   r   r   )TN)r   r   r   r   r   r   r   r   r   r   r   r%   )r*   r   r(   r+   r)   r,   )r   r   )	__name__
__module____qualname____doc__r$   r   r   r.   r   r"   r"   r"   r#   r      s    	r   N)
__future__r   abcr   r   typingr   r   r   httpxr   r	   utilsr   r   r   r   r   r"   r"   r"   r#   <module>   s    