o
    lqi3                     @   s   d Z ddlm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jZdS )z/
This module provides a client class for CERT.
    )unicode_literalsN)bce_base_client)utils)bce_v1_signer)bce_http_client)handler)http_content_types)http_headers)http_methods)
cert_modelc                   @   sl   e Zd ZdZdZdddZedd Z			ddd	Zdd
dZ	dddZ
dddZdddZdddZdS )
CertClientz
    CertClient
    s   /v1/certificateNc                 C   s   t j| | d S N)r   BceBaseClient__init__selfconfig r   i/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/baidubce/services/cert/cert_client.pyr   *   s   zCertClient.__init__c                 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CertClient._merge_configc              
   C   sX   |  | |}|d u rtj}|pi }tj|tj< t|t	j
tj|g|ttj||||S r   )r   r   Z
parse_jsonr   JSONr	   ZCONTENT_TYPEr   send_requestr   signZparse_errorr   Z
append_urir   prefix)r   Zhttp_methodpathbodyheadersparamsr   Zbody_parserr   r   r   _send_request6   s   zCertClient._send_requestc                 C   s   | j tjdt|j|dS )a>  
        create certificate

        :param cert_create_request: certificate base informations
        :type cert_create_request: cert_model.CertCreateRequest

        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
         )r   r   )r   r
   POSTjsondumps__dict__)r   cert_create_requestr   r   r   r   create_certE   s   zCertClient.create_certc                 C   s   | j tjd|dS )z
        list user's certificates

        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r    r   r   r
   GETr   r   r   r   list_user_certsV   s   
zCertClient.list_user_certsc                 C      | j tjd| |dS )a  
        get a certificate information by id

        :param cert_id: certificate id
        :type cert_id: string

        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        /r'   r(   r   cert_idr   r   r   r   get_cert_infod   s   
zCertClient.get_cert_infoc                 C   r+   )a  
        delete a certificate by id
        :param cert_id: certificate id
        :type cert_id: string
        :param config: None
        :type config: baidubce.BceClientConfiguration
        :return:
        :rtype: baidubce.bce_response.BceResponse
        r,   r'   )r   r
   DELETEr-   r   r   r   delete_certu   s   

zCertClient.delete_certc                 C   s&   | j tjd| t|jddi|dS )a  
        delete a certificate by id

        :param cert_id: certificate id
        :type cert_id: string

        :param cert_create_request: certificate base informations
        :type cert_create_request: cert_model.CertCreateRequest

        :param config: None
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype: baidubce.bce_response.BceResponse
        r,   ZcertDatar    )r   r   r   )r   r
   PUTr"   r#   r$   )r   r.   r%   r   r   r   r   replace_cert   s   

zCertClient.replace_certr   )NNNNN)__name__
__module____qualname____doc__r   r   staticmethodr   r   r&   r*   r/   r1   r3   r   r   r   r   r   $   s    







r   )r7   
__future__r   r   r"   loggingZbaidubcer   r   Zbaidubce.authr   Zbaidubce.httpr   r   r   r	   r
   Zbaidubce.services.certr   	getLoggerr4   Z_loggerr   r   r   r   r   r   <module>   s    
