o
    lqi9                    @   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daddZdaddZ	
	
dbddZ		
dcddZ	
dbddZ	
	
	
ddddZ	
	
	
ddddZdeddZdaddZdeddZdfdd Z	
dbd!d"Zdad#d$Z	
dbd%d&Z	
dbd'd(Zdad)d*Z	
ded+d,Zdad-d.Z	
ded/d0Z	
dbd1d2Zdad3d4Z e!e"e"d5dad6d7Z#e!e"e"d5dad8d9Z$e!e"e"e%e%d:dgd;d<Z&d=d> Z'e!e"e"d5dgd?d@Z(e!e"e"e%e%d:	
	
dgdAdBZ)dCdD Z*	
dadEdFZ+	
dbdGdHZ,dadIdJZ-dKdL Z.dMdN Z/e!e"e"d5	
	
dhdOdPZ0e!e%dQ	
	S	SdidTdUZ1e!e%dQ	
	S	SdidVdWZ2dbdXdYZ3dedZd[Z4	
	
dhd\d]Z5ded^d_Z6ded`daZ7dedbdcZ8dfdddeZ9dfdfdgZ:dfdhdiZ;	
	
djdjdkZ<dedldmZ=dedndoZ>dedpdqZ?dedrdsZ@dedtduZA	
dgdvdwZBdedxdyZCdfdzd{ZDded|d}ZEdad~dZF	
	
dfddZGe!eHeHe%ddaddZIdgddZJdaddZKe!eHeHeHe"eHe"eHeHeHe"e%e%d	
	
dkddZLdaddZMdgddZNe!eHeHeHeHe"eHe"eHeHeHe"e%e%d	
	
dkddZOdaddZPdaddZQdgddZRdaddZSdaddZTe!e"e"eUeUeUd	
	
	
dlddZVe!e"e"eUeUeUd	
	
	
dmddZWe!eUeUeUeUe%ddd ZXe!eUeUeUeUeUddd ZYe!eUeUeUeUeUeUddd ZZe!eUeUddd Z[e!eUeUddd Z\e!eUe"e"ddd Z]e!eUeUe%ddd Z^e!eUeUe%ddd Z_e!eUeUeUeUeUeUe"e"ddd Z`e!eUeUeUeUeUeUeUe"e"d	dd Zae!eUeUeUeUeUeUeUeUeUe"e"ddd ZbdfddĄZc	
	
	
ddddƄZd	
	
	
djddȄZe	
	
	
dnddʄZf	
	
	
dodd̄Zgdedd΄Zh	
	
	
dnddЄZi	
	
	
dodd҄ZjdeddԄZk	
	
	
ddddքZl	
	
	
dndd؄ZmdeddڄZn	
	
	
dpdd܄Zo	
	
	
dqddބZpdeddZq	
	
	
dpddZr	
	
	
dqddZsdeddZt	
	
	
doddZu	
	
	
drddZvdeddZw	
	
	
dnddZx	
	
	
doddZydeddZzdhddZ{deddZ|deddZ}	
	
	
	
dsddZ~deddZ	
	
	
	
dtddZdedd Z	
	
djddZdfddZdfddZ	
	
	
ddddZded	d
ZdfddZdgddZdeddZ			
duddZ			
duddZdaddZdaddZdaddZdaddZ		
dvd"d#Zdwd$d%Z	S	S	
	
dxd'd(Z	S	S	
	
dxd)d*Zdad+d,Zdad-d.Zdad/d0Ze!e%e"e"e"d1		
	
	S	Sdyd2d3Ze!e%d4d5d6 Ze!e%e"e"e"d1		
	
	S	Sdyd7d8Zded9d:Zd;d< Zd=d> Zd?d@ Z	C	
dzdDdEZ		
d{dFdGZdHdI Z	
	
d|dJdKZ		
d}dLdMZdNdO Zd~dPdQZddRdSZe!eUeUeUeUe%e%eUe%e"dT		
	
djdUdVZ	
	
dhdWdXZ	YddZd[Z	Ydd\d]Z	dd_d`Zd
S (  	BcmClientz
    BCM base sdk client
    s	   /json-apis   /csm/apis
   /event-api   /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   g/home/app/PaddleOCR-VL/.venv_paddleocr/lib/python3.10/site-packages/baidubce/services/bcm/bcm_client.pyr   2   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_config5   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_requestH   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_requestX   s   


zBcmClient._send_event_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_datah   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[]r2   r3   r4   r5   r6   r7   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   r8   r.   r   POSTjsondumpsr   r;   rI   Znamespace_aliasrJ   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   rE   names should not be emptys#   /userId/%s/custom/namespaces/delete)rH   namesrK   rL   )r   r;   rV   r   r"   r#   r   r   r   batch_delete_namespaces%  s   z!BcmClient.batch_delete_namespacesc                 C   rD   )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   rE   rF   s#   /userId/%s/custom/namespaces/updaterG   rK   	rM   rN   r   r8   r.   r   PUTrP   rQ   rR   r   r   r   update_namespaceE  rT   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   rE   s!   /userId/%s/custom/namespaces/list   userIdN   name      pageNo
      pageSizer6   rM   rN   r   r8   r.   r   r9   )r   r;   rI   page_no	page_sizer   r"   r%   r   r   r   list_namespaceso  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   rE   ,namespace should not be none or empty string.metric_name should not be none or empty strings.   /userId/%s/custom/namespaces/%s/metrics/create)rH   	namespace
metricNameNmetricAliasunitcycle<   r>   rK   rL   r   r;   rg   r=   metric_aliasrj   rk   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   rE   zids should not be emptys.   /userId/%s/custom/namespaces/%s/metrics/delete)rH   rg   idsrK   rL   )r   r;   rg   rp   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   rE   re   rf   Nzcycle should not be none*   /userId/%s/custom/namespaces/%s/metrics/%s)rH   rg   rh   rk   ri   rj   r>   rK   rX   rm   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   rE   re   s$   /userId/%s/custom/namespaces/metricsr[   	   namespaceN
   metricNames   metricAliasr]   r^   r_   r`   r6   ra   )
r   r;   rg   r=   rn   rb   rc   r   r"   r%   r   r   r   list_namespace_metricsW  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   rE   re   rf   rr   r6   ra   )r   r;   rg   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   rE   re   -event_name should not be none or empty stringevent_level must be one of %ss   /custom/event/configs/createrH   rg   Z	eventNameZ
eventLevelNeventNameAliasrJ   rK   rM   rN   r
   
EventLevelcontainsstrall_event_levelsr.   r   rO   rP   rQ   
r   r;   rg   
event_nameevent_levelZevent_name_aliasrJ   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   rE   rU   s   /custom/event/configs/delete)rH   rg   rV   rK   rM   rN   r.   r   rO   rP   rQ   )r   r;   rg   rV   r   r"   r#   r   r   r   batch_delete_namespace_events  s   z'BcmClient.batch_delete_namespace_eventsc           
      C   ry   )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   rE   re   rz   r{   s   /custom/event/configs/updater|   Nr}   rJ   rK   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   rE   re   Nz%event_level must be none or one of %ss   /custom/event/configs/listrt   r\   s   event_levelr]   r^   r_   r`   r6   )
rM   rN   r
   r   r   r   r   r.   r   r9   )
r   r;   rg   rI   r   rb   rc   r   r"   r%   r   r   r   list_namespace_eventsX  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   rE   re   rf   s   /custom/event/configs/detail)r[   ru   	   eventNamer6   rM   rN   r.   r   r9   )r   r;   rg   r   r   r"   r%   r   r   r   get_custom_event  s   zBcmClient.get_custom_event)rb   rc   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rI   pageNopageSizer$   r#   r(   r)   r'   r   rO   rP   rQ   r   rb   rc   rI   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)rb   rc   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)rH   r   r   aliasdisableTimesactionCallBacksr#   r   r8   r.   r   rO   rP   rQ   )	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   r8   r.   r   DELETE)r   r;   rI   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)rI   r   r   orderr   r   )r   r;   rb   rc   rI   r   r"   r#   r   r   r   list_action  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productNamerI   r   r   r   r   r   sourcer   r   r8   r.   r   rY   rP   rQ   )
r   r;   rI   r   r   r   r   r   r"   r#   r   r   r   update_action:  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   r8   r.   r   rO   rP   rQ   r	   parse_json_list)r   r;   Zextract_rulelog_exampler"   r#   r   r   r   log_extracta  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,)rv   s   dimensionKeysNr   	   instancesr   )r   r8   joinprintrM   r.   r   r9   )	r   r;   app_name	task_namer=   Zdimension_keys	instancesr"   r%   r   r   r   !query_metric_meta_for_applicationv  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)r3   r4   rv   Nr   r   
   statistics   cycles   aggrDatar   r1   r%   r&   	r   r8   rM   r   r.   r   r9   r	   r   )r   r;   r   r   r=   r@   rA   r   rk   r>   r?   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   r8   r.   r   r9   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   r8   r.   r   r9   )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   r8   r.   r   r   rP   rQ   )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^   r`   r   	   alarmName   actionEnableds   srcTypes   taskNamer   r   )r   r;   rb   rc   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/createrH   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_application'  N   /	
z-BcmClient.create_alarm_policy_for_applicationc                 C   r   )r   s*   /userId/%s/application/alarm/config/updaterH   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_applicationm  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
        rH   title	configurer   s!   /dashboard/products/%s/dashboardsrK   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   rE   1dashboard_name should not be none or empty string$   /dashboard/products/%s/dashboards/%sr   ra   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   rE   r   r   r   rK   rX   )	r   r;   r   r   r   r   r   r#   r"   r   r   r   update_dashboard  s   

zBcmClient.update_dashboardc                 C   r   r   rM   rN   r   r8   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   rE   r   s.   /dashboard/products/%s/dashboards/%s/duplicater   rL   r   r;   r   r   r#   r"   r   r   r   duplicate_dashboard7     

zBcmClient.duplicate_dashboardc                 C   r   )r   r   rE   r   s,   /dashboard/products/%s/dashboards/%s/widgetsrK   rL   r  r   r   r   create_dashboard_widgetS  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   rE   r   *widget_name should be none or empty string/   /dashboard/products/%s/dashboards/%s/widgets/%sr   ra   r   r;   r   widget_namer   r"   r   r   r   get_dashboard_widgeto     


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   rE   r   r  s9   /dashboard/products/%s/dashboards/%s/widgets/%s/duplicaterK   rL   )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   rE   r   r  )r   r   r   r	  rK   rX   )
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/reportrK   r.   r   rO   rP   rQ   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/trendrK   r  r  r   r   r   get_dashboard_trend_data  r  z"BcmClient.get_dashboard_trend_datac                 C   r  )r  r  s   /dashboard/metric/gaugechartrK   r  r  r   r   r   get_dashboard_gauge_chart_data4  r  z(BcmClient.get_dashboard_gauge_chart_datac                 C   r  )r  r  s   /dashboard/metric/billboardrK   r  r  r   r   r   get_dashboard_billboard_dataL  r  z&BcmClient.get_dashboard_billboard_datac                 C   r  )r  r  s   /dashboard/metric/trend/seniorrK   r  r  r   r   r   get_dashboard_trend_senior_datad  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   rE   rf   )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)r1   r[   rv      regions   services   showIds2   /userId/%s/services/%s/region/%s/metric/dimensionsr6   ra   )
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)rI   r   rH   Nr   description   /userId/%s/applicationrK   rL   )	r   rI   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]   r_   r&  )r`   r^   r   r6   )rM   rN   r   r8   r'   r   r9   )r   r;   rb   rc   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)rH   idrI   r   Nr   r%  r&  rK   rX   )
r   r;   r+  rI   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 nullrI   r&  rK   	rM   rN   r   r8   r.   r   r   rP   rQ   )r   r;   rI   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]   r_   s   /userId/%s/instances/all)r   r   r   r   
searchNameZsearchValuerK   rL   )r   r;   r   r   r   rb   rc   Zsearch_valuer   r"   r'  r   r   r   get_application_instance_list%  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"  r0  zhost_list should not be null)r   rH   ZhostLists$   /userId/%s/application/instance/bindrK   )
rM   rN   appendr   r8   r.   r   rO   rP   rQ   )	r   r;   r   r3  r   Zhost_list_jsonhostr'  r"   r   r   r   create_application_instanceK  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"  r0  s'   /userId/%s/application/%s/instance/listNr   r6   ra   )r   r;   r   r   r   r"   r%   r   r   r   %get_application_instance_created_listj  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"  r0  r*  s   /userId/%s/application/instance)r+  r   rK   r-  )r   r;   r   r+  r   r"   r'  r   r   r   delete_application_instance  s   	
z%BcmClient.delete_application_instance)r;   r   
alias_namer   targetrk   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"  r0  Nr#  alias_name should not be nulltarget should not be nullrl   )r   r   	aliasNamer;  rk   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=  extractResultr?  s"   /userId/%s/application/task/createrK   )rM   rN   r   r4  r   r8   r.   r   rO   rP   rQ   )r   r;   r   r:  r   r;  rk   r%  r   r<  r=  r>  r?  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"  r0  ztask_name should not be nulls!   /userId/%s/application/%s/task/%sr   ra   )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"  r0  s#   /userId/%s/application/%s/task/listNr   )r%   r   r&   )	rM   rN   r   r8   r.   r   r9   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   rI   r:  r   r;  rk   r%  r   r<  r=  r>  r?  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"  r0  r$  Nr#  r@  rA  )r   rI   r   rB  r;  rk   r%  rC  rD  rE  rF  rG  rH  r   rI  r=  rJ  r?  s"   /userId/%s/application/task/updaterK   )rM   rN   r   r4  r   r8   r.   r   rY   rP   rQ   )r   r;   r   r:  rI   r   r;  rk   r%  r   r<  r=  r>  r?  r   r'  rK  rL  rM  rN  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"  r0  r$  s"   /userId/%s/application/task/delete)rI   r   rK   r-  )r   r;   rI   r   r   r"   r'  r   r   r   delete_application_monitor_task[	  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"  r0  table_name should not be null#map_content_json should not be nullrH   r   	tableNameZmapContentJsons*   /userId/%s/application/dimensionMap/createrK   rL   r   r;   r   
table_nameZmap_content_jsonr   r'  r"   r   r   r   "create_application_dimension_tables	      
z,BcmClient.create_application_dimension_tablec                 C   r7  )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"  r0  s+   /userId/%s/application/%s/dimensionMap/listNr1  r6   ra   )r   r;   r   r   r   r"   r%   r   r   r   $get_application_dimension_table_list	  s   


z.BcmClient.get_application_dimension_table_listc                 C   rT  )	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"  r0  rU  rV  rW  s*   /userId/%s/application/dimensionMap/updaterK   rX   rY  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"  r0  rU  )rH   r   rX  s*   /userId/%s/application/dimensionMap/deleterK   r-  )r   r;   r   rZ  r   r'  r"   r   r   r   "delete_application_dimension_table	  s   

z,BcmClient.delete_application_dimension_table)rb   rc   
account_idr@   rA   r]   r_   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^   r`   r3   r4   	   accountId	   ascending   scoper  
   eventLevelr   
   eventAliass   resourceTypes
   resourceId   eventIdr   r0   r   r9   )r   rb   rc   r@   rA   r`  	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^   r`   r3   r4   ra  rb  rc  r  rd  r   re  rf  r   rg  )r   rb   rc   r@   rA   r`  rh  r<   r   r   r   ri  rk  r"   r%   r   r   r   get_platform_event_data
  s   !z!BcmClient.get_platform_event_data)r`  service_namerI   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)r`  rn  rI   ZblockStatusZeventFilterresourcer   r   )rN   r   r8   r0   r   rO   rP   rQ   )
r   r`  rn  rI   ro  Zevent_filterrp  r   r"   r#   r   r   r   create_event_policyH
  s    
	zBcmClient.create_event_policy)r;   r   rn  	type_namerI   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)rH   r   serviceNametypeNamerI   resourceIdListr   r   )	r   r;   r   rn  rr  rI   resource_id_listr"   r#   r   r   r   create_instance_groupm
     zBcmClient.create_instance_group)r;   ig_idr   rn  rr  rI   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
        rs  )r+  rH   r   rt  ru  rI   r   )r   r8   r.   r   PATCHrP   rQ   )	r   rz  r;   r   rn  rr  rI   r"   r#   r   r   r   update_instance_group
  ry  zBcmClient.update_instance_group)r;   rz  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;   rz  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;   rb   rc   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^   r`   r   r   )
r   r;   rI   rn  r   rr  rb   rc   r"   r%   r   r   r   list_instance_group
  s   	zBcmClient.list_instance_group)r;   rz  rw  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+  rH   rv  r   r   r   rz  r;   rw  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;   rz  rn  rr  r   	view_typerb   rc   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^   r`   r   r   )r   r;   rz  rn  rr  r   r  rb   rc   r"   r%   r   r   r   list_ig_instance
  s   
zBcmClient.list_ig_instance)	r;   rn  rr  r   r  keyword_typekeywordrb   rc   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^   r`   r   r   )r   r;   rn  rr  r   r  r  r  rb   rc   r"   r%   r   r   r   list_all_instance  s   zBcmClient.list_all_instance)r;   rz  ig_uuidrn  rr  r   r  r  r  rb   rc   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^   r`   r   r   )r   r;   rz  r  rn  rr  r   r  r  r  rb   rc   r"   r%   r   r   r   list_filter_instanceE  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
metricDatarK   )r   r8   r'   r   rO   rP   rQ   )r   r;   r<   Zmetric_datar   r"   r#   r   r   r   push_metric_dataq  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)r?   r>   	startTimeendTimerk   )r#   r&   r   r   )r   r;   
namespacesr=   r>   r?   r@   rA   rk   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)rg   rh   r>   value	timestamprK   r   )
r   r;   rg   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	rH   taskNameaddressmethodpostContentadvanceConfigrk   idctimeoutrK   r   r   r;   r   r  r  post_contentadvance_configrk   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
rH   taskIdr  r  r  r  r  rk   r  r  rK   r   r   r;   task_idr   r  r  r  r  rk   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  r6   r   r   r;   r  r   r"   r%   r   r   r   get_site_http_task_configE     
z#BcmClient.get_site_http_task_configc              
   C   r  )r  s   /userId/%s/site/https/creater  rK   r   r  r   r   r   create_site_https_task_configY  r  z'BcmClient.create_site_https_task_configc                 C   r  )r  s   /userId/%s/site/https/updater  rK   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  r6   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)rH   r  r  packetCountpacketLossRaterk   r  r  rK   r   )r   r;   r   r  packet_countpacket_loss_raterk   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)	rH   r  r  r  r  r  rk   r  r  rK   r   )r   r;   r  r   r  r  r  rk   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  r6   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rH   r  r  portr  	inputType
outputTypeinputexpectedOutputrk   r  r  rK   r   r   r;   r   r  r  r  rk   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rH   r  r  r  r  r  r  r  r  r  rk   r  r  rK   r   r   r;   r  r   r  r  r  rk   r  r  r  r  r  r  r   r"   r#   r   r   r   update_site_tcp_task_config[  "   
%z%BcmClient.update_site_tcp_task_configc                 C   r  )r  s   /userId/%s/site/tcp/detailNr  r6   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  rK   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  rK   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  r6   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)
rH   r  r  r  anonymousLoginuserNamepasswordrk   r  r  rK   r   )r   r;   r   r  r  anonymous_loginrk   r  r  	user_namer  r   r"   r#   r   r   r   create_site_ftp_task_config#     
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)rH   r  r  r  r  r  r  r  rk   r  r  rK   r   )r   r;   r  r   r  r  r  rk   r  r  r  r  r   r"   r#   r   r   r   update_site_ftp_task_configS  s   
!z%BcmClient.update_site_ftp_task_configc                 C   r  )r  s   /userId/%s/site/ftp/detailNr  r6   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)	rH   r  r  serverresolveTypekidnapWhiterk   r  r  rK   r   )r   r;   r   r  rk   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)
rH   r  r  r  r  r  r  rk   r  r  rK   r   )r   r;   r  r   r  rk   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  r6   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^   r_   r`   r6   r   )	r   r;   queryr   rb   rc   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   taskIdr6   r   r  r   r   r   delete_site_task_config1  
   
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_infoE  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/createrH   r  rJ   rB  r   r   r   r   incidentActionr   r   r   callbackUrlr  siteMonitortagrK   r   )r   r;   r  rJ   r:  r   r   r   r   incident_actionr   r   r   callback_urlr  site_monitorr  r   r"   r#   r   r   r   create_site_alarm_configW  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
alarmNamesrK   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/updaterH   r  r   rJ   rB  r   r   r   r   r  r   r   r   r  r  r  r  rK   r   )r   r;   r  r   rJ   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   r6   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^   r_   r`   r6   r   )
r   r;   r  r   r   rb   rc   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   rg   r6   r   r8   r.   r   rO   r   r;   r   rg   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  r6   r  r  r   r   r   unblock_site_alarm_config?  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  Nrv   r1   r   r   r   r3   r4   r   r%   r&   r   r   )r   r;   r  r=   r?   r@   rA   rk   r>   r   r"   r%   r   r   r   get_site_metric_dataT  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  r6   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   rE   -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   rB  rH   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   rE   r  -alarm_name should not be none or empty stringr  r  r  Nr  r  r  s   /services/alarm/config/updater   r   rB  rH   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_configB  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   rE   r$  r  s   /services/alarm/config/deleter   r[   rc  r6   NrM   rN   r.   r   rO   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   rE   r$  r  s   /services/alarm/config/blockr'  r6   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   rE   r$  r  s   /services/alarm/config/unblockr'  r6   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   rE   r$  r  s   /services/alarm/configr'  r6   r   r)  r   r   r   get_alarm_config_detail  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   rE   r  z page_no should be greater than 0z"page_size should be greater than 0s   /services/alarm/config/list)r  r[   rc  r^   r`   r1   s   orders   alarmNamePrefixNtruer   falser6   r   )r   r;   r<   rb   rc   r   Zalarm_name_prefixr   r>   r   r   r"   r%   r   r   r   !get_single_instance_alarm_configsB  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   rE   r  s   /services/alarm/config/metrics)r  r[   rc  r1   r  s   localer  )rM   rN   r.   r   r9   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   rE   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/createrH   r<   rB  
targetTyperesourceType
alarmLeveltargetInstanceGroupstargetInstanceTagsr  r  insufficientDataPendingPeriodalarmRepeatIntervalalarmRepeatCountpoliciestargetInstancesactionsr#   r   r   )	rM   rN   r.   r   rO   rP   rQ   r   
version_v2)r   r;   r:  r<   target_typer   r   rJ  rH  target_instancesinsufficient_periodalarm_repeat_intervalalarm_repeat_countr  r"  target_instance_tagstarget_instance_groupsrj  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   rE   r  r$  r  r7  r  r  r8  r9  r:  r;  r<  r=  r>  r?  Ns*   /userId/%s/services/%s/alarm/config/updaterH   r<   rB  r   r@  rA  rB  rC  rD  r  r  rE  rF  rG  rH  rI  rJ  rK  )	rM   rN   r.   r   rY   rP   rQ   r   rL  )r   r;   r   r:  r<   rM  r   r   rJ  rH  rN  rO  rP  rQ  r  r"  rR  rS  rj  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   rE   r$  r  s)   /userId/%s/services/%s/alarm/config/blockr   r%   r   r   NrM   rN   r.   r   rO   r   rL  r)  r   r   r   block_alarm_config_v2     
zBcmClient.block_alarm_config_v2c                 C   rV  )	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   rE   r$  r  s+   /userId/%s/services/%s/alarm/config/unblockr   rW  NrX  r)  r   r   r   unblock_alarm_config_v2  rZ  z!BcmClient.unblock_alarm_config_v2c                 C   rV  )	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   rE   r$  r  s#   /userId/%s/services/%s/alarm/configr   rW  N)rM   rN   r.   r   r9   r   rL  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/createrH   r   rg   r   rJ   r   policyEnabledr  r  r   r   r   r   r  r  r   r   r  r   r  r   r;   r   rg   r   rJ   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<   rH   r   )r<   rH   r   r   )r4  r.   r   rO   rP   rQ   )r   ra  r"   r#   Zcustom_alarmr   r   r   delete_custom_alarm_policyP  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 )r]  Ns   /custom/alarm/configs/updaterH   r   rg   r   rJ   r   r^  r  r  r   r   r   r   r  r  r   r   r  r   )r.   r   rY   rP   rQ   r_  r   r   r   update_custom_alarm_policyf  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^   r`   r[   r   r   ru   s   /custom/alarm/configs/listr   r.   r   r9   )	r   r;   rb   rc   r   rg   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   ru   s   /custom/alarm/configs/detailr   rd  r   r;   rg   r   r%   r"   r   r   r   detail_custom_policy     zBcmClient.detail_custom_policyc                 C   rf  )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
        rg  s   /custom/alarm/configs/blockr   r.   r   rO   rh  r   r   r   block_custom_policy  rj  zBcmClient.block_custom_policyc                 C   rf  )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
        rg  s   /custom/alarm/configs/unblockr   rk  rh  r   r   r   unblock_custom_policy  rj  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)rH   r  r  r  ZprotocolTypeZ
onceConfigZtaskTypeZipTypeZadvancedFlagZadvancedConfiggroupIdr   )	rN   r   r   r8   r.   r   rO   rP   rQ   )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)rH   urlr   r   r   orderByrs  r   r  )
r   r;   rx  rb   rc   r   order_byru  r"   r#   r   r   r   list_site_once_recordsB  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rH   siteIdr   r  r   r;   site_idr"   r#   r   r   r   delete_site_once_recordc  
   
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)rH   r  r   r   r   ry  
filterArea	filterIspr   r  )r   r;   r  rb   rc   r   rz  filter_area
filter_ispr"   r#   r   r   r   detail_site_once_resultt  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)
rH   r  ZsiteIdsrs  r   r   r   ry  r  r  r   r  )r   r;   r  Zsite_idsru  rb   rc   r   rz  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)rH   rs  r  r   r  )r   r;   r  ru  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
        ro  Zipv6Nz!ip_type must be none or one of %s)r[   s   ipTypes   /site/once/siteAgentr   )rN   r   r.   r   r9   )r   r;   rt  rv  r%   r"   r   r   r   get_site_once_agent  s   
zBcmClient.get_site_once_agent)	r;   r<   r   rj  r>   metric_namesr  r?   rk   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 rl   )rH   r<   rk   metricNamesr   rA  r>   r  r?   s3   /userId/%s/services/%s/data/metricData/latest/batchr   r   r#   rM   rN   MAX_INSTANCE_NUMBERr4  r   r8   r.   r   rO   rP   rQ   )r   r;   r<   r   rj  r>   r  r  r?   rk   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  )rH   r<   r  r  r?   rh   Nr   rA  r>   rk   r   r   s7   /userId/%s/services/%s/data/metricData/PartialDimensionr   r  r  )r   r;   r<   r?   r=   r@   rA   r   rj  r>   rk   r   r   r#   r  r  r"   r   r   r   !get_metrics_by_partial_dimensions1  sP   

z+BcmClient.get_metrics_by_partial_dimensionsrl   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  r/  Nr  dimensions should not be nullr  r  	rH   r<   rk   r   r  r  r  r>   r?   r   s   /data/metricAllDatar   r  rM   rN   r  r.   r   rO   rP   rQ   r   r;   r<   r   r>   r  r?   r@   rA   r   rk   r#   r"   r   r   r   get_all_data_metrics_v2n  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  r/  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  r/  r  r  zlables should not be nullr  r  r  )rH   r<   r   r  r  rh   r>   r?   labelsr   topNums   /dimensions/topr   r  r   )r   r;   r<   r   r>   r=   r?   r  r@   rA   r   r  r#   r"   r   r   r   get_metric_dimension_top  s@   'z"BcmClient.get_metric_dimension_topr   )NNNNN)r   NNNNN)	NNNNNNNNN)NNN)NNNN)NN)NNNNNN)TNNNNr   r   )NNNNNNN)NNNNNNNN)r]   r_   NNNNNNNNNNNN)r]   r_   NNNNNNNNNN)
NNNNNNNNNN)NNNNNNNNNNN)NNNNNNNNNNNNN)NNNNNNNNNNNNNN)NNNNNNNNNNNN)NNNNNNNNNNNNNNNNN)NNNNNNNNNNNNNNNNNN)r  NNr  r   r   r   r  r  r  N)r/  r  Nr  r0  N)r/  r  r  r  N)
Nr   r   r   r  r  NNr6  N)r  TNNNNNNNNNr  r   r   )rn  ro  FNN)NNr]   r_   NNN)r]   r_   NNNN)	NNNr]   r_   NNNN)r  r  r  )ro  )r6  rl   )r  r_   )__name__
__module____qualname____doc__r   r-   r/   r   rL  r(   r)   r*   r   r   r'   r.   r0   rB   rC   rS   rW   rZ   rd   ro   rq   rs   rw   rx   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,  r.  r2  
value_typer6  r8  r9  rO  rP  rQ  rR  rS  r[  r]  r^  r_  r   rl  rm  rq  rx  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-  r.  r3  r5  rT  rU  rY  r[  r\  r`  rb  rc  re  ri  rl  rm  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r   #   s   	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r   )r  r   rP   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   
