o
    ip9                     @   s   d dl Z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 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" G dd dZ#G dd dZ$dS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)serialize_datetime)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)BadRequestError)GetProjectRequestV1Response)ListProjectRequestsV1Response   )RequestsListRequestDeployment)RequestsListRequestEndpoint)RequestsListRequestMethod)RequestsListRequestStatusc                   @      e Zd ZdefddZdddddddddddddedejej	 dejej	 d	eje
 d
eje
 deje deje deje deje dej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S )RawRequestsClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   c/home/ubuntu/.local/lib/python3.10/site-packages/deepgram/manage/v1/projects/requests/raw_client.py__init__      
zRawRequestsClient.__init__Nstartendlimitpageaccessor
request_id
deploymentendpointmethodstatusrequest_options
project_idr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   returnc                C   s   | j jjdt| d| j  jd|durt|nd|dur"t|nd||||||	|
|d
|d}z@d|j  kr=dk rRn nt	t
tt
| d	}t||d
W S |jdkrltt|jt	tjttj| d	d| }W n ty   t|jt|j|jdw t|jt|j|d)a  
        Generates a list of requests for a specific project

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

        start : typing.Optional[dt.datetime]
            Start date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        end : typing.Optional[dt.datetime]
            End date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        limit : typing.Optional[float]
            Number of results to return per page. Default 10. Range [1,1000]

        page : typing.Optional[float]
            Navigate and return the results to retrieve specific portions of information of the response

        accessor : typing.Optional[str]
            Filter for requests where a specific accessor was used

        request_id : typing.Optional[str]
            Filter for a specific request id

        deployment : typing.Optional[RequestsListRequestDeployment]
            Filter for requests where a specific deployment was used

        endpoint : typing.Optional[RequestsListRequestEndpoint]
            Filter for requests where a specific endpoint was used

        method : typing.Optional[RequestsListRequestMethod]
            Filter for requests where a specific method was used

        status : typing.Optional[RequestsListRequestStatus]
            Filter for requests that succeeded (status code < 300) or failed (status code >=400)

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

        Returns
        -------
        HttpResponse[ListProjectRequestsV1Response]
            A list of requests for a specific project
        v1/projects/	/requestsGETN
r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   base_urlr+   paramsr-      ,  type_object_responsedata  headersbodystatus_coderA   rB   )r   httpx_clientrequestr
   get_environmentbaser   rD   typingcastr   r   jsonr	   r   dictrA   Anyr   r   textr   r.   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   	_response_data_response_jsonr   r   r   list   sV   >


zRawRequestsClient.listr-   c             	   C   s   | 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 a specific request for a specific project

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

        request_id : str
            The unique identifier of the request

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

        Returns
        -------
        HttpResponse[GetProjectRequestV1Response]
            A specific request for a specific project
        r0   
/requests/r2   r5   r+   r-   r7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r
   rG   rH   rD   rI   rJ   r   r   rK   r	   r   rL   rA   rM   r   r   rN   r   r.   r(   r-   rP   rQ   rR   r   r   r   get   s@   


zRawRequestsClient.get)__name__
__module____qualname__r   r    strrI   Optionaldtdatetimefloatr   r   r   r   r   r	   r   rS   r   rX   r   r   r   r   r      d    

	

kr   c                   @   r   )AsyncRawRequestsClientr   c                C   r   r   r   r   r   r   r   r       r!   zAsyncRawRequestsClient.__init__Nr"   r.   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r/   c                   s(  | j jjdt| d| j  jd|durt|nd|dur#t|nd||||||	|
|d
|dI dH }z@d|j  krAdk rVn nt	t
tt
| d	}t||d
W S |jdkrptt|jt	tjttj| d	d| }W n ty   t|jt|j|jdw t|jt|j|d)a  
        Generates a list of requests for a specific project

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

        start : typing.Optional[dt.datetime]
            Start date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        end : typing.Optional[dt.datetime]
            End date of the requested date range. Formats accepted are YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS, or YYYY-MM-DDTHH:MM:SS+HH:MM

        limit : typing.Optional[float]
            Number of results to return per page. Default 10. Range [1,1000]

        page : typing.Optional[float]
            Navigate and return the results to retrieve specific portions of information of the response

        accessor : typing.Optional[str]
            Filter for requests where a specific accessor was used

        request_id : typing.Optional[str]
            Filter for a specific request id

        deployment : typing.Optional[RequestsListRequestDeployment]
            Filter for requests where a specific deployment was used

        endpoint : typing.Optional[RequestsListRequestEndpoint]
            Filter for requests where a specific endpoint was used

        method : typing.Optional[RequestsListRequestMethod]
            Filter for requests where a specific method was used

        status : typing.Optional[RequestsListRequestStatus]
            Filter for requests that succeeded (status code < 300) or failed (status code >=400)

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

        Returns
        -------
        AsyncHttpResponse[ListProjectRequestsV1Response]
            A list of requests for a specific project
        r0   r1   r2   Nr3   r4   r7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r
   rG   rH   r   rD   rI   rJ   r   r   rK   r   r   rL   rA   rM   r   r   rN   rO   r   r   r   rS      sX   >


zAsyncRawRequestsClient.listrT   c             	      s   | 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 a specific request for a specific project

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

        request_id : str
            The unique identifier of the request

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

        Returns
        -------
        AsyncHttpResponse[GetProjectRequestV1Response]
            A specific request for a specific project
        r0   rU   r2   rV   Nr7   r8   r9   r<   r?   r@   rC   )r   rE   rF   r
   rG   rH   rD   rI   rJ   r   r   rK   r   r   rL   rA   rM   r   r   rN   rW   r   r   r   rX   *  sB   


zAsyncRawRequestsClient.get)rY   rZ   r[   r   r    r\   rI   r]   r^   r_   r`   r   r   r   r   r   r   r   rS   r   rX   r   r   r   r   rb      ra   rb   )%r_   r^   rI   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.datetime_utilsr   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.unchecked_base_modelr   errors.bad_request_errorr   $types.get_project_request_v1responser   &types.list_project_requests_v1responser   &types.requests_list_request_deploymentr   $types.requests_list_request_endpointr   "types.requests_list_request_methodr   "types.requests_list_request_statusr   r   rb   r   r   r   r   <module>   s(    &