o
    lWix                     @   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 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)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)AddChapterResponseModel)ChapterContentInputModel)ChapterWithContentResponseModel)ConvertChapterResponseModel)DeleteChapterResponseModel)EditChapterResponseModel)GetChaptersResponse)HttpValidationError.c                   @   6  e Zd ZdefddZdddedeje de	e
 fd	d
Zeddde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eeddded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ddededeje de	e fddZdS )RawChaptersClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   r/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/studio/projects/chapters/raw_client.py__init__      
zRawChaptersClient.__init__Nrequest_options
project_idr$   returnc             	   C   s   | j jjdt| dd|d}z>d|j  krdk r1n ntttt|	 d}t
||dW S |jd	krItt|jtttt|	 dd
|	 }W n tya   t|jt|j|jdw t|jt|j|d)a|  
        Returns a list of a Studio project's chapters.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

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

        Returns
        -------
        HttpResponse[GetChaptersResponse]
            Successful Response
        v1/studio/projects/	/chaptersGETmethodr$      ,  type_object_responsedata  headersbodystatus_coder6   r7   )r   httpx_clientrequestr	   r9   typingcastr   r   jsonr   r   dictr6   r   r   r   textr   r%   r$   	_response_data_response_jsonr   r   r    list   s>   

zRawChaptersClient.listfrom_urlr$   namerG   c             	   C   s   | j jjdt| dd||dddi|td}z>d|j  kr$d	k r9n nttt	t|
 d
}t||dW S |jdkrQtt|jttt	t|
 d
d|
 }W n tyi   t|jt|j|jdw t|jt|j|d)a  
        Creates a new chapter either as blank or from a URL.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

        name : str
            The name of the chapter, used for identification only.

        from_url : typing.Optional[str]
            An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' and 'from_content' must be null. If neither 'from_url', 'from_document', 'from_content' are provided we will initialize the Studio project as blank.

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

        Returns
        -------
        HttpResponse[AddChapterResponseModel]
            Successful Response
        r'   r(   POSTrH   rG   content-typeapplication/jsonr+   r>   r6   r$   omitr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   OMITr9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   r   r%   rH   rG   r$   rB   rC   rD   r   r   r    createQ   sJ   

zRawChaptersClient.create
chapter_idc             	   C      | j jjdt| dt| d|d}z>d|j  kr dk r5n ntttt|	 d}t
||dW S |jd	krMtt|jtttt|	 dd
|	 }W n tye   t|jt|j|jdw t|jt|j|d)a  
        Returns information about a specific chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        HttpResponse[ChapterWithContentResponseModel]
            Successful Response
        r'   
/chapters/r)   r*   r,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   r   r%   rR   r$   rB   rC   rD   r   r   r    get   >   

zRawChaptersClient.getrH   contentr$   rY   c          	   	   C   s   | j jjdt| dt| d|t|tdddddi|td	}z>d
|j  kr-dk rBn nt	t
tt
| d}t||dW S |jdkrZtt|jt	ttt| dd| }W n tyr   t|jt|j|jdw t|jt|j|d)ar  
        Updates a chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

        name : typing.Optional[str]
            The name of the chapter, used for identification only.

        content : typing.Optional[ChapterContentInputModel]
            The chapter content to use.

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

        Returns
        -------
        HttpResponse[EditChapterResponseModel]
            Successful Response
        r'   rT   rI   writer0   
annotation	directionrH   rY   rK   rL   rM   r,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r   r   rO   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   	r   r%   rR   rH   rY   r$   rB   rC   rD   r   r   r    update   sN   "

zRawChaptersClient.updatec             	   C   rS   )a  
        Deletes a chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        HttpResponse[DeleteChapterResponseModel]
            Successful Response
        r'   rT   DELETEr*   r,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rU   r   r   r    delete  rW   zRawChaptersClient.deletec             	   C   s   | j jjdt| dt| dd|d}z>d|j  kr!dk r6n ntttt|	 d}t
||d	W S |jd
krNtt|jtttt|	 dd|	 }W n tyf   t|jt|j|jdw t|jt|j|d)a  
        Starts conversion of a specific chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        HttpResponse[ConvertChapterResponseModel]
            Successful Response
        r'   rT   /convertrI   r*   r,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rU   r   r   r    convertK  s>   

zRawChaptersClient.convert)__name__
__module____qualname__r   r!   strr<   Optionalr
   r   r   rE   rO   r   rQ   r   rV   r   r   r`   r   rb   r   rd   r   r   r   r    r          
7
F
:
L
6r   c                   @   r   )AsyncRawChaptersClientr   c                C   r   r   r   r   r   r   r    r!     r"   zAsyncRawChaptersClient.__init__Nr#   r%   r$   r&   c             	      s   | j jjdt| dd|dI dH }z>d|j  kr dk r5n ntttt|	 d}t
||d	W S |jd
krMtt|jtttt|	 dd|	 }W n tye   t|jt|j|jdw t|jt|j|d)a  
        Returns a list of a Studio project's chapters.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

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

        Returns
        -------
        AsyncHttpResponse[GetChaptersResponse]
            Successful Response
        r'   r(   r)   r*   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rA   r   r   r    rE     s@   

zAsyncRawChaptersClient.listrF   rH   rG   c             	      s   | j jjdt| dd||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rUtt|jttt	t|
 dd|
 }W n tym   t|jt|j|jdw t|jt|j|d)a  
        Creates a new chapter either as blank or from a URL.

        Parameters
        ----------
        project_id : str
            The ID of the Studio project.

        name : str
            The name of the chapter, used for identification only.

        from_url : typing.Optional[str]
            An optional URL from which we will extract content to initialize the Studio project. If this is set, 'from_url' and 'from_content' must be null. If neither 'from_url', 'from_document', 'from_content' are provided we will initialize the Studio project as blank.

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

        Returns
        -------
        AsyncHttpResponse[AddChapterResponseModel]
            Successful Response
        r'   r(   rI   rJ   rK   rL   rM   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   rO   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rP   r   r   r    rQ     sL   

zAsyncRawChaptersClient.createrR   c             	         | j jjdt| dt| d|dI dH }z>d|j  kr$dk r9n ntttt|	 d}t
||d	W S |jd
krQtt|jtttt|	 dd|	 }W n tyi   t|jt|j|jdw t|jt|j|d)a  
        Returns information about a specific chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        AsyncHttpResponse[ChapterWithContentResponseModel]
            Successful Response
        r'   rT   r)   r*   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rU   r   r   r    rV     @   

zAsyncRawChaptersClient.getrX   rY   c          	   	      s  | j jjdt| dt| d|t|tdddddi|td	I d
H }z>d|j  kr1dk rFn nt	t
tt
| d}t||dW S |jdkr^tt|jt	ttt| dd| }W n tyv   t|jt|j|jdw t|jt|j|d)aw  
        Updates a chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

        name : typing.Optional[str]
            The name of the chapter, used for identification only.

        content : typing.Optional[ChapterContentInputModel]
            The chapter content to use.

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

        Returns
        -------
        AsyncHttpResponse[EditChapterResponseModel]
            Successful Response
        r'   rT   rI   rZ   r[   r^   rK   rL   rM   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r   r   rO   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   r_   r   r   r    r`   1  sP   "

zAsyncRawChaptersClient.updatec             	      rl   )a  
        Deletes a chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        AsyncHttpResponse[DeleteChapterResponseModel]
            Successful Response
        r'   rT   ra   r*   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rU   r   r   r    rb   |  rm   zAsyncRawChaptersClient.deletec             	      s   | j jjdt| dt| d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rRtt|jtttt|	 d	d|	 }W n tyj   t|jt|j|jdw t|jt|j|d)a  
        Starts conversion of a specific chapter.

        Parameters
        ----------
        project_id : str
            The ID of the project to be used. You can use the [List projects](/docs/api-reference/studio/get-projects) endpoint to list all the available projects.

        chapter_id : str
            The ID of the chapter to be used. You can use the [List project chapters](/docs/api-reference/studio/get-chapters) endpoint to list all the available chapters.

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

        Returns
        -------
        AsyncHttpResponse[ConvertChapterResponseModel]
            Successful Response
        r'   rT   rc   rI   r*   Nr,   r-   r.   r1   r4   r5   r8   )r   r:   r;   r	   r9   r<   r=   r   r   r>   r   r   r?   r6   r   r   r   r@   rU   r   r   r    rd     s@   

zAsyncRawChaptersClient.convert)re   rf   rg   r   r!   rh   r<   ri   r
   r   r   rE   rO   r   rQ   r   rV   r   r   r`   r   rb   r   rd   r   r   r   r    rk     rj   rk   )*r<   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr    types.add_chapter_response_modelr   !types.chapter_content_input_modelr   )types.chapter_with_content_response_modelr   $types.convert_chapter_response_modelr   #types.delete_chapter_response_modelr   !types.edit_chapter_response_modelr   types.get_chapters_responser   types.http_validation_errorr   r=   AnyrO   r   rk   r   r   r   r    <module>   s.     h