o
    eF                    @   s   d Z ddl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 dd
lmZ ejdk rPed eeZG dd dejZdd ZeZdS )z.
This module provides a client class for BLB.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)utils)required)compat3zutf-8c                   @   s  e Zd ZdZdZdHddZdHddZ		dIdd	Zee	e
fe	e
fd
		dJddZ			dKddZee	e
fddHddZee	e
fd		dJddZee	e
fddLddZee	e
feee	e
fd					dMddZee	e
feee	e
fe	e
fd					dMddZee	e
feee	e
fd													dNddZee	e
feee	e
fed														dOd d!Zee	e
feee	e
fed							dPd"d#Zee	e
fd		dJd$d%Zee	e
fd		dJd&d'Zee	e
fd		dJd(d)Zee	e
fd		dJd*d+Zee	e
fd		dJd,d-Zee	e
fed.						dKd/d0Zee	e
feed1							dQd2d3Zee	e
fed.														dRd4d5Zee	e
fed.														dSd6d7Zee	e
fed.										dTd8d9Z ee	e
fed:dLd;d<Z!	 ee	e
fed=	dLd>d?Z"ee	e
fed.	dUd@dAZ#ee	e
fd		dUdBdCZ$ee	e
fed=	dLdDdEZ%ee	e
fed=	dLdFdGZ&dS )V	BlbClientz
    BLB base sdk client
    s   /v1Nc                 C   s   t j| | d S N)r   BceBaseClient__init__)selfconfig r   PD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/blb/blb_client.pyr   .   s   zBlbClient.__init__c                 C   s(   |du r| j S t| j }|| |S )zg
        :param config:
        :type config: baidubce.BceClientConfiguration
        :return:
        N)r   copyZmerge_non_none_values)r   r   Z
new_configr   r   r   _merge_config1   s
   
zBlbClient._merge_configc              
   C   sJ   |  |}|d u rtj}|d u rddd}t|tjtj|g|||||S )Ns   */*s   application/json;charset=utf-8)s   Accepts   Content-Type)r   r   Z
parse_jsonr   send_requestr   signZparse_error)r   Zhttp_methodpathbodyheadersparamsr   Zbody_parserr   r   r   _send_request>   s   

zBlbClient._send_request)vpc_id	subnet_idc           
      C   s   t | jd}i }|du rt |d< n||d< i }	|dur$t||	d< |dur/t||	d< t||	d< t||	d< | jtj|t	
|	||dS )	aI  
        Create a LoadBalancer with the specified options.

        :param name:
                the name of LoadBalancer to create
        :type name: string

        :param desc:
                The description of LoadBalancer
        :type desc: string

        :param vpc_id:
                id of vpc which the LoadBalancer belong to
        :type vpc_id: string

        :param subnet_id:
                id of subnet which the LoadBalancer belong to
        :type subnet_id: string

        :param client_token:
            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
        blbN   clientTokennamedescZvpcIdZsubnetIdr   r   r   r   
append_uriversiongenerate_client_tokenr	   convert_to_stringr   r   POSTjsondumps)
r   r   r   r    r!   client_tokenr   r   r   r   r   r   r   create_loadbalancerK   s    "

zBlbClient.create_loadbalancerc           
      C   s   t | jd}i }	|dur||	d< |dur||	d< |dur!||	d< |dur)||	d< |dur1||	d< |dur9||	d< | jtj||	|d	S )
a  
        Return a list of LoadBalancers

        :param address:
            Intranet service address in dotted decimal notation
        :type address: string

        :param name:
            name of LoadBalancer to describe
        :type name: string

        :param blb_id:
            id of LoadBalancer to describe
        :type blb_id: string

        :param bcc_id:
            bcc which bind the LoadBalancers
        :type bcc_id: string

        :param marker:
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result
            which listing should begin.
            If the marker is not specified, the list result will
            listing from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   Ns   addresss   names   blbIds   bccId   marker   maxKeysr   r   r   r$   r%   r   r   GET)
r   addressr    blb_idZbcc_idmarkermax_keysr   r   r   r   r   r   describe_loadbalancers   s"   +
z BlbClient.describe_loadbalancers)r3   c                 C   s"   t | jd|}| jtj||dS )a5  
        Return detail imformation of specific LoadBalancer

        :param blb_id:
            id of LoadBalancer to describe
        :type blb_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   )r   r0   )r   r3   r   r   r   r   r   describe_loadbalancer_detail   s   
z&BlbClient.describe_loadbalancer_detail)ZblbIdc           	      C   s|   t | jd|}i }|du rt |d< n||d< i }|dur%t||d< |dur0t||d< | jtj|t	
|||dS )a  
        Modify the special attribute to new value of the LoadBalancer
        owned by the user.

        :param name:
                name of LoadBalancer to describe
        :type name: string

        :param blb_id:
                id of LoadBalancer to describe
        :type blb_id: string

        :param desc:
                The description of LoadBalancer
        :type desc: string

        :param client_token:
                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   PUTr)   r*   )	r   r3   r    r!   r+   r   r   r   r   r   r   r   update_loadbalancer   s   zBlbClient.update_loadbalancerc                 C   sD   t | jd|}i }|du rt |d< n||d< | jtj|||dS )a  
        delete the LoadBalancer owned by the user.

        :param blb_id:
                id of LoadBalancer to describe
        :type blb_id: string

        :param client_token:
                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   DELETE)r   r3   r+   r   r   r   r   r   r   delete_loadbalancer  s   
zBlbClient.delete_loadbalancer)r3   listener_portbackend_port	schedulerc                 C   s   t | jd|d}i }|	du rt |d< n|	|d< ||t|d}|dur*||d< |dur2||d< |dur:||d< |durB||d	< | jtj|t	
|||
d
S )a  
        Create a tcp listener rule with the specified options.

        :param blb_id:
            the id of blb which the listener work on
        :type blb_id: string

        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int

        :param backend_port:
            port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int

        :param scheduler
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection' or 'Hash'
        :type scheduler: string

        :param health_check_timeout_in_second
            Health check timeout
        :value 1-60, default: 3, unit: seconds
        :type health_check_timeout_in_second: string

        :param health_check_interval
            Health check interval
        :value 1-10, default: 3, unit: seconds
        :type health_check_interval: string

        :param unhealthy_threshold
            Unhealthy threshold,
            how many consecutive health check failures,
            shielding the backend server
        :value 2-5, default: 3
        :type unhealthy_threshold: string

        :param healthy_threshold
            Health threshold,
            how many consecutive health checks are successful,
            then re-use the back-end server
        :value 2-5, default: 3
        :type healthy_threshold: string

        :param client_token:
            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   TCPlistenerNr   listenerPortbackendPortr>   healthCheckTimeoutInSecondhealthCheckIntervalunhealthyThresholdhealthyThresholdr"   r#   )r   r3   r<   r=   r>   health_check_timeout_in_secondhealth_check_intervalunhealthy_thresholdhealthy_thresholdr+   r   r   r   r   r   r   r   create_tcp_listener#  s,   D

zBlbClient.create_tcp_listener)r3   r<   r=   r>   health_check_stringc                 C   s   t | jd|d}i }|
du rt |d< n|
|d< ||t|t|d}|dur.||d< |dur6||d< |dur>||d< |	durF|	|d	< | jtj|t	
|||d
S )a  
        Create a udp listener rule with the specified options.

        :param blb_id:
            the id of blb which the listener work on
        :type blb_id: string

        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int

        :param backend_port:
            port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int

        :param scheduler
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection' or 'Hash'
        :type scheduler: string

        :param health_check_string
            The request string sent by the health,
            the backend server needs to respond after receiving it.
        :type health_check_string: string

        :param health_check_timeout_in_second
            Health check timeout
        :value 1-60, default: 3, unit: seconds
        :type health_check_timeout_in_second: string

        :param health_check_interval
            Health check interval
        :value 1-10, default: 3, unit: seconds
        :type health_check_interval: string

       :param unhealthy_threshold
            Unhealthy threshold,
            how many consecutive health check failures,
            shielding the backend server
        :value 2-5, default: 3
        :type unhealthy_threshold: string

        :param healthy_threshold
            Health threshold,
            how many consecutive health checks are successful,
            then re-use the back-end server
        :value 2-5, default: 3
        :type healthy_threshold: string

        :param client_token:
            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   UDPlistenerNr   )rA   rB   r>   healthCheckStringrC   rD   rE   rF   r"   r#   )r   r3   r<   r=   r>   rL   rG   rH   rI   rJ   r+   r   r   r   r   r   r   r   create_udp_listener  s.   J

zBlbClient.create_udp_listenerc                 C   sb  t | jd|d}i }|du rt |d< n||d< ||t|d}|dur*||d< |dur2||d< |dur:||d< |durB||d	< |	durJ|	|d
< |
durUt|
|d< |dur]||d< |durht||d< |durp||d< |durx||d< |dur||d< |dur||d< |durt||d< |dur||d< |dur||d< | jtj|t	
|||dS )a  
        Create a http listener rule with the specified options.
        :param blb_id:
            the id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection'
        :type scheduler: string
        :param keep_session:
            Whether to enable the session hold function,
            that is,the request sent by the same client will
            reach the same backend server
        :value true or false  default:false
        :type keep_session: bool
        :param keep_session_type:
            The cookie handling method maintained by the session,
            valid only if the session is held open
            :value 'insert' or 'rewrite'  default:insert
        :type keep_session_type: string
        :param keep_session_duration:
            The time the cookie is kept in session (in seconds),
            valid only if the session is held open
            :value 1-15552000  default:3600
        :type keep_session_duration: int
        :param keep_session_cookie_name:
            The session keeps the name of the cookie that needs to be
            overridden if and only if session persistence is enabled
            and keep_session_type="rewrite"
        :type keep_session_cookie_name: int
        :param x_forward_for:
            Whether to enable the real IP address of the client,
            the backend server can obtain the real address of the client
            through the X-Forwarded-For HTTP header.
        :value true or false, default: False
        :type x_forward_for: bool
        :param health_check_type:
            Health check protocol
        :value 'HTTP' or 'TCP'
        :type health_check_type: string
        :param health_check_port:
            Health check port, the default is the same as backend_port
        :type health_check_port: int
        :param health_check_uri:
            Health check URI, default '/'.
            Effective when the health check protocol is "HTTP"
        :type health_check_uri: string
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
            :value 1-60, default: 3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
            :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealthy_threshold:
            The unhealthy threshold, that is,
            how many consecutive health check failures,
            shields the backend server.
        :value 2-5, default: 3
        :type unhealthy_threshold: int
        :param healthy_threshold:
            Health threshold, that is,
            how many consecutive health checks are successful,
            then re-use the back-end server
        value: 2-5, default: 3
        :type health_threshold: int
        :param health_check_normal_status:
            The HTTP status code when the health check is normal supports
            a combination of five types of status codes,
            such as "http_1xx|http_2xx",
            Effective when the health check protocol is "HTTP"
        :value default:http_2xx|http_3xx
        :type health_check_normal_status:string
        :param server_timeout:
            Backend server maximum timeout (unit: second)
        :value 1-3600, default: 30
        :type server_timeout:int
        :param redirect_port:
            Forward the request received by this listener to the
            HTTPS listener, which is specified by the HTTPS listener.
        :type redirect_port:int
        :param client_token:
            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   HTTPlistenerNr   r@   keepSessionkeepSessionTypekeepSessionDurationkeepSessionCookieNamexForwardForhealthCheckTypehealthCheckPorthealthCheckURIrC   rD   rE   rF   healthCheckNormalStatusserverTimeoutredirectPortr"   r#   )r   r3   r<   r=   r>   keep_sessionkeep_session_typekeep_session_durationkeep_session_cookie_namex_forward_forhealth_check_typehealth_check_porthealth_check_urirG   rH   rI   rJ   health_check_normal_statusserver_timeoutredirect_portr+   r   r   r   r   r   r   r   create_http_listener  s^   t

zBlbClient.create_http_listener)r3   r<   r=   r>   cert_idsc                 C   s  t | jd|d}i }|du rt |d< n||d< ||t||d}|dur+||d< |dur6t||d< |dur>||d< |	durF|	|d	< |
durN|
|d
< |durYt||d< |dura||d< |durlt||d< |durt||d< |dur|||d< |dur||d< |dur||d< |durt||d< |dur||d< |dur||d< |durt||d< |dur||d< |dur||d< |dur||d< | jtj|t	
|||dS )a   
        Create a https listener rule with the specified options
        :param blb_id:
            The id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            Port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection'
        :type scheduler: string
        :param cert_ids:
            The certificate to be loaded by the listener.
        :type cert_ids: List<String>
        :param keep_session:
            Whether to enable the session hold function,
            that is, the request sent by the same client will reach the
            same backend server
        :value true or false, default: false
        :type keep_session: bool
        :param keep_session_type:
            The cookie handling method maintained by the session,
            valid only if the session is held open
        :value 'insert' or 'rewrite', default:insert
        :type keep_session_type: string
        :param keep_session_duration:
            The time the cookie is kept in session (in seconds),
            valid only if the session is held open
        :value 1-15552000, default:3600
        :type keep_session_duration: int
        :param keep_session_cookie_name:
            The session keeps the name of the cookie that needs
            to be overridden if and only if session persistence
            is enabled and keep_session_type="rewrite"
        :type keep_session_cookie_name: int
        :param x_forward_for:
            Whether to enable the real IP address of the client,
            the backend server can obtain the real address of the client
            through the X-Forwarded-For HTTP header.
        :value true or false, default: flase
        :type x_forward_for: bool
        :param health_check_type:
            Health check protocol
        :value 'HTTP' or 'TCP'
        :type health_check_type: string
        :param health_check_port:
            Health check port, the default is the same as backend_port
        :type health_check_port: int
        :param health_check_uri:
            Health check URI, default '/'.
            Effective when the health check protocol is "HTTP"
        :type health_check_uri: string
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
            :value 1-60, default:3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
        :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealth_threshold:
            The unhealthy threshold, that is, how many consecutive health
             check failures, shields the backend server.
        :value 2-5, default: 3
        :type unhealth_threshold: int
        :param health_threshold:
            Health threshold, that is, how many consecutive health checks
             are successful, then re-use the back-end server
        :value:2-5, default: 3
        :type health_threshold: int
        :param health_check_normal_status:
            The HTTP status code when the health check is normal
            supports a combination of five types of status codes,
            such as "http_1xx|http_2xx", Effective when the health check
            protocol is "HTTP"
        :value default: http_2xx|http_3xx
        :type health_check_normal_status: string
        :param server_timeout:
            Backend server maximum timeout (unit: second)
        :value 1-3600, default: 30
        :type server_timeout: int
        :param ie6_compatible:
            compatible with IE6 HTTPS request
            (the protocol format is earlier SSL3.0, the security is poor)
        :value true or false, default: true
        :type ie6_compatible: bool
        :param encryption_type:
            Encryption options, support three types:
            compatibleIE or incompatibleIE or userDefind,
            corresponding to:
            IE-compatible encryption or disabled unsecure encryption
            or custom encryption,
            when encryptionType is valid and legitimate,
            ie6Compatible field transfer value will not take effect
        type: encryption_type:string
        :param encryption_protocols:
            When the encryptionType value is userDefind,
            the list of protocol types is a string list composed of four protocols:
            "sslv3", "tlsv10", "tlsv11", "tlsv12".
        type: encryption_protocols:list
        :param dual_auth:
            Whether to Open Two-way Authentication,
            default:false
        :type dual_auth: boolean
        :param client_certIds:
            When dualAuth is true, the loaded client certificate chain
        :type client_certIds: list
        :param client_token:
            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   HTTPSlistenerNr   rA   rB   r>   certIdsrQ   rR   rS   rT   rU   rV   rW   rX   rC   rD   rE   rF   rY   rZ   ie6CompatibleencryptionTypeencryptionProtocolsdualAuthclientCertIdsr"   r#   )r   r3   r<   r=   r>   rh   r\   r]   r^   r_   r`   ra   rb   rc   rG   rH   unhealth_thresholdhealth_thresholdrd   re   ie6_compatibleencryption_typeencryption_protocols	dual_authclient_certIdsr+   r   r   r   r   r   r   r   create_https_listener  st    
zBlbClient.create_https_listenerc                 C   s   t | jd|d}i }|du rt |d< n||d< ||t||d}|dur+||d< |dur3||d< |dur;||d< |	durC|	|d	< |
durK|
|d
< |durVt||d< |dur^||d< |durf||d< |durn||d< | jtj|t	
|||dS )aP  
        Create a ssl listener rule with thSe specified options.
        :param blb_id:
            The id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            Port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection'
        :type scheduler: string
        :param cert_ids:
            The SSL certificate to be loaded by the listener.
            Currently HTTPS listeners can only bind one SSL certificate.
        :type cert_ids: List<String>
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
            :value 1-60, default:3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
        :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealth_threshold:
            The unhealthy threshold, that is, how many consecutive health
             check failures, shields the backend server.
        :value 2-5, default: 3
        :type unhealth_threshold: int
        :param health_threshold:
            Health threshold, that is, how many consecutive health checks
             are successful, then re-use the back-end server
        :value:2-5, default: 3
        :type health_threshold: int
        :param ie6_compatible:
            compatible with IE6 HTTPS request
            (the protocol format is earlier SSL3.0, the security is poor)
        :value true or false, default: true
        :type ie6_compatible: bool
        :param encryption_type:
            Encryption options, support three types:
            compatibleIE or incompatibleIE or userDefind,
            corresponding to:
            IE-compatible encryption or disabled unsecure encryption
            or custom encryption,
            when encryptionType is valid and legitimate,
            ie6Compatible field transfer value will not take effect
        type: encryption_type:string
        :param encryption_protocols:
            When the encryptionType value is userDefind,
            the list of protocol types is a string list composed of four protocols:
            "sslv3", "tlsv10", "tlsv11", "tlsv12".
        type: encryption_protocols:list
        :param dual_auth:
            Whether to Open Two-way Authentication,
            default:false
        :type dual_auth: boolean
        :param client_certIds:
            When dualAuth is true, the loaded client certificate chain
        :type client_certIds: list
        :param client_token:
            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   SSLlistenerNr   rj   rC   rD   rE   rF   rl   rm   rn   ro   rp   r"   r#   )r   r3   r<   r=   r>   rh   rG   rH   rq   rr   rs   rt   ru   rv   rw   r+   r   r   r   r   r   r   r   create_ssl_listenerS  sB   U
zBlbClient.create_ssl_listenerc                 C   Z   t | jd|d}i }|dur||d< |dur||d< |dur#||d< | jtj|||dS )a  
        get tcp listeners identified by bibID

        :param blb_id
             the id of blb which the listener work on
        :type blb_id:string

        :param listener_port
             The listener port to query
        :type listener_port:int

        :param marker
            The optional parameter marker specified in the
            original request to specify
            where in the results to begin listing.
            Together with the marker, specifies the list result
            which listing should begin.
            If the marker is not specified, the list result will
            listing from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r?   N   listenerPortr-   r.   r/   r0   r   r3   r<   r4   r5   r   r   r   r   r   r   describe_tcp_listener  s   $
zBlbClient.describe_tcp_listenerc                 C   r{   )a  
        get udp listeners identified by bibID

        :param blb_id
             the id of blb which the listener work on
        :type blb_id:string

        :param listener_port
             The listener port to query
        :type listener_port:int

        :param marker
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result which
            listing should begin.
            If the marker is not specified, the list result will
            listing from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rM   Nr|   r-   r.   r/   r0   r}   r   r   r   describe_udp_listener     #
zBlbClient.describe_udp_listenerc                 C   r{   )a  
        get http listeners identified by blbID

        :param blb_id
             the id of blb which the listener work on
        :type blb_id:string

        :param listener_port
             The listener port to query
        :type listener_port:int

        :param marker
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result which
            listing should begin.
            If the marker is not specified, the list result will listing
            from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rP   Nr|   r-   r.   r/   r0   r}   r   r   r   describe_http_listener-  r   z BlbClient.describe_http_listenerc                 C   r{   )a  
        get https listeners identified by bibID

        :param blb_id
             the id of blb which the listener work on
        :type blb_id:string

        :param listener_port
             The listener port to query
        :type listener_port:int

        :param marker
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result which
            listing should begin.
            If the marker is not specified, the list result will listing
            from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   ri   Nr|   r-   r.   r/   r0   r}   r   r   r   describe_https_listener]  r   z!BlbClient.describe_https_listenerc                 C   r{   )a  
        get ssl listeners identified by bibID

        :param blb_id
             the id of blb which the listener work on
        :type blb_id:string

        :param listener_port
             The listener port to query
        :type listener_port:int

        :param marker
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result which
            listing should begin.
            If the marker is not specified, the list result will listing
            from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   ry   Nr|   r-   r.   r/   r0   r}   r   r   r   describe_ssl_listener  r   zBlbClient.describe_ssl_listener)r3   r<   c
                 C   s   t | jd|d}
i }||d< i }|dur||d< |dur$t||d< |dur,||d< |dur4||d< |dur<||d	< |durD||d
< | jtj|
t	|||	dS )a  
        update a tcp listener rule with the specified options.

        :param blb_id:
            the id of blb which the listener work on
        :type blb_id:string

        :param listener_port:
             port to be linstened owned by listener
        :value 1-65535
        :type listener_port:int

        :param backend_port:
            port to be listened owned by Backend server
        :value 1-65535
        :type backend_port:int

        :param scheduler
            balancing algorithm
        :value 'RoundRobin'or'LeastConnection'or'Hash'
        :type scheduler:string

        :param health_check_timeout_in_second
            Health check timeout
        :value 1-60  default:3 unit:seconds
        :type health_check_timeout_in_second:string

        :param health_check_interval
            Health check interval
        :value 1-10 default:3 unit:seconds
        :type health_check_interval:string

        :param unhealth_threshold
            Unhealthy threshold,
             how many consecutive health check failures,
             shielding the backend server
        :value 2-5 default:3
        :type unhealth_threshold:string

        :param health_threshold
            Health threshold,
            how many consecutive health checks are successful,
            then re-use the back-end server
        :value 2-5 default:3
        :type health_threshold:string

         :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r?   r|   NrB   r>   rC   rD   rE   rF   r"   
r   r$   r%   r	   r'   r   r   r8   r)   r*   )r   r3   r<   r=   r>   rG   rH   rq   rr   r   r   r   r   r   r   r   update_tcp_listener  s*   =

zBlbClient.update_tcp_listener)r3   r<   r=   c                 C   s   t | jd|d}i }||d< i }|dur||d< |dur$t||d< |dur/t||d< |dur7||d< |dur?||d	< |durG||d
< |	durO|	|d< | jtj|t	|||
dS )a2  
        update a udp listener rule with the specified options.

        :param blb_id:
                the id of blb which the listener work on
        :type blb_id:string

        :param listener_port:
                port to be linstened owned by listener
        :value 1-65535
        :type listener_port:int

        :param backend_port:
                port to be listened owned by Backend server
        :value 1-65535
        :type backend_port:int

        :param scheduler
              balancing algorithm
        :value 'RoundRobin'or'LeastConnection'or'Hash'
        :type scheduler:string

        :param health_check_string
              The request string sent by the health,
              the backend server needs to respond after receiving it,
              and supports standard escaping
        :type health_check_string:string

        :param health_check_timeout_in_second
                Health check timeout
        :value 1-60  default:3 unit:seconds
        :type health_check_timeout_in_second:string

        :param health_check_interval
                Health check interval
        :value 1-10 default:3 unit:seconds
        :type health_check_interval:string

        :param unhealth_threshold
                Unhealthy threshold,
                 how many consecutive health check failures,
                 shielding the backend server
        :value 2-5 default:3
        :type unhealth_threshold:string

        :param health_threshold
                Health threshold,
                how many consecutive health checks are successful,
                then re-use the back-end server
        :value 2-5 default:3
        :type health_threshold:string

         :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rM   r|   NrB   r>   rN   rC   rD   rE   rF   r"   r   )r   r3   r<   r=   r>   rL   rG   rH   rq   rr   r   r   r   r   r   r   r   update_udp_listener  s0   D
zBlbClient.update_udp_listenerc                 C   sl  t | jd|d}i }||d< i }|dur||d< |dur$t||d< |dur,||d< |dur7t||d< |dur?||d	< |durG||d
< |	durO|	|d< |
durZt|
|d< |durb||d< |durmt||d< |duru||d< |dur}||d< |dur||d< |dur||d< |durt||d< |dur||d< |dur||d< | jtj|t	|||dS )a  
        update a http listener rule with the specified options.
        :param blb_id:
            The id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            Port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            Balancing algorithm
        :value 'RoundRobin' or 'LeastConnection' or 'Hash'
        :type scheduler: string
        :param keep_session:
            Whether to enable the session hold function, that is,
            the request sent by the same client will reach the
            same backend server
        :value true or false, default:false
        :type keep_session: bool
        :param keep_session_type:
            The cookie handling method maintained by the session,
            valid only if the session is held open
        :value 'insert' or 'rewrite', default:insert
        :type keep_session_type: string
        :param keep_session_duration:
            The time the cookie is kept in session (in seconds),
            valid only if the session is held open
        :value 1-15552000, default:3600
        :type keep_session_duration: int
        :param keep_session_cookie_name:
            The session keeps the name of the cookie that needs
            to be overridden,if and only if session persistence is
            enabled and keep_session_type="rewrite"
        :type keep_session_cookie_name: int
        :param x_forward_for:
            Whether to enable the real IP address of the client,
            the backend server can obtain the real address of the
            client through the X-Forwarded-For HTTP header.
        :value true or false, default: flase
        :type x_forward_for: bool
        :param health_check_type:
            Health check protocol
        :value 'HTTP' or 'TCP'
        :type health_check_type: string
        :param health_check_port:
            Health check port, the default is the same as backend_port
        :type health_check_port: int
        :param health_check_uri:
            Health check URI, default '/'.
            Effective when the health check protocol is "HTTP"
        :type health_check_uri: string
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
        :value 1-60, default: 3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
        :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealth_threshold:
            The unhealthy threshold, that is, how many consecutive health
            check failures, shields the backend server.
        :value 2-5, default: 3
        :type unhealth_threshold: int
        :param health_threshold:
            Health threshold, that is, how many consecutive health checks
            are successful, then re-use the back-end server
        :value:2-5, default: 3
        :type health_threshold: int
        :param health_check_normal_status:
            The HTTP status code when the health check is normal supports
            a combination of five types of status codes,
            such as "http_1xx|http_2xx", Effective when the health check
            protocol is "HTTP"
        :value default: http_2xx|http_3xx
        :type health_check_normal_status: string
        :param server_timeout:
            Backend server maximum timeout (unit: second)
        :value 1-3600, default: 30
        :type server_timeout: int
        :param redirect_port:
            Forward the request received by this listener to the HTTPS
            listener, which is specified by the HTTPS listener.
        :type redirect_port: int
        :param config:
        :type config: baidubce.BceClientConfiguration
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   rP   r|   NrB   r>   rQ   rR   rS   rT   rU   rV   rW   rX   rC   rD   rE   rF   rY   rZ   r[   r"   r   )r   r3   r<   r=   r>   r\   r]   r^   r_   r`   ra   rb   rc   rG   rH   rq   rr   rd   re   rf   r   r   r   r   r   r   r   update_http_listenerq  s^   m
zBlbClient.update_http_listenerc                 C   s|  t | jd|d}i }||d< i }|dur||d< |dur$t||d< |dur,||d< |dur7t||d< |dur?||d	< |durG||d
< |	durO|	|d< |
durZt|
|d< |durb||d< |durmt||d< |duru||d< |dur}||d< |dur||d< |dur||d< |durt||d< |dur||d< |dur||d< |dur||d< | jtj|t	|||dS )a  
        update a https listener rule with the specified options.
        :param blb_id:
            The id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            Port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            Port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            Balancing algorithm
        :value 'RoundRobin' or 'LeastConnection' or 'Hash'
        :type scheduler: string
        :param keep_session:
            Whether to enable the session hold function, that is, the request
            sent by the same client will reach the same backend server
        :value true or false, default: false
        :type keep_session: bool
        :param keep_session_type:
            The cookie handling method maintained by the session,
            valid only if the session is held open
        :value 'insert' or 'rewrite', default: insert
        :type keep_session_type: string
        :param keep_session_duration:
            The time the cookie is kept in session (in seconds),
            valid only if the session is held open
        :value 1-15552000, default:3600
        :type keep_session_duration: int
        :param keep_session_cookie_name:
            The session keeps the name of the cookie that needs to be
            overridden,if and only if session persistence is enabled and
            keep_session_type="rewrite"
        :type keep_session_cookie_name: int
        :param x_forward_for:
            Whether to enable the real IP address of the client,
            the backend server can obtain the real address of the client
            through the X-Forwarded-For HTTP header.
        :value true or false, default: False
        :type x_forward_for: bool
        :param health_check_type:
            Health check protocol
        :value 'HTTP' or 'TCP'
        :type health_check_type: string
        :param health_check_port:
            Health check port, the default is the same as backend_port
        :type health_check_port: int
        :param health_check_uri:
            Health check URI, default '/'.
            Effective when the health check protocol is "HTTP"
        :type health_check_uri: string
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
        :value 1-60, default: 3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
        :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealth_threshold:
            The unhealthy threshold, that is, how many consecutive health
            check failures, shields the backend server.
        :value 2-5, default: 3
        :type unhealth_threshold: int
        :param health_threshold:
            Health threshold, that is, how many consecutive health checks
            are successful, then re-use the back-end server
        :value:2-5, default: 3
        :type health_threshold: int
        :param health_check_normal_status:
            The HTTP status code when the health check is normal supports
            a combination of five types of status codes,
            such as "http_1xx|http_2xx", Effective when the health check
            protocol is "HTTP"
        :value default: http_2xx|http_3xx
        :type health_check_normal_status: string
        :param server_timeout:
            Backend server maximum timeout (unit: second)
        :value 1-3600, default: 30
        :type server_timeout: int
        :param cert_ids:
            The SSL certificate to be loaded by the listener.
            Currently HTTPS listeners can only bind one SSL certificate.
        :type cert_ids:List<String>
        :param ie6_compatible:
            Is it compatible with IE6 HTTPS request
            (the protocol format is earlier SSL3.0, the security is poor)
        :value true or false, default: true
        :type ie6_compatible: bool
        :param config:
        :type config: baidubce.BceClientConfiguration
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   ri   r|   NrB   r>   rQ   rR   rS   rT   rU   rV   rW   rX   rC   rD   rE   rF   rY   rZ   rk   rl   r"   r   )r   r3   r<   r=   r>   r\   r]   r^   r_   r`   ra   rb   rc   rG   rH   rq   rr   rd   re   rh   rs   r   r   r   r   r   r   r   update_https_listener  sb   q

zBlbClient.update_https_listenerc                 C   s
  t | jd|d}i }||d< i }|dur||d< |dur$t||d< |dur,||d< |dur4||d< |dur<||d	< |durD||d
< |	durL|	|d< |
durT|
|d< |dur_t||d< |durg||d< |duro||d< |durw||d< | jtj|t	|||dS )a  
        update a ssl listener rule with the specified options.
        :param blb_id:
            The id of blb which the listener work on
        :type blb_id: string
        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int
        :param backend_port:
            Port to be listened owned by Backend server
        :value 1-65535
        :type backend_port: int
        :param scheduler:
            balancing algorithm
        :value 'RoundRobin' or 'LeastConnection'
        :type scheduler: string
        :param health_check_timeout_in_second:
            Health check timeout (unit: second)
            :value 1-60, default:3
        :type health_check_timeout_in_second: int
        :param health_check_interval:
            Health check interval (unit: second)
        :value 1-10, default: 3
        :type health_check_interval: int
        :param unhealth_threshold:
            The unhealthy threshold, that is, how many consecutive health
             check failures, shields the backend server.
        :value 2-5, default: 3
        :type unhealth_threshold: int
        :param health_threshold:
            Health threshold, that is, how many consecutive health checks
             are successful, then re-use the back-end server
        :value:2-5, default: 3
        :type health_threshold: int
        :param cert_ids:
            The SSL certificate to be loaded by the listener.
            Currently HTTPS listeners can only bind one SSL certificate.
        :type cert_ids: List<String>
        :param ie6_compatible:
            compatible with IE6 HTTPS request
            (the protocol format is earlier SSL3.0, the security is poor)
        :value true or false, default: true
        :type ie6_compatible: bool
        :param encryption_type:
            Encryption options, support three types:
            compatibleIE or incompatibleIE or userDefind,
            corresponding to:
            IE-compatible encryption or disabled unsecure encryption or
            custom encryption,
            when encryptionType is valid and legitimate,
            ie6Compatible field transfer value will not take effect
        type: encryption_type:string
        :param encryption_protocols:
            When the encryptionType value is userDefind,
            the list of protocol types is a string list composed of four protocols:
            "sslv3", "tlsv10", "tlsv11", "tlsv12".
        type: encryption_protocols:list
        :param dual_auth:
            Whether to Open Two-way Authentication,
            default:false
        :type dual_auth: boolean
        :param client_certIds:
            When dualAuth is true, the loaded client certificate chain
        :type client_certIds: list
        :param config:
        :type config: baidubce.BceClientConfiguration
        :return
        :rtype baidubce.bce_response.BceResponse
        r   ry   r|   NrB   r>   rC   rD   rE   rF   rk   rl   rm   rn   ro   rp   r"   r   )r   r3   r<   r=   r>   rG   rH   rq   rr   rh   rs   rt   ru   rv   rw   r   r   r   r   r   r   r   update_ssl_listener  sD   R
zBlbClient.update_ssl_listener)r3   portListc                 C   b   t | jd|d}i }d|d< |du rt |d< n||d< i }||d< | jtj|t|||dS )a  
        Release the listener under the specified LoadBalancer,
        the listener is specified by listening to the port.

        :param blb_id:
            id of LoadBalancer
        :type blb_id:string

        :param portList:
            The ports of listeners to be released
        :type portList:list<int>

        :param client_token:
            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   listenerNs   batchdeleter   r   r"   	r   r$   r%   r&   r   r   r8   r)   r*   )r   r3   r   r+   r   r   r   r   r   r   r   delete_listeners$  s   

zBlbClient.delete_listeners)r3   backend_server_listc                 C   Z   t | jd|d}i }|du rt |d< n||d< i }||d< | jtj|t|||dS )ao  
        Add a backend server for the specified LoadBalancer,
        support batch add

        :param blb_id:
                id of LoadBalancer
        :type blb_id:string

        :param backend_server_list
                List of backend servers to be added
        :type backend_server_list:List<BackendServerModel>
        BackendServerModel{:param:instanceId
                               id of  Backend server
                           :type instanceId:string

                           :param weight
                               Backend server weight, value range [0, 100],
                               weight 0 means not to forward traffic to
                               the backend server
                           :type weight:int
                          }

        :param client_token:
            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   backendserverNr   backendServerListr"   )	r   r$   r%   r&   r   r   r(   r)   r*   r   r3   r   r+   r   r   r   r   r   r   r   add_backend_serversS  s   %

zBlbClient.add_backend_serversc                 C   sR   t | jd|d}i }||d< |dur||d< |dur||d< | jtj|||dS )a7  
        Query the information about the backend server under the specified
        LoadBalancer identified by listenPort

        :param blb_id:
            id of LoadBalancer
        :type blb_id: string

        :param listener_port:
            port to be linstened owned by listener
        :value 1-65535
        :type listener_port: int

        :param marker:
            The optional parameter marker specified in the original request
            to specify where in the results to begin listing.
            Together with the marker, specifies the list result which listing
            should begin. If the marker is not specified, the list result will
            listing from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   r|   Nr-   r.   r/   r0   r}   r   r   r   describe_health_status  s   %z BlbClient.describe_health_statusc                 C   sJ   t | jd|d}i }|dur||d< |dur||d< | jtj|||dS )a~  
        Query the list of backend servers under the specified LoadBalancer

        :param blb_id:
            Id of LoadBalancer
        :type blb_id:string

        :param marker:
            The optional parameter marker specified in the original
            request to specify where in the results to begin listing.
            Together with the marker, specifies the list result which
            listing should begin. If the marker is not specified,
            the list result will listing from the first one.
        :type marker: string

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

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r   Nr-   r.   r/   r0   )r   r3   r4   r5   r   r   r   r   r   r   describe_backend_servers  s   z"BlbClient.describe_backend_serversc                 C   r   )as  
        update the information about the backend server under
        the specified LoadBalancer

        :param blb_id:
            id of LoadBalancer
        :type blb_id:string

        :param backend_server_list:
            List of backend servers to be updated
        :type backend_server_list:List<BackendServerModel>
        BackendServerModel{:param:instanceId
                              id of  Backend server
                           :type instanceId:string

                           :param weight
                               Backend server weight, value range [0, 100],
                               weight 0 means not to forward traffic to
                               the backend server
                           :type weight:int
                          }

        :param client_token:
            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   r   Ns   updater   r   r"   r   r   r   r   r   update_backend_servers  s   %

z BlbClient.update_backend_serversc                 C   r   )a  
        Release the backend server under the specified LoadBalancer,
        which is specified by its backend server

        :param blb_id:
                id of LoadBalancer
        :type blb_id:string

        :param backend_server_list:
                List of backend servers to be removed
        :type backend_server_list:List<string>

        :param client_token:
                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   r   Nr   r   r"   r   r   r   r   r   remove_backend_servers  s   

z BlbClient.remove_backend_serversr   )NNNNN)NNNN)NNNNNNN)NN)NNNNNN)NNNNNNNNNNNNNNNNN)NNNNNNNNNNNNNNNNNNNNN)NNNNNNNNNNN)NNNNNNNN)NNNNNNNNNNNNNNNNNN)NNNNNNNNNNNNNNNNNNN)NNNNNNNNNNNNN)NNN)'__name__
__module____qualname____doc__r%   r   r   r   r   bytesstrr,   r6   r7   r9   r;   intrK   rO   rg   listrx   rz   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   (   s   


4
>0\
b 
#
 
D
w0////S\  "s)30(4r   c                   C   s   t t S )z
    The default method to generate the random string for client_token
    if the optional parameter client_token is not specified by the user.

    :return:
    :rtype string
    )r   uuiduuid4r   r   r   r   generate_client_token_by_uuidD  s   r   )r   r   r)   loggingr   sysZbaidubcer   Zbaidubce.authr   Zbaidubce.httpr   r   r   r   Zbaidubce.utilsr   r	   r%   Zsetdefaultencoding	getLoggerr   Z_loggerr   r   r   r&   r   r   r   r   <module>   sH   


                ,