o
    lWi%                     @   s   d dl Z d dlm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 e e jdZG dd dZG dd dZdS )    N)JSONDecodeError   )core)ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)construct_type)UnprocessableEntityError)EditProjectResponseModel)HttpValidationError.c                   @   r   e Zd ZdefddZeeeedddedeje deje	j
 d	eje d
eje deje dee fddZdS )RawContentClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   q/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/studio/projects/content/raw_client.py__init__      
zRawContentClient.__init__Nfrom_urlfrom_documentfrom_content_jsonauto_convertrequest_options
project_idr   r   r    r!   r"   returnc          
   	   C   s   | j jjdt| dd|||di |durd|ini |tdd}z>d	|j  kr.d
k rCn 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ys   t|jt|j|jdw t|jt|j|	d)aT  
        Updates Studio project content.

        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.

        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.

        from_document : typing.Optional[core.File]
            See core.File for more documentation

        from_content_json : typing.Optional[str]

                An optional content to initialize the Studio project with. If this is set, 'from_url' and 'from_document' must be null. If neither 'from_url', 'from_document', 'from_content' are provided we will initialize the Studio project as blank.

                Example:
                [{"name": "Chapter A", "blocks": [{"sub_type": "p", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "A", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "B", "type": "tts_node"}]}, {"sub_type": "h1", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "C", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "D", "type": "tts_node"}]}]}, {"name": "Chapter B", "blocks": [{"sub_type": "p", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "E", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "F", "type": "tts_node"}]}, {"sub_type": "h2", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "G", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "H", "type": "tts_node"}]}]}]


        auto_convert : typing.Optional[bool]
            Whether to auto convert the Studio project to audio or not.

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

        Returns
        -------
        HttpResponse[EditProjectResponseModel]
            Successful Response
        v1/studio/projects//contentPOSTr   r    r!   Nr   Tmethoddatafilesr"   omitforce_multipart   ,  type_object_responser+     headersbodystatus_coder8   r9   )r   httpx_clientrequestr
   OMITr;   typingcastr   r   jsonr	   r   dictr8   r   r   r   text
r   r#   r   r   r    r!   r"   	_response_data_response_jsonr   r   r   update   sP   +

zRawContentClient.update)__name__
__module____qualname__r   r   r>   strr?   Optionalr   Fileboolr   r	   r   rH   r   r   r   r   r      ,    
	r   c                   @   r   )AsyncRawContentClientr   c                C   r   r   r   r   r   r   r   r   o   r   zAsyncRawContentClient.__init__Nr   r#   r   r   r    r!   r"   r$   c          
   	      s  | j jjdt| dd|||di |durd|ini |tddI dH }z>d	|j  kr2d
k rGn 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yw   t|jt|j|jdw t|jt|j|	d)aY  
        Updates Studio project content.

        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.

        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.

        from_document : typing.Optional[core.File]
            See core.File for more documentation

        from_content_json : typing.Optional[str]

                An optional content to initialize the Studio project with. If this is set, 'from_url' and 'from_document' must be null. If neither 'from_url', 'from_document', 'from_content' are provided we will initialize the Studio project as blank.

                Example:
                [{"name": "Chapter A", "blocks": [{"sub_type": "p", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "A", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "B", "type": "tts_node"}]}, {"sub_type": "h1", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "C", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "D", "type": "tts_node"}]}]}, {"name": "Chapter B", "blocks": [{"sub_type": "p", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "E", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "F", "type": "tts_node"}]}, {"sub_type": "h2", "nodes": [{"voice_id": "6lCwbsX1yVjD49QmpkT0", "text": "G", "type": "tts_node"}, {"voice_id": "6lCwbsX1yVjD49QmpkT1", "text": "H", "type": "tts_node"}]}]}]


        auto_convert : typing.Optional[bool]
            Whether to auto convert the Studio project to audio or not.

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

        Returns
        -------
        AsyncHttpResponse[EditProjectResponseModel]
            Successful Response
        r%   r&   r'   r(   Nr   Tr)   r/   r0   r1   r4   r6   r7   r:   )r   r<   r=   r
   r>   r;   r?   r@   r   r   rA   r   r   rB   r8   r   r   r   rC   rD   r   r   r   rH   r   sR   +

zAsyncRawContentClient.update)rI   rJ   rK   r   r   r>   rL   r?   rM   r   rN   rO   r   r   r   rH   r   r   r   r   rQ   n   rP   rQ   )r?   json.decoderr    r   core.api_errorr   core.client_wrapperr   r   core.http_responser   r	   core.jsonable_encoderr
   core.request_optionsr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   !types.edit_project_response_modelr   types.http_validation_errorr   r@   Anyr>   r   rQ   r   r   r   r   <module>   s   Y