o
    #Îjˆ)  ã                   @   sŠ   d Z ddl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ƒZdS )z/
This module provides a client class for LBDC.
é    N)ÚBceBaseClient)Úbce_v1_signer)Úbce_http_client)Úhandler)Úhttp_methods)Úcompatc                   @   sŠ   e Zd ZdZdZdZddd„Zedd„ ƒZ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dd„Zddd„ZdS )#Ú
LbdcClientz"

       LBDC base sdk client
    s   /v1s   /lbdcNc                 C   s   t  | |¡ dS )zY
        :param config: client config info
        reuse BceBaseClient init func
        N)r   Ú__init__)ÚselfÚconfig© r   úc/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/baidubce/services/lbdc/lbdc_client.pyr	   +   s   zLbdcClient.__init__c                   C   s   t  ¡ S )z0

        default client token by uuid1
        )ÚuuidÚuuid1r   r   r   r   Ú_generate_default_client_token2   s   z)LbdcClient._generate_default_client_tokenc                 C   s(   |du r| j S t | j ¡}| |¡ |S )zh

        :type config: baidubce.BceClientConfiguration
        :param config:
        :return:
        N)r   ÚcopyZmerge_non_none_values)r
   r   Z
new_configr   r   r   Ú_merge_config:   s
   
zLbdcClient._merge_configc              
   C   sP   |   |¡}|du rtj}|du rdddœ}t |tjtj|g|tj	| |||¡S )a  

        :param http_method:
        :param path:
        :param body:
        :param headers:
        :param params:

        :type config: baidubce.BceClientConfiguration
        :param config:

        :param body_parser:

        :return: baidubce.BceResponse
        Ns   */*s   application/json;charset=utf-8)s   Accepts   Content-Type)
r   r   Z
parse_jsonr   Úsend_requestr   ÚsignZparse_errorr   Úprefix)r
   Zhttp_methodÚpathÚbodyÚheadersÚparamsr   Zbody_parserr   r   r   Ú_send_requestH   s   
ÿ
ýzLbdcClient._send_requestc	                 C   sx   |du r|   ¡ }d|i}	||||jd|jidœdœ}
|dur"||
d< |dur-d|ji|
d< | jtjtjt 	|
¡|	|dS )	a  

        The method of lbdc to be created.
        :param name:
            name
        :type name: str

        :param type:
            lbdc type
        :type type: str

        :param ccu_count:
            count of Cluster Capacity Unit
        :type ccu_count: int

        :param billing:
           order_configuration
        :type billing:Billing

        :param desc:
            description of the cluster
        :type desc: string

        :param renew:
           reservation info of order_configuration
        :type renew:Billing.reservation

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if clientToken is provided.
            If the clientToken is not specified by the user, a random String
            generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nó   clientTokenÚreservationLength)ZpaymentTimingÚreservation)ÚnameÚtypeÚccuCountÚbillingÚdescZrenewReservation©r   r   r   )
r   Zpayment_timingÚreservation_lengthr   r   ÚPOSTr   r   ÚjsonÚdumps)r
   r   r   Ú	ccu_countr!   r"   ZrenewÚclient_tokenr   r   r   r   r   r   Úcreate_lbdcf   s(   )ÿÿþüÿÿzLbdcClient.create_lbdcó   resizec           	      C   sT   t jd t |¡ }|du r|  ¡ }d||di}d|i}| jtj|t 	|¡||dS )aè  
        The method of lbdc to be upgrade.

        :param lbdc_id: lbdc id
        :type lbdc_id: str

        :param ccu_count: count of Cluster Capacity Unit
        :type ccu_count: int

        :param action: action to upgrade lbdc
        :type action: str

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if clientToken is provided.
            If the clientToken is not specified by the user, a random String
            generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        ó   /Nr   Ú r    r#   ©
r   r   r   Úconvert_to_bytesr   r   r   ÚPUTr&   r'   )	r
   Úlbdc_idr(   Úactionr)   r   r   r   r   r   r   r   Úupgrade_lbdc©   s   þÿÿzLbdcClient.upgrade_lbdcó   purchaseReservedc           	      C   s^   t jd t |¡ }|du r|  ¡ }d||di}ddd|jiii}| jtj|t	 
|¡||dS )	aÙ  

        renew lbdc

        :param lbdc_id:
            The id of lbdc.
        :type lbdc_id: str

        :param billing: order_configuration
        :type billing:Billing

        :param action: action to update lbdc
        :type action: str

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if clientToken is provided.
            If the clientToken is not specified by the user, a random String generated by default algorithm will
            be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r,   Nr   r-   r!   r   r   r#   )r   r   r   r/   r   r$   r   r   r0   r&   r'   )	r
   r1   r!   r2   r)   r   r   r   r   r   r   r   Ú
renew_lbdcÔ   s   þÿÿÿÿzLbdcClient.renew_lbdcc                 C   s:   i }|dur
||d< |dur||d< | j tjtj||dS )a=  

        return all lbdc list about query info

        :param lbdc_id: lbdc id
        :type lbdc_id: str

        :param name: lbdc name
        :type name: str

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        Ns   ids   name)r   r   )r   r   ÚGETr   r   )r
   r1   r   r   r   r   r   r   Ú	list_lbdc  s   zLbdcClient.list_lbdcc                 C   s&   t jd t |¡ }| jtj||dS )a  

        Get the detail information of lbdc.

        :param lbdc_id:
            The id of lbdc.
        :type lbdc_id: str

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r,   ©r   ©r   r   r   r/   r   r   r6   ©r
   r1   r   r   r   r   r   Úget_lbdc  s   zLbdcClient.get_lbdcc           	      C   sl   t jd t |¡ }|du r|  ¡ }d|i}i }|dur ||d< |dur(||d< | jtj|t 	|¡||dS )aÎ  

        renew lbdc

        :param lbdc_id:
            The id of lbdc.
        :type lbdc_id: string

        :param name:
            The name of lbdc
        :type name: str

        :param desc: description
        :type desc: str

        :param client_token:
            An ASCII string whose length is less than 64.
            The request will be idempotent if clientToken is provided.
            If the clientToken is not specified by the user, a random String generated by default algorithm will
            be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r,   Nr   r   r"   r#   r.   )	r
   r1   r   r"   r)   r   r   r   r   r   r   r   Úupdate_lbdc.  s   ÿÿzLbdcClient.update_lbdcc                 C   s*   t jd t |¡ d }| jtj||dS )a  

        return all lbdc list about query info

        :param lbdc_id: lbdc id
        :type lbdc_id:string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r,   s   /blbr8   r9   r:   r   r   r   Úlist_lbdc_blbZ  s   zLbdcClient.list_lbdc_blb)N)NNNNN)NNNN)r+   NN)r4   NN)NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   Ústaticmethodr   r   r   r*   r3   r5   r7   r;   r<   r=   r   r   r   r   r   "   s$    


ÿ

C
+
.

,r   )rA   r   r&   Úloggingr   Zbaidubce.bce_base_clientr   Zbaidubce.authr   Zbaidubce.httpr   r   r   Zbaidubcer   Ú	getLoggerr>   Ú_loggerr   r   r   r   r   Ú<module>   s   
