
    9i3                         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\R&                  5      rS r\rg)z.
This module provides a client class for VPC.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)required)compatc                   R   \ rS rSrSrSrSS jrSS jr  SS j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S9SS j5       r\	" \
\4S9SS j5       r\	" \
\4S9SS j5       rSrg)	VpcClient"   z
VPC base sdk client
s   /v1Nc                 B    [         R                  R                  X5        g N)r   BceBaseClient__init__)selfconfigs     `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/vpc/vpc_client.pyr   VpcClient.__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VpcClient._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/U[        R                  U-   X4U5      $ )Ns   */*s   application/json;charset=utf-8)s   Accepts   Content-Type)
r   r   
parse_jsonr   send_requestr   signparse_errorr   prefix)r   http_methodpathbodyheadersparamsr   body_parsers           r   _send_requestVpcClient._send_request9   sv     ##F+!,,K?"(;\]G++M&&)<)<k(J))D0$I 	Ir   namecidrc                 L   Sn0 n	Uc  [        5       U	S'   OXIS'   [        R                  " U5      [        R                  " U5      S.n
Ub  [        R                  " U5      U
S'   Ub  XjS'   Ub  XZS'   U R                  [        R
                  U[        R                  " U
5      U	US9$ )a  
The name of vpc to be created.

:param name:
    The name of vpc to be created.
:type name: string

:param cidr:
    The CIDR of the vpc.
:type cidr: string

:param description:
    The description of the vpc.
:type description: string

:param enable_ipv6:
    The option param to enable or disable ipv6 for the subnet
:type enable_ipv6: boolean

:param tags:
    List of tags to be bind
:type tags: list

: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 the 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
   /vpc   clientTokenr*   descriptiontags
enableIpv6)r$   r&   r   )generate_client_tokenr	   convert_to_stringr(   r   POSTjsondumps)r   r+   r,   r0   client_tokenenable_ipv6r1   r   r#   r&   r$   s              r   
create_vpcVpcClient.create_vpcE   s    J %:%<F>"%1>" ,,T2,,T2
 ""(":":;"GDL"!,!!,"3"3T

4@PY_)/ " 1 	1r   )markermax_Keys
is_Defaultc                     Sn0 nUb  XS'   Ub  X'S'   Ub  X7S'   Ub  XGS'   U R                  [        R                  XgUS9$ )aA  
Return a list of vpcs owned by the authenticated user.

: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 vpc_ids:
    filter by vpc_ids, optional parameter
:type vpc_ids: string

:param isDefault:
    The option param demotes whether the vpc is default vpc.
:type isDefault: boolean

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
r.   s   markers   maxKeyss   vpcIdss	   isDefaultr&   r   )r(   r   GET)r   r<   r=   vpc_ids	isDefaultr   r#   r&   s           r   	list_vpcsVpcClient.list_vpcs   se    >  &9!): '9 #,< !!,"2"2DPV!WWr   )vpc_idc                 p    S[         R                  " U5      -  nU R                  [        R                  X2S9$ )z
Get the detail information of specified vpc.

:param vpc_id:
    The id of vpc.
:type vpc_id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
   /vpc/%sr   )r	   convert_to_bytesr(   r   rA   )r   rF   r   r#   s       r   get_vpcVpcClient.get_vpc   s5     F33F;;!!,"2"2D!HHr   c                     S[         R                  " U5      -  n0 nUc  [        5       US'   OX%S'   U R                  [        R
                  XEUS9$ )a@  
Delete the specified vpc owned by the user.All resource in the vpc must be deleted before the vpc itself
can be deleted.

:param vpc_id:
    The id of instance.
:type vpc_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 the 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
rH   r/   r@   )r	   rJ   r3   r(   r   DELETEr   rF   r8   r   r#   r&   s         r   
delete_vpcVpcClient.delete_vpc   sX    . F33F;;%:%<F>"%1>"!!,"5"5tSY!ZZr   )rF   r+   c                 R   S[         R                  " U5      -  nSS0n	S[         R                  " U5      0n
Uc  [        5       U	S'   OXiS'   Ub  [         R                  " U5      U
S'   Ub  XJS'   Ub  XZS'   U R	                  [
        R                  U[        R                  " U
5      XS	9$ )
a  
Modify the special attribute to new value of the vpc owned by the user.

:param vpc_id:
    The id of the specified vpc
:type vpc_id: string

:param name:
    The name of the specified vpc
:type name: string

:param description:
   The description of the vpc.
:type description: string

:param enable_ipv6:
    The option param to enable or disable ipv6 for the subnet
:type enable_ipv6: boolean

:param secondaryCidr:
    This parameter specifies the secondary CIDR ranges associated with the VPC.
:type secondaryCidr: list

: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 the 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
rH   s   modifyAttributeNr+   r/   r0   r2   secondaryCidrr@   )	r	   rJ   r4   r3   r(   r   PUTr6   r7   )r   rF   r+   r0   r9   rS   r8   r   r#   r&   r$   s              r   
update_vpcVpcClient.update_vpc   s    N F33F;;
 F,,T2
 %:%<F>"%1>"""(":":;"GD"!,$$1!!!,"2"2D$**T:J)/ " @ 	@r   c                     S[         R                  " U5      -  n0 nUb  X&S'   Ub  SR                  U5      US'   U R                  [        R
                  XVUS9$ )a  
Get the privateIpAddressesInfo from vpc.

:param vpc_id:
    The id of vpc.
:type vpc_id: string

:param private_ip_range:
    The optional parameter specifying the private IP range.
:type private_ip_range: string

:param private_ip_addresses:
    The optional list parameter specifying the private IP addresses.
:type private_ip_addresses: list

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
s   /vpc/%s/privateIpAddressInfos   privateIpRange,s   privateIpAddressesr@   )r	   rJ   joinr(   r   rA   )r   rF   private_ip_rangeprivate_ip_addressesr   r#   r&   s          r   get_private_ip_address_info%VpcClient.get_private_ip_address_info"  sg    . /1H1H1PP'(8$%+-0JJ7K,LF()!!,"2"2DPV!WWr   c                     S[         R                  " U5      -  n0 nUc  [        5       US'   OX%S'   U R                  [        R
                  XCS9$ )a  
Open relay for the specified vpc.

:param vpc_id:
    The id of vpc.
:type vpc_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 the 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   /vpc/openRelay/%sr/   rI   r	   rJ   r3   r(   r   rT   rO   s         r   
open_relayVpcClient.open_relayD  sU    * $f&=&=f&EE%:%<F>"%1>"!!,"2"2D!HHr   c                     S[         R                  " U5      -  n0 nUc  [        5       US'   OX%S'   U R                  [        R
                  XCS9$ )a  
Shutdown relay for the specified vpc.

:param vpc_id:
    The id of vpc.
:type vpc_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 the 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   /vpc/shutdownRelay/%sr/   rI   r_   rO   s         r   shutdown_relayVpcClient.shutdown_relayc  sU    * (&*A*A&*II%:%<F>"%1>"!!,"2"2D!HHr    r   )NNNNN)NN)NNN)__name__
__module____qualname____firstlineno____doc__r!   r   r   r(   r   bytesstrr:   intboolrD   rK   rP   rU   r\   r`   rc   __static_attributes__re   r   r   r   r   "   s8    F= 7;/3
I E3<ucl391 491v eS\CDA*X B*XX eS\"I #I$ eS\"[ #[@ eS\5EIHL=@ 6=@~ eS\"X #XB eS\"I #I< eS\"I #I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
)rl   uuiduuid4re   r   r   generate_client_token_by_uuidrs     s     tzz|r   )rj   r   r6   loggingrq   baidubcer   baidubce.authr   baidubce.httpr   r   r   baidubce.utilsr   r	   	getLoggerrf   _loggerr   r   rs   r3   re   r   r   <module>r{      sa        $ ' ) ! & # 


H
%^I-- ^I@ 6 r   