
    g		                    r    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e      Zy	)
    )annotations)ABCabstractmethod)DictOptionalUnion)	BasicAuthTimeout   )AsyncClient
SyncClientis_http_urlis_valid_jwtc                      e Zd ZdZddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZe	 	 d	 	 	 	 	 	 	 	 	 	 	 dd       Zddd	 	 	 	 	 dd	Zdd
Zy)BasePostgrestClientzBase PostgREST client.TN)verifyproxyc               v    t        |      st        d       i |||d}| j                  |||||      | _        y )Nz(base_url must be a valid HTTP URL stringzAccept-ProfilezContent-Profile)r   
ValueErrorcreate_sessionsession)selfbase_urlschemaheaderstimeoutr   r   s          J/var/www/openai/venv/lib/python3.12/site-packages/postgrest/base_client.py__init__zBasePostgrestClient.__init__   sK     8$AB

$%

 **8WgvuU    c                    t               )N)NotImplementedError)r   r   r   r   r   r   s         r   r   z"BasePostgrestClient.create_session!   s     "##r     )usernamepasswordc                   |r4t        |      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   tokenr$   r%   s       r   r(   zBasePostgrestClient.auth,   sk      &JK6=eW4EDLL  1   )(H =DLL
  Q r    c                V    | j                   j                  j                  ||d       | S )zSwitch to another schema.r   )r   r   update)r   r   s     r   r   zBasePostgrestClient.schemaH   s,    ##"(#)	
 r    )r   strr   r,   r   Dict[str, str]r   Union[int, float, Timeout]r   boolr   Optional[str]returnNone)TN)r   r,   r   r-   r   r.   r   r/   r   r0   r1   zUnion[SyncClient, AsyncClient])r)   r0   r$   zUnion[str, bytes, None]r%   zUnion[str, bytes])r   r,   )	__name__
__module____qualname____doc__r   r   r   r(   r    r    r   r   r      s      #VV 	V
  V ,V V V 
V&  #$$  $ ,	$
 $ $ 
($ $ -1&( *	
 $8r    r   N)
__future__r   abcr   r   typingr   r   r   httpxr	   r
   utilsr   r   r   r   r   r7   r    r   <module>r=      s(    " # ( ( $ E EE# Er    