o
    iI                     @   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 ddlmZ ddl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)jsonable_encoder)RequestOptions)construct_type)BadRequestError)CreateKeyV1RequestOne)CreateKeyV1Response)DeleteProjectKeyV1Response)GetProjectKeyV1Response)ListProjectKeysV1Response   )KeysListRequestStatus.c                
   @      e Zd ZdefddZddddedeje deje	 d	e
e fd
dZdddededeje	 d	e
e fddZdddededeje	 d	e
e fddZdddededeje	 d	e
e fddZdS )RawKeysClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   _/home/ubuntu/.local/lib/python3.10/site-packages/deepgram/manage/v1/projects/keys/raw_client.py__init__      
zRawKeysClient.__init__Nstatusrequest_options
project_idr"   r#   returnc             	   C   s   | j jjdt| d| j  jdd|i|d}z@d|j  kr$dk r9n ntt	t
t	| d}t||d	W S |jd
krStt|jttjt
tj| dd| }W n tyk   t|jt|j|jdw t|jt|j|d)a  
        Retrieves all API keys associated with the specified project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        status : typing.Optional[KeysListRequestStatus]
            Only return keys with a specific status

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

        Returns
        -------
        HttpResponse[ListProjectKeysV1Response]
            A list of API keys
        v1/projects//keysGETr"   base_urlmethodparamsr#      ,  type_object_responsedata  headersbodystatus_coder7   r8   )r   httpx_clientrequestr	   get_environmentbaser:   typingcastr   r   jsonr   r   dictr7   Anyr   r   textr   r$   r"   r#   	_response_data_response_jsonr   r   r   list   sD   
	

zRawKeysClient.listr#   r<   c             	   C   s   | j jjdt| d| j  jd|ddi|td}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  
        Creates a new API key with specified settings for the project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        request : CreateKeyV1RequestOne

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

        Returns
        -------
        HttpResponse[CreateKeyV1Response]
            API key created successfully
        r&   r'   POSTcontent-typeapplication/jsonr*   r+   rA   r7   r#   omitr-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   OMITr:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   r   r$   r<   r#   rF   rG   rH   r   r   r   createY   sH   


zRawKeysClient.createkey_idc             	   C      | j jjdt| dt| | j  jd|d}z@d|j  kr%dk r:n ntt	t
t	| d}t||dW S |jd	krTtt|jttjt
tj| dd
| }W n tyl   t|jt|j|jdw t|jt|j|d)a  
        Retrieves information about a specified API key

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        key_id : str
            The unique identifier of the API key

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

        Returns
        -------
        HttpResponse[GetProjectKeyV1Response]
            A specific API key
        r&   /keys/r(   r*   r+   r#   r-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   r   r$   rS   r#   rF   rG   rH   r   r   r   get   @   


zRawKeysClient.getc             	   C   rT   )a  
        Deletes an API key for a specific project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        key_id : str
            The unique identifier of the API key

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

        Returns
        -------
        HttpResponse[DeleteProjectKeyV1Response]
            API key deleted
        r&   rU   DELETErV   r-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   rW   r   r   r   delete   rY   zRawKeysClient.delete)__name__
__module____qualname__r   r   strr?   Optionalr   r
   r   r   rI   r   r   rR   r   rX   r   r[   r   r   r   r   r      V    
B
?
7r   c                
   @   r   )AsyncRawKeysClientr   c                C   r   r   r   r   r   r   r   r     r    zAsyncRawKeysClient.__init__Nr!   r$   r"   r#   r%   c             	      s   | j jjdt| d| j  jdd|i|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rWtt|jttjt
tj| d	d| }W n tyo   t|jt|j|jdw t|jt|j|d)a  
        Retrieves all API keys associated with the specified project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        status : typing.Optional[KeysListRequestStatus]
            Only return keys with a specific status

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

        Returns
        -------
        AsyncHttpResponse[ListProjectKeysV1Response]
            A list of API keys
        r&   r'   r(   r"   r)   Nr-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   rE   r   r   r   rI     sF   
	

zAsyncRawKeysClient.listrJ   r<   c             	      s   | j jjdt| d| j  jd|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rYtt|jt	tjttj| d
d| }W n tyq   t|jt|j|jdw t|jt|j|d)a  
        Creates a new API key with specified settings for the project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        request : CreateKeyV1RequestOne

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

        Returns
        -------
        AsyncHttpResponse[CreateKeyV1Response]
            API key created successfully
        r&   r'   rK   rL   rM   rN   Nr-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   rP   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   rQ   r   r   r   rR   E  sJ   


zAsyncRawKeysClient.createrS   c             	         | j jjdt| dt| | j  jd|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rXtt|jttjt
tj| dd| }W n typ   t|jt|j|jdw t|jt|j|d)a  
        Retrieves information about a specified API key

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        key_id : str
            The unique identifier of the API key

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

        Returns
        -------
        AsyncHttpResponse[GetProjectKeyV1Response]
            A specific API key
        r&   rU   r(   rV   Nr-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   rW   r   r   r   rX     B   


zAsyncRawKeysClient.getc             	      rc   )a  
        Deletes an API key for a specific project

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        key_id : str
            The unique identifier of the API key

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

        Returns
        -------
        AsyncHttpResponse[DeleteProjectKeyV1Response]
            API key deleted
        r&   rU   rZ   rV   Nr-   r.   r/   r2   r5   r6   r9   )r   r;   r<   r	   r=   r>   r:   r?   r@   r   r   rA   r   r   rB   r7   rC   r   r   rD   rW   r   r   r   r[     rd   zAsyncRawKeysClient.delete)r\   r]   r^   r   r   r_   r?   r`   r   r
   r   r   rI   r   r   rR   r   rX   r   r[   r   r   r   r   rb     ra   rb   )$r?   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.unchecked_base_modelr   errors.bad_request_errorr   types.create_key_v1request_oner   types.create_key_v1responser   #types.delete_project_key_v1responser    types.get_project_key_v1responser   "types.list_project_keys_v1responser   types.keys_list_request_statusr   r@   rC   rP   r   rb   r   r   r   r   <module>   s&    m