
    9i^                         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  \R"                  " \5      r " S
 S\
5      rg)z.
This module provides a client class for EIP.
    N)utils)bce_v1_signer)BceBaseClient)bce_http_client)handler)http_methods)	EipStatusc                      \ 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S
 jrSS jr  SS jrSS jrSS jrSS jrSS jr  S S jrS!S jrS"S jrSS jrSS jr\S 5       r\SS j5       rS r  SS jrSrg)#	EipClient%   z
eip sdk client
s   /v1s   /eipNc                 0    [         R                  " X5        g)z>
:type config: baidubce.BceClientConfiguration
:param config:
N)r   __init__)selfconfigs     `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/eip/eip_client.pyr   EipClient.__init__,   s    
 	t,    c                 R   UUS.nUb  XGS'   Uc	  SSS.US'   O4UR                   UR                  UR                  UR                  S.S.US'   U R	                  5       nUc  U R                  5       nS	U0n	U R                  [        R                  U[        R                  " U5      U	US
9$ )aY  
Create an eip with the specified options.

:type bandwidth_in_mbps: int
:param bandwidth_in_mbps: specify the bandwidth in Mbps

:type name: string
:param name: name of eip. The optional parameter

:type billing: Billing
:param billing: billing information. The optional parameter,
 default paymentTiming is Postpaid

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: created eip address, for example,{"eip":"x.x.x.x"}
)namebandwidthInMbps	routeTypePostpaidByBandwidth)paymentTimingbillingMethodbillingreservationLengthreservationTimeUnit)r   r   reservation   clientToken)bodyparamsr   )payment_timingbilling_methodreservation_lengthreservation_time_unit	_get_path_generate_default_client_token_send_requestr   POSTjsondumps)
r   bandwidth_in_mbpsr   r   
route_typeclient_tokenr   r"   pathr#   s
             r   
create_eipEipClient.create_eip3   s    2 0
 ! *?!+!.DO ")!7!7!(!7!7)0)C)C+2+H+H DO ~~>>@LL
 !!,"3"3T'+zz$'7)/ " 1 	1r   c                     SU0n[         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  Xg[        R                  " U5      US9$ )a  
Resizing eip

:type eip: string
:param eip: eip address to be resized

:type new_bandwidth_in_mbps: int
:param new_bandwidth_in_mbps: specify new bandwidth in Mbps for eip

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
newBandwidthInMbpsr   )s   resizer!   r#   r"   r   	r   
append_urir(   r)   r*   r   PUTr,   r-   )r   eipnew_bandwidth_in_mbpsr0   r   r"   r1   r#   s           r   
resize_eipEipClient.resize_eipj   s    * !"7
  0#6>>@L(
 !!,"2"2D'+zz$'7 " H 	Hr   c                 8   Uc
  SSSSS.00nOSSUR                   UR                  S.00n[        R                  " U R	                  5       U5      nUc  U R                  5       nSUS.nU R                  [        R                  Xg[        R                  " U5      US9$ )	a  
PurchaseReserved eip with fixed duration,only Prepaid eip can do this

:type eip: string
:param eip: eip address to be renewed

:type billing: Billing
:param billing: billing information. The optional parameter,
 default reservationLength is 1

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
r   r       Monthr   r   )s   purchaseReservedr!   r6   )r&   r'   r   r8   r(   r)   r*   r   r9   r,   r-   )r   r:   r   r0   r   r"   r1   r#   s           r   purchase_reserved_eipEipClient.purchase_reserved_eip   s    * ?!-./6$D !-4-G-G/6/L/L$D  0#6>>@L!$(
 !!,"2"2D'+zz$'7 " H 	Hr   c                    Uc  SnUc  SnUUS.n[         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  Xx[        R                  " U5      US9$ )aC  
Enable auto renew for specified EIP.

:type eip: string
:param eip: eip address to be enable to auto-renew.

:type auto_renew_time_unit: string
:param auto_renew_time_unit: time unit of auto_renew_time, default 'Month'.

:type auto_renew_time: int
:param auto_renew_time: the unit of time for auto renew,
default auto_renew_time is 1

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
monthr?   )autoRenewTimeUnitautoRenewTimer   )s   startAutoRenewr!   r6   r7   )	r   r:   auto_renew_time_unitauto_renew_timer0   r   r"   r1   r#   s	            r   start_auto_renew_eipEipClient.start_auto_renew_eip   s    0  '#* "O!5,
  0#6>>@L"(
 !!,"2"2D'+zz$'7 " H 	Hr   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  XEUS9$ )ac  
Disable auto renew for specified EIP.

:type eip: string
:param eip: eip address to be disable to auto-renew.

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
r   )s   stopAutoRenewr!   r#   r   r   r8   r(   r)   r*   r   r9   r   r:   r0   r   r1   r#   s         r   stop_auto_renew_eipEipClient.stop_auto_renew_eip   s_    "  0#6>>@L!(
 !!,"2"2DPV!WWr   c                     UUS.nUb  XGS'   [         R                  " U R                  5       U5      nUc  U R                  5       nSUS.n	U R	                  [
        R                  X[        R                  " U5      US9$ )a  
bind the eip to a specified instanceId and instanceType

:type eip: string
:param eip: eip address to be bound

:type instance_type: string
:param instance_type: type of instance to be bound(BCC BLB et.)

:type instance_id: string
:param instance_id: id of instance to be bound

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
)instanceType
instanceId
instanceIpr   )s   bindr!   r6   r7   )
r   r:   instance_typeinstance_idinstance_ipr0   r   r"   r1   r#   s
             r   bind_eipEipClient.bind_eip  s    0 *%
 "!, 0#6>>@L(
 !!,"2"2D'+zz$'7 " H 	Hr   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  XEUS9$ )aW  
unbind the eip from a specified instance

:type eip: string
:param eip: eip address to be unbound

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
r   )s   unbindr!   rL   rM   rN   s         r   
unbind_eipEipClient.unbind_eip+  se       0#6>>@L(
 !!,"2"2D)/ " 1 	1r   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nSU0nU R	                  [
        R                  XEUS9$ )a  
release the eip(delete operation)
Only the Postpaid instance or Prepaid which is expired can be released.
if the eip has been bound, must unbind before releasing.

:type eip: string
:param eip: eip address to be released

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
r!   rL   r   r8   r(   r)   r*   r   DELETErN   s         r   release_eipEipClient.release_eipE  sd    $  0#6>>@LL
 !!,"5"5t)/ " 1 	1r   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  XEUS9$ )ab  
turn on EIP pass through with the specific parameters.

:type eip: string
:param eip: the specific EIP.

:type client_token: string
:param client_token: if the clientToken is not specified by the user, 
a random String generated by default algorithm will be used.

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

:return: BceResponse
r   )s   directr!   rL   rM   rN   s         r   
direct_eipEipClient.direct_eip`  s_       0#6>>@L(
 !!,"2"2DPV!WWr   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nSUS.nU R	                  [
        R                  XEUS9$ )ao  
Remove the direction of an EIP from a specific instance.

:type eip: string
:param eip: the EIP address to undirect.

:type client_token: string
:param client_token: If the clientToken is not specified by the user, 
a random String generated by default algorithm will be used.

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

:return: BceResponse
r   )s   unDirectr!   rL   rM   rN   s         r   undirect_eipEipClient.undirect_eipy  s_       0#6>>@L(
 !!,"2"2DPV!WWr   c	                    U R                  5       n	0 n
Ub  XS'   Ub  X*S'   Ub  XJS'   Ub$  [        U[        5      (       a  UR                  U
S'   Ub  XjS'   Ub  XzS'   Ub  X:S'   U R	                  [
        R                  XUS9$ )	aa  
get a list of eip owned by the authenticated user and specified
conditions. we can Also get a single eip function  through this
interface by eip condition

:type eip: string
:param eip: eip address condition

:type instance_type: string
:param instance_type: bound instance type condition

:type instance_id: string
:param instance_id: bound instance id condition
if query by the instanceId or instanceType condition, must provides
 both of them at the same time

:type status: string
:param status of eip condition
if query by the status condition, must provides

:type marker: string
:param marker: The optional parameter marker specified in the original
 request to specify where in the results to begin listing.

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

:type config: baidubce.BceClientConfiguration
:param config:

:return: list of eip model, for example:
        {
            "eipList": [
                {
                    "name":"eip-xxxxxxx-1",
                    "eip": "x.x.x.x",
                    "status":"binded",
                    "instanceType": "BCC",
                    "instanceId": "i-xxxxxxx",
                    "bandwidthInMbps": 5,
                    "paymentTiming":"Prepaid",
                    "billingMethod":"ByBandwidth",
                    "createTime":"2016-03-08T08:13:09Z",
                    "expireTime":"2016-04-08T08:13:09Z"
                },
                {
                    "name":"eip-xxxxxxx-1",
                    "eip": "x.x.x.x",
                    "status":"binded",
                    "instanceType": "BCC",
                    "instanceId": "i-xxxxxxx",
                    "bandwidthInMbps": 1,
                    "paymentTiming":"Postpaid",
                    "billingMethod":"ByTraffic",
                    "createTime":"2016-03-08T08:13:09Z",
                    "expireTime":null
                },
            ],
            "marker":"eip-xxxxxxx-1",
            "isTruncated": true,
            "nextMarker": "eip-DCB50387",
            "maxKeys": 2
        }
   eips   instanceTypes
   instanceIds   status   marker   maxKeyss	   ipVersionrL   )r(   
isinstancer	   valuer*   r   GET)r   r:   rU   
ip_versionrV   statusmarkermax_keysr   r1   r#   s              r   	list_eipsEipClient.list_eips  s    F ~~? 6N$&3?#"$/=!*VY"?"? &F9 &9!):!#-< !!,"2"2D)/ " 1 	1r   c                     [         R                  " U R                  5       S5      n0 nUb  XS'   Ub  X'S'   Ub  X7S'   Ub  XGS'   U R                  [        R
                  XgUS9$ )a  
list all EIP in the recycle bin with the specific parameters.

:type eip: string
:param eip: eip address condition

:type name: string
:param name: eip name condition

:type marker: string
:param marker: The optional parameter marker specified in the original
 request to specify where in the results to begin listing.

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

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

:return: list of eip model, for example:
        {
            "eipList": [
                {
                    "name":"eip-xxxxxxx-1",
                    "eip": "x.x.x.x",
                    "eip_id":"ip-xxxxxxxx",
                    "status": "paused",
                    "route_type": "BGP",
                    "bandwidth_in_mbps": 5,
                    "payment_timing":"Prepaid",
                    "billing_method":"ByBandwidth",
                    "recycle_time":"2016-03-08T08:13:09Z",
                    "scheduled_delete_time":"2016-04-08T08:13:09Z"
                },
                {
                    "name":"eip-xxxxxxx-2",
                    "eip": "x.x.x.x",
                    "eip_id":"ip-xxxxxxxx",
                    "status": "paused",
                    "route_type": "BGP",
                    "bandwidth_in_mbps": 10,
                    "payment_timing":"Postpaid",
                    "billing_method":"ByBandwidth",
                    "recycle_time":"2016-03-08T08:13:09Z",
                    "scheduled_delete_time":"2016-04-08T08:13:09Z"
                },
            ],
            "marker":"ip-xxxxxxxx",
            "is_truncated": true,
            "max_keys": 1000
        }
recycleri   s   namerj   rk   rL   )r   r8   r(   r*   r   rn   )r   r:   r   rq   rr   r   r1   r#   s           r   list_eip_recycleEipClient.list_eip_recycle  sw    l  0)<? 6N"7O &9!):!!,"2"2DPV!WWr   c                     [         R                  " U R                  5       U5      nUc  U R                  5       nUUS.nU R	                  [
        R                  XVUS9$ )a  
delete an EIP with additional options.

:type eip: string
:param eip: the EIP address to delete.

:type release_to_recycle: bool
:param release_to_recycle: flag to release EIP to recycle bin.

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
)r!   s   releaseToRecyclerL   r^   )r   r:   release_to_recycler0   r   r1   r#   s          r   optional_delete_eipEipClient.optional_delete_eip+  s_    (  0#6>>@L(!3
 !!,"5"5tSY!ZZr   c                     [         R                  " U R                  5       SU5      nUc  U R                  5       nSUS.nU R	                  [
        R                  XEUS9$ )af  
restore an EIP from the recycle bin.

:type eip: string
:param eip: eip address to be restored from recycle bin.

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
rv   r   )s   restorer!   rL   rM   rN   s         r   restore_recycle_eipEipClient.restore_recycle_eipI  sa    "  0)SA>>@L(
 !!,"2"2DPV!WWr   c                     [         R                  " U R                  5       SU5      nUc  U R                  5       nSU0nU R	                  [
        R                  XEUS9$ )ac  
delete an EIP from the recycle bin.

:type eip: string
:param eip: eip address to be delete from recycle bin.

:type client_token: string
:param client_token: if the clientToken is not specified by the user,
 a random String generated by default algorithm will be used.

:type config: baidubce.BceClientConfiguration
:param config:

:return: BceResponse
rv   r!   rL   r^   rN   s         r   delete_recycle_eipEipClient.delete_recycle_eipd  s`    "  0)SA>>@LL
 !!,"5"5tSY!ZZr   c                  ,    [         R                  " 5       $ )z
default client token by uuid1
)uuiduuid1 r   r   r)   (EipClient._generate_default_client_token~  s    
 zz|r   c                 r    U c  [         R                  n [        R                  " [         R                  U 5      $ )z1
:type prefix: string
:param prefix: path prefix
)r   prefixr   r8   version)r   s    r   r(   EipClient._get_path  s-     >%%F	 1 16::r   c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ )zH

:type config: baidubce.BceClientConfiguration
:param config:
:return:
)r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configEipClient._merge_config  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      $ )z

:param http_method:
:param path:
:param body:
:param headers:
:param params:

:type config: baidubce.BceClientConfiguration
:param config:

:param body_parser:

:return: baidubce.BceResponse
s   */*s   application/json;charset=utf-8)s   Accepts   Content-Type)r   r   
parse_jsonr   send_requestr   signparse_error)r   http_methodr1   r"   headersr#   r   body_parsers           r   r*   EipClient._send_request  sm    " ##F+!,,K?"((IKG ++FM4F4F-4-@-@+,N,7t,24 	4r   r   )N)NNNNN)NN)NNN)NNNN)NNNNNN  N)NNNr   N)FNN)__name__
__module____qualname____firstlineno____doc__r   r   r   r2   r<   rA   rI   rO   rX   r[   r`   rc   rf   rs   rw   r{   r~   r   staticmethodr)   r(   r   r*   __static_attributes__r   r   r   r   r   %   s     GF- @D>B51n CGHB EI%)/Hb TX7;(HTX< SW%HN1416X2X4 TXBFT1l@XD[<X6[4   ; ; CG<@4r   r   )r   r   r,   loggingr   baidubcer   baidubce.authr   baidubce.bce_base_clientr   baidubce.httpr   r   r   baidubce.services.eip.modelr	   	getLoggerr   _loggerr   r   r   r   <module>r      sK   "      ' 2 ) ! & 1


H
%T
4 T
4r   