
    9i~.                     <   S r SSK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$                  S:  a  \" \5        \R(                  " S5        \R*                  " \5      r " S S\R0                  5      rS r\rg)z.
This module provides a client class for ACL.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)utils)required)compat3zutf-8c                       \ rS rSrSrSrSS jrSS jr  SS jr\	" \
\4S9SS	 j5       r\	" \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)	AclClient)   z
ACL 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/acl_client.pyr   AclClient.__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AclClient._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AclClient._send_request?   sk     ##F+!,,K?"(13G ++M&&)<)<k(Jtf6 	6r   )vpc_idc                     [         R                  " U R                  S5      n0 nXS'   U R                  [        R
                  UXBS9$ )z
Get the detail information of acl for specific vpc.

:param vpc_id:
    the vpc id
:type vpc_id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
acls   vpcIdr'   r   r   
append_uriprefixr)   r   GET)r   r+   r   r$   r'   s        r   list_acl_entrysAclClient.list_acl_entrysM   sN     U3!x!!,"2"2D)/ " @ 	@r   )	rule_listc                     [         R                  " U R                  SS5      n0 nUc  [        5       US'   OX%S'   SU0nU R	                  [
        R                  U[        R                  " U5      UUS9$ )a  
Create  acl rules with the specified options.

:param rule_list:
        a list contains acl rules.
        https://cloud.baidu.com/doc/VPC/API.html#AclRuleRequest
        The elements of the list are AclRuleRequest
:type rule_list: list

AclRuleRequest{
    :param subnetId:
        The subnet id which the acl rule applied to
    :type subnetId: string

    :param protocol:
        The parameter specify which protocol will the acl rule work on
    :value: "all" or ""tcp" or "udp" or "icmp"
    :type protocol: string

    :param sourceIpAddress:
        Source ip address which the rule applied to
    :type sourceIpAddress: string

    :param destinationIpAddress:
        Destination ip address which the rule applied to
    :type destinationIpAddress: string

    :param sourcePort:
        Port used by source ip address
    :value 1-65535
    :type sourcePort: string

    :param destinationPort:
        Port used by destination ip address
    :value 1-65535
    :type destinationPort:string

    :param position:
        Priority of the rule
    :value 1-5000,unique,The smaller the value, the higher the priority
    :type:position:Integer

    :param direction:
        The rule is a ingress or a egress rule
    :value: "ingress" or "egress"
    :type direction:string

    :param action:
        The rule is allowed or denied
    :value "allow" or "deny"
    :type action:string

    :param description(Optional):
        The option param to describe the acl rule.
    :type description: string
}

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

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
r-   rule   clientTokenaclRules)r%   r'   r   )	r   r0   r1   generate_client_tokenr)   r   POSTjsondumps)r   r5   client_tokenr   r$   r'   r%   s          r   
create_aclAclClient.create_aclc   s    L UF;%:%<F>"%1>" 	
 !!,"3"3T'+zz$'7)/ " 1 	1r   )	subnet_idc                     [         R                  " U R                  SS5      n0 nUb  X&S'   Ub  X6S'   XS'   U R                  [        R
                  UXdS9$ )a  
Return a list of acl rules of specify subnet.

:param subnet_id
    the id of subnet whhich the acl applied
:type subnet_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
 r-   r7   s   markers   maxKeyss   subnetIdr.   r/   )r   rA   markermax_keysr   r$   r'   s          r   list_subnet_aclAclClient.list_subnet_acl   sl    : UF; &9!):'{!!,"2"2D)/ " @ 	@r   )acl_rule_idc                     [         R                  " U R                  SSU5      n0 nUc  [        5       US'   OX%S'   U R	                  [
        R                  UXSS9$ )a  
Delete the  specific acl rule.

:param acl_rule_id:
    The id of the specified acl.
:type acl_rule_id: string

:param client_token:
    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
r-   r7   r8   r.   )r   r0   r1   r:   r)   r   DELETE)r   rG   r>   r   r$   r'   s         r   
delete_aclAclClient.delete_acl   se    ( UFKH%:%<F>"%1>"!!,"5"5t)/ " @ 	@r   c                 x   [         R                  " U R                  SSU5      n0 nU
c  [        5       US'   OXS'   0 nUb  [        R
                  " U5      US'   Ub  [        R
                  " U5      US'   Ub  [        R
                  " U5      US'   Ub  [        R
                  " U5      US'   Ub  [        R
                  " U5      US'   Ub  [        R
                  " U5      US	'   Ub  XS
'   U	b  [        R
                  " U	5      US'   U R                  [        R                  U[        R                  " U5      XS9$ )ap  
Modify the special attribute to new value of the acl owned by the user.

:param acl_rule_id
        id of the acl to be modified
:type acl_rule_id:string

:param description:
        The option param to describe the acl rule.
:type description: string

:param protocol:
         The parameter specify which protocol will the acl rule work on
:value: "all" or ""tcp" or "udp" or "icmp"
:type protocol: string

:param source_ip_address:
         source ip address which the rule applied to
:type source_ip_address: string

:param destination_ip_address:
         destination ip address which the rule applied to
:type destination_ip_address: string

:param source_port:
         port used by source ip address
:value 1-65535
:type source_port: string

:param destination_port:
         port used by destination ip address
:value 1-65535
:type destination_port:string

:param position:
         priority of the rule
:value 1-5000,unique,The smaller the value, the higher the priority
:type:position:Integer

:param action:
        the rule is allowed or denied
:value "allow" or "deny"
:type action:string

:param client_token:
        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
r-   r7   r8   descriptionprotocolsourceIpAddressdestinationIpAddress
sourcePortdestinationPortpositionactionr.   )r   r0   r1   r:   r
   convert_to_stringr)   r   PUTr<   r=   )r   rG   rM   rN   source_ip_addressdestination_ip_addresssource_portdestination_portrS   rT   r>   r   r$   r'   r%   s                  r   
update_aclAclClient.update_acl   sU   | UFKH%:%<F>"%1>"""(":":;"GD%77AD((():; "# "-(()?@ '( "!'!9!9+!FD'(()9: "# '#55f=DN!!,"2"2D$**T:J)/ " @ 	@r    r   )NNNNN)NN)NNN)
NNNNNNNNNN)__name__
__module____qualname____firstlineno____doc__r1   r   r   r)   r	   bytesstrr3   listr?   rE   rJ   r[   __static_attributes__r]   r   r   r   r   )   s     F= 7;/36 eS\"@ #@* S1 S1j %&@ &&@P 5#,'@ (@8 5#,'2648<@$()--1b@ (b@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
)rd   uuiduuid4r]   r   r   generate_client_token_by_uuidrj   e  s     tzz|r   )rb   r   r<   loggingrh   sysbaidubcer   baidubce.authr   baidubce.httpr   r   r   r   baidubce.utilsr	   r
   versionreloadsetdefaultencoding	getLoggerr^   _loggerr   r   rj   r:   r]   r   r   <module>rv      s        
 $ ' ) ! &  # ;;
3K7#


H
%y@-- y@x	 6 r   