
                  
          S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  \R                  " S5      r
SS	 jr\" S
S9r\" SS9r\R                  " S5      r\R                  " S\SSS
S
SS9r\R                  " S5      r\R                  " S\SSS
S
SS9r\R                  " S5      r\R                  " S\SSS
S
SS9rSrS rSS jrSS jrS rS rg)z>Flags and helpers for the compute routers nats rules commands.    )absolute_import)division)unicode_literalsN)flagsz    External IP Addresses to use for connections matching this rule. This flag
    is supported only for Public NAT and is required when creating a Public NAT
    gateway.

    These must be valid reserved external IP addresses in the same region.Fc           
      >    [         R                  " S[        SSSSU S9$ )Nz--source-nat-active-ipsaddresscompute.addressesTnamedetailed_helpresource_nameregional_collectionregion_hiddenpluralrequired)compute_flagsResourceArgument_ACTIVE_IPS_HELPr   s    Blib/googlecloudsdk/command_lib/compute/routers/nats/rules/flags.py_ActiveIpsArgumentr   !   s*    		'	'$%-
     Tr   a      Subnetworks from which addresses are used for connections matching this
    rule. This flag is supported only for Private NAT and is required when
    creating a Private NAT gateway.

    These must be subnetwork resources in the same region, with purpose set to
    PRIVATE_NAT.z--source-nat-active-rangessubnetworkszcompute.subnetworksr
   z    Subnetwork ranges to drain connections on.

    These must be subnetworks previously used as active ranges on this rule.
    No new connections will be established using these ranges.z--source-nat-drain-rangesz    External IP Addresses to drain connections on.

    These must be external IPs previously used as active IPs on this rule.
    No new connections will be established using these IPs.z--source-nat-drain-ipsr   r	   z.    table(
      ruleNumber,
      match
    )c                 &    U R                  SSSS9  g)z?Adds an argument to identify the NAT to which the Rule belongs.z--natz&Name of the NAT that contains the RuleThelpr   N)add_argumentparsers    r   AddNatNameArgr    i   s    <t  Mr   c                     SR                  U(       a  SOSU5      nSU0nU(       a  SUS'   U R                  " S	S[        0UD6  g)
z/Adds a positional argument for the Rule number.z0Number that uniquely identifies the Rule{} to {}s r   +nargstypeN)rule_number)formatr   int)r   operation_typer   	help_textparamss        r   AddRuleNumberArgr-   o   sG    @GGc^-)I&F7O8#88r   c                 P    [         R                  " S5      nU R                  SX!S9  g)z:Adds common arguments for creating and updating NAT Rules.a  
      CEL Expression used to identify traffic to which this rule applies.

      * Supported attributes (Public NAT): destination.ip
      * Supported attributes (Private NAT): nexthop.hub
      * Supported methods (Public Nat): inIpRange
      * Supported operators (Public NAT): ||, ==
      * Supported operators (Private NAT): ==

      Examples of allowed Match expressions (Public NAT):
      * 'inIpRange(destination.ip, "203.0.113.0/24")''
      * 'destination.ip == "203.0.113.7"'
      * 'destination.ip == "203.0.113.7" || inIpRange(destination.ip, "203.0.113.16/25")'

      Example of allowed Match expression (Private NAT):
      * nexthop.hub == "//networkconnectivity.googleapis.com/projects/p1/locations/global/hubs/h1"
  z--matchr   N)textwrapdedentr   )r   r   r+   s      r   AddMatchArgr1   z   s*    oo  )" 	iyEr   c                 T    [         R                  U SS9  [        R                  U SS9  g)zGAdds arguments to specify source NAT IP Addresses when creating a rule.
IP_ADDRESScust_metavar
SUBNETWORKN)ACTIVE_IPS_ARG_OPTIONALAddArgumentACTIVE_RANGES_ARGr   s    r   AddIpAndRangeArgsForCreater:      s(    %%f<%H\Br   c                 (   [         R                  U SS9  [        R                  U SS9  U R                  SS9nUR	                  SSSS	S
9  [
        R                  XSS9  U R                  SS9nUR	                  SSSS	S
9  [        R                  XSS9  g	)zFAdds argument to specify source NAT IP Addresses when updating a rule.r6   r4   r3   Fr   z--clear-source-nat-drain-ipszClear drained IPs from the rule
store_trueN)r   actiondefault)mutex_groupr5   z--clear-source-nat-drain-rangesz"Clear drained ranges from the rule)r9   r8   r7   add_mutually_exclusive_groupr   DRAIN_IPS_ARGDRAIN_RANGES_ARG)r   drain_ip_mutexdrain_range_mutexs      r   AddIpAndRangeArgsForUpdaterE      s    \B%%f<%H666F.$,	   |  E 9959I  '/	 !  ,  r   )F)z
operate onF)__doc__
__future__r   r   r   r/   "googlecloudsdk.command_lib.computer   r   r0   r   r   ACTIVE_IPS_ARG_REQUIREDr7   _ACTIVE_RANGES_HELP_TEXTr   r9   _DRAIN_RANGES_HELP_TEXTrB   _DRAIN_IPS_HELP_TEXTrA   DEFAULT_LIST_FORMATr    r-   r1   r:   rE    r   r   <module>rO      s-   E &  '  E?? $N O 	 -d; ,e<  $?? ,   "22	%*-  #// +B C  !11	$)-    (? @ 
 ..	!&+	 M9F,Cr   