o
    es                     @   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 eeZG d	d
 d
ejZdd Zdd ZdS )z.
This module provides a client class for CDN.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)requiredc                   @   sT   e Zd ZdZdddZeeefeefeddddZ	e
d	d
 Z		dddZdS )DumapClientz
    DumapClient
    Nc                 C   s   t j| | d S N)r   BceBaseClient__init__)selfconfig r   TD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/dumap/dumap_client.pyr   $   s   zDumapClient.__init__)app_iduriparams   GETc                 C   s0   | j ||||d|i|d}|jr|jdS |S )a  
        call open_api
        :param app_id: app_id
        :type app_id: string
        :param uri: open api uri
        :type uri: string
        :param params: dict
        :type params:request params
        :param body: request body (default: None)
        :type body: string
        :param method: http method (default GET)
        :type method: http_methods
        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
                   x-app-id)http_methodpathr   bodyheadersr   zutf-8)_send_requestr   decode)r   r   r   r   r   methodr   responser   r   r   call_open_api'   s   	zDumapClient.call_open_apic                 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_configI   s
   
zDumapClient._merge_configc              
   C   sF   |  | |}t |d< d|d< t|tg dtjtg|||||S )N   x-bce-request-ids   application/json;charset=utf-8s   Content-Type)s   hosts
   x-bce-dater    r   )	r   uuiduuid4r   send_requestsign_wrapperr   Zparse_error
parse_none)r   r   r   r   r   r   r   r   r   r   r   R   s   
zDumapClient._send_requestr	   )NNNNr   N)NNNN)__name__
__module____qualname____doc__r   r   bytesstrdictr   staticmethodr   r   r   r   r   r   r      s    
!

r   c                    s    fdd}|S )z!wrapper the bce_v1_signer.sign().c                    s   t j| |||| dS )Nheaders_to_sign)r   sign)credentialsr   r   r   r   r.   r   r   _wrapperc   s   zsign_wrapper.<locals>._wrapperr   )r/   r2   r   r.   r   r$   `   s   r$   c                 C   s   |   }|r	||_|   dS )a  If the body is not empty, convert it to a python object and set as the value of
    response.body. http_response is always closed if no error occurs.

    :param http_response: the http_response object returned by HTTPConnection.getresponse()
    :type http_response: httplib.HTTPResponse

    :param response: general response object which will be returned to the caller
    :type response: baidubce.BceResponse

    :return: always true
    :rtype bool
    T)readr   close)http_responser   r   r   r   r   r%   j   s
   r%   )r)   r   loggingr!   Zbaidubcer   Zbaidubce.authr   Zbaidubce.httpr   r   r   Zbaidubce.utilsr   	getLoggerr&   Z_loggerr
   r   r$   r%   r   r   r   r   <module>   s   
A
