
    9iV                         S r SSKrSSKrSSKrSSKJrJr  SSKJr  SSK	J
r
JrJr  SSKJr  SSKJr   " S S	\R"                  5      rg)
z-
This module provides a client class for AS.
    N)bce_base_clientcompat)bce_v1_signer)handlerbce_http_clienthttp_methods)
as_handler)requiredc                   f   \ rS rSrSrSrSrSrSrS"S jr	S"S	 jr
 S#S
 jrS$S jrS r  S$S jrS r   S%S jr\" \\S9S 5       r\" \\\\\\\S9   S&S j5       r\" \\\\\\\\S9   S&S j5       r\" \S9S 5       r\" \S9  S'S j5       rS(S jr  S)S jrS rS"S jrS rS rS  r S!r!g)*AsClient   z
AS base sdk client
s   /v1s   content-types   application/json;charset=UTF-8s   x-bce-request-idNc                 B    [         R                  R                  X5        g N)r   BceBaseClient__init__)selfconfigs     g/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/autoscaling/as_client.pyr   AsClient.__init__   s    %%..t<    c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ r   )r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configAsClient._merge_config   s7    >;;4;;/J,,V4r   c           
         U R                  U5      nUc  [        R                  nUc  0 nU R                  U;  a  U R                  X@R                  '   U R
                  U;  a!  [        R                  " 5       X@R
                  '   [        R                  " U[        R                  [        R                  U/U[        R                  U-   X4U5      $ r   )r   r   
parse_jsoncontent_type_header_keycontent_type_header_valuerequest_id_header_keyuuiduuid4r   send_requestr   signr	   parse_errorr   version)r   http_methodpathbodyheadersparamsr   body_parsers           r   _send_requestAsClient._send_request$   s    ##F+!,,K?G''w6484R4RG001%%W426**,G../++M&&)?)?(M))D0$I 	Ir   c                 T    UUUUUUS.nSnU R                  [        R                  XS9$ )a  
Get autoscaling group list
:param page_no:
     page_no
:type page_no: int

:param keyword:
    query keyword
:type keyword: string

:param keyword_type:
    query keyword type
:type keyword_type: string

:param order:
    order-ascending order or descending order
:type order: string

:param order_by:
    order by param
:type order_by:

:return:
:rtype baidubce.bce_response.BceResponse
)   keyword   keywordType   order   orderBy   pageNo   pageSize   /groupr,   r.   r   GET)	r   page_no	page_sizekeywordkeyword_typeorderorder_byr,   r)   s	            r   get_as_group_listAsClient.get_as_group_list4   s@    6  ( "
 !!,"2"2D!HHr   c                     [        U5      S::  a  [        S5      e[        R                  " U5      nSU-  nU R	                  [
        R                  U5      $ )z
Get autoscaling group detail
:param group_id:
    autoscaling group_id
:type group_id: string
:return:
:rtype baidubce.bce_response.BceResponse
r   +group_id should not be none or empty string	   /group/%s)len
ValueErrorr   convert_to_bytesr.   r   r:   )r   group_idr)   s      r   get_as_group_detailAsClient.get_as_group_detailY   sO     x=AJKK**84h&!!,"2"2D99r   c                     [        U5      S::  a  [        S5      eUUUUUUUS.nSn	U R                  [        R                  XS9$ )a  
Get autoscaling group node list

:param group_id:
    autoscaling group_id
:type group_id: string

:param page_no:
     page_no
:type page_no: int

:param keyword:
    query keyword
:type keyword: string

:param keyword_type:
    query keyword type
:type keyword_type: string

:param order:
    order-ascending order or descending order
:type order: string

:param order_by:
    order by param
:type order_by:

:return:
:rtype baidubce.bce_response.BceResponse
r   rD   )   groupidr1   r2   r3   r4   r5   r6   s   /noder8   )rF   rG   r.   r   r:   )
r   rI   r;   r<   r=   r>   r?   r@   r,   r)   s
             r   get_as_group_node_listAsClient.get_as_group_node_listh   s\    @ x=AJKK ( "
 !!,"2"2D!HHr   c                     [        U5      S::  a  [        S5      eSnSU0nU R                  [        R                  U[
        R                  " U5      S9$ )zo
Get autoscaling group node list

:param group_ids:
    autoscaling group_ids
:type group_ids: list of strings
r   rD   s   /group/deletegroupIdsr*   )rF   rG   r.   r   POSTjsondumps)r   	group_idsr)   r*   s       r   delete_groupAsClient.delete_group   sV     y>QJKK	
 !!,"3"3T

4@P!QQr   c                     SnUUUUUUUUU	U
UUUUS.nU R                  [        R                  U[        R                  " U5      S9$ )a7  
Create autoscaling group

:param group_name:
    autoscaling group_name
:type group_name: string

:param config:
     autoscaling group config
:type config: dict

:param health_check:
    autoscaling group health check info
:type health_check: dict

:param blb:
    blb info
:type blb: list of strings

:param rds:
    rds info
:type rds: list of strings

:param scs:
    scs info
:type scs: list of strings

:param shrinkage_strategy:
    autoscaling group shrinkage strategy
:type shrinkage_strategy: string

:param zone_info:
    autoscaling group zone info
:type zone_info: dict

:param assign_tag_info:
    autoscaling group tag info
:type assign_tag_info: dict

:param nodes:
    autoscaling group nodes
:type nodes: dict

:param eip:
    autoscaling group eip info
:type eip: dict

:param billing:
    autoscaling group billing info
:type billing: dict

:param cmd_config:
    autoscaling group cmd config
:type cmd_config: dict

:param bcc_name_config:
    autoscaling group bcc name config
:type bcc_name_config: dict

:return:
:rtype baidubce.bce_response.BceResponse
r7   )	groupNamer   healthCheckblbrdsscsshrinkageStrategyzoneInfoassignTagInfonodeseipbilling	cmdConfigbccNameConfigrR   r.   r   rS   rT   rU   )r   
group_namer   health_checkr\   r]   r^   shrinkage_strategy
zone_infosassign_tag_info	node_listrc   rd   
cmd_configbcc_name_configr)   r*   s                    r   create_groupAsClient.create_group   sd    D #'!3",#,
  !!,"3"3T

4@P!QQr   )rI   rb   c                     S[         R                  " U5      -  nSS0nSU0nU R                  [        R                  U[
        R                  " U5      US9$ )z
Detach nodes from group
:param group_id: the id of group
:type group_id: string
:param nodes: the list of node
:type nodes: list
:return: the result of detach node
:rtype: dict
rE   
detachNode rb   )r*   r,   r   rH   r.   r   rS   rT   rU   r   rI   rb   r)   r,   r*   s         r   detach_nodeAsClient.detach_node   s_     f55h??"
 U
 !!,"3"3T

4@PY_!``r   )	rule_namerI   state	rule_typeaction_type
action_numcooldown_in_secc                     Sn0 SU_SU_SU_SU_SU_SU	_SU
_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_SU_SU0EnU R                  [        R                  U[        R                  " U5      S9$ )ay  
Create rule
:param rule_name: the name of the rule
:type rule_name: string
:param group_id: the id of the group
:type group_id: string
:param state: the state of the rule, can be "ENABLE" or "DISABLE"
:type state: string
:param rule_type: the type of the rule, can be "ALARM", "CRONTAB", or "PERIOD"
:type rule_type: string
:param target_type: the type of the target
:type target_type: string
:param target_id: the id of the target
:type target_id: string
:param indicator: the indicator of the rule
:type indicator: string
:param threshold: the threshold of the rule
:type threshold: string
:param unit: the unit of the threshold
:type unit: string
:param comparison_operator: the comparison operator of the rule
:type comparison_operator: string
:param action_type: the action type of the rule, can be INCREASE, DECREASE, ADJUST
:type action_type: string
:param action_num: the number of actions to be performed
:type action_num: int
:param cron_time: the cron time of the rule
:type cron_time: string
:param cooldown_in_sec: the cooldown time in seconds
:type cooldown_in_sec: int
:param period_type: the period type of the rule
:type period_type: string
:param period_value: the period value of the rule
:type period_value: int
:param period_start_time: the start time of the period
:type period_start_time: string
:param period_end_time: the end time of the period
:type period_end_time: string
   /ruleruleNamegroupIdrz   type
targetTypetargetId	indicator	thresholdunitcomparisonOperator
actionType	actionNumcronTimecooldownInSec
periodTypeperiodValueperiodStartTimeperiodEndTimerR   rg   )r   ry   rI   rz   r{   r|   r}   r~   target_type	target_idr   r   r   comparison_operator	cron_timeperiod_typeperiod_valueperiod_start_timeperiod_end_timer)   r*   s                        r   create_ruleAsClient.create_rule  s   \ 
	
x
 U
 I	

 +
 	
 
 
 D
 !"5
 +
 
 	
 _
 +
  <!
" 0#
$ _%
( !!,"3"3T

4@P!QQr   )rule_idry   rI   rz   r{   r|   r}   r~   c                    S[         R                  " U5      -  n0 SU_SU_SU_SU_SU	_SU
_SU_S	U_S
U_SU_SU_SU_SU_SU_SU_SU_SU_SU0EnU R                  [        R                  U[
        R                  " U5      S9$ )a  
Update rule
:param rule_id: the id of the rule
:type rule_id: string
:param rule_name: the name of the rule
:type rule_name: string
:param group_id: the id of the group
:type group_id: string
:param state: the state of the rule, can be "ENABLE" or "DISABLE"
:type state: string
:param rule_type: the type of the rule, can be "ALARM", "CRONTAB", or "PERIOD"
:type rule_type: string
:param target_type: the type of the target
:type target_type: string
:param target_id: the id of the target
:type target_id: string
:param indicator: the indicator of the rule
:type indicator: string
:param threshold: the threshold of the rule
:type threshold: string
:param unit: the unit of the threshold
:type unit: string
:param comparison_operator: the comparison operator of the rule
:type comparison_operator: string
:param action_type: the action type of the rule, can be INCREASE, DECREASE, ADJUST
:type action_type: string
:param action_num: the number of actions to be performed
:type action_num: int
:param cron_time: the cron time of the rule
:type cron_time: string
:param cooldown_in_sec: the cooldown time in seconds
:type cooldown_in_sec: int
:param period_type: the period type of the rule
:type period_type: string
:param period_value: the period value of the rule
:type period_value: int
:param period_start_time: the start time of the period
:type period_start_time: string
:param period_end_time: the end time of the period
:type period_end_time: string
   /rule/%sr   r   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rR   )r   rH   r.   r   PUTrT   rU   )r   r   ry   rI   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r)   r*   s                         r   update_ruleAsClient.update_ruleT  s    ^ V44W==
	
x
 U
 I	

 +
 	
 
 
 D
 !"5
 +
 
 	
 _
 +
  <!
" 0#
$ _%
( !!,"2"2Dtzz$?O!PPr   )r   c                 t    S[         R                  " U5      -  nU R                  [        R                  U5      $ )zp
Get rule
:param rule_id: the id of the rule
:type rule_id: string
:return: the result of get rule
:rtype: dict
r   )r   rH   r.   r   r:   )r   r   r)   s      r   get_ruleAsClient.get_rule  s2     V44W==!!,"2"2D99r   )rI   c                 V    SnUUUUUUUS.n	U R                  [        R                  XS9$ )a  
Query rule list
:param group_id: the id of the group
:type group_id: string
:param keyword: the keyword of the rule
:type keyword: string
:param keyword_type: the type of the keyword
:type keyword_type: string
:param order: the order of the rule
:type order: string
:param order_by: the order by of the rule
:type order_by: string
:param page_no: the page number
:type page_no: int
:param page_size: the page size
:type page_size: int
r   )groupidr=   keywordTyper?   orderBypageNopageSizer8   r9   )
r   rI   r=   r>   r?   r@   r;   r<   r)   r,   s
             r   	list_ruleAsClient.list_rule  sC    ( '!
 !!,"2"2D!HHr   c                     U(       d  U(       d  [        S5      eSnSS0nUUS.nU R                  [        R                  X4[        R
                  " U5      S9$ )z
Delete rule
:param rule_ids: the list of rule id
:type rule_ids: list
:param group_ids: the list of group id
:type group_ids: list
z8rule_ids and group_ids can not be empty at the same timer   deletert   )ruleIdsrQ   r,   r*   )rG   r.   r   rS   rT   rU   )r   rule_idsrV   r)   r,   r*   s         r   delete_ruleAsClient.delete_rule  s_     	WXXb
  !
 !!,"3"3TtzzZ^O_!``r   c                 V    UUUUUUUS.nSn	U R                  [        R                  XS9$ )a1  
Get details of a specific group
: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-ascending order or descending order
:type order: string

:param order_by:
    Order by parameter
:type order_by: string

:param start_time:
    Start time for filtering the results
:type start_time: string

:param end_time:
    End time for filtering the results
:type end_time: string

:return:
rtype baidubce.bce_response.BceResponse
)rM   r3   r4   r5   r6   s	   startTimes   endTimes   /recordr8   r9   )
r   rI   r;   r<   r?   r@   
start_timeend_timer,   r)   s
             r   get_recordsAsClient.get_records  sD    H ! "$ 
 !!,"2"2D!HHr   c                     [         R                  " U5      nSU-  nSS0nSU0nU R                  [        R                  X4[
        R                  " U5      S9$ )z
Execute a specific rule within a group
:param group_id:
     Group identifier
:type group_id: str

:param rule_id:
     Rule identifier within the group
:type rule_id: str

:return:
rtype baidubce.bce_response.BceResponse
rE   s   execRulert   ruleIdr   ru   )r   rI   r   r)   r,   r*   s         r   	exec_ruleAsClient.exec_rule	  sb     **84h&
 g
 !!,"3"3TtzzZ^O_!``r   c                     [         R                  " U5      nSU-  nSS0nUUUS.nU R                  [        R                  XV[
        R                  " U5      S9$ )a  
Scale up a specific group

:param group_id:
    Group identifier
:type group_id: str

:param node_count:
    Number of nodes to be added
:type node_count: int

:param zone:
    Zone where the nodes will be added
:type zone: str

:param expansion_strategy:
    Strategy to be used for the expansion, optional
:type expansion_strategy: str, optional

:return:
rtype baidubce.bce_response.BceResponse
rE   s	   scalingUprt   )	nodeCountzoneexpansionStrategyr   ru   )r   rI   
node_countr   expansion_strategyr)   r,   r*   s           r   
scaling_upAsClient.scaling_up"  sf    . **84h&"
 $!3

 !!,"3"3TtzzZ^O_!``r   c                     [         R                  " U5      nSU-  nSS0nSU0nU R                  [        R                  X4[
        R                  " U5      S9$ )z
Scale down a specific group

:param group_id:
    Group identifier
:type group_id: str

:param nodes:
    Nodes to be removed
:type nodes: list or str

:return:
rtype baidubce.bce_response.BceResponse
rE   s   scalingDownrt   rb   r   ru   rv   s         r   scaling_downAsClient.scaling_downE  sb     **84h&B
 U
 !!,"3"3TtzzZ^O_!``r   c                     [         R                  " U5      nSU-  nSS0nSU0nU R                  [        R                  X4[
        R                  " U5      S9$ )a:  
Adjust the number of nodes in a specific group

:param group_id:
    Group identifier
:type group_id: str

:param adjust_num:
    Number to adjust the nodes by. This could be positive (for adding nodes) or
    negative (for removing nodes).
:type adjust_num: int

:return:
rtype baidubce.bce_response.BceResponse
rE   s
   adjustNodert   	adjustNumr   ru   )r   rI   
adjust_numr)   r,   r*   s         r   adjust_nodeAsClient.adjust_node^  sb      **84h&2
 
 !!,"3"3TtzzZ^O_!``r   c                     [         R                  " U5      nSU-  nSS0nSU0nU R                  [        R                  X4[
        R                  " U5      S9$ )am  
Attach nodes to a specific group.

:param group_id: str
    The unique identifier of the group to which the nodes will be attached.
:param nodes: list or str
    The nodes that will be attached to the group.
    This can be a list of node identifiers or a single node identifier.

:return: baidubce.bce_response.BceResponse
rtype baidubce.bce_response.BceResponse
rE   s
   attachNodert   rb   r   ru   rv   s         r   attach_nodeAsClient.attach_nodex  sb     **84h&2
 U
 !!,"3"3TtzzZ^O_!``r    r   )NNNNN)     NNNN)NNNNNNNNNNNNNN)rt   rt   rt   0rt   rt   rt   NNNN)rt   rt   desc
createTimer   r   )NN)r   r   N	startTimeNN)"__name__
__module____qualname____firstlineno____doc__r'   r   r    r!   r   r   r.   rA   rJ   rN   rW   rp   r
   strlistrw   intr   r   r   r   r   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      sv    G- A/= VZI #IJ: rv(,,I\R  ei_cNRSRj s$'a (a& cQTad!# UWY]<@AR#ARF cS3cS^anq!# UWY]<@BQ#BQH c	: 	: slm I I>a( U`.2-I^a2!aFa2a4ar   r   )r   r   rT   r"   baidubcer   r   baidubce.authr   baidubce.httpr   r   r   baidubce.services.autoscalingr	   baidubce.utilsr
   r   r   r   r   r   <module>r      s=       , ' @ @ 4 #~	a,, ~	ar   