o
    i.                     @  s   d dl mZ d dlZd dlZd dlmZmZmZmZm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZ d dlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZm Z m!Z! G dd deZ"dS )    )annotationsN)AnyDictOptionalUnioncast)warn)
deprecated)AsyncClientHeadersQueryParamsTimeout)URL   )BasePostgrestClient) DEFAULT_POSTGREST_CLIENT_HEADERS DEFAULT_POSTGREST_CLIENT_TIMEOUT)CountMethod)__version__   )AsyncRequestBuilderAsyncRPCFilterRequestBuilderRequestConfigc                   @  s   e Zd ZdZdedddddd5ddZd6ddZd7ddZd8ddZd8ddZ	d9d d!Z
d9d"d#Zed$d%ed&d9d'd(Z		)	)d:d;d3d4ZdS )<AsyncPostgrestClientzPostgREST client.publicN)schemaheaderstimeoutverifyproxyhttp_clientbase_urlstrr   r   Dict[str, str]r    Union[int, float, Timeout, None]r   Optional[bool]r   Optional[str]r    Optional[AsyncClient]returnNonec             	   C  s  dt  t t dt d|}tjdk rtdtdd |d ur*tdtdd |d ur5td	tdd |d ur@td
tdd |d urHt	|nd| _
t|trR|n|d ur\tt|nt| _tj| t|||| j| j
|d |p}t|| j|| j
|ddd| _d S )Nzsupabase-py/postgrest-py vpython)zX-Client-InfozX-Supabase-Client-Platformz"X-Supabase-Client-Platform-VersionzX-Supabase-Client-Runtimez!X-Supabase-Client-Runtime-Version)   
   zPython versions below 3.10 are deprecated and will not be supported in future versions. Please upgrade to Python 3.10 or newer.r   )
stacklevelzVThe 'timeout' parameter is deprecated. Please configure it in the http client instead.zUThe 'verify' parameter is deprecated. Please configure it in the http client instead.zTThe 'proxy' parameter is deprecated. Please configure it in the http client instead.T)r   r   r   r   r   )r!   r   r   r   r   follow_redirectshttp2)r   platformsystemreleasepython_versionsysversion_infor   DeprecationWarningboolr   
isinstancer   intabsr   r   r   __init__r   r
   r   session)selfr!   r   r   r   r   r   r     r>   U/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/postgrest/_async/client.pyr;      sr   
		
zAsyncPostgrestClient.__init__c                 C  s&   t t| j|t| j| j| j| jdS )zSwitch to another schema.)r!   r   r   r   r   r   )r   r"   r!   dictr   r   r   r   )r=   r   r>   r>   r?   r   i   s   zAsyncPostgrestClient.schemac                   s   | S Nr>   r=   r>   r>   r?   
__aenter__t   s   zAsyncPostgrestClient.__aenter__c                   s   |   I d H  d S rA   )aclose)r=   exc_typeexctbr>   r>   r?   	__aexit__w   s   zAsyncPostgrestClient.__aexit__c                   s   | j  I dH  dS )z&Close the underlying HTTP connections.N)r<   rD   rB   r>   r>   r?   rD   z   s   zAsyncPostgrestClient.aclosetabler   c                 C  s   t | j| j|| j| jS )zPerform a table operation.

        Args:
            table: The name of the table
        Returns:
            :class:`AsyncRequestBuilder`
        )r   r<   r!   joinpathr   
basic_authr=   rI   r>   r>   r?   from_~   s   zAsyncPostgrestClient.from_c                 C  
   |  |S zAlias to :meth:`from_`.rM   rL   r>   r>   r?   rI      s   
zAsyncPostgrestClient.tablez0.2.0z1.0.0zUse self.from_() insteadc                 C  rN   rO   rP   rL   r>   r>   r?   
from_table   s   
zAsyncPostgrestClient.from_tableFfuncparamsdict[str, str]countOptional[CountMethod]headr7   getr   c                 C  s   |rdn|rdnd}|rt dd| int  }|| j |dv r(i t|fn|t f\}}	t| j| jd||||	| j|}
t	|
S )a  Perform a stored procedure call.

        Args:
            func: The name of the remote procedure to run.
            params: The parameters to be passed to the remote procedure.
            count: The method to use to get the count of rows returned.
            head: When set to `true`, `data` will not be returned. Useful if you only need the count.
            get: When set to `true`, the function will be called with read-only access mode.
        Returns:
            :class:`AsyncRPCFilterRequestBuilder`
        Example:
            .. code-block:: python

                await client.rpc("foobar", {"arg": "value"}).execute()

        .. versionchanged:: 0.10.9
            This method now returns a :class:`AsyncRPCFilterRequestBuilder`.
        .. versionchanged:: 0.10.2
            This method now returns a :class:`AsyncFilterRequestBuilder` which allows you to
            filter on the RPC's resultset.
        HEADGETPOSTPreferzcount=)rY   rZ   rpc)
r   updater   r   r   r<   r!   rJ   rK   r   )r=   rR   rS   rU   rW   rX   methodr   jsonhttp_paramsrequestr>   r>   r?   r]      s"   	zAsyncPostgrestClient.rpc)r!   r"   r   r"   r   r#   r   r$   r   r%   r   r&   r    r'   r(   r)   )r   r"   r(   r   )r(   r   )r(   r)   )rI   r"   r(   r   )NFF)rR   r"   rS   rT   rU   rV   rW   r7   rX   r7   r(   r   )__name__
__module____qualname____doc__r   r;   r   rC   rH   rD   rM   rI   r	   r   rQ   r]   r>   r>   r>   r?   r      s*    
L




r   )#
__future__r   r0   r4   typingr   r   r   r   r   warningsr   deprecationr	   httpxr
   r   r   r   yarlr   base_clientr   	constantsr   r   typesr   versionr   request_builderr   r   r   r   r>   r>   r>   r?   <module>   s    