
    9iK                     &   S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SSK
Jr  SS	KJr  SS
KJr  \R$                  " \5      r\R*                  " S5      r\R*                  " 5       r " S S\R0                  5      rS r\rg)z4
This module provides a client class for EIP group.
    N)utils)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)eip_group_model)requiredPrepaidc                      \ 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
9   S!S j5       r  S"S jr\" \\4S9SS j5       r\" \\4\\4S9S#S j5       r\" \\4\S9 S#S j5       r\" \\4\S9 S#S j5       r\" \\4\S9 S#S j5       r\" \\4S9  S$S j5       r\" \\4S9S#S j5       r\" \4S9S#S j5       r\" \4S9S#S j5       r\SS j5       r\SS j5       rSrg)%EipGroupClient*   z
EIP group sdk client
s   /v1s   /v2s	   /eipgroupNc                 B    [         R                  R                  X5        g N)r   BceBaseClient__init__)selfconfigs     f/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/eip/eip_group_client.pyr   EipGroupClient.__init__2   s    %%..t<    c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ )zG
:param config:
:type config: baidubce.BceClientConfiguration
:return:
)r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configEipGroupClient._merge_config5   s9     >;;4;;/J,,V4r   c           
          U R                  U5      nUc  [        R                  nUc  SSS.n[        R                  " U[
        R                  [        R                  U/XX4U5      $ )Ns   */*s   application/json;charset=utf-8)s   Accepts   Content-Type)r   r   
parse_jsonr   send_requestr   signparse_error)r   http_methodpathbodyheadersparamsr   body_parsers           r   _send_requestEipGroupClient._send_requestB   sj     ##F+!,,K?"((IKG++M&&)<)<k(Jtf6 	6r   )	eip_countbandwidth_in_mbpsc
                    U R                  5       n
Uc
  [        5       nSU0nUc  [        nUUUR                  S.nUb  XlS'   Ub  X<S'   Ub  X|S'   Ub  XS'   U R	                  [
        R                  U
[        R                  " U5      XS9$ )a  
Create a shared bandwidth EIP group with specified options.
Real-name authentication is required before creating EIP groups.
Only prepaid EIP groups is supported.

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if client token is provided.
:type client_token: string

:param eip_count:
    Numbers of EIP addresses in the EIP group.
    The minimum number of public IP addresses is two,
    and the maximum number multiplies 5Mbps mustn't exceed the
    total amount of shared bandwidth package.
:type eip_count: int

:param bandwidth_in_mbps:
    Public Internet bandwidth in unit Mbps. For Prepaid EIP groups,
    this value must be integer between 10 and 200.
:type bandwidth_in_mbps: int

:param billing:
    Billing information.
:type billing: eip_group_model.Billing

:param name:
    The name of EIP group that will be created.
    The name, beginning with letter, should have the length between
    1 and 65 bytes, and could contain alphabets, numbers or '-_/.'.
    If not specified, the service will generate it automatically.
:type name: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
   clientToken)eipCountbandwidthInMbpsbilling	routeTypenameidctagsr%   r'   r   )		_get_pathgenerate_client_token#default_billing_to_purchase_created__dict__r)   r   POSTjsondumps)r   r+   r,   r3   client_tokenr1   
route_typer4   r5   r   r$   r'   r%   s                r   create_eip_groupEipGroupClient.create_eip_groupO   s    Z ~~02L ,/?9G!0''

 ! *L?KL!!,"3"3"&TZZ-=)/ " @ 	@r   c                     U R                  5       n0 nUb  XS'   Ub  X(S'   Ub  X8S'   Ub  XHS'   Ub  XXS'   U R                  [        R                  UXS9$ )a  
Return a list of EIP groups, according to the ID,
name or status of EIP group. If not specified,
returns a full list of EIP groups in VPC.

:param id:
    The id of specified EIP group.
:type id: string

:param name:
    The name of specified EIP group.
:type name: string

:param status:
    The status of specified EIP group.
:type status: string

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

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

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
s   ids   names   statuss   markers   maxKeysr'   r   )r7   r)   r   GET)	r   idr3   statusmarkermax_keysr   r$   r'   s	            r   list_eip_groupsEipGroupClient.list_eip_groups   s    N ~~>5M"7O &9 &9!):!!,"2"2D)/ " @ 	@r   )rE   c                     [         R                  " U R                  5       U5      nU R                  [        R
                  X2S9$ )z
Get the detail information of specified EIP group.

:param id:
    The id of specified EIP group.
:type id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
)r   )r   
append_urir7   r)   r   rD   )r   rE   r   r$   s       r   get_eip_groupEipGroupClient.get_eip_group   s9      0"5!!,"2"2D!HHr   )rE   r3   c                     [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nSU0nU R	                  [
        R                  U[        R                  " U5      XdS9$ )a1  
Update the name of specified EIP group.

:param id:
    The id of specified EIP group.
:type id: string

:param name:
    The new name of the EIP group
:type name: string

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if clientToken is provided.
    If the clientToken is not specified by user,
    a random String generated by default algorithm will be used.
:type client_token: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
N)s   updater.   r3   r6   	r   rL   r7   r8   r)   r   PUTr<   r=   )r   rE   r3   r>   r   r$   r'   r%   s           r   update_eip_groupEipGroupClient.update_eip_group   s{    4  0"502L(

 D
 !!,"2"2"&TZZ-=)/ " @ 	@r   )rE   r,   c                     [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nSU0nU R	                  [
        R                  U[        R                  " U5      XdS9$ )a  
Resize the bandwidth of a specified EIP group.

:param id:
    The id of specified EIP group.
:type id: string

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if clientToken is provided.
    If the clientToken is not specified by user,
    a random String generated by default algorithm will be used.
:type client_token: string

:param bandwidth_in_mbps:
    The new bandwidth of EIP group.
    For prepaid EIP groups, this value must be integer
    between 10 and 200.
:type bandwidth_in_mbps: int

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
Ns   resizer.   r0   r6   rP   )r   rE   r,   r>   r   r$   r'   r%   s           r   resize_eip_group_bandwidth)EipGroupClient.resize_eip_group_bandwidth  s|    :  0"502L(

 0
 !!,"2"2"&TZZ-=)/ " @ 	@r   )rE   eip_add_countc                     [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nSU0nU R	                  [
        R                  U[        R                  " U5      XdS9$ )a  
Resize the EIP count of a specified EIP group.

:param id:
    The id of specified EIP group.
:type id: string

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if clientToken is provided.
    If the clientToken is not specified by user,
    a random String generated by default algorithm will be used.
:type client_token: string

:param eip_add_count:
    The increase number of EIP addresses in the EIP group.
    This value must larger than zero, and the maximum number multiplies
    5Mbps mustn't exceed the total amount of shared bandwidth package.
:type eip_add_count: int

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
NrU   eipAddCountr6   rP   r   rE   rX   r>   r   r$   r'   r%   s           r   resize_eip_group_count%EipGroupClient.resize_eip_group_count.  s{    :  0"502L(

 =
 !!,"2"2"&TZZ-=)/ " @ 	@r   c                     [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nSU0nU R	                  [
        R                  U[        R                  " U5      XdS9$ )a  
Resize the EIP count of a specified EIP group.

:param id:
    The id of specified EIP group.
:type id: string

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if clientToken is provided.
    If the clientToken is not specified by user,
    a random String generated by default algorithm will be used.
:type client_token: string

:param eip_add_count:
    The increase number of EIP addresses in the EIP group.
    This value must larger than zero, and the maximum number multiplies
    5Mbps mustn't exceed the total amount of shared bandwidth package.
:type eip_add_count: int

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype add ip list.
NrU   rZ   r6   )	r   rL   _get_v2_pathr8   r)   r   rQ   r<   r=   r[   s           r   resize_eip_group_count_v2(EipGroupClient.resize_eip_group_count_v2Y  s}    :  1 1 3R802L(

 =
 !!,"2"2"&TZZ-=)/ " @ 	@r   c                    [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nUc  [        nSUR
                  0nU R                  [        R                  U[        R                  " U5      XdS9$ )af  
Renew specified EIP group.
EIP groups cannot can not be renewed during resizing process.

:param id:
    The id of EIP group.
:type id: string

:param client_token:
    An ASCII string whose length is less than 64.
    The request will be idempotent if clientToken is provided.
    If the clientToken is not specified by user,
    a random String generated by default algorithm will be used.
:type client_token: string

:param billing:
    Billing information.
:type billing: eip_group_model.Billing

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
N)s   purchaseReservedr.   r1   r6   )r   rL   r7   r8   $default_billing_to_purchase_reservedr:   r)   r   rQ   r<   r=   )r   rE   r>   r1   r   r$   r'   r%   s           r   purchase_reserved_eip_group*EipGroupClient.purchase_reserved_eip_group  s    8  0"502L!%(
 ?:Gw''
 !!,"2"2"&TZZ-=)/ " @ 	@r   c                     [         R                  " U R                  5       U5      nUc
  [        5       nSU0nU R	                  [
        R                  XEUS9$ )a"  
Delete an EIP group.

:type id: string
:param id: The ID of the EIP group to delete.

:type client_token: string
:param client_token: A unique token for identifying the request.

:type config: baidubce.BceClientConfiguration
:param config: None

:return: baidubce.bce_response.BceResponse
r.   rC   )r   rL   r7   r8   r)   r   DELETE)r   rE   r>   r   r$   r'   s         r   delete_eip_groupEipGroupClient.delete_eip_group  sX       0"502LL
 !!,"5"5tSY!ZZr   )move_out_argsc                    [         R                  " U R                  5       U5      nUc
  [        5       nSUS.n/ nU H\  n0 n	US   U	S'   UR	                  S5      b  US   U	S'   UR	                  S5      b  US   R
                  U	S'   UR                  U	5        M^     SU0n
[        R                  " U
5      nU R                  [        R                  XVXS9$ )a  
Move out an EIP from a group.

:type id: string
:param id: The ID of the EIP group.

:type move_out_args: List[dict]
:param move_out_args: List of dictionaries for moving out the EIPs, 
                    each dict containing 'eip', 'bandwidth_in_mbps', 
                    and 'billing' keys.

:type client_token: string
:param client_token: A unique token for identifying the request.

:type config: baidubce.BceClientConfiguration
:param config: None

:return: baidubce.bce_response.BceResponse
N)s   move_outr.   eipr0   r1   moveOutEipsr'   r%   r   )r   rL   r7   r8   getr:   appendr<   r=   r)   r   rQ   )r   rE   rj   r>   r   r$   r'   move_out_eipsargmove_out_eipr%   	json_bodys               r   eip_group_move_out!EipGroupClient.eip_group_move_out  s    *  0"502L(
  CL"%e*Lww()5256G2H./wwy!-*-i.*A*AY'  . ! =
 JJt$	!!,"2"2Di!ggr   )eipsc                     [         R                  " U R                  5       U5      nUc
  [        5       nSUS.nSU0n[        R
                  " U5      nU R                  [        R                  XVXS9$ )a\  
Move in an EIP to a group.

:type id: string
:param id: The ID of the EIP group.

:type eips: List[]
:param eips: The list of EIPs to move in.

:type client_token: string
:param client_token: A unique token for identifying the request.

:type config: baidubce.BceClientConfiguration
:param config: None

:return: baidubce.bce_response.BceResponse
N)s   move_inr.   rw   rn   )	r   rL   r7   r8   r<   r=   r)   r   rQ   )	r   rE   rw   r>   r   r$   r'   r%   rt   s	            r   eip_group_move_in EipGroupClient.eip_group_move_in  st    &  0"502L(

 D
 JJt$	!!,"2"2Di!ggr   c                 r    U c  [         R                  n [        R                  " [         R                  U 5      $ z1
:type prefix: string
:param prefix: path prefix
)r   prefixr   rL   versionr}   s    r   r7   EipGroupClient._get_path  s-     >#**F 6 6??r   c                 r    U c  [         R                  n [        R                  " [         R                  U 5      $ r|   )r   r}   r   rL   
version_v2r   s    r   r_   EipGroupClient._get_v2_path   s-     >#**F 9 96BBr    r   )NNNNN)NNNNNNN)NNNNNN)NN)NNN)__name__
__module____qualname____firstlineno____doc__r~   r   r}   r   r   r)   r
   intr@   rI   bytesstrrM   rR   rV   r\   r`   rd   rh   listru   ry   staticmethodr7   r_   __static_attributes__r   r   r   r   r   *   s    GJF= 7;/36  #% 26<@+/@@%@@D :>;?4@l %I I" %UCL1%@ 2%@N %5=A(@ 6(@T %S19=(@ 2(@T %S1<@(@ 2(@T %;?9=)@ )@V %[ [. TG$*h %*hX D7h h@ @ @ C Cr   r   c                  >    [        [        R                  " 5       5      $ )z
The default method to generate the random string for client_token
if the optional parameter client_token is not specified by the user.

:return:
:rtype string
)r   uuiduuid4r   r   r   generate_client_token_by_uuidr   +  s     tzz|r   )r   r   r<   loggingr   baidubcer   r   baidubce.authr   baidubce.httpr   r   r   baidubce.services.eipr	   baidubce.utilsr
   	getLoggerr   _loggerBillingr9   rc   r   r   r   r8   r   r   r   <module>r      s   "      $ ' ) ! & 1 #


H
% '6&=&=i&H #'6'>'>'@ $~C_22 ~CB 6 r   