o
    #jA                    @   s   d Z ddlZddlZddlZddlZddlmZmZmZ ddl	m
Z
 ddlmZmZmZ ddlmZmZ ddlmZ ejd dkrFeefZneefZd	ZG d
d dejZdS )z.
This module provides a client class for BCM.
    N)bce_base_clientutilscompat)bce_v1_signer)handlerbce_http_clienthttp_methods)bcm_handler	bcm_model)required   d   c                   @   s(  e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdddZdddZ		dddZ		dddZ	dddZ	dddZ			dddZ			dddZdddZdddZdd d!Zdd"d#Z	dd$d%Zdd&d'Z	dd(d)Z	dd*d+Zdd,d-Z	dd.d/Zdd0d1Z	dd2d3Z 	dd4d5Z!dd6d7Z"e#e$e$d8dd9d:Z%e#e$e$d8dd;d<Z&e#e$e$e'e'd=dd>d?Z(d@dA Z)e#e$e$d8ddBdCZ*e#e$e$e'e'd=		ddDdEZ+dFdG Z,	ddHdIZ-	ddJdKZ.ddLdMZ/dNdO Z0dPdQ Z1e#e$e$d8		ddRdSZ2e#e'dT		V	VddWdXZ3e#e'dT		V	VddYdZZ4dd[d\Z5dd]d^Z6		dd_d`Z7ddadbZ8ddcddZ9ddedfZ:ddgdhZ;ddidjZ<ddkdlZ=		ddmdnZ>ddodpZ?ddqdrZ@ddsdtZAddudvZBddwdxZC	ddydzZDdd{d|ZEdd}d~ZFdddZGdddZH		dddZIe#eJeJe'ddddZKdddZLdddZMe#eJeJeJe$eJe$eJeJeJe$e'e'd		dddZNdddZOdddZPe#eJeJeJeJe$eJe$eJeJeJe$e'e'd		dddZQdddZRdddZSdddZTdddZUdddZVe#e$e$eWeWeWd			dddZXe#e$e$eWeWeWd			dddZYe#eWeWeWeWe'ddd ZZe#eWeWeWeWeWddd Z[e#eWeWeWeWeWeWddd Z\e#eWeWddd Z]e#eWeWddd Z^e#eWe$e$ddd Z_e#eWeWe'ddd Z`e#eWeWe'ddd Zae#eWeWeWeWeWeWe$e$ddd Zbe#eWeWeWeWeWeWeWe$e$d	dd Zce#eWeWeWeWeWeWeWeWeWe$e$dÍddń ZddddǄZe			dddɄZf			ddd˄Zg			ddd̈́Zh			dddτZidddфZj			dddӄZk			dddՄZldddׄZm			dddلZn			dddۄZoddd݄Zp			ddd߄Zq			dddZrdddZs			dddZt			dddZudddZv			dddZw			dddZxdddZy			dddZz			dddZ{dddZ|dddZ}dddZ~dddZ				dddZddd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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d'd(Z	V	V		dd*d+Z	V	V		dd,d-Zdd.d/Zdd0d1Zdd2d3Ze#e'e$e$e$d4				V	Vdd5d6Ze#e'd7d8d9 Ze#e'e$e$e$d4				V	Vdd:d;Zdd<d=Zd>d? Zd@dA ZdBdC Z	F	ddGdHZ		ddIdJZdKdL Z		ddMdNZ		ddOdPZdQdR ZddSdTZddUdVZe#eWeWeWeWe'e'eWe'e$dW			ddXdYZ		ddZd[Z	\dd]d^Z	\dd_d`Z	ddbdcZ		ddddeZ		ddfdgZddhdiZddjdkZddldmZ			ddndoZddpdqZ			ddrdsZ	ddtduZ		ddvdwZddxdyZ			ddz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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ddZdS (  	BcmClientz
    BCM base sdk client
    s	   /json-apis   /csm/apis
   /event-apis   /v1/event-bus   /v1   /v2s   content-types   application/json;charset=UTF-8s   x-bce-request-idNc                 C   s   t j| | d S N)r   BceBaseClient__init__)selfconfig r   a/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/baidubce/services/bcm/bcm_client.pyr   4   s   zBcmClient.__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_config7   s
   
zBcmClient._merge_configc              
   C   sD   |  |}|d u rtj}t|tjtj|g|tj	tj
 | |||S r   )r   r   
parse_jsonr   send_requestr   signparse_errorr   prefixversionr   http_methodpathbodyheadersparamsr   body_parserr   r   r   _send_request?   s   
zBcmClient._send_requestc	           	   
   C   s|   |  |}|d u rtj}|d u ri }| j|vr| j|| j< | j|vr)t || j< t	|t
jtj|g|tj| | |||S r   )r   r   r   content_type_header_keycontent_type_header_valuerequest_id_header_keyuuiduuid4r   r   r   r   r	   r   r   
csm_prefix)	r   r!   r"   r   r#   r$   r%   r   r&   r   r   r   _send_csm_requestJ   s   


zBcmClient._send_csm_requestc              
   C   s~   |  |}|d u rtj}|d u ri }| j|vr| j|| j< | j|vr)t || j< t	|t
jtj|g|tjtj | |||S r   )r   r   r   r(   r)   r*   r+   r,   r   r   r   r   r	   r   r   event_prefixr   r    r   r   r   _send_event_requestZ   s   


zBcmClient._send_event_requestc              
   C   sx   |  |}|d u rtj}|d u ri }| j|vr| j|| j< | j|vr)t || j< t	|t
jtj|g|tj| |||S r   )r   r   r   r(   r)   r*   r+   r,   r   r   r   r   r	   r   r   	eb_prefixr    r   r   r   _send_eb_requestj   s   


zBcmClient._send_eb_requestc
                 C   s   t |}t |}t |}d|||f }
i }|dur ||d< |dur(||d< |dur0||d< |dur8||d< |dur@||d< | jtj|
||	dS )	a  
        Return metric data of product instances owned by the authenticated user.

        This site may help you: https://cloud.baidu.com/doc/BCM/s/9jwvym3kb

        :param user_id:
            Master account ID
        :type user_id: string

        :param scope:
            Cloud product namespace, eg: BCE_BCC.
        :type scope: string

        :param metric_name:
            The metric name of baidu cloud monitor, eg: CpuIdlePercent.
        :type metric_name: string

        :param dimensions:
            Consists of dimensionName: dimensionValue.
            Use semicolons when items have multiple dimensions,
            such as dimensionName: dimensionValue; dimensionName: dimensionValue.
            Only one dimension value can be specified for the same dimension.
            eg: InstanceId:fakeid-2222
        :type dimensions: string

        :param statistics:
            According to the format of statistics1,statistics2,statistics3,
            the optional values are `average`, `maximum`, `minimum`, `sum`, `sampleCount`
        :type statistics: string

        :param start_time:
            Query start time.
            Please refer to the date and time, UTC date indication
        :type start_time: string

        :param end_time:
            Query end time.
            Please refer to the date and time, UTC date indication
        :type end_time: string

        :param period_in_second:
            Statistical period.
            Multiples of 60 in seconds (s).
        :type period_in_second: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /metricdata/%s/%s/%sN
   dimensions   statistics[]	   startTime   endTime   periodInSecondr%   r   r   convert_to_bytesr'   r   GETr   user_idscopemetric_name
dimensions
statistics
start_timeend_timeZperiod_in_secondr   r"   r%   r   r   r   get_metric_dataz   s    
6

zBcmClient.get_metric_datac
                 C   s   t |}t |}d||f }
i }|dur||d< |dur"||d< |dur*||d< |dur2||d< |dur:||d< |durB||d< | jtj|
||	d	S )
aa  
            Return batch metric data of product instances owned by the authenticated user.

            :param user_id:
                Master account ID
            :type user_id: string

            :param scope:
                Cloud product namespace, eg: BCE_BCC.
            :type scope: string

            :param metric_name:
                The metric name of baidu cloud monitor, eg: CpuIdlePercent.
                Use comma when items have multiple metrics,
                such as metric1,metric2,metric3.
            :type metric_name: string

            :param dimensions:
                Consists of dimensionName:dimensionValue.
                Use comma when items have multiple dimensions,
                such as dimensionName:dimensionValue,dimensionName:dimensionValue.
                Only one dimension value can be specified for the same dimension.
                eg: InstanceId:itk-1010,InstanceId:itk-1011
            :type dimensions: string

            :param statistics:
                According to the format of statistics1,statistics2,statistics3,
                the optional values are `average`, `maximum`, `minimum`, `sum`, `sampleCount`
            :type statistics: string

            :param start_time:
                Query start time.
                Please refer to the date and time, UTC date indication
            :type start_time: string

            :param end_time:
                Query end time.
                Please refer to the date and time, UTC date indication
            :type end_time: string

            :param period_in_second:
                Statistical period.
                Multiples of 60 in seconds (s).
            :type period_in_second: int

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        s   /metricdata/batch/%s/%sNs   metricName[]s   dimensions[]r4   r5   r6   r7   r8   r9   r<   r   r   r   get_batch_metric_data   s"   
6
zBcmClient.get_batch_metric_datac                 C   ^   t |dkr
tdt |dkrtddt| }||||d}| jtj|t||dS )a  
            create a custom namespace for custom monitor

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param name:
                namespace name
            :type name: string

            :param namespace_alias:
                namespace alias name
            :type namespace_alias: string

            :param comment:
                namespace comment
            :type user_id: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   *user_id should not be none or empty string'name should not be none or empty strings#   /userId/%s/custom/namespaces/createuserIdnameZnamespaceAliascommentr#   r   	len
ValueErrorr   r:   r.   r   POSTjsondumpsr   r=   rK   Znamespace_aliasrL   r   r"   r#   r   r   r   create_namespace     zBcmClient.create_namespacec                 C   sZ   t |dkr
tdt |dkrtddt| }||d}| jtj|t||dS )a   
            create a custom namespace for custom monitor

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param names:
                namespace name collection
            :type names: string array

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   names should not be emptys#   /userId/%s/custom/namespaces/delete)rJ   namesrM   rN   )r   r=   rX   r   r"   r#   r   r   r   batch_delete_namespaces7  s   z!BcmClient.batch_delete_namespacesc                 C   rF   )a  
            update a custom namespace for custom monitor

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param name:
                namespace name
            :type name: string

            :param namespace_alias:
                namespace alias name
            :type namespace_alias: string

            :param comment:
                namespace comment
            :type user_id: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rH   s#   /userId/%s/custom/namespaces/updaterI   rM   	rO   rP   r   r:   r.   r   PUTrR   rS   rT   r   r   r   update_namespaceW  rV   zBcmClient.update_namespacec                 C   s   t |dkr
tddt| }d|i}|dur||d< |du r&d|d< n||d< |du r3d	|d
< n||d
< | jtj|||dS )a  
            list custom namespaces

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param name:
                namespace name prefix for query
            :type name: string

            :param page_no:
                page number
            :type page_no: int

            :param page_size:
                page size
            :type page_size: int

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   s!   /userId/%s/custom/namespaces/list   userIdN   name      pageNo
      pageSizer8   rO   rP   r   r:   r.   r   r;   )r   r=   rK   page_no	page_sizer   r"   r%   r   r   r   list_namespaces  s   

zBcmClient.list_namespacesc	                 C   s   t |dkr
tdt |dkrtdt |dkrtddt|t|f }	|||d}
|dur8||
d< |dur@||
d	< |durI||
d
< nd|
d
< |durV||
d< ng |
d< | jtj|	t|
|dS )a`  
            create custom metric in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param metric_name:
                custom metric name
            :type metric_name: string

            :param metric_alias:
                custom metric alias
            :type metric_alias: string

            :param unit:
                custom metric unit
            :type unit: string

            :param unit:
                custom metric unit
            :type unit: string

            :param cycle:
                custom metric cycle
            :type cycle: int

            :param dimensions:
                custom dimension collection
            :type dimensions: CustomDimensionModel array

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   ,namespace should not be none or empty string.metric_name should not be none or empty strings.   /userId/%s/custom/namespaces/%s/metrics/create)rJ   	namespace
metricNameNmetricAliasunitcycle<   r@   rM   rN   r   r=   ri   r?   metric_aliasrl   rm   r@   r   r"   r#   r   r   r   create_namespace_metric  s0   -

z!BcmClient.create_namespace_metricc                 C   sf   t |dkr
tdt |dkrtddt|t|f }|||d}| jtj|t||dS )af  
            batch delete custom metric in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                custom namespace name
            :type namespace: string

            :param ids:
                namespace metric id collection
            :type ids: int array

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   zids should not be emptys.   /userId/%s/custom/namespaces/%s/metrics/delete)rJ   ri   idsrM   rN   )r   r=   ri   rr   r   r"   r#   r   r   r   batch_delete_namespace_metrics  s   z(BcmClient.batch_delete_namespace_metricsc	                 C   s   t |dkr
tdt |dkrtdt |dkrtd|du r&tddt|t|t|f }	||||d}
|durE||
d	< |durM||
d
< |durU||
d< | jtj|	t|
|dS )a`  
            update custom metric in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param metric_name:
                custom metric name
            :type metric_name: string

            :param metric_alias:
                custom metric alias
            :type metric_alias: string

            :param unit:
                custom metric unit
            :type unit: string

            :param unit:
                custom metric unit
            :type unit: string

            :param cycle:
                custom metric cycle
            :type cycle: int

            :param dimensions:
                custom dimension collection
            :type dimensions: CustomDimensionModel array

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   rh   Nzcycle should not be none*   /userId/%s/custom/namespaces/%s/metrics/%s)rJ   ri   rj   rm   rk   rl   r@   rM   rZ   ro   r   r   r   update_namespace_metric!  s0   -
z!BcmClient.update_namespace_metricc           
      C   s   t |dkr
tdt |dkrtddt| }||d}	|dur(||	d< |dur0||	d< |du r9d	|	d
< n||	d
< |du rFd|	d< n||	d< | jtj||	|dS )a  
            list custom metric in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param metric_name:
                custom metric name prefix for query
            :type metric_name: string

            :param metric_alias:
                custom metric alias prefix for query
            :type metric_alias: string

            :param page_no:
                page number
            :type page_no: int

            :param page_size:
                page size
            :type page_size: int

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   s$   /userId/%s/custom/namespaces/metricsr]   	   namespaceN
   metricNames   metricAliasr_   r`   ra   rb   r8   rc   )
r   r=   ri   r?   rp   rd   re   r   r"   r%   r   r   r   list_namespace_metricsi  s&   %

z BcmClient.list_namespace_metricsc                 C   st   t |dkr
tdt |dkrtdt |dkrtddt|t|t|f }i }| jtj|||dS )aM  
            get custom metric detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param metric_name:
                custom metric name
            :type metric_name: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   rh   rt   r8   rc   )r   r=   ri   r?   r   r"   r%   r   r   r   get_custom_metric  s   
zBcmClient.get_custom_metricc           
      C      t |dkr
tdt |dkrtdt |dkrtdtj|s/tdttj  d}||||d}	|dur@||	d	< |durH||	d
< | jtj	|t
|	|dS )a  
            create custom event in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param event_level:
                custom event level
            :type event_level: ENUM {'NOTICE', 'WARNING', 'MAJOR', 'CRITICAL'}

            :param event_name:
                custom event name
            :type event_name: string

            :param event_name_alias:
                custom event alias
            :type event_name_alias: string

            :param comment:
                custom event comment
            :type comment: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   -event_name should not be none or empty stringevent_level must be one of %ss   /custom/event/configs/createrJ   ri   Z	eventName
eventLevelNeventNameAliasrL   rM   rO   rP   r
   
EventLevelcontainsstrall_event_levelsr.   r   rQ   rR   rS   
r   r=   ri   
event_nameevent_levelZevent_name_aliasrL   r   r"   r#   r   r   r   create_namespace_event  &   %z BcmClient.create_namespace_eventc                 C   sR   t |dkr
tdt |dkrtdd}|||d}| jtj|t||dS )an  
            batch delete custom metric in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                custom namespace name
            :type namespace: string

            :param names:
                namespace event name collection
            :type names: string array

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rW   s   /custom/event/configs/delete)rJ   ri   rX   rM   rO   rP   r.   r   rQ   rR   rS   )r   r=   ri   rX   r   r"   r#   r   r   r   batch_delete_namespace_events	  s   z'BcmClient.batch_delete_namespace_eventsc           
      C   r{   )a  
            update custom event in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param event_level:
                custom event level
            :type event_level: ENUM {'NOTICE', 'WARNING', 'MAJOR', 'CRITICAL'}

            :param event_name:
                custom event name
            :type event_name: string

            :param event_name_alias:
                custom event alias
            :type event_name_alias: string

            :param comment:
                custom event comment
            :type comment: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   r|   r}   s   /custom/event/configs/updater~   Nr   rL   rM   r   r   r   r   r   update_namespace_event.  r   z BcmClient.update_namespace_eventc           
      C   s   t |dkr
tdt |dkrtd|dur)tj|s)tdttj  d}||d}	|dur8||	d< |dur@||	d	< |du rId
|	d< n||	d< |du rVd|	d< n||	d< | jtj	||	|dS )a  
            list custom event in one namespace

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param name:
                custom metric name prefix for query
            :type name: string

            :param event_level:
                custom metric level
            :type event_level: None or ENUM {'NOTICE', 'WARNING', 'MAJOR', 'CRITICAL'}

            :param page_no:
                page number
            :type page_no: int

            :param page_size:
                page size
            :type page_size: int

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   Nz%event_level must be none or one of %ss   /custom/event/configs/listrv   r^   s   event_levelr_   r`   ra   rb   r8   )
rO   rP   r
   r   r   r   r   r.   r   r;   )
r   r=   ri   rK   r   rd   re   r   r"   r%   r   r   r   list_namespace_eventsj  s*   %

zBcmClient.list_namespace_eventsc                 C   s`   t |dkr
tdt |dkrtdt |dkrtdd}|||d}| jtj|||dS )aI  
            get custom event detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/cktnhszhv

            :param user_id:
                master account id
            :type user_id: string

            :param namespace:
                namespace name
            :type namespace: string

            :param event_name:
                custom event name
            :type event_name: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rg   rh   s   /custom/event/configs/detail)r]   rw   	   eventNamer8   rO   rP   r.   r   r;   )r   r=   ri   r   r   r"   r%   r   r   r   get_custom_event  s   zBcmClient.get_custom_event)rd   re   c                 C   6   | j | ji}d}|||d}| jtj||t|dS )'  
            :param name: notify name
            :type name: string
            :param page_no: page number
            :type page_no: int
            :param page_size: page size
            :type page_size: int

            :return
            :rtype baidubce.bce_response.BceResponse
        s   /alarm/notify/group/listrK   pageNopageSizer$   r#   r(   r)   r'   r   rQ   rR   rS   r   rd   re   rK   r$   r"   r#   r   r   r   list_notify_group     zBcmClient.list_notify_groupc                 C   r   )r   s   /alarm/notify/party/listr   r   r   r   r   r   r   list_notify_party  r   zBcmClient.list_notify_party)rd   re   notificationsmembersc           	      C   sP   |du rg }|du rg }dt | }||||||d}| jtj|t|dS )a(  
        :param user_id:
        :type user_id: string
        :param notifications:
        :type notifications: list of bcm_model.Notification
        :param members:
        :type members: list of bcm_model.Member
        :param alias: action's alias
        :type alias: string
        :param disable_times: disable time
        :type disable_times: list of bcm_model.DisableTime
        :param action_callbacks: list of action callback
        :type action_callbacks: list

        :return
        :rtype baidubce.bce_response.BceResponse
        Ns   /userId/%s/action/create)rJ   r   r   aliasdisableTimesactionCallBacksr#   r   r:   r.   r   rQ   rR   rS   )	r   r=   r   r   r   disable_timesaction_callbacksr"   r#   r   r   r   create_action   s   zBcmClient.create_actionc                 C   s(   dt | }d|i}| jtj||dS )z

        :param user_id:
        :type user_id: string
        :param name: action name
        :type name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /userId/%s/action/deleter^   r%   r   r:   r.   r   DELETE)r   r=   rK   r"   r%   r   r   r   delete_action"  s   zBcmClient.delete_actionc                 C   s4   dt | }||||d}| jtj|t|dS )a|  

        :param user_id:
        :type user_id: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        :param name: action name
        :type name: string
        :param order: desc or asc
        :type name: string

        :return:
        :rtype baidubce.bce_response.BceResponse
        s   /userId/%s/action/actionList)rK   r   r   orderr   r   )r   r=   rd   re   rK   r   r"   r#   r   r   r   list_action1  s   zBcmClient.list_actionc           
   	   C   sT   |du rg }|du rg }dt | }|||||||dd}	| jtj|t|	dS )ad  
        :param user_id:
        :type user_id: string
        :param name: action name
        :type name: string
        :param notifications:
        :type notifications: list of bcm_model.Notification
        :param members:
        :type members: list of bcm_model.Member
        :param alias: action's alias
        :type alias: string
        :param disable_times: disable time
        :type disable_times: list of bcm_model.DisableTime
        :param action_callbacks: list of action callback
        :type action_callbacks: list

        :return
        :rtype baidubce.bce_response.BceResponse
        Ns   /userId/%s/action/updateUSER)ZproductNamerK   r   r   r   r   r   sourcer   r   r:   r.   r   r[   rR   rS   )
r   r=   rK   r   r   r   r   r   r"   r#   r   r   r   update_actionL  s   
zBcmClient.update_actionc                 C   s4   dt | }||d}| jtj|t|tjdS )a  

        :param user_id:
        :type user_id: string
        :param extract_rule: the log extract rule
        :type: string
        :param log_example: log example
        :type: string

        :return
        :rtype baidubce.bce_response.BceResponse
        s!   /userId/%s/application/logextract)ZextractRule
logExample)r#   r&   	r   r:   r.   r   rQ   rR   rS   r	   parse_json_list)r   r=   Zextract_rulelog_exampler"   r#   r   r   r   log_extracts  s   zBcmClient.log_extractc           	      C   sl   dt |t |t |f }|d|d}t| |dur-t|dkr-d||d< | jtj||dS )a  

        :param user_id:
        :type user_id string
        :param app_name: application name
        :type app_name: string
        :param task_name: task name
        :type task_name: string
        :param metric_name:
        :type metric_name: string
        :param dimension_keys: multi dimension keys
        :type dimension_keys: list of string
        :param instances: multiple instance names
        :type instances: list of string

        :return
        :rtype baidubce.bce_response.BceResponse
        s,   /userId/%s/application/%s/task/%s/metricMeta,)rx   s   dimensionKeysNr   	   instancesr   )r   r:   joinprintrO   r.   r   r;   )	r   r=   app_name	task_namer?   Zdimension_keys	instancesr"   r%   r   r   r   !query_metric_meta_for_application  s   
z+BcmClient.query_metric_meta_for_applicationc                 C   s   dt |t |t |f }|||d}|
dur't|
dkr'd|
|d< |dur3|dkr3||d< |dur;||d< |durLt|dkrLd||d	< |	dur]t|	dkr]d|	|d
< | jtj||tjdS )a  

        :param user_id:
        :type user_id: string
        :param app_name: application name
        :type app_name: string
        :param task_name: task name
        :type task_name: string
        :param metric_name: metric name
        :type metric_name: string
        :param start_time: start time, such as 2023-12-05T09:54:15Z
        :type start_time: string
        :param end_time: end time, such as 2023-12-05T09:54:15Z
        :type end_time: string
        :param instances: multiple instance names
        :type instances: list of string
        :param cycle: period time
        :type cycle: int
        :param dimensions: dimensions, such as ["httpMethod:POST___GET,path:apipath","httpMethod:POST,path:apipath1]
        :type dimensions: list of string
        :param statistics: statistics, enum: average, maximum, minimum, sum, sampleCount
        :type statistics: list of string
        :param aggr_data: is aggregation data
        :type aggr_data: bool

        :return
        :rtype baidubce.bce_response.BceResponse
        s,   /userId/%s/application/%s/task/%s/metricData)r5   r6   rx   Nr   r   
   statistics   cycles   aggrDatar   r3   r%   r&   	r   r:   rO   r   r.   r   r;   r	   r   )r   r=   r   r   r?   rB   rC   r   rm   r@   rA   Z	aggr_datar"   r%   r   r   r   !query_metric_data_for_application  s    
z+BcmClient.query_metric_data_for_applicationc                 C   sJ   dt |t |t |f }i }|du r||d< | jtj||tjdS )aY  

        :param user_id:
        :type user_id: string
        :param app_name: application name
        :type app_name: string
        :param task_name: task name
        :type task_name: string
        :param search_name: metric name
        :type search_name: string

        :return
        :rtype baidubce.bce_response.BceResponse
        s*   /userId/%s/application/%s/%s/alarm/metricsN
   searchNamer   r   r:   r.   r   r;   r	   r   )r   r=   r   r   search_namer"   r%   r   r   r   "list_alarm_metrics_for_application  s   
z,BcmClient.list_alarm_metrics_for_applicationc                 C   s2   dt |t |f }d|i}| jtj||dS )  

        :param user_id:
        :type user_id: string
        :param app_name: application name
        :type app_name: string
        :param alarm_name: alarm name
        :type alarm_name: string

        :return
        :rtype baidubce.bce_response.BceResponse
        s&   /userId/%s/application/alarm/%s/config   appNamer   r   r:   r.   r   r;   )r   r=   
alarm_namer   r"   r%   r   r   r    get_alarm_policy_for_application  s
   
z*BcmClient.get_alarm_policy_for_applicationc                 C   s0   dt | }||d}| jtj|t|dS )r   s#   /userId/%s/application/alarm/config)appName	alarmNamer   r   r:   r.   r   r   rR   rS   )r   r=   r   r   r"   r#   r   r   r   #delete_alarm_policy_for_application   s
   z-BcmClient.delete_alarm_policy_for_applicationc	                 C   s4   dt | }	|||||||d}
| jtj|	|
dS )a  

        :param user_id:
        :type user_id: string
        :param page_no: page number
        :type page_no: int
        :param app_name: application name
        :type app_name: string
        :param alarm_name: alarm name
        :type alarm_name: string
        :param action_enabled: is action enabled
        :type action_enabled: bool
        :param src_type: task type, enum: PROC,PORT,LOG,SCR
        :type src_type: string
        :param task_name: task name
        :type task_name: string
        :param page_size: page size
        :type page_size: int

        :return
        :rtype baidubce.bce_response.BceResponse
        s(   /userId/%s/application/alarm/config/list)r`   rb   r   	   alarmName   actionEnableds   srcTypes   taskNamer   r   )r   r=   rd   re   r   r   action_enabledsrc_typer   r"   r%   r   r   r   !list_alarm_policy_for_application  s   	z+BcmClient.list_alarm_policy_for_application)rulesTr   c                 C      dt | }i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|i}| jtj|t|dS )  
        :param user_id:
        :type user_id: string
        :param alarm_description: alarm policy comment
        :type alarm_description: string
        :param alarm_name: unique alarm name in user_id
        :type alarm_name: string
        :param app_name: application name
        :type app_name: string
        :param monitor_object_type: monitor object type, enum: APP, SERVICE
        :type monitor_object_type: string
        :param monitor_object: application monitor object
        :type monitor_object: bcm_model.ApplicationMonitorObject
        :param src_name: task name
        :type src_name: string
        :param src_type: task type, enum: PROC,PORT,LOG,SCR
        :type src_type: string
        :param type: alarm type
        :type type: string
        :param level: alarm level
        :type level: string
        :param rules: list of application alarm rules
        :type rules: list of ApplicationAlarmRule
        :param action_enabled: is alarm action enabled
        :type action_enabled: bool
        :param incident_actions: The action to be taken in the alarm state
        :type incident_actions: list of string
        :param resume_actions: The action to be taken in the alarm resume
        :type resume_actions: list of string
        :param insufficient_actions:
        :type insufficient_actions: list of string
        :param insufficient_cycle: insufficient cycle
        :type insufficient_cycle: int
        :param repeat_alarm_cycle: repeat alarm_cycle
        :type repeat_alarm_cycle: int
        :param max_repeat_count: max repeat count
        :type max_repeat_count: int

        :return
        :rtype baidubce.bce_response.BceResponse
        s*   /userId/%s/application/alarm/config/createrJ   alarmDescriptionr   r   monitorObjectTypemonitorObjectsrcNamesrcTypetypelevelactionEnabledincidentActionsresumeActionsinsufficientActionsinsufficientCyclerepeatAlarmCyclemaxRepeatCountr   r   r   r   r=   Zalarm_descriptionr   r   Zmonitor_object_typemonitor_objectZsrc_namer   r   r   r   r   incident_actionsresume_actionsinsufficient_actionsinsufficient_cyclerepeat_alarm_cyclemax_repeat_countr"   r#   r   r   r   #create_alarm_policy_for_application9  N   /	
z-BcmClient.create_alarm_policy_for_applicationc                 C   r   )r   s*   /userId/%s/application/alarm/config/updaterJ   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   #update_alarm_policy_for_application  r   z-BcmClient.update_alarm_policy_for_applicationc                 C   s:   ||||d}t |}d| }| jtj|t||dS )aa  
            Create a dashboard
            :param user_id:
                 Master account ID
            :type user_id: string

            :param title:
                Title of the dashboard
            :type title: string

            :param configure:
                Configure the dashboard
            :type configure:string

            :param dashboard_type:
                Dashboard type
            :type dashboard_type:string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        rJ   title	configurer   s!   /dashboard/products/%s/dashboardsrM   r   )r   r=   r   r   dashboard_typer   r#   r"   r   r   r   create_dashboard  s   
zBcmClient.create_dashboardc                 C   Z   t |dkr
tdt |dkrtdt|}t|}d||f }| jtj||dS   
            Create a dashboard
            :param user_id:
                 Master account ID
            :type user_id: string

            :param dashboard_name:
                Dashboard name
            :type dashboard_name:string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   1dashboard_name should not be none or empty string$   /dashboard/products/%s/dashboards/%sr   rc   r   r=   dashboard_namer   r"   r   r   r   get_dashboard     

zBcmClient.get_dashboardc           	      C   sp   t |dkr
tdt |dkrtd||||d}t|}t|}d||f }| jtj|t||dS )a  
            Create a dashboard
            :param user_id:
                 Master account ID
            :type user_id: string

            :param title:
                Title of the dashboard
            :type title: string

            :param configure:
                Configure the dashboard
            :type configure:string

            :param dashboard_type:
                Dashboard type
            :type dashboard_type:string

            :param dashboard_name:
                Dashboard name
            :type dashboard_name:string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r   r   r   rM   rZ   )	r   r=   r   r   r   r   r   r#   r"   r   r   r   update_dashboard  s   

zBcmClient.update_dashboardc                 C   r   r   rO   rP   r   r:   r.   r   r   r   r   r   r   delete_dashboard/  r   zBcmClient.delete_dashboardc                 C   f   t |dkr
tdt |dkrtdi }t|}t|}d||f }| jtj|t||dS )r   r   rG   r   s.   /dashboard/products/%s/dashboards/%s/duplicater   rN   r   r=   r   r   r#   r"   r   r   r   duplicate_dashboardI     

zBcmClient.duplicate_dashboardc                 C   r  )r   r   rG   r   s,   /dashboard/products/%s/dashboards/%s/widgetsrM   rN   r  r   r   r   create_dashboard_widgete  r  z!BcmClient.create_dashboard_widgetc                 C   z   t |dkr
tdt |dkrtdt |dkrtdt|}t|}t|}d|||f }| jtj||dS   
            Create a dashboard
            :param user_id:
                 Master account ID
            :type user_id: string

            :param dashboard_name:
                Dashboard name
            :type dashboard_name:string

            :param widget_name:
                Widget name
            :type widget_name:string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r   *widget_name should be none or empty string/   /dashboard/products/%s/dashboards/%s/widgets/%sr   rc   r   r=   r   widget_namer   r"   r   r   r   get_dashboard_widget     


zBcmClient.get_dashboard_widgetc                 C   r  r	  r  r  r   r   r   delete_dashboard_widget  r  z!BcmClient.delete_dashboard_widgetc                 C   s   t |dkr
tdt |dkrtdt |dkrtdi }t|}t|}t|}d|||f }| jtj|t||dS )r
  r   rG   r   r  s9   /dashboard/products/%s/dashboards/%s/widgets/%s/duplicaterM   rN   )r   r=   r   r  r   r#   r"   r   r   r   duplicate_dashboard_widget  s   


z$BcmClient.duplicate_dashboard_widgetc           
      C   s   t |dkr
tdt |dkrtdt |dkrtd|||d}t|}t|}t|}d|||f }	| jtj|	t||dS )a  
            Create a dashboard
            :param user_id:
                 Master account ID
            :type user_id: string

            :param dashboard_name:
                Dashboard name
            :type dashboard_name:string

            :param widget_name:
                Widget name
            :type widget_name:string

            :param widget_type:
                Widget type
            :type widget_type:string

            :param configure:
                Widget configure
            :type configure:object

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r   r  )r   r   r   r  rM   rZ   )
r   r=   r   r  Zwidget_typer   r   r   r#   r"   r   r   r   update_dashboard_widget  s   


z!BcmClient.update_dashboard_widgetc                 C   (   ||d}d}| j tj|t||dS )|  
            Get dashboard report data
            :param data:
                Query data
            :type data: object

            :param time:
                Query data time
            :type time: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        datatimes   /dashboard/metric/reportrM   r.   r   rQ   rR   rS   r   r  r  r   r#   r"   r   r   r   get_dashboard_report_data  
   z#BcmClient.get_dashboard_report_datac                 C   r  )r  r  s   /dashboard/metric/trendrM   r  r  r   r   r   get_dashboard_trend_data.  r  z"BcmClient.get_dashboard_trend_datac                 C   r  )r  r  s   /dashboard/metric/gaugechartrM   r  r  r   r   r   get_dashboard_gauge_chart_dataF  r  z(BcmClient.get_dashboard_gauge_chart_datac                 C   r  )r  r  s   /dashboard/metric/billboardrM   r  r  r   r   r   get_dashboard_billboard_data^  r  z&BcmClient.get_dashboard_billboard_datac                 C   r  )r  r  s   /dashboard/metric/trend/seniorrM   r  r  r   r   r   get_dashboard_trend_senior_datav  r  z)BcmClient.get_dashboard_trend_senior_datac           
      C   s   t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2td||||||d}t|}t|}t|}d|||f }	| jtj|	||d	S )
a  
            Get dashboard dimensions
            :param user_id:
                 Master account ID
            :type user_id: string

            :param dimensions:
                dashboard dimensions
            :type dimensions: string

            :param metric_name:
                dashboard metric_name
            :type metric_name: string

            :param region:
                dashboard dimensions region
            :type region: string

            :param service:
                cloud service
            :type service:

            :param show_id:
                cloud resourceId
            :type show_id:

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   rh   )region should not be none or empty stringz*service should not be none or empty stringz*show_id should not be none or empty string)r3   r]   rx      regions   services   showIds2   /userId/%s/services/%s/region/%s/metric/dimensionsr8   rc   )
r   r=   r?   regionZserviceZshow_idr@   r   r%   r"   r   r   r   get_dashboard_dimensions  s,   "


z"BcmClient.get_dashboard_dimensionsc           	      C   s   t |dkr
tdt |dkrtdt |dkrtd|||d}|dur,||d< |dur4||d< t|}d	| }| jtj|t||d
S )z
        create application data
        :param name:
        :param type:
        :param user_id:
        :param alias:
        :param description:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   user_id should not be nulltype should not be nullname should not be null)rK   r   rJ   Nr   description   /userId/%s/applicationrM   rN   )	r   rK   r   r=   r   r(  r   reqr"   r   r   r   create_application_data  s"   
z!BcmClient.create_application_datac                 C   sl   t |dkr
td|du rd}|du rd}t|}d| }||d}|dur,||d< | jtj|||d	S )
z
        get_application_data_list
        :param user_id:
        :param page_no:
        :param page_size:
        :param search_name:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  Nr_   ra   r)  )rb   r`   r   r8   )rO   rP   r   r:   r'   r   r;   )r   r=   rd   re   r   r   r"   r%   r   r   r   get_application_data_list  s   
z#BcmClient.get_application_data_listc           
      C   s   t |dkr
tdt |dkrtdt |dkrtdt |dkr(td||||d}|dur7||d< |dur?||d	< t|}d
| }	| jtj|	t||dS )z
        update_application_data
        :param user_id:
        :param id:
        :param name:
        :param type:
        :param alias:
        :param description:
        :param config:
        :return:
        r   r%  r&  r'  id should not be null)rJ   idrK   r   Nr   r(  r)  rM   rZ   )
r   r=   r.  rK   r   r   r(  r   r*  r"   r   r   r   update_application_data  s(   
z!BcmClient.update_application_datac                 C   s\   t |dkr
tdt |dkrtdd|i}t|}d| }| jtj|t||dS )z~
        delete_application_data
        :param user_id:
        :param name:
        :param config:
        :return:
        r   r%  zname should null be nullrK   r)  rM   	rO   rP   r   r:   r.   r   r   rR   rS   )r   r=   rK   r   r*  r"   r   r   r   delete_application_data$  s   
z!BcmClient.delete_application_datac	                 C   s   t |dkr
tdt |dkrtdt |dkrtd|du r$d}|du r*d}t|}d| }	|||||d	}
|durC||
d
< | jtj|	t|
|dS )a;  
        get_application_instance_list
        :param user_id:
        :param region:
        :param app_name:
        :param search_name:
        :param page_no:
        :param page_size:
        :param search_value:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  region should not be nullapp_name should not be nullNr_   ra   s   /userId/%s/instances/all)r   r#  r   r   
searchNameZsearchValuerM   rN   )r   r=   r#  r   r   rd   re   Zsearch_valuer   r"   r*  r   r   r   get_application_instance_list7  s*   
z'BcmClient.get_application_instance_list)r=   r   	host_listc           	      C   s   t |dkr
tdt |dkrtdt |dkrtdg }|D ]}|| q"|||d}t|}d| }| jtj|t	||dS )z
        create_application_instance
        :param user_id:
        :param app_name:
        :param host_list:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  zhost_list should not be null)r   rJ   ZhostLists$   /userId/%s/application/instance/bindrM   )
rO   rP   appendr   r:   r.   r   rQ   rR   rS   )	r   r=   r   r6  r   Zhost_list_jsonhostr*  r"   r   r   r   create_application_instance]  s    
z%BcmClient.create_application_instancec                 C   p   t |dkr
tdt |dkrtdt|}t|}d||f }d}|dur.d|i}| jtj|||dS )z
        get_application_instance_created_list
        :param user_id:
        :param app_name:
        :param region:
        :param config:
        :return:
        r   r%  r3  s'   /userId/%s/application/%s/instance/listNr#  r8   rc   )r   r=   r   r#  r   r"   r%   r   r   r   %get_application_instance_created_list|  s   	

z/BcmClient.get_application_instance_created_listc                 C   sr   t |dkr
tdt |dkrtdt |dkrtdt|}d| }||d}| jtj|t||dS )z
        delete_application_instance
        :param user_id:
        :param app_name:
        :param id:
        :param config:
        :return:
        r   r%  r3  r-  s   /userId/%s/application/instance)r.  r   rM   r0  )r   r=   r   r.  r   r"   r*  r   r   r   delete_application_instance  s   	
z%BcmClient.delete_application_instance)r=   r   
alias_namer   targetrm   r(  r   
match_rulerateextract_resultmetricsc                 C   st  t |dkr
tdt |dkrtd|du rtdt |dkr&tdt |dkr0td|du r6d}|t|||t|d	}|durJ||d
< t|dkr|du rXtd|	du r`td|
du rhtd|du rptd|du rxtd||d< |	|d< |
|d< g }|D ]}|| q||d< g }|D ]}|| q||d< t|}d| }| jtj|t	
||dS )a  
        create_application_instance_task
        :param user_id:
        :param app_name:
        :param alias_name:
        :param type:
        :param target:
        :param cycle:
        :param description:
        :param log_example:
        :param match_rule:
        :param rate:
        :param extract_result:
        :param metrics:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  Nr&  alias_name should not be nulltarget should not be nullrn   )r   r   	aliasNamer>  rm   r(  2log_example should not be nullmatch_rule should not be nullrate should not be null!extract_result should not be nullmetrics should not be nullr   	matchRuler@  extractResultrB  s"   /userId/%s/application/task/createrM   )rO   rP   r   r7  r   r:   r.   r   rQ   rR   rS   )r   r=   r   r=  r   r>  rm   r(  r   r?  r@  rA  rB  r   r*  extract_result_jsonresultmetrics_jsonmetricr"   r   r   r    create_application_instance_task  sZ   
z*BcmClient.create_application_instance_taskc                 C   r  )z
        get_application_monitor_task_detail
        :param user_id:
        :param app_name:
        :param task_name:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  ztask_name should not be nulls!   /userId/%s/application/%s/task/%sr   rc   )r   r=   r   r   r   r"   r   r   r   #get_application_monitor_task_detail  s   



z-BcmClient.get_application_monitor_task_detailc                 C   st   t |dkr
tdt |dkrtdt|}t|}d||f }d}|dur.d|i}| jtj|||tjdS )z
        get_application_monitor_task_list
        :param user_id:
        :param app_name:
        :param type:
        :param config:
        :return:
        r   r%  r3  s#   /userId/%s/application/%s/task/listNr   )r%   r   r&   )	rO   rP   r   r:   r.   r   r;   r	   r   )r   r=   r   r   r   r"   r%   r   r   r   !get_application_monitor_task_list		  s   	

z+BcmClient.get_application_monitor_task_list)r=   r   rK   r=  r   r>  rm   r(  r   r?  r@  rA  rB  c                 C   s  t |dkr
tdt |dkrtdt |dkrtd|du r&tdt |dkr0tdt |dkr:td||t|||d	}|durL||d
< |durT||d< t|dkr|	du rbtd|
du rjtd|du rrtd|du rztd|du rtd|	|d< |
|d< ||d< g }|D ]}|| q||d< g }|D ]}|| q||d< t|}d| }| jtj|t	
||dS )a  
        update application monitor task
        :param user_id:
        :param app_name:
        :param alias_name:
        :param name:
        :param type:
        :param target:
        :param cycle:
        :param description:
        :param log_example:
        :param match_rule:
        :param rate:
        :param extract_result:
        :param metrics:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  r'  Nr&  rC  rD  )r   rK   r   rE  r>  rm   r(  rF  rG  rH  rI  rJ  rK  r   rL  r@  rM  rB  s"   /userId/%s/application/task/updaterM   )rO   rP   r   r7  r   r:   r.   r   r[   rR   rS   )r   r=   r   r=  rK   r   r>  rm   r(  r   r?  r@  rA  rB  r   r*  rN  rO  rP  rQ  r"   r   r   r   update_application_monitor_task!	  s^   
z)BcmClient.update_application_monitor_taskc                 C   sr   t |dkr
tdt |dkrtdt |dkrtdt|}d| }||d}| jtj|t||dS )z
        delete_application_monitor_task
        :param user_id:
        :param name:
        :param app_name:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  r'  s"   /userId/%s/application/task/delete)rK   r   rM   r0  )r   r=   rK   r   r   r"   r*  r   r   r   delete_application_monitor_taskm	  s   

z)BcmClient.delete_application_monitor_taskc                 C      t |dkr
tdt |dkrtdt |dkrtdt |dkr(td||||d}t|}d| }| jtj|t||dS )	z
        create_application_dimension_table
        :param user_id:
        :param app_name:
        :param table_name:
        :param map_content_json:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  table_name should not be null#map_content_json should not be nullrJ   r   	tableNameZmapContentJsons*   /userId/%s/application/dimensionMap/createrM   rN   r   r=   r   
table_nameZmap_content_jsonr   r*  r"   r   r   r   "create_application_dimension_table	      
z,BcmClient.create_application_dimension_tablec                 C   r:  )z
        get_application_dimension_table_list
        :param user_id:
        :param app_name:
        :param search_name:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  s+   /userId/%s/application/%s/dimensionMap/listNr4  r8   rc   )r   r=   r   r   r   r"   r%   r   r   r   $get_application_dimension_table_list	  s   


z.BcmClient.get_application_dimension_table_listc                 C   rW  )	z
        update_application_dimension_table
        :param user_id:
        :param app_name:
        :param table_name:
        :param map_content_json:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  rX  rY  rZ  s*   /userId/%s/application/dimensionMap/updaterM   rZ   r\  r   r   r   "update_application_dimension_table	  r_  z,BcmClient.update_application_dimension_tablec                 C   st   t |dkr
tdt |dkrtdt |dkrtd|||d}t|}d| }| jtj|t||dS )z
        delete_application_dimension_table
        :param user_id:
        :param app_name:
        :param table_name:
        :param config:
        :return:
        :rtype baidubce.bce_response.BceResponse
        r   r%  r3  rX  )rJ   r   r[  s*   /userId/%s/application/dimensionMap/deleterM   r0  )r   r=   r   r]  r   r*  r"   r   r   r   "delete_application_dimension_table	  s   

z,BcmClient.delete_application_dimension_table)rd   re   
account_idrB   rC   r_   ra   c                 C   s8   d}|||||||||	|
||||d}| j tj||dS )ar  
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        :param start_time: start time, such as 2023-12-05T09:54:15Z
        :type start_time: string
        :param end_time: end time, such as 2023-12-05T09:54:15Z
        :type end_time: string
        :param account_id: account id
        :type account_id: string
        :param ascending: ascending
        :type ascending: bool
        :param scope: scope
        :type scope: string
        :param region: region
        :type region: string
        :param event_level: event level
        :type event_level: None or ENUM {'NOTICE', 'WARNING', 'MAJOR', 'CRITICAL'}
        :param event_name: event name
        :type event_name: string
        :param event_alias: event alias
        :type event_alias: string
        :param resource_type: resource type
        :type resource_type: string
        :param resource_id: resource id
        :type resource_id: string
        :param event_id: event id
        :type event_id: string

        :return
        :rtype baidubce.bce_response.BceResponse
        s   /bce-event/list)r`   rb   r5   r6   	   accountId	   ascending   scoper"  
   eventLevelr   
   eventAliass   resourceTypes
   resourceId   eventIdr   r0   r   r;   )r   rd   re   rB   rC   rc  	ascendingr>   r#  r   r   event_aliasresource_typeZresource_idevent_idr"   r%   r   r   r   get_cloud_event_data	  s"   %zBcmClient.get_cloud_event_datac                 C   s4   d}|||||||||	|
||d}| j tj||dS )a  
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        :param start_time: start time, such as 2023-12-05T09:54:15Z
        :type start_time: string
        :param end_time: end time, such as 2023-12-05T09:54:15Z
        :type end_time: string
        :param account_id: account id
        :type account_id: string
        :param ascending: ascending
        :type ascending: bool
        :param scope: scope
        :type scope: string
        :param region: region
        :type region: string
        :param event_level: event level
        :type event_level: None or ENUM {'NOTICE', 'WARNING', 'MAJOR', 'CRITICAL'}
        :param event_name: event name
        :type event_name: string
        :param event_alias: event alias
        :type event_alias: string
        :param event_id: event id
        :type event_id: string

        :return
        :rtype baidubce.bce_response.BceResponse
        s   /platform-event/list)r`   rb   r5   r6   rd  re  rf  r"  rg  r   rh  ri  r   rj  )r   rd   re   rB   rC   rc  rk  r>   r#  r   r   rl  rn  r"   r%   r   r   r   get_platform_event_data(
  s   !z!BcmClient.get_platform_event_data)rc  service_namerK   block_statusr   c           
      C   sd   |du rt d|du rt ddt|t|f }|||||||d}	| jtj|t|	dS )aK  
        :param account_id: account id
        :type account_id: string
        :param service_name: service name
        :type service_name: string
        :param name: event policy name
        :type name: string
        :param block_status: block status, enum: NORMAL, BLOCKED
        :type block_status: string
        :param event_filter: event filter
        :type event_filter: EventFilter
        :param resource: resource filter
        :type resource: EventResourceFilter
        :param incident_actions: incident actions
        :type incident_actions: list of string
        Nzevent_filter should not be nonezresource should not be nones'   /accounts/%s/services/%s/alarm-policies)rc  rq  rK   ZblockStatusZeventFilterresourcer   r   )rP   r   r:   r0   r   rQ   rR   rS   )
r   rc  rq  rK   rr  Zevent_filterrs  r   r"   r#   r   r   r   create_event_policyZ
  s    
	zBcmClient.create_event_policy)r=   r#  rq  	type_namerK   c           	      C   s8   dt | }||||||d}| jtj|t|dS )a  
        :param user_id: user id
        :type user_id: string
        :param region: region
        :type region: string
        :param service_name: service name
        :type service_name: string
        :param type_name: type name
        :type type_name: string
        :param name: instance group name
        :type name: string
        :param resource_id_list: resource id list
        :type resource_id_list: list of MonitorResource
           /userId/%s/instance-group)rJ   r#  serviceNametypeNamerK   resourceIdListr   r   )	r   r=   r#  rq  ru  rK   resource_id_listr"   r#   r   r   r   create_instance_group
     zBcmClient.create_instance_group)r=   ig_idr#  rq  ru  rK   c           	      C   s8   dt | }||||||d}| jtj|t|dS )a  
        :param ig_id: instance group id
        :type ig_id: string
        :param user_id: user id
        :type user_id: string
        :param region: region
        :type region: string
        :param service_name: service name
        :type service_name: string
        :param type_name: type name
        :type type_name: string
        :param name: instance group name
        :type name: string
        rv  )r.  rJ   r#  rw  rx  rK   r   )r   r:   r.   r   PATCHrR   rS   )	r   r}  r=   r#  rq  ru  rK   r"   r#   r   r   r   update_instance_group
  r|  zBcmClient.update_instance_group)r=   r}  c                 C   &   dt |t |f }| tj|S z
        :param user_id: user id
        :type user_id: string
        :param ig_id: instance group id
        :type ig_id: string
        s   /userId/%s/instance-group/%sr   r   r=   r}  r"   r   r   r   delete_instance_group
     zBcmClient.delete_instance_groupc                 C   r  r  r   r  r   r   r   get_instance_group
  r  zBcmClient.get_instance_group)r=   rd   re   c           
      C   s4   dt | }|||||||d}	| jtj||	dS )a  
        :param user_id: user id
        :type user_id: string
        :param name: instance group name
        :type name: string
        :param service_name: service name
        :type service_name: string
        :param region: region
        :type region: string
        :param type_name: type name
        :type type_name: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        s   /userId/%s/instance-group/list)r]   r^      serviceNamer"     typeNamer`   rb   r   r   )
r   r=   rK   rq  r#  ru  rd   re   r"   r%   r   r   r   list_instance_group
  s   	zBcmClient.list_instance_group)r=   r}  rz  c                 C   <   dt |t |f }|||d}| jtj|t|dS )
        :param ig_id: instance group id
        :type ig_id: string
        :param user_id: user id
        :type user_id: string
        :param resource_id_list: resource id list
        :type resource_id_list: list of MonitorResource
        s)   /userId/%s/instance-group/%s/instance/addr.  rJ   ry  r   r   r   r}  r=   rz  r"   r#   r   r   r   add_ig_instance
     

zBcmClient.add_ig_instancec                 C   r  )r  s,   /userId/%s/instance-group/%s/instance/remover  r   r   r  r   r   r   remove_ig_instance
  r  zBcmClient.remove_ig_instance)r=   r}  rq  ru  r#  	view_typerd   re   c	              	   C   s6   dt | }	||||||||d}
| jtj|	|
dS )a9  
        :param user_id: user id
        :type user_id: string
        :param ig_id: instance group id
        :type ig_id: string
        :param service_name: service name
        :type service_name: string
        :param type_name: type name
        :type type_name: string
        :param region: region
        :type region: string
        :param view_type: view type, enum: LIST_VIEW, DETAIL_VIEW
        :type view_type: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        s'   /userId/%s/instance-group/instance/list)   idr]   r  r  r"     viewTyper`   rb   r   r   )r   r=   r}  rq  ru  r#  r  rd   re   r"   r%   r   r   r   list_ig_instance  s   
zBcmClient.list_ig_instance)	r=   rq  ru  r#  r  keyword_typekeywordrd   re   c
              
   C   s8   dt | }
|||||||||	d	}| jtj|
|dS )a  
        :param user_id: user id
        :type user_id: string
        :param service_name: service name
        :type service_name: string
        :param type_name: type name
        :type type_name: string
        :param region: region
        :type region: string
        :param view_type: view type, enum: LIST_VIEW, DETAIL_VIEW
        :type view_type: string
        :param keyword_type: keyword type, enum: name, id
        :type keyword_type: string
        :param keyword: keyword
        :type keyword: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        s   /userId/%s/instance/list)	r]   r  r  r"  r     keywordType   keywordr`   rb   r   r   )r   r=   rq  ru  r#  r  r  r  rd   re   r"   r%   r   r   r   list_all_instance1  s   zBcmClient.list_all_instance)r=   r}  ig_uuidrq  ru  r#  r  r  r  rd   re   c                 C   s<   dt | }|||||||||	|
|d}| jtj||dS )a  
        :param user_id: user id
        :type user_id: string
        :param ig_id: instance group id
        :type ig_id: string
        :param ig_uuid: instance group uuid
        :type ig_uuid: string
        :param service_name: service name
        :type service_name: string
        :param type_name: type name
        :type type_name: string
        :param region: region
        :type region: string
        :param view_type: view type, enum: LIST_VIEW, DETAIL_VIEW
        :type view_type: string
        :param keyword_type: keyword type, enum: name, id
        :type keyword_type: string
        :param keyword: keyword
        :type keyword: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        s    /userId/%s/instance/filteredList)r]   r  s   uuidr  r  r"  r  r  r  r`   rb   r   r   )r   r=   r}  r  rq  ru  r#  r  r  r  rd   re   r"   r%   r   r   r   list_filter_instanceW  s   zBcmClient.list_filter_instancec                 C   sB   t |}t |}d||f }d|i}| jtj|t||dS )z
        :param user_id: user_id
        :type user_id: string
        :param scope: scope
        :type scope: string
        :param metric_data: metric_data
        :type bcm_model.MetricDatum array
        :return:
        s   /metricdata/%s/%sZ
metricDatarM   )r   r:   r'   r   rQ   rR   rS   )r   r=   r>   Zmetric_datar   r"   r#   r   r   r   push_metric_data  s   

zBcmClient.push_metric_datac
                 C   sZ   t |}t |}t |}d|||f }
|||||d}| jtj|
t|tj|	dS )a  
        Return metric data of product instances owned by the authenticated user.

        This site may help you: https://cloud.baidu.com/doc/BCM/s/9jwvym3kb

        :param user_id:
            Master account ID
        :type user_id: string

        :param namespaces:
            Cloud product namespace, eg: BCE_BCC.
        :type namespaces: string

        :param metric_name:
            The metric name of baidu cloud monitor, eg: CpuIdlePercent.
        :type metric_name: string

        :param dimensions:
            Consists of dimensionName: dimensionValue.
            Use semicolons when items have multiple dimensions,
            such as dimensionName: dimensionValue; dimensionName: dimensionValue.
            Only one dimension value can be specified for the same dimension.
            eg: InstanceId:fakeid-2222
        :type dimensions: string

        :param statistics:
            According to the format of statistics1,statistics2,statistics3,
            the optional values are `average`, `maximum`, `minimum`, `sum`, `sampleCount`
        :type statistics: string

        :param start_time:
            Query start time.
            Please refer to the date and time, UTC date indication
        :type start_time: string

        :param end_time:
            Query end time.
            Please refer to the date and time, UTC date indication
        :type end_time: string

        :param cycle:
            Statistical period.
            Multiples of 60 in seconds (s).
        :type cycle: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        s/   /userId/%s/custom/namespaces/%s/metrics/%s/data)rA   r@   	startTimeendTimerm   )r#   r&   r   r   )r   r=   
namespacesr?   r@   rA   rB   rC   rm   r   r"   r#   r   r   r   get_custom_metric_data  s   
6

z BcmClient.get_custom_metric_datac           
      C   sF   t |}t |}d| }|||||d}	| jtj|t|	|dS )a  
        :param user_id:
        :type user_id: string
        :param namespace:
        :type namespace: string
        :param metric_name:
        :type metric_name: string
        :param dimensions:
        :type dimensions: bcm_model.Dimension array
        :param value:
        :type value: double
        :param timestamp:
        :type timestamp: string
        :param config:
        :return:
        s   /userId/%s/custom/data)ri   rj   r@   value	timestamprM   r   )
r   r=   ri   r?   r@   r  r  r   r"   r#   r   r   r   push_custom_metric_data  s   

z!BcmClient.push_custom_metric_datac              
   C   D   t |}d| }|||||||||	d	}| jtj|t||
dS )2  
        :param user_id:
        :type user_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param method:
        :type method: string
        :param post_content:
        :type post_content: string
        :param advance_config:
        :type advance_config: bool
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param config:
        :type config
        :return:
        s   /userId/%s/site/http/create	rJ   taskNameaddressmethodpostContentadvanceConfigrm   idctimeoutrM   r   r   r=   r   r  r  post_contentadvance_configrm   r  r  r   r"   r#   r   r   r   create_site_http_task_config     
z&BcmClient.create_site_http_task_configc                 C   F   t |}d| }|||||||||	|
d
}| jtj|t||dS )h  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param method:
        :type method: string
        :param post_content:
        :type post_content: string
        :param advance_config:
        :type advance_config: bool
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param config:
        :type config
        :return:
        s   /userId/%s/site/http/update
rJ   taskIdr  r  r  r  r  rm   r  r  rM   r   r   r=   task_idr   r  r  r  r  rm   r  r  r   r"   r#   r   r   r   update_site_http_task_config)     
z&BcmClient.update_site_http_task_configc                 C   :   t |}d| }i }|dur||d< | jtj|||dS )
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/http/detailNr  r8   r   r   r=   r  r   r"   r%   r   r   r   get_site_http_task_configW     
z#BcmClient.get_site_http_task_configc              
   C   r  )r  s   /userId/%s/site/https/creater  rM   r   r  r   r   r   create_site_https_task_configk  r  z'BcmClient.create_site_https_task_configc                 C   r  )r  s   /userId/%s/site/https/updater  rM   r   r  r   r   r   update_site_https_task_config  r  z'BcmClient.update_site_https_task_configc                 C   r  )r  s   /userId/%s/site/https/detailNr  r8   r   r  r   r   r   get_site_https_task_config  r  z$BcmClient.get_site_https_task_configc
              	   C   sB   t |}d| }
||||||||d}| jtj|
t||	dS )a  
        :param user_id:
        :type user_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param packet_count:
        :type packet_count: int
        :param packet_loss_rate:
        :type packet_loss_rate: int
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param config:
        :type config
        :return:
        s   /userId/%s/site/ping/create)rJ   r  r  packetCountpacketLossRaterm   r  r  rM   r   )r   r=   r   r  packet_countpacket_loss_raterm   r  r  r   r"   r#   r   r   r   create_site_ping_task_config  s   
z&BcmClient.create_site_ping_task_configc              
   C   r  )a4  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param packet_count:
        :type packet_count: int
        :param packet_loss_rate:
        :type packet_loss_rate: int
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param config:
        :type config
        :return:
        s   /userId/%s/site/ping/update)	rJ   r  r  r  r  r  rm   r  r  rM   r   )r   r=   r  r   r  r  r  rm   r  r  r   r"   r#   r   r   r   update_site_ping_task_config   r  z&BcmClient.update_site_ping_task_configc                 C   r  )r  s   /userId/%s/site/ping/detailNr  r8   r   r  r   r   r   get_site_ping_task_config+  r  z#BcmClient.get_site_ping_task_configc                 C   J   t |}d| }||||||	|
|||||d}| jtj|t||dS )r  s   /userId/%s/site/tcp/createrJ   r  r  portr  	inputType
outputTypeinputexpectedOutputrm   r  r  rM   r   r   r=   r   r  r  r  rm   r  r  
input_typeoutput_typer  expected_outputr   r"   r#   r   r   r   create_site_tcp_task_config?      
z%BcmClient.create_site_tcp_task_configc                 C   L   t |}d| }|||||||
||||||	d}| jtj|t||dS )M  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param port:
        :type port: int
        :param post_content:
        :type post_content: string
        :param advance_config:
        :type advance_config: bool
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param input_type:
        :type input_type: int
        :param output_type:
        :type output_type: int
        :param input:
        :type input: string
        :param expected_output:
        :type expected_output: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/tcp/updaterJ   r  r  r  r  r  r  r  r  r  rm   r  r  rM   r   r   r=   r  r   r  r  r  rm   r  r  r  r  r  r  r   r"   r#   r   r   r   update_site_tcp_task_configm  "   
%z%BcmClient.update_site_tcp_task_configc                 C   r  )r  s   /userId/%s/site/tcp/detailNr  r8   r   r  r   r   r   get_site_tcp_task_config  r  z"BcmClient.get_site_tcp_task_configc                 C   r  )a  
            :param user_id:
            :type user_id: string
            :param task_name:
            :type task_name: string
            :param address:
            :type address: string
            :param method:
            :type method: string
            :param post_content:
            :type post_content: string
            :param advance_config:
            :type advance_config: bool
            :param cycle:
            :type cycle: int
            :param idc:
            :type idc: string
            :param timeout:
            :type timeout: int
            :param config:
            :type config
            :return:
        s   /userId/%s/site/udp/creater  rM   r   r  r   r   r   create_site_udp_task_config  r  z%BcmClient.create_site_udp_task_configc                 C   r  )r  s   /userId/%s/site/udp/updater  rM   r   r  r   r   r   update_site_udp_task_config  r  z%BcmClient.update_site_udp_task_configc                 C   r  )r  s   /userId/%s/site/udp/detailNr  r8   r   r  r   r   r   get_site_udp_task_config!  r  z"BcmClient.get_site_udp_task_configc                 C   sF   t |}d| }||||||	|
|||d
}| jtj|t||dS )a  
        :param user_id:
        :type user_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param port:
        :type port: int
        :param post_content:
        :type post_content: string
        :param anonymous_login:
        :type anonymous_login: bool
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param user_name:
        :type user_name: string
        :param password:
        :type password: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/ftp/create)
rJ   r  r  r  anonymousLoginuserNamepasswordrm   r  r  rM   r   )r   r=   r   r  r  anonymous_loginrm   r  r  	user_namer  r   r"   r#   r   r   r   create_site_ftp_task_config5     
z%BcmClient.create_site_ftp_task_configc                 C   sH   t |}d| }|||||||
||||	d}| jtj|t||dS )a  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param port:
        :type port: int
        :param post_content:
        :type post_content: string
        :param anonymous_login:
        :type anonymous_login: bool
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param user_name:
        :type user_name: string
        :param password:
        :type password: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/ftp/update)rJ   r  r  r  r  r  r  r  rm   r  r  rM   r   )r   r=   r  r   r  r  r  rm   r  r  r  r  r   r"   r#   r   r   r   update_site_ftp_task_confige  s   
!z%BcmClient.update_site_ftp_task_configc                 C   r  )r  s   /userId/%s/site/ftp/detailNr  r8   r   r  r   r   r   get_site_ftp_task_config  r  z"BcmClient.get_site_ftp_task_configc              
   C   sD   t |}d| }||||||	|||d	}| jtj|t||
dS )a  
        :param user_id:
        :type user_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param post_content:
        :type post_content: string
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param server:
        :type server: string
        :param resolve_type:
        :type resolve_type: ENUM {'RECURSION', 'ITERATION'}
        :param kidnap_white:
        :type kidnap_white: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/dns/create)	rJ   r  r  serverresolveTypekidnapWhiterm   r  r  rM   r   )r   r=   r   r  rm   r  r  r  resolve_typekidnap_whiter   r"   r#   r   r   r   create_site_dns_task_config  s   
z%BcmClient.create_site_dns_task_configc                 C   sF   t |}d| }||||||	|
|||d
}| jtj|t||dS )a  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param task_name:
        :type task_name: string
        :param address:
        :type address: string
        :param post_content:
        :type post_content: string
        :param cycle:
        :type cycle: int
        :param idc:
        :type idc: string
        :param timeout:
        :type timeout: int
        :param server:
        :type server: string
        :param resolve_type:
        :type resolve_type: ENUM {'RECURSION', 'ITERATION'}
        :param kidnap_white:
        :type kidnap_white: string
        :param config:
        :type config
        :return:
        s   /userId/%s/site/dns/update)
rJ   r  r  r  r  r  r  rm   r  r  rM   r   )r   r=   r  r   r  rm   r  r  r  r  r  r   r"   r#   r   r   r   update_site_dns_task_config  r  z%BcmClient.update_site_dns_task_configc                 C   r  )r  s   /userId/%s/site/dns/detailNr  r8   r   r  r   r   r   get_site_dns_task_config	  r  z"BcmClient.get_site_dns_task_configc           	      C   sp   t |}d| }|du rd}||d}|du rd|d< n||d< |du r*d|d< n||d< | jtj|||d	S )
aI  
        :param user_id:
        :type user_id: string
        :param query:
        :type query: string
        :param type:
        :type type: string
        :param page_no:
        :type page_no: int
        :param page_size:
        :type page_size: int
        :param config:
        :type config:
        :return:
        s   /userId/%s/site/listNzNAME:)s   query   typer_   r`   ra   rb   r8   r   )	r   r=   queryr   rd   re   r   r"   r%   r   r   r   get_site_task_config_list  s   


z#BcmClient.get_site_task_config_listc                 C   .   t |}d| }d|i}| jtj|||dS )
        :param user_id:
        :type user_id: string
        :param task_Id:
        :type task_Id: string
        :param config:
        :type config:
        :return:
        s   /userId/%s/site/delete   taskIdr8   r   r  r   r   r   delete_site_task_configC  
   
z!BcmClient.delete_site_task_configc                 C   s2   t |}t |}d||f }| jtj||dS )r  s   /userId/%s/site/%sr   r   )r   r=   r  r   r"   r   r   r   get_site_task_config_infoW  s   

z#BcmClient.get_site_task_config_infoc                 C   s   t |}d| }i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|}| jtj|t||dS )a   
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param comment:
        :type comment: string
        :param alias_name:
        :type alias_name: string
        :param level:
        :type level: ENUM {'NOTICE', 'WARNING', 'CRITICAL', 'MAJOR', 'CUSTOM'}
        :param action_enabled:
        :type action_enabled: bool
        :param resume_actions:
        :type :type user_id: string: string
        :param insufficient_actions:
        :type insufficient_actions: string
        :param incident_action:
        :type incident_action: string
        :param insufficient_cycle:
        :type insufficient_cycle: int
        :param rules:
        :type rules: list of SiteAlarmRule
        :param region:
        :type region: string
        :param callback_url:
        :type callback_url: string
        :param method:
        :type method: string
        :param site_monitor:
        :type site_monitor: string
        :param tag:
        :type tag: string
        :return:
        s#   /userId/%s/site/alarm/config/createrJ   r  rL   rE  r   r   r   r   incidentActionr   r   r#  callbackUrlr  siteMonitortagrM   r   )r   r=   r  rL   r=  r   r   r   r   incident_actionr   r   r#  callback_urlr  site_monitorr  r   r"   r#   r   r   r   create_site_alarm_configi  sH   
(	
z"BcmClient.create_site_alarm_configc                 C   s4   t |}d| }d|i}| jtj|t||dS )z
        :param user_id:
        :type user_id: string
        :param alarm_names:
        :type alarm_names: list
        :param config:
        :type config:
        :return:
        s#   /userId/%s/site/alarm/config/deleteZ
alarmNamesrM   r   )r   r=   Zalarm_namesr   r"   r#   r   r   r   delete_site_alarm_config  s
   
z"BcmClient.delete_site_alarm_configc                 C   s   t |}d| }i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|}| jtj|t||dS )a\  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param alarm_name:
        :type alarm_name: string
        :param comment:
        :type comment: string
        :param alias_name:
        :type alias_name: string
        :param level:
        :type level: ENUM {'NOTICE', 'WARNING', 'CRITICAL', 'MAJOR', 'CUSTOM'}
        :param action_enabled:
        :type action_enabled: bool
        :param resume_actions:
        :type :type user_id: string: string
        :param insufficient_actions:
        :type insufficient_actions: string
        :param incident_action:
        :type incident_action: string
        :param insufficient_cycle:
        :type insufficient_cycle: int
        :param rules:
        :type rules: list of SiteAlarmRule
        :param region:
        :type region: string
        :param callback_url:
        :type callback_url: string
        :param method:
        :type method: string
        :param site_monitor:
        :type site_monitor: string
        :param tag:
        :type tag: string
        :return:
        s#   /userId/%s/site/alarm/config/updaterJ   r  r   rL   rE  r   r   r   r   r  r   r   r#  r  r  r  r  rM   r   )r   r=   r  r   rL   r=  r   r   r   r   r  r   r   r#  r  r  r   r  r   r"   r#   r   r   r   update_site_alarm_config  sL   
*	
z"BcmClient.update_site_alarm_configc                 C   r  )
        :param user_id:
        :type user_id: string
        :param alarm_name:
        :type alarm_name: string
        :param config:
        :type config:
        :return:
        s#   /userId/%s/site/alarm/config/detailr   r8   r   )r   r=   r   r   r"   r%   r   r   r   get_site_alarm_config_detail  r  z&BcmClient.get_site_alarm_config_detailc           
      C   s   t |}d| }i }	|dur||	d< |dur||	d< |dur#||	d< |du r,d|	d< n||	d< |du r9d|	d	< n||	d	< | jtj||	|d
S )a  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param alarm_name:
        :type alarm_name: string
        :param action_enabled:
        :type action_enabled: bool
        :param page_no:
        :type page_no: int
        :param page_size:
        :type page_size: int
        :param config:
        :return:
        s!   /userId/%s/site/alarm/config/listNr  r   r   r_   r`   ra   rb   r8   r   )
r   r=   r  r   r   rd   re   r   r"   r%   r   r   r   get_site_alarm_config_list  s    


z$BcmClient.get_site_alarm_config_listc                 C   0   t |}d| }||d}| jtj|||dS )r  s"   /userId/%s/site/alarm/config/blockr   ri   r8   r   r:   r.   r   rQ   r   r=   r   ri   r   r"   r%   r   r   r   block_site_alarm_config<     
z!BcmClient.block_site_alarm_configc                 C   r  )r  s$   /userId/%s/site/alarm/config/unblockr  r8   r	  r
  r   r   r   unblock_site_alarm_configQ  r  z#BcmClient.unblock_site_alarm_configc
                 C   s   t |}d| }
d|i}|dur||d< |dur||d< |dur.t|dkr.d||d< |dur6||d	< |dur>||d
< |durF||d< | jtj|
|tj|	dS )a  
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param metric_name:
        :type metric_name: string
        :param statistics:
        :type statistics: list
        :param start_time:
        :type start_time: string
        :param end_time:
        :type end_time: string
        :param cycle:
        :type cycle: int
        :param dimensions:
        :type dimensions: string
        :param config:
        :return:
        s   /userId/%s/site/metricSiteDatar  Nrx   r3   r   r   r   r5   r6   r   r%   r&   r   r   )r   r=   r  r?   rA   rB   rC   rm   r@   r   r"   r%   r   r   r   get_site_metric_dataf  s&   
zBcmClient.get_site_metric_datac                 C   s2   t |}d| }d|i}| jtj||tj|dS )
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param config:
        :type config:
        :return:
        s   /userId/%s/site/idc/overallViewr  r  r   r  r   r   r   get_site_overall_view  s   
zBcmClient.get_site_overall_viewc                 C   s4   t |}d| }||d}| jtj||tj|dS )z
        :param user_id:
        :type user_id: string
        :param task_id:
        :type task_id: string
        :param isp:
        :type isp: string
        :param config:
        :type config:
        :return:
        s"   /userId/%s/site/idc/provincialView)r  ispr  r   )r   r=   r  r  r   r"   r%   r   r   r   get_site_provincial_view  s   
z"BcmClient.get_site_provincial_viewc                 C   s(   t |}d| }| jtj|tj|dS )z}
        :param user_id:
        :type user_id: string
        :param config:
        :type config:
        :return:
        s   /userId/%s/site/agent/list)r&   r   r   )r   r=   r   r"   r   r   r   get_site_agent  s   

zBcmClient.get_site_agentc                 C   r  )r  s   /userId/%s/site/agent/idcIspr  r8   r   r  r   r   r   get_site_agent_for_task  r  z!BcmClient.get_site_agent_for_taskINSTANCENORMAL c                 C   sF  t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2td|du r:tdt |dkrDtd	t |dkrNtd
|du rTg }|
du rZg }
d}i d|d|d|d|d|d|d|d|d|
d|d|	d|d|d|d|d|d|d|i}| jtj|t|d dS )a  
            create alarm config

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alias_name: alarm config alias name
            :type alias_name: string

            :param scope: scope
            :type scope: string

            :param level: alarm level
            :type level: string

            :param region: alarm region
            :type region: string

            :param monitor_object: monitor object
            :type monitor_object: MonitorObject

            :param alarm_actions: alarm actions
            :type alarm_actions: string array

            :param rules: alarm rules
            :type rules: AlarmRule double dimensional array

            :param src_type: src type
            :type src_type: string

            :param ok_actions: ok actions
            :type ok_actions: string array

            :param insufficient_actions: insufficient actions
            :type insufficient_actions: string array

            :param config_type: alarm config type
            :type config_type: string

            :param insufficient_cycle: insufficient cycle
            :type insufficient_cycle: int

            :param max_repeat_count: max repeat count
            :type max_repeat_count: int

            :param repeat_alarm_cycle: repeat alarm cycle
            :type repeat_alarm_cycle: int

            :param callback_url: callback url
            :type callback_url: string

            :param callback_token: callback token
            :type callback_token: string

            :param description: description
            :type description: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   -alias_name should not be none or empty string(scope should not be none or empty stringr!  (level should not be none or empty stringN!monitor_object should not be none!alarm_actions should not be emptyrules should not be emptys   /services/alarm/config/creater   rE  rJ   r>   r#  r   r   alarmActions	okActionsr   r   r   r   r   r   r  callbackTokenr   r   r   )r   r=   r=  r>   r   r#  r   alarm_actionsr   r   
ok_actionsr   config_typer   r   r   r  callback_tokenr(  r   r"   r#   r   r   r   create_alarm_config  sv   C	
zBcmClient.create_alarm_configc                 C   s\  t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<td|du rDtd	t |dkrNtd
t |	dkrXtd|du r^g }|du rdg }d}i d|d|d|d|d|d|d|d|d|d|d|d|
d|d|d|d|d|||	d}| jtj|t|d dS ) ah  
            update alarm config

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param alias_name: alarm config alias name
            :type alias_name: string

            :param scope: scope
            :type scope: string

            :param level: alarm level
            :type level: string

            :param region: alarm region
            :type region: string

            :param monitor_object: monitor object
            :type monitor_object: MonitorObject

            :param alarm_actions: alarm actions
            :type alarm_actions: string array

            :param rules: alarm rules
            :type rules: AlarmRule double dimensional array

            :param src_type: src type
            :type src_type: string

            :param ok_actions: ok actions
            :type ok_actions: string array

            :param insufficient_actions: insufficient actions
            :type insufficient_actions: string array

            :param config_type: alarm config type
            :type config_type: string

            :param insufficient_cycle: insufficient cycle
            :type insufficient_cycle: int

            :param max_repeat_count: max repeat count
            :type max_repeat_count: int

            :param repeat_alarm_cycle: repeat alarm cycle
            :type repeat_alarm_cycle: int

            :param callback_url: callback url
            :type callback_url: string

            :param callback_token: callback token
            :type callback_token: string

            :param description: description
            :type description: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r  -alarm_name should not be none or empty stringr  r!  r  Nr  r  r  s   /services/alarm/config/updater   r   rE  rJ   r>   r#  r   r   r  r   r   r   r   r   r   r   r  )r!  r   r   r   )r   r=   r   r=  r>   r   r#  r   r"  r   r   r#  r   r$  r   r   r   r  r%  r(  r   r"   r#   r   r   r   update_alarm_configT  s|   G	
zBcmClient.update_alarm_configc                 C   d   t |dkr
tdt |dkrtdt |dkrtdd}|||d}| jtj|||d dS )	a  
            delete alarm config

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s   /services/alarm/config/deleter   r]   rf  r8   NrO   rP   r.   r   rQ   r   r=   r   r>   r   r"   r%   r   r   r   delete_alarm_config     zBcmClient.delete_alarm_configc                 C   r)  )	a  
            block alarm config

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s   /services/alarm/config/blockr*  r8   Nr+  r,  r   r   r   block_alarm_config  r.  zBcmClient.block_alarm_configc                 C   r)  )	a  
            unblock alarm config

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s   /services/alarm/config/unblockr*  r8   Nr+  r,  r   r   r   unblock_alarm_config  r.  zBcmClient.unblock_alarm_configc                 C   s`   t |dkr
tdt |dkrtdt |dkrtdd}|||d}| jtj|||dS )a  
            get alarm config detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r'  r  s   /services/alarm/configr*  r8   r   r,  r   r   r   get_alarm_config_detail0  s   z!BcmClient.get_alarm_config_detailbjdescc              	   C   s   t |dkr
tdt |dkrtd|dkrtd|dkr$tdd}|||||||	|d}|dur@|r<d	|d
< nd|d
< | jtj|||
dS )a  
            get alarm config detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param scope: scope
            :type scope: string

            :param region: region
            :type region: string

            :param page_no: page no
            :type page_no: int

            :param page_size: page size
            :type page_size: int

            :param alarm_name_prefix: alarm name prefix
            :type alarm_name_prefix: string

            :param action_enabled: action enable flag
            :type action_enabled: bool

            :param dimensions: dimensions
            :type dimensions: string

            :param order: order
            :type order: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r  z page_no should be greater than 0z"page_size should be greater than 0s   /services/alarm/config/list)r"  r]   rf  r`   rb   r3      orders   alarmNamePrefixNtruer   falser8   r   )r   r=   r>   rd   re   r#  Zalarm_name_prefixr   r@   r   r   r"   r%   r   r   r   !get_single_instance_alarm_configsT  s.   )

z+BcmClient.get_single_instance_alarm_configsc           
      C   sV   t |dkr
tdt |dkrtdd}||||||d}	| jtj||	tj|dS )a  
            get alarm config detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/Vks8iqqnx

            :param user_id: master account id
            :type user_id: string

            :param scope: scope
            :type scope: string

            :param region: region
            :type region: string

            :param dimensions: dimensions
            :type dimensions: string

            :param metric_type: metric type
            :type metric_type: string

            :param locale: locale
            :type locale: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r  s   /services/alarm/config/metrics)r"  r]   rf  r3   r  s   localer  )rO   rP   r.   r   r;   r	   r   )
r   r=   r>   r#  r@   Zmetric_typelocaler   r"   r%   r   r   r   get_alarm_metrics  s   zBcmClient.get_alarm_metricsInstancec                 C   s  t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<tdt |dkrFtdt |dkrPtd	|d
kr^t |	dkr^td|dkrlt |dkrltd|dkrzt |dkrztd|du rg }|du rg }|	du rg }	d||f }i d|d|d|d|d|d|d|d|d|d|d|
d|d|d|d |	d!|}| jtj|t||tjd"S )#a  
            get alarm config detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/blhrp7kdx

            :param user_id: master account id
            :type user_id: string

            :param alias_name: alarm config alias name
            :type alias_name: string

            :param scope: scope
            :type scope: string

            :param target_type: alarm config target type
            :type target_type: string

            :param level: alarm level
            :type level: string

            :param region: alarm config region
            :type region: string

            :param actions: alarm actions
            :type actions: AlarmAction array

            :param policies: alarm config policies
            :type policies: AlarmConfigPolicy array

            :param target_instances: alarm config target instances
            :type target_instances: TargetInstance array

            :param insufficient_period: insufficient data pending period
            :type insufficient_period: int

            :param alarm_repeat_interval: alarm repeat interval
            :type alarm_repeat_interval: int

            :param alarm_repeat_count: alarm repeat count
            :type alarm_repeat_count: int

            :param callback_url: callback url
            :type callback_url: string

            :param callback_token: callback token
            :type callback_token: string

            :param target_instance_tags: target instance tags
            :type target_instance_tags: KV array

            :param target_instance_groups: target instance groups
            :type target_instance_groups: string array

            :param resource_type: resource type
            :type resource_type: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r  r  .target_type should not be none or empty stringr  r!  actions should not be emptypolicies should not be emptyTARGET_TYPE_MULTI_INSTANCES$target_instances should not be emptyTARGET_TYPE_INSTANCE_GROUP*target_instance_groups should not be emptyTARGET_TYPE_INSTANCE_TAGS(target_instance_tags should not be emptyNs*   /userId/%s/services/%s/alarm/config/createrJ   r>   rE  
targetTyperesourceType
alarmLeveltargetInstanceGroupstargetInstanceTagsr  r!  insufficientDataPendingPeriodalarmRepeatIntervalalarmRepeatCountpoliciestargetInstancesactionsr#   r   r   )	rO   rP   r.   r   rQ   rR   rS   r   
version_v2)r   r=   r=  r>   target_typer   r#  rN  rL  target_instancesinsufficient_periodalarm_repeat_intervalalarm_repeat_countr  r%  target_instance_tagstarget_instance_groupsrm  r   r"   r#   r   r   r   create_alarm_config_v2  s   C	
z BcmClient.create_alarm_config_v2c                 C   s  t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<tdt |dkrFtdt |dkrPtd	t |	dkrZtd
|dkrht |
dkrhtd|dkrvt |dkrvtd|dkrt |dkrtd|du rg }|du rg }|
du rg }
d||f }i d|d|d|d|d|d|d|d|d|d|d|d|d|d |d!|	d"|
d#|}| jtj|t||tjd$S )%a  
            get alarm config detail

            This site may help you: https://cloud.baidu.com/doc/BCM/s/blhrp7kdx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param alias_name: alarm config alias name
            :type alias_name: string

            :param scope: scope
            :type scope: string

            :param target_type: alarm config target type
            :type target_type: string

            :param level: alarm level
            :type level: string

            :param region: alarm config region
            :type region: string

            :param actions: alarm actions
            :type actions: AlarmAction array

            :param policies: alarm config policies
            :type policies: AlarmConfigPolicy array

            :param target_instances: alarm config target instances
            :type target_instances: TargetInstance array

            :param insufficient_period: insufficient data pending period
            :type insufficient_period: int

            :param alarm_repeat_interval: alarm repeat interval
            :type alarm_repeat_interval: int

            :param alarm_repeat_count: alarm repeat count
            :type alarm_repeat_count: int

            :param callback_url: callback url
            :type callback_url: string

            :param callback_token: callback token
            :type callback_token: string

            :param target_instance_tags: target instance tags
            :type target_instance_tags: KV array

            :param target_instance_groups: target instance groups
            :type target_instance_groups: string array

            :param resource_type: resource type
            :type resource_type: string

            :param config:
            :type config: baidubce.BceClientConfiguration

            :return:
            :rtype baidubce.bce_response.BceResponse
        r   rG   r  r'  r  r;  r  r!  r<  r=  r>  r?  r@  rA  rB  rC  Ns*   /userId/%s/services/%s/alarm/config/updaterJ   r>   rE  r   rD  rE  rF  rG  rH  r  r!  rI  rJ  rK  rL  rM  rN  rO  )	rO   rP   r.   r   r[   rR   rS   r   rP  )r   r=   r   r=  r>   rQ  r   r#  rN  rL  rR  rS  rT  rU  r  r%  rV  rW  rm  r   r"   r#   r   r   r   update_alarm_config_v2=  s   F	
z BcmClient.update_alarm_config_v2c                 C   l   t |dkr
tdt |dkrtdt |dkrtdd||f }d|i}| jtj|||tjd dS )	a  
            block alarm config v2

            This site may help you: https://cloud.baidu.com/doc/BCM/s/blhrp7kdx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s)   /userId/%s/services/%s/alarm/config/blockr   r%   r   r   NrO   rP   r.   r   rQ   r   rP  r,  r   r   r   block_alarm_config_v2     
zBcmClient.block_alarm_config_v2c                 C   rZ  )	a  
            unblock alarm config v2

            This site may help you: https://cloud.baidu.com/doc/BCM/s/blhrp7kdx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s+   /userId/%s/services/%s/alarm/config/unblockr   r[  Nr\  r,  r   r   r   unblock_alarm_config_v2  r^  z!BcmClient.unblock_alarm_config_v2c                 C   rZ  )	a  
            get alarm config detail v2

            This site may help you: https://cloud.baidu.com/doc/BCM/s/blhrp7kdx

            :param user_id: master account id
            :type user_id: string

            :param alarm_name: alarm config name
            :type alarm_name: string

            :param scope: scope
            :type scope: string

            :param config:
            :type config: baidubce.BceClientConfiguration

        r   rG   r'  r  s#   /userId/%s/services/%s/alarm/configr   r[  N)rO   rP   r.   r   r;   r   rP  r,  r   r   r   get_alarm_config_detail_v2  s   z$BcmClient.get_alarm_config_detail_v2)r   r   r   r   c                 C   s   d}i d|d|d|d|d|d|d|d	|d
|	d|
d|d|d|d|d|d|d|d|i}| j tj|t|dS )  
        :param user_id:
        :type user_id: string
        :param alarm_name: alarm name
        :type alarm_name: string
        :param namespace: custom namespace
        :type namespace: string
        :param level: level
        :type level: string  enum: NOTICE, NOTICE, CRITICAL, MAJOR
        :param comment: comment
        :type comment: string
        :param action_enabled: is action enabled
        :type action_enabled: bool
        :param policy_enabled: is policy enabled
        :type policy_enabled: bool
        :param alarm_actions: alarm actions
        :type alarm_actions: list
        :param ok_actions: ok actions
        :type ok_actions: list of string
        :param insufficient_actions: insufficient actions
        :type insufficient_actions: list of string
        :param insufficient_cycle: insufficient cycle
        :type insufficient_cycle: int
        :param rules: rules
        :type rules: list of CustomAlarmRule
        :param region: region
        :type region: string
        :param callback_url: callback url
        :type callback_url: string
        :param callback_token: callback token
        :type callback_token: string
        :param tag: tag
        :type tag: string
        :param repeat_alarm_cycle: repeat alarm cycle
        :type repeat_alarm_cycle: int
        :param max_repeat_count: max repeat count
        :type max_repeat_count: int

        :return
        :rtype baidubce.bce_response.BceResponse
        s   /custom/alarm/configs/createrJ   r   ri   r   rL   r   policyEnabledr  r   r   r   r   r#  r  r!  r   r   r  r   r  r   r=   r   ri   r   rL   r   Zpolicy_enabledr"  r#  r   r   r   r#  r  r%  r  r   r   r"   r#   r   r   r   create_custom_alarm_policy  sN   0	
z$BcmClient.create_custom_alarm_policy)custom_alarm_listc                 C   sP   d}dg i}|D ]}|d  |d |d |d d q| jtj|t|dS )z
        :param custom_alarm_list:
        :type custom_alarm_list:  list of custom alarm

        :return
        :rtype baidubce.bce_response.BceResponse
        s   /custom/alarm/configs/deleteZcustomAlarmListr>   rJ   r   )r>   rJ   r   r   )r7  r.   r   rQ   rR   rS   )r   re  r"   r#   Zcustom_alarmr   r   r   delete_custom_alarm_policyb  s   	
z$BcmClient.delete_custom_alarm_policyc                 C   s   |du rg }|	du rg }|
du rg }
d}i d|d|d|d|d|d|d	|d
|d|	d|
d|d|d|d|d|d|d|d|i}| j tj|t|dS )ra  Ns   /custom/alarm/configs/updaterJ   r   ri   r   rL   r   rb  r  r   r   r   r   r#  r  r!  r   r   r  r   )r.   r   r[   rR   rS   rc  r   r   r   update_custom_alarm_policyx  sZ   0	
z$BcmClient.update_custom_alarm_policyc           	      C   s(   ||||||d}d}| j tj||dS )a  
        :param user_id:
        :type user_id: string
        :param page_no: page number
        :type page_no: int
        :param page_size: page size
        :type page_size: int
        :param alarm_name: alarm name
        :type alarm_name: string
        :param namespace: namespace
        :type namespace: string
        :param action_enabled: is action enabled
        :type action_enabled: bool

        :return
        :rtype baidubce.bce_response.BceResponse
        )r`   rb   r]   r   r   rw   s   /custom/alarm/configs/listr   r.   r   r;   )	r   r=   rd   re   r   ri   r   r%   r"   r   r   r   list_custom_policy  s   zBcmClient.list_custom_policyc                 C   "   |||d}d}| j tj||dS )aB  
        :param user_id:
        :type user_id: string
        :param namespace: namespace
        :type namespace: string
        :param alarm_name: alarm name
        :type alarm_name: string

        :return: Returns detailed information about a custom policy.
        :rtype: baidubce.bce_response.BceResponse
        r]   r   rw   s   /custom/alarm/configs/detailr   rh  r   r=   ri   r   r%   r"   r   r   r   detail_custom_policy     zBcmClient.detail_custom_policyc                 C   rj  )a   
        :param user_id: User's identifier
        :type user_id: string
        :param namespace: Namespace
        :type namespace: string
        :param alarm_name: Alarm name
        :type alarm_name: string

        :return:
        :rtype: baidubce.bce_response.BceResponse
        rk  s   /custom/alarm/configs/blockr   r.   r   rQ   rl  r   r   r   block_custom_policy  rn  zBcmClient.block_custom_policyc                 C   rj  )a  
        :param user_id: User's identifier
        :type user_id: str
        :param namespace: Namespace
        :type namespace: str
        :param alarm_name: Alarm name
        :type alarm_name: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        rk  s   /custom/alarm/configs/unblockr   ro  rl  r   r   r   unblock_custom_policy  rn  zBcmClient.unblock_custom_policyNET_QUAILTYipv4Fc                 C   sv   g d}|dur||vrt dt| dt| }|du r!i }||||||||	|
||d}| jtj|t|dS )a  
        :param site_once_type: Type of site
        :type site_once_type: str
        :param user_id: User's identifier
        :type user_id: str
        :param address: Address
        :type address: str
        :param idc: IDC
        :type idc: str
        :param timeout: Timeout
        :type timeout: int
        :param protocol_type: Protocol type
        :type protocol_type: str
        :param once_config: Configuration for once
        :type once_config: dict
        :param task_type: Task type
        :type task_type: str
        :param ip_type: IP type
        :type ip_type: str
        :param advanced_flag: Advanced flag
        :type advanced_flag: bool
        :param advanced_config: Advanced configuration
        :type advanced_config: dict
        :param group_id: Group identifier
        :type group_id: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        )HTTPZHTTPSZPINGFTPZTCPZUDPDNSNz(site_once_type must be none or one of %ss   /site/once/%s/taskCreate)rJ   r  r  r  ZprotocolTypeZ
onceConfigZtaskTypeZipTypeZadvancedFlagZadvancedConfiggroupIdr   )	rP   r   r   r:   r.   r   rQ   rR   rS   )r   Zsite_once_typer=   r  r  r  Zprotocol_typeZonce_configZ	task_typeip_typeZadvanced_flagZadvanced_configgroup_idtypesr"   r#   r   r   r   create_site_once_task  s&    zBcmClient.create_site_once_taskc           
      C   s0   d}|||||||d}	| j tj|t|	dS )a  
        :param user_id: User's identifier, defaults to None
        :type user_id: str
        :param url: URL
        :type url: str
        :param page_no: Page number
        :type page_no: int
        :param page_size: Page size
        :type page_size: int
        :param order: Order
        :type order: str
        :param order_by: Order by
        :type order_by: str
        :param group_id: Group identifier
        :type group_id: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        s   /site/once/taskList)rJ   urlr   r   r   orderByrw  r   r  )
r   r=   r|  rd   re   r   order_byry  r"   r#   r   r   r   list_site_once_recordsT  s   	z BcmClient.list_site_once_recordsc                 C   &   d}||d}| j tj|t|dS )
        :param user_id: User's identifier
        :type user_id: str
        :param site_id: Site identifier
        :type site_id: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        s   /site/once/taskDeleterJ   siteIdr   r  r   r=   site_idr"   r#   r   r   r   delete_site_once_recordu  
   
z!BcmClient.delete_site_once_recordc	              	   C   s2   d}	||||||||d}
| j tj|	t|
dS )aS  
        :param user_id: User's identifier
        :type user_id: str
        :param site_id: Site identifier
        :type site_id: str
        :param page_no: Page number
        :type page_no: int
        :param page_size: Page size
        :type page_size: int
        :param order: Order
        :type order: str
        :param order_by: Order by
        :type order_by: str
        :param filter_area: Filter area
        :type filter_area: str
        :param filter_isp: Filter ISP
        :type filter_isp: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        s   /site/once/loadData)rJ   r  r   r   r   r}  
filterArea	filterIspr   r  )r   r=   r  rd   re   r   r~  filter_area
filter_ispr"   r#   r   r   r   detail_site_once_result  s   
z!BcmClient.detail_site_once_resultc                 C   s6   d}|||||||||	|
d
}| j tj|t|dS )a  
        :param user_id: User's identifier
        :type user_id: str
        :param site_id: Site identifier
        :type site_id: str
        :param site_ids: List of site identifiers
        :type site_ids: list
        :param group_id: Group identifier
        :type group_id: str
        :param page_no: Page number
        :type page_no: int
        :param page_size: Page size
        :type page_size: int
        :param order: Order
        :type order: str
        :param order_by: Order by
        :type order_by: str
        :param filter_area: Filter area
        :type filter_area: str
        :param filter_isp: Filter ISP
        :type filter_isp: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        s   /site/once/groupTask)
rJ   r  ZsiteIdsrw  r   r   r   r}  r  r  r   r  )r   r=   r  Zsite_idsry  rd   re   r   r~  r  r  r"   r#   r   r   r   detail_site_once  s   zBcmClient.detail_site_oncec                 C   r  )r  s   /site/once/createFromTaskr  r   r  r  r   r   r   again_exec_site_once  r  zBcmClient.again_exec_site_oncec                 C   s(   d}|||d}| j tj|t|dS )a  
        :param user_id: User's identifier
        :type user_id: str
        :param site_id: Site identifier
        :type site_id: str
        :param group_id: group identifier
        :type group_id: str
        :return:
        :rtype: baidubce.bce_response.BceResponse
        s   /site/once/groupTaskList)rJ   rw  r  r   r  )r   r=   r  ry  r"   r#   r   r   r   list_site_once_history  s   z BcmClient.list_site_once_historyc                 C   sH   ddg}|dur||vrt dt| ||d}d}| jtj||dS )z
        :param user_id: User's identifier
        :type user_id: str
        :param ip_type: the type of ip, enum: ipv4, ipv6
        :type ip_type: str

        :return:
        :rtype: baidubce.bce_response.BceResponse
        rs  Zipv6Nz!ip_type must be none or one of %s)r]   s   ipTypes   /site/once/siteAgentr   )rP   r   r.   r   r;   )r   r=   rx  rz  r%   r"   r   r   r   get_site_once_agent  s   
zBcmClient.get_site_once_agent)	r=   r>   r#  rm  r@   metric_namesr  rA   rm   c
                 C   s*  t |dkr
tdt |dkrtd|du rtdt |tkr(tdt |	du r.d}	|||	d}
g }|D ]}|| q8||
d	< |durL||
d
< |durT||
d< |durhg }|D ]}|| q\||
d< |durp||
d< |durx||
d< t|}t|}d||f }| jtj|dt	
|
dS )a(  
        :param user_id: str
        :param scope: str
        :param region: str
        :param resource_type: str
        :param dimensions: list
        :param metric_names: list
        :param timestamp: str
        :param statistics: list
        :param cycle: int

        :return:
        r   r%  scope should not be nullNmetric_names should not be null!dimensions size cannot more than rn   )rJ   r>   rm   metricNamesr#  rE  r@   r  rA   s3   /userId/%s/services/%s/data/metricData/latest/batchr   r   r#   rO   rP   MAX_INSTANCE_NUMBERr7  r   r:   r.   r   rQ   rR   rS   )r   r=   r>   r#  rm  r@   r  r  rA   rm   r#   Zmetric_names_reqresdimensions_resr"   r   r   r   "get_multi_dimension_latest_metrics  sF   

z,BcmClient.get_multi_dimension_latest_metricsc                 C   sT  t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<tdt |	tkrHtdt ||||||d	}|d
urY||d< |d
ura||d< |	d
urug }|	D ]}|| qi||d< |
d
ur}|
|d< |d
ur||d< |d
ur||d< t|}t|}d||f }| jtj|dt	
|dS )a|  
        :param user_id: str
        :param scope: str
        :param statistics: list
        :param metric_name: str
        :param start_time: str
        :param end_time: str
        :param region: str
        :param resource_type: str
        :param dimensions: list
        :param cycle: int
        :param pageNo: int
        :param pageSize: int

        :return:
        r   r%  r  metric_name should not be nullstart_time should not be nullend_time should not be nullstatistics should not be nullr  )rJ   r>   r  r  rA   rj   Nr#  rE  r@   rm   r   r   s7   /userId/%s/services/%s/data/metricData/PartialDimensionr   r  r  )r   r=   r>   rA   r?   rB   rC   r#  rm  r@   rm   r   r   r#   r  r  r"   r   r   r   !get_metrics_by_partial_dimensionsC  sP   

z+BcmClient.get_metrics_by_partial_dimensionsrn   c              
   C   s   t |dkr
tdt |dkrtdt |dkrtd|du r&td|du r.td|du r6tdt |tkrBtd	t |||
||||||d
	}|	durV|	|d< d}| jtj|dt|dS )ag  
        :param user_id: user_id
        :type string

        :param scope: scope
        :type string

        :param region: region
        :type string

        :param type: resource type
        :type string

        :param dimensions: dimensions
        :type double string array

        :param metric_names: metric names
        :type  string array

        :param statistics: statistics
        :type  string array

        :param cycle: cycle
        :type  int

        :param start_time: start time
        :type  string

        :param end_time: end time
        :type  string
        :return:
        r   r%  r  r2  Nr  dimensions should not be nullr  r  	rJ   r>   rm   r#  r  r  r  r@   rA   r   s   /data/metricAllDatar   r  rO   rP   r  r.   r   rQ   rR   rS   r   r=   r>   r#  r@   r  rA   rB   rC   r   rm   r#   r"   r   r   r   get_all_data_metrics_v2  s8   #z!BcmClient.get_all_data_metrics_v2c              
   C   s   t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<tdt |tkrHtdt |||
||||||d		}|	d
ur\|	|d< d}| jtj|dt|dS )ah  
        :param user_id: user_id
        :type string

        :param scope: scope
        :type string

        :param region: region
        :type string

        :param dimensions: dimensions
        :type double dimensional dict array

        :param metric_names: metric names
        :type  string array

        :param statistics: statistics
        :type  string array

        :param start_time: start time
        :type  string

        :param end_time: end time
        :type  string

        :param type: type
        :type string

        :param cycle: cycle
        :type  int
        :return:
        r   r%  r  r2  r  r  r  r  r  Nr   s   /data/metricAllData/batchr   r  r  r  r   r   r   batch_get_all_data_metrics_v2  s8   #z'BcmClient.batch_get_all_data_metrics_v2topc                 C   s   t |dkr
tdt |dkrtdt |dkrtdt |dkr(tdt |dkr2tdt |dkr<tdt |dkrFtdt |dkrPtd	t |	dkrZtd
|||||	|||||
|d}d}| jtj|dt|dS )a  
        :param user_id: user_id
        :type string

        :param scope: scope
        :type string

        :param region: region
        :type string

        :param dimensions: dimensions
        :type map

        :param metric_name: metric_name
        :type string

        :param statistics: statistics
        :type string

        :param labels: labels
        :type set

        :param start_time: start_time
        :type string

        :param end_time: end_time
        :type string

        :param order: order default top
        :type string

        :param topNum: topNum default 10
        :type int

        :return:
        r   r%  r  r2  r  r  zlables should not be nullr  r  r  )rJ   r>   r#  r  r  rj   r@   rA   labelsr   topNums   /dimensions/topr   r  r   )r   r=   r>   r#  r@   r?   rA   r  rB   rC   r   r  r#   r"   r   r   r   get_metric_dimension_top  s@   'z"BcmClient.get_metric_dimension_topc                 C   j   t |dkr
tdd|i}|dur||d< |dur||d< |dur&||d< d}| jtj|t||d	S )
u  
        创建事件总线。

        :param event_bus_name:
            事件总线名称，不能为空。
        :type event_bus_name: string

        :param event_bus_alias:
            事件总线别名。
        :type event_bus_alias: string

        :param description:
            事件总线描述信息。
        :type description: string

        :param type:
            事件总线类型。
        :type type: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_name 为空时抛出。
        r   z!event_bus_name should not be nulleventBusNameNeventBusAliasr(  r       rM   rO   rP   r2   r   rQ   rR   rS   )r   event_bus_nameevent_bus_aliasr(  r   r   r#   r"   r   r   r   create_event_busR  s   

zBcmClient.create_event_busc           	      C   sz   t |dkr
tdd|i}|dur||d< |dur||d< |dur&||d< |dur.||d< d	}| jtj|t||d
S )u  
        更新事件总线信息。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param event_bus_name:
            事件总线名称。
        :type event_bus_name: string

        :param event_bus_alias:
            事件总线别名。
        :type event_bus_alias: string

        :param description:
            事件总线描述信息。
        :type description: string

        :param type:
            事件总线类型。
        :type type: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   event_bus_id should not be null
eventBusIdNr  r  r(  r   r  rM   rO   rP   r2   r   r[   rR   rS   )	r   event_bus_idr  r  r(  r   r   r#   r"   r   r   r   update_event_bus  s    !

zBcmClient.update_event_busc                 C   :   t |dkr
tdd|i}d}| jtj|t||dS )up  
        删除指定的事件总线。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  r  rM   rO   rP   r2   r   r   rR   rS   )r   r  r   r#   r"   r   r   r   delete_event_bus     

zBcmClient.delete_event_busc                 C   r  )ut  
        批量删除事件总线。

        :param event_bus_ids:
            事件总线ID列表，不能为空。
        :type event_bus_ids: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_ids 为空时抛出。
        r   z event_bus_ids should not be nullZeventBusIdss   /batchrM   r  )r   Zevent_bus_idsr   r#   r"   r   r   r   batch_delete_event_bus  r  z BcmClient.batch_delete_event_busc                 C   4   t |dkr
tdd|i}d}| jtj|||dS )um  
        获取事件总线详情。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  
   eventBusIdr  r8   rO   rP   r2   r   r;   r   r  r   r%   r"   r   r   r   get_event_bus_detail     
zBcmClient.get_event_bus_detailc	                 C   s   i }	|du rd|	d< n||	d< |du rd|	d< n||	d< |dur$||	d< |dur,||	d< |dur4||	d< |dur<||	d	< |durD||	d
< d}
| j tj|
|	|dS )u6  
        分页查询事件总线列表。

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param type:
            事件总线类型过滤。
        :type type: string

        :param keyword_type:
            关键字搜索类型。
        :type keyword_type: string

        :param keyword:
            搜索关键字。
        :type keyword: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        Nr_   r`   ra   rb      orderByr4  r  r  r  s   /listr8   )r2   r   r;   )r   rd   re   r~  r   r   r  r  r   r%   r"   r   r   r   list_event_bus  s*   (


zBcmClient.list_event_busc                 C   r  )u  
        获取事件总线的事件源事件信息。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  s   /source-eventr8   r  r  r   r   r   get_event_bus_eventB  r  zBcmClient.get_event_bus_eventc	                 C   s   t |dkr
tdd|i}	|du rd|	d< n||	d< |du r$d|	d< n||	d< |dur0||	d	< |dur8||	d
< |dur@||	d< |durH||	d< d}
| jtj|
|	|dS )u  
        分页查询事件总线的事件源列表。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param keyword_type:
            关键字搜索类型。
        :type keyword_type: string

        :param keyword:
            搜索关键字。
        :type keyword: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  Nr_   r`   ra   rb   r  r4  r  r  s   /source/listr8   r  )r   r  rd   re   r~  r   r  r  r   r%   r"   r   r   r   list_event_bus_source^  s,   *


zBcmClient.list_event_bus_sourcec                 C   sp   t |dkr
tdt |dkrtd||d}|dur!||d< |dur)||d< d}| jtj|t||d	S )
u  
        为事件总线创建事件源。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param event_source_name:
            事件源名称，不能为空。
        :type event_source_name: string

        :param event_source_alias:
            事件源别名。
        :type event_source_alias: string

        :param type:
            事件源类型。
        :type type: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 或 event_source_name 为空时抛出。
        r   r  z$event_source_name should not be null)r  eventSourceNameNeventSourceAliasr      /sourcerM   r  )r   r  event_source_nameevent_source_aliasr   r   r#   r"   r   r   r   create_event_bus_source  s   

z!BcmClient.create_event_bus_sourcec           	      C   s   t |dkr
tdt |dkrtd||d}|dur!||d< |dur)||d< |dur1||d< d	}| jtj|t||d
S )u$  
        更新事件总线的事件源信息。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param event_source_name:
            事件源名称。
        :type event_source_name: string

        :param event_source_alias:
            事件源别名。
        :type event_source_alias: string

        :param type:
            事件源类型。
        :type type: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 或 event_source_id 为空时抛出。
        r   r  "event_source_id should not be null)r  eventSourceIdNr  r  r   r  rM   r  )	r   r  event_source_idr  r  r   r   r#   r"   r   r   r   update_event_bus_source  s"   "

z!BcmClient.update_event_bus_sourcec                 C   r  )us  
        删除指定的事件源。

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_source_id 为空时抛出。
        r   r  r  r  rM   r  )r   r  r   r#   r"   r   r   r   delete_event_bus_source  r  z!BcmClient.delete_event_bus_sourcec
                 C      t |dkr
tdd|i}
|du rd|
d< n||
d< |du r$d|
d< n||
d< |dur0||
d	< |dur8||
d
< |dur@||
d< |durH||
d< |durP||
d< d}| jtj||
|	dS )u  
        分页查询事件源下的事件类型列表。

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param event_level:
            事件级别过滤。
        :type event_level: string

        :param keyword_type:
            关键字搜索类型。
        :type keyword_type: string

        :param keyword:
            搜索关键字。
        :type keyword: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_source_id 为空时抛出。
        r   r     eventSourceIdNr_   r`   ra   rb   r  r4  rg  r  r  s   /event/listr8   r  )r   r  rd   re   r~  r   r   r  r  r   r%   r"   r   r   r   list_event_bus_event_type$  0   .


z#BcmClient.list_event_bus_event_typec                 C   sJ   t |dkr
tdt |dkrtd||d}d}| jtj|||dS )u  
        获取指定事件源下某个事件类型的详情。

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param event_type:
            事件类型，不能为空。
        :type event_type: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_source_id 或 event_type 为空时抛出。
        r   r  event_type should not be null)r  	   eventType   /eventr8   r  )r   r  
event_typer   r%   r"   r   r   r   get_event_bus_event_detailo  s   
z$BcmClient.get_event_bus_event_detailc
                 C      t |dkr
tdt |dkrtd||d}
|dur!||
d< |dur)||
d< |dur1||
d< |dur9||
d	< |durA||
d
< |durI||
d< d}| jtj|t|
|	dS )u/  
        在指定事件源下创建事件类型。

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param event_type:
            事件类型标识，不能为空。
        :type event_type: string

        :param event_alias:
            事件类型中文别名。
        :type event_alias: string

        :param event_alias_en:
            事件类型英文别名。
        :type event_alias_en: string

        :param event_level:
            事件级别。
        :type event_level: string

        :param type:
            类型。
        :type type: string

        :param description:
            事件类型描述信息。
        :type description: string

        :param demo:
            事件示例数据。
        :type demo: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_source_id 或 event_type 为空时抛出。
        r   r  r  r  Z	eventTypeN
eventAliaseventAliasEnr   r   r(  demor  rM   r  r   r  r  rl  Zevent_alias_enr   r   r(  r  r   r#   r"   r   r   r   create_event_bus_event  .   .

z BcmClient.create_event_bus_eventc                 C   r  )u  
        批量创建事件类型。

        :param events:
            事件类型列表，不能为空。每个元素应包含 eventSourceId、eventType 等字段。
        :type events: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 events 为空时抛出。
        r   events should not be nullevents   /event/batchrM   r  r   r  r   r#   r"   r   r   r   batch_create_event_bus_event  r  z&BcmClient.batch_create_event_bus_eventc
                 C   r  )u5  
        更新指定事件源下的事件类型信息。

        :param event_source_id:
            事件源ID，不能为空。
        :type event_source_id: string

        :param event_type:
            事件类型标识，不能为空。
        :type event_type: string

        :param event_alias:
            事件类型中文别名。
        :type event_alias: string

        :param event_alias_en:
            事件类型英文别名。
        :type event_alias_en: string

        :param event_level:
            事件级别。
        :type event_level: string

        :param type:
            类型。
        :type type: string

        :param description:
            事件类型描述信息。
        :type description: string

        :param demo:
            事件示例数据。
        :type demo: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_source_id 或 event_type 为空时抛出。
        r   r  r  r  Nr  r  r   r   r(  r  r  rM   r  r  r   r   r   update_event_bus_event  r  z BcmClient.update_event_bus_eventc                 C   r  )u  
        批量删除事件类型。

        :param events:
            待删除的事件类型列表，不能为空。每个元素应包含 eventSourceId、eventType 等字段。
        :type events: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 events 为空时抛出。
        r   r  r  r  rM   r  r  r   r   r   batch_delete_event_bus_event:  r  z&BcmClient.batch_delete_event_bus_eventc                 C   s>   t |dkr
tdd|i}d}| jtj|t||tjdS )ug  
        接收并投递事件到事件总线。

        :param events:
            事件列表，不能为空。每个事件包含事件数据。
        :type events: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype list

        :raises ValueError: 当 events 为空时抛出。
        r   r  r  s   /recv)r#   r   r&   )	rO   rP   r2   r   rQ   rR   rS   r	   r   r  r   r   r   recv_event_bus_eventV  s   

zBcmClient.recv_event_bus_eventc           
      C      t |dkr
tdt |dkrtdt |dkrtdt |dkr(td||||d}|dur7||d< |dur?||d	< d
}	| jtj|	t||dS )u  
        为事件总线创建事件规则。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param rule_name:
            规则名称，不能为空。
        :type rule_name: string

        :param targets:
            规则触发目标列表，不能为空。
        :type targets: list

        :param filter_pattern:
            事件过滤模式，不能为空。
        :type filter_pattern: string

        :param description:
            规则描述信息。
        :type description: string

        :param status:
            规则状态。
        :type status: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id、rule_name、targets 或 filter_pattern 为空时抛出。
        r   r  rule_name should not be nulltargets should not be null!filter_pattern should not be null)r  ruleNametargetsfilterPatternNr(  status   /rulerM   r  )
r   r  	rule_namer  filter_patternr(  r  r   r#   r"   r   r   r   create_event_bus_rules  *   %

zBcmClient.create_event_bus_rulec           
      C   r  )u  
        更新事件总线的事件规则。

        :param event_rule_id:
            事件规则ID，不能为空。
        :type event_rule_id: string

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param rule_name:
            规则名称，不能为空。
        :type rule_name: string

        :param filter_pattern:
            事件过滤模式，不能为空。
        :type filter_pattern: string

        :param description:
            规则描述信息。
        :type description: string

        :param status:
            规则状态。
        :type status: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_rule_id、event_bus_id、rule_name 或 filter_pattern 为空时抛出。
        r    event_rule_id should not be nullr  r  r  )eventRuleIdr  r  r  Nr(  r  r  rM   r  )
r   event_rule_idr  r  r  r(  r  r   r#   r"   r   r   r   update_event_bus_rule  r  zBcmClient.update_event_bus_rulec                 C   sf   t |dkr
tdt |dkrtdt |dkrtd|||d}d}| jtj|t||dS )uh  
        批量更新事件规则的状态。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param event_rule_ids:
            事件规则ID列表，不能为空。
        :type event_rule_ids: list

        :param status:
            目标状态，不能为空。
        :type status: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id、event_rule_ids 或 status 为空时抛出。
        r   r  !event_rule_ids should not be nullzstatus should not be null)r  eventRuleIdsr  s   /rule/statusrM   r  )r   r  event_rule_idsr  r   r#   r"   r   r   r   "batch_update_event_bus_rule_status  s   

z,BcmClient.batch_update_event_bus_rule_statusc                 C   P   t |dkr
tdt |dkrtd||d}d}| jtj|t||dS )u  
        批量删除事件总线下的事件规则。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param event_rule_ids:
            事件规则ID列表，不能为空。
        :type event_rule_ids: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 或 event_rule_ids 为空时抛出。
        r   r  r  )r  r  r  rM   r  )r   r  r  r   r#   r"   r   r   r   batch_delete_event_bus_rule     

z%BcmClient.batch_delete_event_bus_rulec
                 C   r  )u  
        分页查询事件总线下的事件规则列表。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param status:
            规则状态过滤。
        :type status: string

        :param keyword_type:
            关键字搜索类型。
        :type keyword_type: string

        :param keyword:
            搜索关键字。
        :type keyword: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  Nr_   r`   ra   rb   r  r4     statusr  r  s
   /rule/listr8   r  )r   r  rd   re   r~  r   r  r  r  r   r%   r"   r   r   r   list_event_bus_rule7  r  zBcmClient.list_event_bus_rulec                 C   r  )up  
        获取事件规则详情。

        :param event_rule_id:
            事件规则ID，不能为空。
        :type event_rule_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_rule_id 为空时抛出。
        r   r     eventRuleIdr  r8   r  )r   r  r   r%   r"   r   r   r   get_event_bus_rule_detail  r  z#BcmClient.get_event_bus_rule_detailc                 C   r   )u  
        为事件规则批量创建触发目标。

        :param event_rule_id:
            事件规则ID，不能为空。
        :type event_rule_id: string

        :param targets:
            触发目标列表，不能为空。
        :type targets: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_rule_id 或 targets 为空时抛出。
        r   r  r  )r  r     /rule/targetrM   r  )r   r  r  r   r#   r"   r   r   r   "batch_create_event_bus_rule_target  r  z,BcmClient.batch_create_event_bus_rule_targetc                 C   r  )
u  
        批量更新事件规则的触发目标，支持新增、编辑和删除操作。

        :param event_rule_id:
            事件规则ID，不能为空。
        :type event_rule_id: string

        :param add_targets:
            待新增的触发目标列表。
        :type add_targets: list

        :param edit_targets:
            待编辑的触发目标列表。
        :type edit_targets: list

        :param del_target_ids:
            待删除的触发目标ID列表。
        :type del_target_ids: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_rule_id 为空时抛出。
        r   r  r  NZ
addTargetsZeditTargetsZdelTargetIdsr  rM   r  )r   r  Zadd_targetsZedit_targetsZdel_target_idsr   r#   r"   r   r   r   "batch_update_event_bus_rule_target  s   

z,BcmClient.batch_update_event_bus_rule_targetc                 C   r   )u  
        批量删除事件规则的触发目标。

        :param event_rule_id:
            事件规则ID，不能为空。
        :type event_rule_id: string

        :param target_ids:
            待删除的触发目标ID列表，不能为空。
        :type target_ids: list

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_rule_id 或 target_ids 为空时抛出。
        r   r  ztarget_ids should not be null)r  Z	targetIdsr  rM   r  )r   r  Z
target_idsr   r#   r"   r   r   r   "batch_delete_event_bus_rule_target  r  z,BcmClient.batch_delete_event_bus_rule_targetc                 C   r  )u  
        测试事件是否匹配指定的事件规则模式。

        :param event:
            待匹配的事件数据。
        :type event: dict

        :param event_pattern:
            事件过滤模式。
        :type event_pattern: dict

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        )eventZeventPatterns   /rule/matchrM   )r2   r   rQ   rR   rS   )r   r  Zevent_patternr   r#   r"   r   r   r   match_event_bus_rule  s   

zBcmClient.match_event_bus_rulec                 C   s  t |dkr
tdd|i}|du rd|d< n||d< |du r$d|d< n||d< |dur0||d	< |dur8||d
< |dur@||d< |durH||d< |durP||d< |	durX|	|d< |
dur`|
|d< |durh||d< |durp||d< |durx||d< d}| jtj|||dS )u  
        分页查询事件总线的历史事件记录。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param start_time:
            查询起始时间。
        :type start_time: string

        :param end_time:
            查询结束时间。
        :type end_time: string

        :param source:
            事件来源过滤。
        :type source: string

        :param event_type:
            事件类型过滤。
        :type event_type: string

        :param event_type_alias:
            事件类型别名过滤。
        :type event_type_alias: string

        :param event_id:
            事件ID过滤。
        :type event_id: string

        :param level:
            事件级别过滤。
        :type level: string

        :param region:
            地域过滤。
        :type region: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  Nr_   r`   ra   rb   r  r4  r5   r6      sourcer     eventTypeAliasri     levelr"  s	   /historicr8   r  )r   r  rd   re   r~  r   rB   rC   r   r  event_type_aliasrn  r   r#  r   r%   r"   r   r   r   get_event_bus_historic*  sD   C


z BcmClient.get_event_bus_historicc                 C   s8  t |dkr
tdd|i}|du rd|d< n||d< |du r$d|d< n||d< |dur0||d	< |dur8||d
< |dur@||d< |durH||d< |durP||d< |	durX|	|d< |
dur`|
|d< |durh||d< |durp||d< |durx||d< |dur||d< |dur||d< |dur||d< d}| jtj|||dS )u  
        分页查询事件总线的历史触发记录。

        :param event_bus_id:
            事件总线ID，不能为空。
        :type event_bus_id: string

        :param page_no:
            页码，默认为1。
        :type page_no: int

        :param page_size:
            每页数量，默认为10。
        :type page_size: int

        :param order_by:
            排序字段。
        :type order_by: string

        :param order:
            排序方式。
        :type order: string

        :param start_time:
            查询起始时间。
        :type start_time: string

        :param end_time:
            查询结束时间。
        :type end_time: string

        :param source:
            事件来源过滤。
        :type source: string

        :param event_type:
            事件类型过滤。
        :type event_type: string

        :param event_type_alias:
            事件类型别名过滤。
        :type event_type_alias: string

        :param event_rule_id:
            事件规则ID过滤。
        :type event_rule_id: string

        :param event_rule_name:
            事件规则名称过滤。
        :type event_rule_name: string

        :param event_id:
            事件ID过滤。
        :type event_id: string

        :param level:
            事件级别过滤。
        :type level: string

        :param status:
            触发状态过滤。
        :type status: string

        :param region:
            地域过滤。
        :type region: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse

        :raises ValueError: 当 event_bus_id 为空时抛出。
        r   r  r  Nr_   r`   ra   rb   r  r4  r5   r6   r  r  r  r  s   eventRuleNameri  r  r  r"  s   /historic/triggerr8   r  )r   r  rd   re   r~  r   rB   rC   r   r  r  r  Zevent_rule_namern  r   r  r#  r   r%   r"   r   r   r   get_event_bus_historic_trigger  sP   Q


z(BcmClient.get_event_bus_historic_triggerr   )NNNNN)r   NNNNN)	NNNNNNNNN)NNN)NNNN)NN)NNNNNN)TNNNNr   r   )NNNNNNN)NNNNNNNN)r_   ra   NNNNNNNNNNNN)r_   ra   NNNNNNNNNN)
NNNNNNNNNN)NNNNNNNNNNN)NNNNNNNNNNNNN)NNNNNNNNNNNNNN)NNNNNNNNNNNN)NNNNNNNNNNNNNNNNN)NNNNNNNNNNNNNNNNNN)r  NNr  r   r   r   r  r  r  N)r2  r  Nr  r3  N)r2  r  r  r  N)
Nr   r   r   r  r  NNr:  N)r  TNNNNNNNNNr  r   r   )rr  rs  FNN)NNr_   ra   NNN)r_   ra   NNNN)	NNNr_   ra   NNNN)r  r  r  )rs  )r:  rn   )r  ra   )NNNNNNNNNNNNNNNN)__name__
__module____qualname____doc__r   r-   r/   r1   r   rP  r(   r)   r*   r   r   r'   r.   r0   r2   rD   rE   rU   rY   r\   rf   rq   rs   ru   ry   rz   r   r   r   r   r   r   intr   r   listr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r   r$  r+  r,  r/  r1  r5  
value_typer9  r;  r<  rR  rS  rT  rU  rV  r^  r`  ra  rb  r   ro  rp  rt  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r&  r(  r-  r/  r0  r1  r7  r9  rX  rY  r]  r_  r`  rd  rf  rg  ri  rm  rp  rq  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r
  r  r  r  r   r   r   r   r   #   sX   	IJ* *1J'I>'<&=@
(
!
& /
$EE#-!!$/:"&
FI71
$











 
$
*F!+.+.(+.9.903-0&?B*/qv"""%D0w|!! 
FM5!$*6>CDM.4@F06K"HH>>)!K"/!jr   )r  r   rR   sysr+   Zbaidubcer   r   r   Zbaidubce.authr   Zbaidubce.httpr   r   r   Zbaidubce.services.bcmr	   r
   Zbaidubce.utilsr   version_infor   unicoder  bytesr  r   r   r   r   r   r   <module>   s   
