
    ̑iq                         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                   6   \ 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 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/banglarbhumi/venv/lib/python3.13/site-packages/baidubce/services/eip/eip_client.pyr   EipClient.__init__,   s    
 	t,    c                    SU0nUb  X-S'   Ub  XMS'   Ub  X]S'   Ub  XmS'   Ub  X}S'   Ub  XS'   U	b  XS'   U
b  XS	'   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$ )a  
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

:type route_type: string
:param route_type: route type (BGP or BGP_S)

:type ip_version: string
:param ip_version: IP version (ipv4 or ipv6), default ipv4

:type tags: list
:param tags: list of tag key-value pairs

:type resource_group_id: string
:param resource_group_id: resource group ID

:type auto_renew_time_unit: string
:param auto_renew_time_unit: auto renew time unit (month or year)

:type auto_renew_time: int
:param auto_renew_time: auto renew time length

:type delete_protect: bool
:param delete_protect: enable delete protection

:type client_token: string
:param client_token: idempotent token

:type config: baidubce.BceClientConfiguration
:param config:

:return: created eip address, for example,{"eip":"x.x.x.x"}
bandwidthInMbpsname	routeType	ipVersiontagsresourceGroupIdautoRenewTimeUnitautoRenewTimedeleteProtect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
ip_versionr   resource_group_idauto_renew_time_unitauto_renew_timedelete_protectclient_tokenr   r(   pathr)   s                   r   
create_eipEipClient.create_eip3   s3   ^ 0
 L! *! *L(&7"#+(<$%&$3!%$2!?!+!.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/   r0   r   PUTr2   r3   )r   eipnew_bandwidth_in_mbpsr;   r   r(   r<   r)   s           r   
resize_eipEipClient.resize_eip   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'   rA   )r,   r-   r   rC   r.   r/   r0   r   rD   r2   r3   )r   rE   r"   r;   r   r(   r<   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
monthrJ   )r   r   r   )s   startAutoRenewr'   rA   rB   )	r   rE   r8   r9   r;   r   r(   r<   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   rC   r.   r/   r0   r   rD   r   rE   r;   r   r<   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$ )aj  
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 instance_ip: string
:param instance_ip: specific IP address within the instance to bind

: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'   rA   rB   )
r   rE   instance_typeinstance_idinstance_ipr;   r   r(   r<   r)   s
             r   bind_eipEipClient.bind_eip(  s    6 *%
 "!, 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'   rS   rT   rU   s         r   
unbind_eipEipClient.unbind_eipR  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'   rS   r   rC   r.   r/   r0   r   DELETErU   s         r   release_eipEipClient.release_eipl  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'   rS   rT   rU   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'   rS   rT   rU   s         r   undirect_eipEipClient.undirect_eip  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  XLS'   Ub  XS'   Ub$  [        U[        5      (       a  UR                  US'   Ub  XlS'   Ub  X|S'   Ub  X<S'   U	b  XS	'   U R	                  [
        R                  XU
S
9$ )a  
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 name: string
:param name: eip name condition

:type eip_ids: string
:param eip_ids: comma-separated EIP IDs for batch query

: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
   instanceId   names   status   marker   maxKeyss	   ipVersions   eipIdsrS   )r.   
isinstancer	   valuer0   r   GET)r   rE   r\   r6   r]   statusmarkermax_keysr   eip_idsr   r<   r)   s                r   	list_eipsEipClient.list_eips  s    T ~~? 6N$&3?#"$/=!"7O*VY"?"? &F9 &9!):!#-<  '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
        }
recyclerp   rq   rr   rs   rS   )r   rC   r.   r0   r   rv   )r   rE   r   rx   ry   r   r<   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   releaseToRecyclerS   re   )r   rE   release_to_recycler;   r   r<   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
r~   r   )s   restorer'   rS   rT   rU   s         r   restore_recycle_eipEipClient.restore_recycle_eip{  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
r~   r'   rS   re   rU   s         r   delete_recycle_eipEipClient.delete_recycle_eip  s`    "  0)SA>>@LL
 !!,"5"5tSY!ZZr   c                     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$ )a  
Change EIP billing method from postpaid to prepaid.

:type eip: string
:param eip: eip address to change billing method

:type purchase_length: int
:param purchase_length: purchase duration in months (1-9, 12, 24, 36)

:type bandwidth: int
:param bandwidth: bandwidth for prepaid 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
)purchaseLength	bandWidths	   TO_PREPAY)s   actionr'   rA   rB   )	r   rE   purchase_length	bandwidthr;   r   r(   r<   r)   s	            r   change_eip_to_prepayEipClient.change_eip_to_prepay  s    . ."

  0#6>>@L#(
 !!,"2"2D'+zz$'7 " H 	Hr   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$ )a@  
Refund a prepaid EIP.

:type eip: string
:param eip: eip address to refund

: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
refundr'   rS   rT   rU   s         r   refund_prepay_eipEipClient.refund_prepay_eip  s`       0(C@>>@LL
 !!,"2"2DPV!WWr   c                     SU0n[         R                  " U R                  5       US5      nUc  U R                  5       nSU0nU R	                  [
        R                  Xg[        R                  " U5      US9$ )a  
Update EIP delete protection setting.

:type eip: string
:param eip: eip address to update

:type delete_protect: bool
:param delete_protect: enable or disable delete protection

: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'   rA   rB   )r   rE   r:   r;   r   r(   r<   r)   s           r   update_eip_delete_protect#EipClient.update_eip_delete_protect  s    ( ^
  0#G>>@LL
 !!,"2"2D'+zz$'7 " H 	Hr   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   rC   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_methodr<   r(   headersr)   r   body_parsers           r   r0   EipClient._send_request,  sm    " ##F+!,,K?"((IKG ++FM4F4F-4-@-@+,N,7t,24 	4r   r   )N)NNNNNNNNNNN)NN)NNN)NNNN)
NNNNNN  NNN)NNNr   N)FNN)NNNNN) __name__
__module____qualname____firstlineno____doc__r   r   r   r=   rG   rL   rP   rV   r_   rb   rg   rj   rm   r{   r   r   r   r   r   r   r   staticmethodr/   r.   r   r0   __static_attributes__r   r   r   r   r   %   s    GF- @D6:<@48)-	Y1v CGHB EI%)/Hb TX7;(HTX< X\(HT1416X2X4 TX5926_1B@XD[<X6[4#HJX0H@   ; ; CG<@4r   r   )r   r   r2   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
%c4 c4r   