
    9iU                         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 parameter template.
    N)bce_base_client)bce_v1_signer)bce_http_client)handler)http_methods)required)compatc                      \ 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S9S!S j5       rS"S j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\	" \
\4S9S!S j5       rS"S jr\	" \
\4S9SS j5       rSrg)#TemplateClient#   z
Tempalte base sdk client
s   /v1Nc                 B    [         R                  R                  X5        g)G
:param config:
:type config: baidubce.BceClientConfiguration
:return:
N)r   BceBaseClient__init__)selfconfigs     e/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/vpc/template_client.pyr   TemplateClient.__init__*   s     	%%..t<    c                     Uc  U R                   $ [        R                  " U R                   5      nUR                  U5        U$ )r   )r   copymerge_non_none_values)r   r   
new_configs      r   _merge_configTemplateClient._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/U[        R                  U-   X4U5      $ )aE  
:param http_method:
:type http_method: string

:param path:
:type path: string

:param body:
:type body: dict

:param headers:
:type headers: dict

:param params:
:type params: dict

:param config:
:type config: baidubce.BceClientConfiguration

:param body_parser:
:type body_parser: function

:return: baidubce.BceResponse
s   */*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TemplateClient._send_request?   sv    6 ##F+!,,K?"(;\]G++M&&)<)<k(J..5tfN 	Nr   )name
ip_versionip_address_infoc                    Sn0 nUc  [        5       US'   OXXS'   [        R                  " U5      [        R                  " U5      S.n	Ub7  / n
U H+  nU
R                  UR                  UR
                  S.5        M-     XS'   Ub  [        R                  " U5      U	S'   U R                  [        R                  U[        R                  " U	5      UUS9$ )a  
Create a new ip set.
:param name:
    The name of ip set to be created.
:type name: string

:param ip_version:
    The IP version of the ip set.
:type ip_version: string

:param ip_address_info:
    The list of IpAddressInfo to be created in this ip set.
:type ip_address_info: List[IpAddressInfo]

:param description:
    The description of the ip set.
:type description: 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
   /ipSet   clientToken)r*   	ipVersion	ipAddressdescriptionipAddressInfor3   r$   r&   r   )generate_client_tokenr	   convert_to_stringappend
ip_addressr3   r(   r   POSTjsondumps)r   r*   r+   r,   r3   client_tokenr   r#   r&   r$   address_info_setr9   s               r   create_ip_setTemplateClient.create_ip_setc   s    @ %:%<F>"%1>" ,,T211*=

 &!-
 ''j6K6K\f\r\r(st .$4!""(":":;"GD!!,"3"3T

4@PY_)/ " 1 	1r   )	ip_set_idr,   c                 F   S[         R                  " U5      -   S-   n0 nUc  [        5       US'   OX6S'   S/ 0nUb4  U H.  nUS   R                  UR                  UR
                  S.5        M0     U R                  [        R                  U[        R                  " U5      XdS9$ )a  
Add a list of IpAddressInfo to specified ip set.

:param ip_set_id:
    The id of the ip set which you want to add IpAddressInfo into.
:type ip_set_id: string

:param ip_address_info:
    The list of IpAddressInfo to be added in this ip set.
:type ip_address_info: List[IpAddressInfo]

: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
   /ipSet/s
   /ipAddressr/   r4   r1   r5   )r	   r7   r6   r8   r9   r3   r(   r   r:   r;   r<   )	r   rA   r,   r=   r   r#   r&   r$   r9   s	            r   add_ip_address_to_ip_set'TemplateClient.add_ip_address_to_ip_set   s    2 F44Y??-O%:%<F>"%1>" R
 &-
_%,,:;P;P=G=S=S.U V . !!,"3"3T

4@PY_!oor   )rA   r9   c                    S[         R                  " U5      -   S-   n0 nUc  [        5       US'   OX6S'   S/ 0nUb  U H  nUS   R                  U5        M     U R	                  [
        R                  U[        R                  " U5      XdS9$ )a  
Delete a list of IpAddressInfo from specified ip set.

:param ip_set_id:
    The id of the ip set which you want to delete IpAddressInfo into.
:type ip_set_id: string

:param ip_address:
    The list of IpAddress to be deleted in this ip set.
:type ip_address: List[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
rC   s   /deleteIpAddressr/   r4   r5   )	r	   r7   r6   r8   r(   r   r:   r;   r<   )	r   rA   r9   r=   r   r#   r&   r$   addresss	            r   delete_ip_address TemplateClient.delete_ip_address   s    2 F44Y??BUU%:%<F>"%1>"R
 !%_%,,W5 & !!,"3"3T

4@PY_!qqr   )rA   c                     S[         R                  " U5      -   n0 nUc  [        5       US'   OXGS'   SUS'   UUS.nU R                  [        R
                  U[        R                  " U5      XuS9$ )a  
Update the specified IpSet.

:param ip_set_id:
    The id of the IpSet which you want to update.
:type ip_set_id: string

:param name:
    The new name of this IpSet.
:type name: string

:param description:
    The new description of this IpSet.
:type description: 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
rC   Nr/      modifyAttribute)r*   r3   r5   r	   r7   r6   r(   r   PUTr;   r<   )	r   rA   r*   r3   r=   r   r#   r&   r$   s	            r   update_ip_setTemplateClient.update_ip_set   s    : F44Y??%:%<F>"%1>"%)!" &

 !!,"2"2Dtzz$?OX^!nnr   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 IpSet.

:param ip_set_id:
    The id of the IpSet which you want to update.
:type ip_set_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
rC   r/   r&   r   r	   r7   r6   r(   r   DELETE)r   rA   r=   r   r#   r&   s         r   delete_ip_setTemplateClient.delete_ip_set  sX    , F44Y??%:%<F>"%1>"!!,"5"5tSY!ZZr   c                 v    SnSS0nUb  XS'   Ub  X&S'   Ub  X6S'   U R                  [        R                  XVUS9$ )a  
Return a list of all IpSets owned by the authenticated user.

:param ip_version:
    The version of IP addresses that are returned.
    Valid values are IPv4 and IPv6.
:type ip_version: 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.   maxKeys  
   ip_version   marker   maxKeysrQ   r(   r   GETr   r+   markermax_keysr   r#   r&   s          r   list_ip_setTemplateClient.list_ip_set:  s\    6 T"!$.=! &9!):!!,"2"2DPV!WWr   c                 p    S[         R                  " U5      -   nU R                  [        R                  X2S9$ )z
Get the detail information of specified IpSet.

:param ip_set_id:
    The id of the IpSet which you want to query.
:type ip_set_id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
rC   r   r	   r7   r(   r   r]   )r   rA   r   r#   s       r   get_ip_set_detail TemplateClient.get_ip_set_detail`  s5     F44Y??!!,"2"2D!HHr   )r*   r+   
ip_set_idsc                     Sn0 nUc  [        5       US'   OXXS'   UUUS.n	Uc  XIS'   U R                  [        R                  U[        R
                  " U	5      XS9$ )a  
Create an IpGroup.

:param name:
    The name of the IpGroup.
:type name: string

:param ip_version:
    The version of IP addresses that are returned.
    Valid values are IPv4 and IPv6.
:type ip_version: string

:param ip_set_ids:
    A list of IpSet ids.
:type ip_set_ids: list

:param description:
    The description of the IpGroup.
:type description: 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
   /ipGroupr/   )r*   r0   ipSetIdsr3   r5   )r6   r(   r   r:   r;   r<   )
r   r*   r+   rh   r3   r=   r   r#   r&   r$   s
             r   create_ip_groupTemplateClient.create_ip_groupr  sv    D %:%<F>"%1>" #"

 "-!!,"3"3T

4@PY_!oor   )ip_group_idrh   c                     S[         R                  " U5      -   S-   n0 nUc  [        5       US'   OX6S'   SU0nU R                  [        R
                  U[        R                  " U5      XdS9$ )aH  
Bind IpSet to IpGroup.

:param ip_group_id:
    The id of the IpGroup which you want to bind IpSet.
:type ip_group_id: string

:param ip_set_ids:
    A list of IpSet ids.
:type ip_set_ids: 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
	   /ipGroup/s
   /bindIpSetr/   rk   r5   r	   r7   r6   r(   r   r:   r;   r<   r   rn   rh   r=   r   r#   r&   r$   s           r   bind_ip_setTemplateClient.bind_ip_set  sx    2 f66{CCmS%:%<F>"%1>" 

 !!,"3"3T

4@PY_!oor   c                     S[         R                  " U5      -   S-   n0 nUc  [        5       US'   OX6S'   SU0nU R                  [        R
                  U[        R                  " U5      XdS9$ )aN  
Unbind IpSet from IpGroup.

:param ip_group_id:
    The id of the IpGroup which you want to remove IpSet.
:type ip_group_id: string

:param ip_set_ids:
    A list of IpSet ids.
:type ip_set_ids: 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
rp   s   /unbindIpSetr/   rk   r5   rq   rr   s           r   unbind_ip_setTemplateClient.unbind_ip_set  sx    2 f66{CCoU%:%<F>"%1>" 

 !!,"3"3T

4@PY_!oor   )rn   c                     S[         R                  " U5      -   n0 nUc  [        5       US'   OXGS'   SUS'   0 nUb  X(S'   Ub  X8S'   U R                  [        R
                  U[        R                  " U5      XuS9$ )a  
Update the IpGroup.

:param ip_group_id:
    The id of the IpGroup which you want to update.
:type ip_group_id: string

:param name:
    The new name of the IpGroup.
:type name: string

:param description:
    The new description of the IpGroup.
:type description: 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
rp   Nr/   rK   r*   r3   r5   rL   )	r   rn   r*   r3   r=   r   r#   r&   r$   s	            r   update_ip_groupTemplateClient.update_ip_group  s    : f66{CC%:%<F>"%1>"%)!"L""-!!,"2"2Dtzz$?OX^!nnr   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 IpGroup.

:param ip_group_id:
    The id of the IpGroup which you want to update.
:type ip_group_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
rp   r/   rQ   rR   )r   rn   r=   r   r#   r&   s         r   delete_ip_groupTemplateClient.delete_ip_group  sX    , f66{CC%:%<F>"%1>"!!,"5"5tSY!ZZr   c                 v    SnSS0nUb  XS'   Ub  X&S'   Ub  X6S'   U R                  [        R                  XVUS9$ )a  
Return a list of all IpGroups owned by the authenticated user.

:param ip_version:
    The version of IP addresses that are returned.
    Valid values are IPv4 and IPv6.
:type ip_version: 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
rj   rW   rX   rY   rZ   r[   rQ   r\   r^   s          r   list_ip_groupTemplateClient.list_ip_group=  s\    6 T"!$.=! &9!):!!,"2"2DPV!WWr   c                 p    S[         R                  " U5      -   nU R                  [        R                  X2S9$ )a  
Get the detail information of specified IpGroup.

:param ip_group_id:
    The id of the IpGroup which you want to query.
:type ip_group_id: string

:param config:
:type config: baidubce.BceClientConfiguration

:return:
:rtype baidubce.bce_response.BceResponse
rp   rd   re   )r   rn   r   r#   s       r   get_ip_group_detail"TemplateClient.get_ip_group_detailc  s5     f66{CC!!,"2"2D!HHr    )N)NNNNN)NNN)NN)NNNN)__name__
__module____qualname____firstlineno____doc__r!   r   r   r(   r   bytesstrlistr?   rD   rH   rN   rT   ra   rf   rl   rs   rv   ry   r|   r   r   __static_attributes__r   r   r   r   r   #   s    F= 7;/3"NH E3<UCL$O41 P41l d;(p <(pV 6&r 7&rP %)o &)oV %[ &[<$XL %I &I" E3<UCLTJ0p K0pd 5#,48#p 9#pJ 5#,48#p 9#pJ 5#,'*o (*oX 5#,'[ ([<$XL 5#,'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
)r   uuiduuid4r   r   r   generate_client_token_by_uuidr   u  s     tzz|r   )r   r   r;   loggingr   baidubcer   baidubce.authr   baidubce.httpr   r   r   baidubce.utilsr   r	   	getLoggerr   _loggerr   r   r   r6   r   r   r   <module>r      sa        $ ' ) ! & # 


H
%P	I_22 P	Id 6 r   