o
    e2                     @   s   d Z ddlZddlZddl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ZG dd deZdS )z.
This module provides a client class for VCR.
    N)str)bytes)compat)bce_v1_signer)BceBaseClient)bce_http_client)handler)http_methods)requiredc                   @   s4  e Zd ZdZd3ddZeeefd		d4ddZeeefdd3dd	Z	eeefd		d4d
dZ
eeefdd3ddZeeefdd5ddZeeefd		d6ddZeeefdd5ddZeeefdd5ddZeeefeefeefdd3ddZeeefeefdd3ddZeeefeefeefdd3ddZeeefdd3d d!Zeeefeefdd3d"d#Zeeefeefeefdd3d$d%Zeeefeefdd3d&d'Zeeefeefd(d3d)d*Zeeefdd3d+d,Zeeefeefdd3d-d.Zed/d0 Z			d4d1d2ZdS )7	VcrClientz
    vcr client
    Nc                 C   s   t | | d S N)r   __init__)selfconfig r   PD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/vcr/vcr_client.pyr   (   s   zVcrClient.__init__)sourcec                 C   b   d|i}|dur||d< |dur||d< |dur||d< |dur$||d< | j tjdt||dS )	a  
        Check a media.
        :param source: media source
        :type source: string
        :param auth: media source auth param
        :type auth: string
        :param description: media description
        :type description: string
        :param preset: check preset name
        :type preset: string
        :param notification: notification name
        :type notification: string
        :return: **Http Response**
        r   Nauthdescriptionpresetnotification	   /v1/mediabodyr   _send_requestr	   PUTjsondumpsr   r   r   r   r   r   r   r   r   r   r   	put_media+      
zVcrClient.put_mediac                 C      | j tjdd|i|dS )zm
        :param source: media source
        :type source: string
        :return: **Http Response**
        r      sourceparamsr   r   r	   GETr   r   r   r   r   r   	get_mediaK      
zVcrClient.get_mediac                 C   r   )	a  
        Check an audio.
        :param source: audio source
        :type source: string
        :param auth: audio source auth param
        :type auth: string
        :param description: audio description
        :type description: string
        :param preset: check preset name
        :type preset: string
        :param notification: notification name
        :type notification: string
        :return: **Http Response**
        r   Nr   r   r   r   	   /v2/audior   r   r    r   r   r   	put_audioV   r"   zVcrClient.put_audioc                 C   r#   )zm
        :param source: audio source
        :type source: string
        :return: **Http Response**
        r,   r$   r%   r'   r)   r   r   r   	get_audiov   r+   zVcrClient.get_audioc                 C   2   d|i}|dur||d< | j tjdt||dS )
        :param source: image source
        :type source: string
        :param preset: check preset name
        :type preset: string
        :return: **Http Response**
        r   Nr   s	   /v1/imager   r   )r   r   r   r   r   r   r   r   	put_image      

zVcrClient.put_imagec                 C   sR   d|i}|dur||d< |dur||d< |dur||d< | j tjdt||dS )aU  
        :param source: image source
        :type source: string
        :param preset: check preset name
        :type preset: string
        :param description: image description
        :type description: string
        :param notification: notification name
        :type notification: string
        :return: **Http Response**
        r   Nr   r   r   	   /v2/imager   r   )r   r   r   r   r   r   r   r   r   r   put_image_async_check   s   
zVcrClient.put_image_async_checkc                 C   s,   d|i}|dur||d< | j tjd||dS )r0   r$   Ns   presetr3   r%   r'   )r   r   r   r   r&   r   r   r   get_image_async_check_result   s   	
z&VcrClient.get_image_async_check_result)textc                 C   r/   )z
        :param text: text to check
        :type text: string
        :param preset: check preset name
        :type preset: string
        :return: **Http Response**
        r6   Nr   s   /v1/textr   r   )r   r6   r   r   r   r   r   r   put_text   r2   zVcrClient.put_text)libbriefimagec                 C   .   ||d}| j tjdt| t||dS )z
        :param lib: private face lib
        :param brief: private face brief
        :param image: private face image url
        :return: **Http Response**
        r9   r:      /v1/face/lib/%sr   r   r	   POSTr   convert_to_bytesr   r   r   r8   r9   r:   r   r   r   r   r   add_face_image      	zVcrClient.add_face_image)r8   r9   c                 C   &   d|i}| j tjdt| ||dS zz
        :param lib: private face lib
        :param brief: private face brief
        :return: **Http Response**
           briefr=   r%   r   r	   DELETEr   r@   r   r8   r9   r   r&   r   r   r   del_face_brief      zVcrClient.del_face_briefc                 C   s(   ||d}| j tjdt| ||dS )z
        :param lib: private face lib
        :param brief: private face brief
        :param image: private face image
        :return: **Http Response**
        )rF      imager=   r%   rG   )r   r8   r9   r:   r   r&   r   r   r   del_face_image   s   	zVcrClient.del_face_image)r8   c                 C      | j tjdt| |dS )zQ
        :param lib: private face lib
        :return: **Http Response**
        r=   r   r   r	   r(   r   r@   r   r8   r   r   r   r   get_face_lib     zVcrClient.get_face_libc                 C   rD   rE   rP   rI   r   r   r   get_face_brief  rK   zVcrClient.get_face_briefc                 C   r;   )z
        :param lib: private logo lib
        :param brief: private logo brief
        :param image: private logo image
        :return: **Http Response**
        r<      /v1/logo/lib/%sr   r>   rA   r   r   r   add_logo_image  rC   zVcrClient.add_logo_imagec                 C   rD   zz
        :param lib: private logo lib
        :param brief: private logo brief
        :return: **Http Response**
        rF   rU   r%   rG   rI   r   r   r   del_logo_brief+  rK   zVcrClient.del_logo_brief)r8   r:   c                 C   rD   )zz
        :param lib: private logo lib
        :param image: private logo image
        :return: **Http Response**
        rL   rU   r%   rG   )r   r8   r:   r   r&   r   r   r   del_logo_image:  rK   zVcrClient.del_logo_imagec                 C   rN   )zQ
        :param lib: private logo lib
        :return: **Http Response**
        rU   rO   rP   rQ   r   r   r   get_logo_libI  rS   zVcrClient.get_logo_libc                 C   rD   rW   rP   rI   r   r   r   get_logo_briefS  rK   zVcrClient.get_logo_briefc                 C   s(   |d u r| j S t| j }|| |S r   )r   copyZmerge_non_none_values)r   r   Z
new_configr   r   r   _merge_configb  s
   
zVcrClient._merge_configc              
   C   s:   |  | |}|d u rtj}t|tjtj|g|||||S r   )r]   r   Z
parse_jsonr   send_requestr   signZparse_error)r   Zhttp_methodpathr   headersr&   r   Zbody_parserr   r   r   r   k  s   
zVcrClient._send_requestr   )NNNNN)NN)NNNN)__name__
__module____qualname____doc__r   r
   r   r   r!   r*   r-   r.   r1   r4   r5   r7   rB   rJ   rM   rR   rT   rV   rX   rY   rZ   r[   staticmethodr]   r   r   r   r   r   r   #   sf    


		

r   )re   r\   r   loggingbuiltinsr   r   Zbaidubcer   Zbaidubce.authr   Zbaidubce.bce_base_clientr   Zbaidubce.httpr   r   r	   Zbaidubce.utilsr
   	getLoggerrb   Z_loggerr   r   r   r   r   <module>   s   
