
    9iV                     &   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)z:
This module provides a client class for peer connection.
    N)utils)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)peerconn_model)requiredPostpaidc                      \ rS rSrSrSrSrSS jrSS jr  SS jr	\
" \\\4\\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\\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\\4S9 S#S j5       r\
" \\4\\4S9 S#S j5       r\
" \\4\4S9 S#S j5       r\SS j5       rSrg)$PeerConnClient(   z
Peer connection sdk client
s   /v1s	   /peerconnNc                 B    [         R                  R                  X5        g N)r   BceBaseClient__init__)selfconfigs     e/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/vpc/peerconn_client.pyr   PeerConnClient.__init__/   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PeerConnClient._merge_config2   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PeerConnClient._send_request?   sj     ##F+!,,K?"((IKG++M&&)<)<k(Jtf6 	6r   )bandwidth_in_mbpslocal_vpc_idpeer_vpc_idpeer_regionc                    U R                  5       nU	c
  [        5       n	SU	0nU
c  [        n
UUUUU
R                  US.nUb  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub!  U Vs/ s H  nUR                  PM     nnUUS'   Ub  UUS'   U R	                  [
        R                  U[        R                  " U5      UUS	9$ s  snf )
a  
Create Peer connection.
For peer connections within the same region, only postpaid is
supported.
For peer connections between different accounts, the peer connections
are available only after the remote account accepts the connections.
For peer connections within the same account, peer connection will be
accepted automatically.
There can be only one peer connection between any two VPCs.
Peer connection endpoints cannot be the same VPC.
If both local VPC and remote VPC are transit VPCs, peer connection
cannot be established.

: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 bandwidth_in_mbps:
    Network bandwidth (in unit of Mbps) of peer connection.
:type bandwidth_in_mbps: int

:param description:
    Description of peer connection.
:type description: string

:param local_if_name:
    Name of local interface of peer connection.
:type local_if_name: string

:param local_vpc_id:
    Local side VPC id of peer connection.
:type local_vpc_id: string

:param peer_account_id:
    Remote account id of peer connection.
    Used only when the peer connection connects two different accounts.
:type peer_account_id: string

:param peer_vpc_id:
    Remote side VPC id of peer connection.
:type peer_vpc_id: string

:param peer_region:
    Remote side region of peer connection.
:type peer_region: string

:param peer_if_name:
    Name of remote interface of peer connection.
:type peer_if_name: string

:param billing:
    Billing information.
:type billing: nat_model.Billing

:param config:
:type config: baidubce.BceClientConfiguration

:param tags:
    Tags of peer connection.
:type tags: list[TagModel]

:param resourceGroupId:
    Resource group ID of peer connection.
:type resourceGroupId: string

:param deleteProtect:
    Whether or not enable delete protection on this resource.
    Default false.
:type deleteProtect: bool

:return:
:rtype baidubce.bce_response.BceResponse
   clientToken)bandwidthInMbps
localVpcId	peerVpcId
peerRegionbillingdeleteProtectdescriptionlocalIfNamepeerAccountId
peerIfNametagsresourceGroupIdr%   r'   r   )		_get_pathgenerate_client_token#default_billing_to_purchase_created__dict__r)   r   POSTjsondumps)r   r+   r,   r-   r.   r7   local_if_namepeer_account_idpeer_if_nameclient_tokenr5   r   r;   r<   r6   r$   r'   r%   tagtag_lists                       r   create_peerconnPeerConnClient.create_peerconnL   s
   h ~~02LL
 ?9G0&$%''*
 ""-D$"/D&$3D!#!-D045H5#DL&&5D"#!!,"3"3"&TZZ-=)/ " @ 	@	 6s   %B?)vpc_idc                     U R                  5       nSU0nUb  X&S'   Ub  X6S'   U R                  [        R                  XVUS9$ )a  
Return a list of peer connections.

:param vpc_id:
    VPC id that peer connections connect to.
:type vpc_id: 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   vpcIds   markers   maxKeysr'   r   )r>   r)   r   GET)r   rM   markermax_keysr   r$   r'   s          r   list_peerconnsPeerConnClient.list_peerconns   sa    < ~~f
  &9!):!!,"2"2"&f " F 	Fr   )peer_conn_idc                     [         R                  " U R                  5       U5      nU R                  [        R
                  X2S9$ )a  
Get the detail information of specified peer connection.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
)r   )r   
append_urir>   r)   r   rP   )r   rU   r   r$   s       r   get_peerconnPeerConnClient.get_peerconn   s9      0,?!!,"2"2D!HHr   )rU   local_if_idc                     [         R                  " U R                  5       U5      nUc
  [        5       nSU0nSU0n	Ub  X9S'   Ub  XIS'   U R	                  [
        R                  U[        R                  " U	5      XS9$ )a6  
Update the interface name or description of specified peer connection.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param local_if_id:
    Local interface id of peer connection
:type local_if_id: string

:param description:
    Description of peer connection.
:type description: string

:param local_if_name:
    Name of local interface of peer connection.
:type local_if_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
r0   	localIfIdr7   r8   r=   	r   rW   r>   r?   r)   r   PUTrC   rD   )
r   rU   rZ   r7   rE   rH   r   r$   r'   r%   s
             r   update_peerconnPeerConnClient.update_peerconn   s    F  0,?02LL
 
 ""-$"/!!,"2"2"&TZZ-=)/ " @ 	@r   )rU   actionc                     [         R                  " U R                  5       U5      nUc
  [        5       nSU0nSXb'   U R	                  [
        R                  XVUS9$ )aA  
Accept or reject peer connection request.
Timeout period of connection request is 7 days.
When timeout or the remote side rejects the connection,
the status of peer connection on initiator side is consulting failed.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param action:
    'accept': when accepting the peer connection.
    'reject': when rejecting the peer connection.
:type action: 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
Nr0   rO   r   rW   r>   r?   r)   r   r^   )r   rU   ra   rH   r   r$   r'   s          r   handle_peerconnPeerConnClient.handle_peerconn0  sg    >  0,?02LL
 !!,"2"2"&f " F 	F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 peer connection.
For peer connections between different accounts,
only initiator can perform this operation.
One cannot delete prepaid peer connections that are not expired.
Consulting failed prepaid peer connections can be deleted.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_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 config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
r0   rO   )r   rW   r>   r?   r)   r   DELETE)r   rU   rH   r   r$   r'   s         r   delete_peerconnPeerConnClient.delete_peerconnY  s`    6  0,?02LL
 !!,"5"5"&f " F 	Fr   )rU   new_bandwidth_in_mbpsc                     [         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>  
Scale down/up the bandwidth of specified peer connection.
For peer connections between different accounts,
only initiator can perform this operation.
Prepaid peer connection can only scale up.
Postpaid peer connection can scale up or down.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_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 new_bandwidth_in_mbps:
    The new bandwidth of the peer connection.
:type new_bandwidth_in_mbps: int

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
N)s   resizer0   newBandwidthInMbpsr=   r]   )r   rU   rj   rH   r   r$   r'   r%   s           r   resize_peerconnPeerConnClient.resize_peerconn}  s|    >  0,?02L(

 !"7
 !!,"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$ )a  
Renew specified peer connection.
Postpaid peer connection cannot be renewed.
For peer connections between different accounts, only the initiator can
perform this operation.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_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: peerconn_model.Billing

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
N)s   purchaseReservedr0   r5   r=   )r   rW   r>   r?   $default_billing_to_purchase_reservedrA   r)   r   r^   rC   rD   )r   rU   rH   r5   r   r$   r'   r%   s           r   purchase_reserved_peerconn)PeerConnClient.purchase_reserved_peerconn  s    <  0,?02L!%(
 ?:Gw''
 !!,"2"2"&TZZ-=)/ " @ 	@r   )rU   rolec                     [         R                  " U R                  5       U5      nUc
  [        5       nSUUS.nU R	                  [
        R                  XVUS9$ )aW  
Open DNS sync between VPCs connected by peer connection.
DNS sync can be opened only when the status of
peer connection is available.
DNS sync cannot be opened when the DNS status of
peer connection is syncing or closing.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param role:
    'initiator': for VPC where peer connection is initiated.
    'acceptor': for VPC where peer connection is accepted.
:type role: 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   open   roler0   rO   rc   r   rU   rs   rH   r   r$   r'   s          r   open_peerconn_dns_sync%PeerConnClient.open_peerconn_dns_sync  se    @  0,?02L(

 !!,"2"2"&f " F 	Fr   c                     [         R                  " U R                  5       U5      nUc
  [        5       nSUUS.nU R	                  [
        R                  XVUS9$ )aX  
Close DNS sync between VPCs connected by peer connection.
DNS sync can be closed only when the status of peer connection
is available. DNS sync cannot be closed when the DNS status
of peer connection is syncing or closing.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param role:
    'initiator': for VPC where peer connection is initiated.
    'acceptor': for VPC where peer connection is accepted.
:type role: 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   closeru   r0   rO   rc   rv   s          r   close_peerconn_dns_sync&PeerConnClient.close_peerconn_dns_sync  sd    >  0,?02L(

 !!,"2"2"&f " F 	Fr   )rU   delete_protectc                     [         R                  " U R                  5       US5      nUc
  [        5       nSU0nSU0nU R	                  [
        R                  U[        R                  " U5      XdS9$ )a~  
Update the delete protect of peer connection.

:param peer_conn_id:
    The id of specified peer connection.
:type peer_conn_id: string

:param delete_protect:
    Whether enable the delete protect of peer connection.
:type delete_protect: boolean

: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
s   deleteProtectr0   r6   r=   r]   )r   rU   r|   rH   r   r$   r'   r%   s           r   update_peerconn_delete_protect-PeerConnClient.update_peerconn_delete_protect-  s|    6  0,@PQ02LL
 ^
 !!,"2"2"&TZZ-=f " ] 	]r   c                 r    U c  [         R                  n [        R                  " [         R                  U 5      $ )z1
:type prefix: string
:param prefix: path prefix
)r   prefixr   rW   version)r   s    r   r>   PeerConnClient._get_pathT  s-     >#**F 6 6??r    r   )NNNNN)
NNNNNNNNNF)NNN)NNNN)NN)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r)   r
   intbytesstrrK   rS   rX   r_   rd   rh   rm   rq   rw   rz   boolr~   staticmethodr>   __static_attributes__r   r   r   r   r   (   s    GF= 7;/36 !3< #, #,(
 ?C<@8<8<<Ao@	(o@b eS\",0-1&F #&FP E3<(I )I" E3<eS\BEIFJ1@ C1@f E3<=AE#&F >&FP E3<(9=#!F )!FF E3<sC26*@ D*@X E3<(DH8<+@ )+@Z E3<ucl;9=(F <(FT E3<ucl;:>'F <'FR E3<@AE$] A$]L @ @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   rC   loggingr   baidubcer   r   baidubce.authr   baidubce.httpr   r   r   baidubce.services.vpcr	   baidubce.utilsr
   	getLoggerr   _loggerBillingr@   rp   r   r   r   r?   r   r   r   <module>r      s         $ ' ) ! & 0 #


H
% '5&<&<Z&H #'5'='='? $t@_22 t@n 6 r   