o
    e                     @   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 VCA.
    N)str)bytes)compat)bce_v1_signer)BceBaseClient)bce_http_client)handler)http_methods)requiredc                   @   s   e Zd ZdZdddZeeefddddZeeefd			ddd	Z	eeefddd
dZ
eeefeefddddZedd Z			dddZdS )	VcaClientz
    vca client
    Nc                 C   s   t | | d S N)r   __init__)selfconfig r   PD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/vca/vca_client.pyr   '   s   zVcaClient.__init__)sourcec                 C   s6   d|i}|dur||d< | j tjdt|ddidS )z
        Analyze a image sync.
        :param source: image source
        :type source: string or unicode
        :param preset: analyze preset name
        :type preset: string or unicode
        :return: **Http Response**
        r   Npresets	   /v2/images   sync )bodyparams_send_requestr	   PUTjsondumps)r   r   r   r   r   r   r   	put_image*   s
   zVcaClient.put_imagec
                 C   s   d|i}
|dur||
d< |dur||
d< |dur||
d< |dur$||
d< |dur,||
d< |dur4||
d< |dur<||
d	< | j tjd
t|
|	dS )a  
        Analyze a media.
        :param source: media source
        :type source: string or unicode
        :param preset: analyze preset name
        :type preset: string or unicode
        :param notification: notification name
        :type notification: string or unicode
        :param priority: priority
        :type priority: integer
        :param title: media title
        :type title: string or unicode
        :param sub_title: media subtitle
        :type sub_title: string or unicode
        :param category: media category
        :type category: string or unicode
        :param description: media description
        :type description: string or unicode
        :return: **Http Response**
        r   Nr   notificationprioritytitleZsubTitlecategorydescription	   /v2/media)r   r   r   )r   r   r   r   r   r   Z	sub_titler    r!   r   r   r   r   r   	put_media;   s(   
zVcaClient.put_mediac                 C   s   | j tjdd|i|dS )z
        Get analyze result, make sure called put_media before calling get_media
        :param source: media source
        :type source: string or unicode
        :return: **Http Response**
        r"      sourcer   r   )r   r	   GET)r   r   r   r   r   r   	get_mediah   s   
zVcaClient.get_media)r   typec                 C   s"   | j tjdt| d|i|dS )a  
        Get sub task result for specified source of directed type
        :param source: media source
        :type source: string or unicode
        :param type: sub task type
        :type type: string or unicode
        :return: **Http Response**
        s   /v2/media/%sr$   r%   )r   r	   r&   r   Zconvert_to_bytes)r   r   r(   r   r   r   r   get_sub_taskt   s
   
zVcaClient.get_sub_taskc                 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_config   s
   
zVcaClient._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      s   
zVcaClient._send_requestr   )NNNNNNNN)NNNNN)__name__
__module____qualname____doc__r   r
   r   r   r   r#   r'   r)   staticmethodr+   r   r   r   r   r   r   "   s(    
,

r   )r3   r*   r   loggingbuiltinsr   r   Zbaidubcer   Zbaidubce.authr   Zbaidubce.bce_base_clientr   Zbaidubce.httpr   r   r	   Zbaidubce.utilsr
   	getLoggerr0   Z_loggerr   r   r   r   r   <module>   s   
