o
    i;                     @   s   d dl Z d dlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ e e jdZG dd dZG dd dZdS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)RequestOptions)construct_type)BadRequestError)GrantV1Response.c                   @   H   e Zd ZdefddZedddeje deje	 de
e fd	d
ZdS )RawTokensClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   V/home/ubuntu/.local/lib/python3.10/site-packages/deepgram/auth/v1/tokens/raw_client.py__init__      
zRawTokensClient.__init__Nttl_secondsrequest_optionsr   r   returnc             	   C   s   | j jjd| j  jdd|iddi|td}z@d|j  kr"dk r7n ntt	t
t	| d	}t||d
W S |jdkrQtt|jttjt
tj| d	d| }W n tyi   t|jt|j|jdw t|jt|j|d)aw  
        Generates a temporary JSON Web Token (JWT) with a 30-second (by default) TTL and usage::write permission for core voice APIs, requiring an API key with Member or higher authorization. Tokens created with this endpoint will not work with the Manage APIs.

        Parameters
        ----------
        ttl_seconds : typing.Optional[float]
            Time to live in seconds for the token. Defaults to 30 seconds.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[GrantV1Response]
            Grant response
        v1/auth/grantPOSTr   content-typeapplication/jsonbase_urlmethodjsonheadersr   omit   ,  type_object_responsedata  r&   bodystatus_coder&   r2   )r   httpx_clientrequestget_environmentbaseOMITr4   typingcastr   r
   r%   r   r   dictr&   Anyr   r   textr   r   r   	_response_data_response_jsonr   r   r   grant   sJ   


zRawTokensClient.grant)__name__
__module____qualname__r   r   r9   r:   Optionalfloatr	   r   r   rC   r   r   r   r   r          r   c                   @   r   )AsyncRawTokensClientr   c                C   r   r   r   r   r   r   r   r   R   r   zAsyncRawTokensClient.__init__Nr   r   r   r   c             	      s   | j jjd| j  jdd|iddi|tdI dH }z@d|j  kr&d	k r;n ntt	t
t	| d
}t||dW S |jdkrUtt|jttjt
tj| d
d| }W n tym   t|jt|j|jdw t|jt|j|d)a|  
        Generates a temporary JSON Web Token (JWT) with a 30-second (by default) TTL and usage::write permission for core voice APIs, requiring an API key with Member or higher authorization. Tokens created with this endpoint will not work with the Manage APIs.

        Parameters
        ----------
        ttl_seconds : typing.Optional[float]
            Time to live in seconds for the token. Defaults to 30 seconds.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[GrantV1Response]
            Grant response
        r   r   r   r    r!   r"   Nr(   r)   r*   r-   r0   r1   r3   )r   r5   r6   r7   r8   r9   r4   r:   r;   r   r
   r%   r   r   r<   r&   r=   r   r   r>   r?   r   r   r   rC   U   sL   


zAsyncRawTokensClient.grant)rD   rE   rF   r   r   r9   r:   rG   rH   r	   r   r   rC   r   r   r   r   rJ   Q   rI   rJ   )r:   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.request_optionsr	   core.unchecked_base_modelr
   errors.bad_request_errorr   types.grant_v1responser   r;   r=   r9   r   rJ   r   r   r   r   <module>   s   ?