o
    lWi^R                     @   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 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)UnprocessableEntityError)HttpValidationError)ResourceMetadataResponseModel)WorkspaceResourceType   )EBodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole.c                   @      e Zd ZdefddZdddededeje	 d	e
e fd
dZeeedddedededeje deje deje deje	 d	e
ej fddZeeedddededeje deje deje deje	 d	e
ej fddZdS )RawResourcesClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   m/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/workspace/resources/raw_client.py__init__      
zRawResourcesClient.__init__Nrequest_optionsresource_idresource_typer    returnc             	   C   s   | j jjdt| dd|i|d}z>d|j  krdk r3n ntttt|	 d}t
||dW S |jd	krKtt|jtttt|	 dd
|	 }W n tyc   t|jt|j|jdw t|jt|j|d)a  
        Gets the metadata of a resource by ID.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

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

        Returns
        -------
        HttpResponse[ResourceMetadataResponseModel]
            Successful Response
        v1/workspace/resources/GETr"   methodparamsr       ,  type_object_responsedata  headersbodystatus_coder3   r4   )r   httpx_clientrequestr	   r6   typingcastr   r   jsonr   r   dictr3   r   r   r   textr   r!   r"   r    	_response_data_response_jsonr   r   r   get   sB   

zRawResourcesClient.get
user_emailgroup_idworkspace_api_key_idr    rolerD   rE   rF   c             	   C   s  | j jjdt| dd|||||dddi|td}zP|du s%|j s,t|dd	W S d
|j  kr7dk rNn nt	
t	jtt	j| d}	t||	d	W S |jdkrftt|jt	
ttt| dd| }
W n ty~   t|jt|j|jdw t|jt|j|
d)a5  
        Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole
            Role to update the target principal with.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

        user_email : typing.Optional[str]
            The email of the user or service account.

        group_id : typing.Optional[str]
            The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'.

        workspace_api_key_id : typing.Optional[str]
            The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.

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

        Returns
        -------
        HttpResponse[typing.Any]
            Successful Response
        r$   /sharePOSTrG   r"   rD   rE   rF   content-typeapplication/jsonr'   r;   r3   r    omitNr.   r)   r*   r+   r1   r2   r5   r   r7   r8   r	   OMITr=   stripr   r6   r9   r:   Anyr   r;   r   r<   r3   r   r   r   r   r!   rG   r"   rD   rE   rF   r    r?   r@   rA   r   r   r   shareX   sT   *

zRawResourcesClient.sharec          
   	   C   s  | j jjdt| dd||||dddi|td}zP|du s$|j s+t|dd	W S d
|j  kr6dk rMn nt	
t	jtt	j| d}t||d	W S |jdkrett|jt	
ttt| dd| }	W n ty}   t|jt|j|jdw t|jt|j|	d)a  
        Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

        user_email : typing.Optional[str]
            The email of the user or service account.

        group_id : typing.Optional[str]
            The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'.

        workspace_api_key_id : typing.Optional[str]
            The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.

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

        Returns
        -------
        HttpResponse[typing.Any]
            Successful Response
        r$   /unsharerI   r"   rD   rE   rF   rK   rL   rM   Nr.   r)   r*   r+   r1   r2   r5   rO   
r   r!   r"   rD   rE   rF   r    r?   r@   rA   r   r   r   unshare   sR   &

zRawResourcesClient.unshare)__name__
__module____qualname__r   r   strr   r9   Optionalr
   r   r   rB   rP   r   rR   rT   rX   r   r   r   r   r      h    
B	

[	r   c                   @   r   )AsyncRawResourcesClientr   c                C   r   r   r   r   r   r   r   r     r   z AsyncRawResourcesClient.__init__Nr   r!   r"   r    r#   c             	      s   | j jjdt| dd|i|dI dH }z>d|j  kr"dk r7n ntttt|	 d}t
||d	W S |jd
krOtt|jtttt|	 dd|	 }W n tyg   t|jt|j|jdw t|jt|j|d)a  
        Gets the metadata of a resource by ID.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

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

        Returns
        -------
        AsyncHttpResponse[ResourceMetadataResponseModel]
            Successful Response
        r$   r%   r"   r&   Nr)   r*   r+   r.   r1   r2   r5   )r   r7   r8   r	   r6   r9   r:   r   r   r;   r   r   r<   r3   r   r   r   r=   r>   r   r   r   rB     sD   

zAsyncRawResourcesClient.getrC   rG   rD   rE   rF   c             	      s  | j jjdt| dd|||||dddi|tdI dH }zP|du s)|j s0t|dd	W S d
|j  kr;dk rRn nt	
t	jtt	j| d}	t||	d	W S |jdkrjtt|jt	
ttt| dd| }
W n ty   t|jt|j|jdw t|jt|j|
d)a:  
        Grants a role on a workspace resource to a user or a group. It overrides any existing role this user/service account/group/workspace api key has on the resource. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be shared with the service account associated with the api key. You must have admin access to the resource to share it.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        role : BodyShareWorkspaceResourceV1WorkspaceResourcesResourceIdSharePostRole
            Role to update the target principal with.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

        user_email : typing.Optional[str]
            The email of the user or service account.

        group_id : typing.Optional[str]
            The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'.

        workspace_api_key_id : typing.Optional[str]
            The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.

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

        Returns
        -------
        AsyncHttpResponse[typing.Any]
            Successful Response
        r$   rH   rI   rJ   rK   rL   rM   Nr.   r)   r*   r+   r1   r2   r5   r   r7   r8   r	   rP   r=   rQ   r   r6   r9   r:   rR   r   r;   r   r<   r3   r   r   r   rS   r   r   r   rT   @  sV   *

zAsyncRawResourcesClient.sharec          
   	      s  | j jjdt| dd||||dddi|tdI dH }zP|du s(|j s/t|dd	W S d
|j  kr:dk rQn nt	
t	jtt	j| d}t||d	W S |jdkritt|jt	
ttt| dd| }	W n ty   t|jt|j|jdw t|jt|j|	d)a  
        Removes any existing role on a workspace resource from a user, service account, group or workspace api key. To target a user or service account, pass only the user email. The user must be in your workspace. To target a group, pass only the group id. To target a workspace api key, pass the api key id. The resource will be unshared from the service account associated with the api key. You must have admin access to the resource to unshare it. You cannot remove permissions from the user who created the resource.

        Parameters
        ----------
        resource_id : str
            The ID of the target resource.

        resource_type : WorkspaceResourceType
            Resource type of the target resource.

        user_email : typing.Optional[str]
            The email of the user or service account.

        group_id : typing.Optional[str]
            The ID of the target group. To target the permissions principals have by default on this resource, use the value 'default'.

        workspace_api_key_id : typing.Optional[str]
            The ID of the target workspace API key. This isn't the same as the key itself that would you pass in the header for authentication. Workspace admins can find this in the workspace settings UI.

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

        Returns
        -------
        AsyncHttpResponse[typing.Any]
            Successful Response
        r$   rU   rI   rV   rK   rL   rM   Nr.   r)   r*   r+   r1   r2   r5   r`   rW   r   r   r   rX     sT   &

zAsyncRawResourcesClient.unshare)rY   rZ   r[   r   r   r\   r   r9   r]   r
   r   r   rB   rP   r   rR   rT   rX   r   r   r   r   r_      r^   r_   ) r9   json.decoderr   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.http_validation_errorr   &types.resource_metadata_response_modelr   types.workspace_resource_typer   Wtypes.body_share_workspace_resource_v_1_workspace_resources_resource_id_share_post_roler   r:   rR   rP   r   r_   r   r   r   r   <module>   s"    i