o
    #jj4                     @   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 dd	lmZ eeZG d
d de
ZdS )z.
This module provides a client class for EIP.
    N)utils)bce_v1_signer)BceBaseClient)bce_http_client)handler)http_methods)requiredc                   @   s   e Zd ZdZdZdZd#ddZeed			d$dd	Z	ee
ed
		d%ddZee
dd#ddZ		d&ddZee
e
d		d%ddZee
e
d		d%ddZee
dd%ddZedd Zed#ddZdd  Z		d'd!d"ZdS )(EipBpClientz
    EIP_BP sdk client
    s   /v1s   /eipbpNc                 C   s   t | | dS )zV
        :type config: baidubce.BceClientConfiguration
        :param config:
        N)r   __init__)selfconfig r   d/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/baidubce/services/eip/eip_bp_client.pyr
   ,   s   zEipBpClient.__init__)bandwidth_in_mbpsc                 C   s   d|i}|du r|du rt d|dur||d< |dur ||d< |dur(||d< |dur0||d< |dur8||d< |dur@||d	< |durH||d
< |  }|	du rT|  }	d|	i}| jtj|t|||
dS )aK  
        Create an eip_bp with the specified options.

        :type eip: string
        :param eip: the eip address that the eip_bp attach.
        Param "eip" and "eip_group_Id" will has only one param take effect.

        :type eip_group_Id: string
        :param eip_group_Id: the eipgroupId that the eip_bp attach.
        Param "eip" and "eip_group_Id" will has only one param take effect.

        :type bandwidth_in_mbps: int
        :param bandwidth_in_mbps: the bandwidth of eip_bp in Mbps.

        :type name: string
        :param name:the name of eipbp. The optional parameter.

        :type auto_release_time: string (UTC format,like yyyy:mm:ddThh:mm:ssZ)
        :param autoReleaseTime: the autoReleaseTime of eipbp. The optional parameter.

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: created eip_bp id, for example,{"id":"bw-xxxxxxxx"}
        bandwidthInMbpsNs4   eip and eip_group_Id can't be none at the same time.eipZ
eipGroupIdnameautoReleaseTimetypetagsZresourceGroupId   clientToken)bodyparamsr   )
ValueError	_get_path_generate_default_client_token_send_requestr   POSTjsondumps)r   r   Zeip_group_Idr   r   r   r   r   Zresource_group_idclient_tokenr   r   pathr   r   r   r   create_eip_bp3   s6   "

zEipBpClient.create_eip_bp)idnew_bandwidth_in_mbpsc                 C   N   d|i}t |  |}|du r|  }d|d}| jtj||t||dS )a  
        Resizing eip_bp

        :type id: string
        :param id: eip_bp's id to be resized

        :type new_bandwidth_in_mbps: int
        :param new_bandwidth_in_mbps: specify new bandwidth in Mbps for eip_bp

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        r   N    )s   resizer   r   r   r   	r   
append_urir   r   r   r   PUTr   r   )r   r#   r$   r    r   r   r!   r   r   r   r   resize_eip_bpt      
zEipBpClient.resize_eip_bp)r#   c                 C   s$   t |  |}| jtj|d|dS )a  
        get eip_bp's detail owned by the authenticated user and givened eip_bp_id.

        :type id: string
        :param eip: eip_bp's id.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: detail of eip_bp, for example:
                {
                    "autoReleaseTime": "2020-05-30T06:46:44Z",
                    "name": "EIP_BP1588821183401",
                    "instanceId": "ip-9340430e",
                    "createTime": "2020-05-07T03:13:03Z",
                    "id": "bw-5fb3ce39",
                    "eips": [
                        "100.88.9.120"
                    ],
                    "instanceBandwidthInMbps": 1,
                    "bandwidthInMbps": 2,
                    "bindType": "eip"
                }
        Nr   r   )r   r)   r   r   r   GET)r   r#   r   r!   r   r   r   get_eip_bp_detail   s   zEipBpClient.get_eip_bp_detail  c           
      C   s   |   }i }	|dur||	d< |dur||	d< |dur||	d< |dur&||	d< |dur.||	d< |dur6||	d< | jtj||	|dS )	a  
        get a list of eip_bp owned by the authenticated user and specified
        conditions. we can Also get a single eip_bp function  through this
        interface by eip_bp condition

        :type id: string
        :param id: eip_bp 's id conditions

        :type name: string
        :param name: eip_bp 's name condition

        :type bind_type: string
        :param bind_type: eip_bp 's bind_type condition, 'eip' or 'eipgroup'

        :type marker: string
        :param marker: The optional parameter marker specified in the original
         request to specify where in the results to begin listing.

        :type max_keys: int
        :param max_keys: The optional parameter to specifies the max number
         of list result to return. The default value is 1000.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: list of eip_bp model, for example:
                {
                    "marker": "bw-5fb3ce39",
                    "maxKeys": 1000,
                    "nextMarker": null,
                    "bpList": [
                        {
                            "autoReleaseTime": "2020-05-30T06:46:44Z",
                            "name": "EIP_BP1588821183401",
                            "instanceId": "ip-9340430e",
                            "createTime": "2020-05-07T03:13:03Z",
                            "id": "bw-5fb3ce39",
                            "eips": [
                                "100.88.9.120"
                            ],
                            "bandwidthInMbps": 2,
                            "bindType": "eip"
                        }
                    ],
                    "isTruncated": false
                }
       Ns   ids   names   bindTypes   types   markers   maxKeysr-   )r   r   r   r.   )
r   r#   r   Z	bind_typer   markerZmax_keysr   r!   r   r   r   r   list_eip_bps   s"   2zEipBpClient.list_eip_bps)r#   auto_release_timec                 C   r%   )a'  
        Update eip_bp's auto_release_time

        :type id: string
        :param id: eip_bp's id

        :type auto_release_time: string (UTC format,like yyyy:mm:ddThh:mm:ssZ)
        :param auto_release_time: specify auto_release_time for eip_bp

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        r   Nr&   )s   retimer   r'   r(   )r   r#   r3   r    r   r   r!   r   r   r   r   update_eip_bp_autoReleaseTime   r,   z)EipBpClient.update_eip_bp_autoReleaseTime)r#   r   c                 C   r%   )a  
        Update eip_bp's name

        :type id: string
        :param id: eip_bp's id

        :type name: string
        :param name: eip_bp's name

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        r   Nr&   )s   renamer   r'   r(   )r   r#   r   r    r   r   r!   r   r   r   r   rename_eip_bp  r,   zEipBpClient.rename_eip_bpc                 C   s<   t |  |}|du r|  }d|i}| jtj|||dS )a  
        release the eip_bp(delete operation)

        :type id: string
        :param id: eip_bp's id to be released

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        Nr   r-   )r   r)   r   r   r   r   DELETE)r   r#   r    r   r!   r   r   r   r   release_eip_bp<  s   zEipBpClient.release_eip_bpc                   C   s   t  S )z/
        default client token by uuid1
        )uuiduuid1r   r   r   r   r   V  s   z*EipBpClient._generate_default_client_tokenc                 C   s   | du rt j} tt j| S )zI
        :type prefix: string
        :param prefix: path prefix
        N)r	   prefixr   r)   version)r:   r   r   r   r   ]  s   zEipBpClient._get_pathc                 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_configg  s
   
zEipBpClient._merge_configc              
   C   sJ   |  |}|du rtj}|du rddd}t|tjtj|g|||||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_error)r   Zhttp_methodr!   r   headersr   r   Zbody_parserr   r   r   r   u  s   

zEipBpClient._send_request)N)NNNNNNN)NN)NNNNNr0   N)NNNNN)__name__
__module____qualname____doc__r;   r:   r
   r   intr"   strr+   r/   r2   r4   r5   r7   staticmethodr   r   r=   r   r   r   r   r   r	   %   sJ    

@!

C
!!
	r	   )rD   r<   r   loggingr8   Zbaidubcer   Zbaidubce.authr   Zbaidubce.bce_base_clientr   Zbaidubce.httpr   r   r   Zbaidubce.utilsr   	getLoggerrA   _loggerr	   r   r   r   r   <module>   s   
