
    L=              
          S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r  SSKJr  \R                  " S	S
SSSSSS9r\R                  " S\R                   " S5      SSSSSS9r " S S\R$                  5      r " S S\R$                  5      rSrS(S jrS rS rS)S jrS rS rS rS rS  rS)S! jrS)S" jr S)S# jr!S$ r"S% r#S& r$ S*S' jr%g)+z3Flags and helpers for the compute routers commands.    )absolute_import)division)unicode_literalsN)arg_parsers)flags)	arg_utilsz--nat-external-ip-poolz*External IP Addresses to use for Cloud NATaddresszcompute.addressesTF)name
short_helpresource_nameregional_collectionregion_hiddenpluralrequiredz--nat-external-drain-ip-poolz~       External IP Addresses to be drained

       These IPs must be valid external IPs that have been used as NAT IPs
       )r
   detailed_helpr   r   r   r   r   c                        \ rS rSrSrSrSrSrg)SubnetOption3   r          N)__name__
__module____qualname____firstlineno__
ALL_RANGESPRIMARY_RANGESCUSTOM_RANGES__static_attributes__r       <lib/googlecloudsdk/command_lib/compute/routers/nats/flags.pyr   r   3   s    *.-r    r   c                       \ rS rSrSrSrSrg)SubnetIpv6Option9   r   r   r   N)r   r   r   r   ALL_IPV6_SUBNETSLIST_OF_IPV6_SUBNETSr   r   r    r!   r#   r#   9   s    r    r#   z    table(
      name,
      natIpAllocateOption,
      sourceSubnetworkIpRangesToNat,
      endpointTypes.list():label=ENDPOINT_TYPES
    )c                 ~    SR                  U(       a  SOSU5      nSU0nU(       a  SUS'   U R                  " S0 UD6  g)	z,Adds a positional argument for the NAT name.zName of the NAT{} to {}s help+nargsN)r
   )formatadd_argument)parseroperation_typer   	help_textparamss        r!   AddNatNameArgr3   G   sB    '..fs"/=?)I&F7O''r    c                 R    SnSSS.nU R                  S[        R                  UUS9  g)zAdds the --type argument.z=Type of the NAT Gateway. Defaults to PUBLIC if not specified.zbUsed for private-to-public NAT translations. Allows VM instances to communicate with the internet.zXUsed for private-to-private NAT translations. Allows communication between VPC Networks.)PUBLICPRIVATEz--type)typechoicesr*   N)r.   r   ChoiceToEnumNamer/   r1   r8   s      r!   
AddTypeArgr;   R   s?    M)."	' 	%%	  r    c                     [         R                  " S5      n/ SQnU R                  S[        R                  " US9USSS9  g)	z"Adds the --endpoint-type argument.a      Endpoint Types supported by the NAT Gateway.

    ENDPOINT_TYPE must be one of:

    ENDPOINT_TYPE_VM
      For VM Endpoints
    ENDPOINT_TYPE_SWG
      For Secure Web Gateway Endpoints
    ENDPOINT_TYPE_MANAGED_PROXY_LB
      For regional Application Load Balancers (internal and external) and regional proxy Network Load Balancers (internal and external) endpoints

  The default is ENDPOINT_TYPE_VM.
  )ENDPOINT_TYPE_VMENDPOINT_TYPE_SWGENDPOINT_TYPE_MANAGED_PROXY_LBz--endpoint-types)r8   ENDPOINT_TYPEF)r7   r*   metavarr   N)textwrapdedentr.   r   ArgListr:   s      r!   AddEndpointTypesArgrE   f   sK    oo  )'
 	w/  r    c                    [        U 5        [        U 5        [        X5        [        X5        [	        X5        [        X5        [        U 5        [        U 5        U(       d  [        U 5        [        U 5        [        X5        g)z5Adds common arguments for creating and updating NATs.N)_AddAutoNetworkTier_AddIpAllocationArgs_AddSubnetworkArgs_AddSubnetworkNat64Args_AddTimeoutsArgs_AddMinPortsPerVmArg_AddLoggingArgs!_AddEndpointIndependentMappingArg_AddDrainNatIpsArgument_AddRulesArg_AddDynamicPortAllocationArgsr/   
for_creates     r!   AddCommonNatArgsrT      s]    fvV(&-6&v*&#F+	F#v3r    c                 N    U R                  S[        R                  " S5      SS9  g )Nz--rulesa            Path to YAML file containing NAT Rules applied to the NAT.
          The YAML file format must follow the REST API schema for NAT Rules.
          See [API Discovery docs](https://www.googleapis.com/discovery/v1/apis/compute/alpha/rest)
          for reference.F)r*   r   r.   rB   rC   )r/   s    r!   rP   rP      s0     ??  
   	r    c                 Z    SSS.nU R                  S[        R                  " S5      USS9  g )NzQHigh quality, Google-grade network tier with support for all networking products.zQPublic internet quality, with only limited support for other networking products.)PREMIUMSTANDARDz--auto-network-tierzBNetwork tier to use when automatically reserving NAT IP addresses.F)r*   r8   r   rV   )r/   r8   s     r!   rG   rG      sB    !!' 	??
N   r    c                 n    U R                  SS9nUR                  SSSSS9  [        R                  XSS9  g	)
zAAdds a mutually exclusive group to specify IP allocation options.Fr   z --auto-allocate-nat-external-ipsz:Automatically allocate external IP addresses for Cloud NAT
store_true)r*   actiondefault
IP_ADDRESS)mutex_groupcust_metavarN)add_mutually_exclusive_groupr.   IP_ADDRESSES_ARGAddArgument)r/   ip_allocations     r!   rH   rH      sQ     55u5E-(G	  
 l  Dr    c           	         SnU(       a  US-  nU R                  SUS9nUR                  S[        R                  " S5      SS[        R
                  [        R                  S	9  UR                  S
[        R                  " S5      SS[        R                  [        R                  S	9  SnUR                  SSU[        R                  " SS9S9  U(       d(  UR                  S[        R                  " S5      SSSS9  gg):Adds a mutually exclusive group to specify subnet options.z#Options for IPv4 subnetwork ranges.zR If not specified, one of the options for IPv6 subnetwork ranges must be provided.F)r   r*   z--nat-all-subnet-ip-rangesz            Allow all IP ranges of all subnetworks in the region, including
            primary and secondary ranges, to use NAT.store_constsubnet_optionr*   r]   destconstr^   z--nat-primary-subnet-ip-rangesza            Allow only primary IP ranges of all subnetworks in the region to use
            NAT.a      List of subnetwork primary and secondary IP ranges to be allowed to
    use NAT.

    * `SUBNETWORK:ALL` - specifying a subnetwork name with ALL includes the
    primary range and all secondary ranges of the subnet.
    * `SUBNETWORK` - including a subnetwork name includes only the primary
    subnet range of the subnetwork.
    * `SUBNETWORK:RANGE_NAME` - specifying a subnetwork and secondary range
    name includes only that secondary range. It does not include the
    primary range of the subnet.
    z--nat-custom-subnet-ip-rangeszSUBNETWORK[:RANGE_NAME|:ALL]r   
min_lengthrA   r*   r7   z--clear-nat-subnet-ip-rangesz)            Clear IPv4 subnetwork ranges.r\   clear_nat_subnet_ip_rangesr*   r]   r^   rk   N)
rb   r.   rB   rC   r   r   r   r   r   rD   r/   rS   group_help_text
subnetworkcustom_subnet_help_texts        r!   rI   rI      s)   9/	O 22? 3 * "?? 9 : ##((  	 &??   ''((  	 %,"!,	   
&__ - .)   
r    c           	      p   SnU(       a  US-  nU R                  US9nUR                  S[        R                  " S5      SS[        R
                  [        R                  S9  S	nUR                  S
SU[        R                  " SS9S9  U(       d(  UR                  S[        R                  " S5      SSSS9  gg)rg   z#Options for IPv6 subnetwork ranges.zR If not specified, one of the options for IPv4 subnetwork ranges must be provided.)r*   z--nat64-all-v6-subnet-ip-rangeszF            Allow all IPv6 subnetwork ranges in the region to use NAT.rh   subnet_ipv6_optionrj   zG    List of subnetworks with IPv6 ranges to be allowed to use NAT.
    z"--nat64-custom-v6-subnet-ip-ranges
SUBNETWORKr   rm   ro   z--clear-nat64-subnet-ip-rangesz)            Clear IPv6 subnetwork ranges.r\   Fclear_nat64_subnet_ip_rangesrq   N)	rb   r.   rB   rC   r#   r%   r&   r   rD   rr   s        r!   rJ   rJ     s    9/	O 22 3 * '?? J K--33   *"!,	   
(__ - .+   
r    c           	          [        XS[        R                  " 5       [        R                  " S5      S5        [        XS[        R                  " 5       [        R                  " S5      S5        [        XS[        R                  " 5       [        R                  " S5      S	5        [        XS
[        R                  " 5       [        R                  " S5      S5        [        XS[        R                  " 5       [        R                  " S5      S5        g)z.Adds arguments to specify connection timeouts.zudp-idle-timeoutz         Timeout for UDP connections. See
         https://cloud.google.com/sdk/gcloud/reference/topic/datetimes for
         information on duration formats.z!Clear timeout for UDP connectionszicmp-idle-timeoutz         Timeout for ICMP connections. See
         https://cloud.google.com/sdk/gcloud/reference/topic/datetimes for
         information on duration formats.z"Clear timeout for ICMP connectionsztcp-established-idle-timeoutz         Timeout for TCP established connections. See
         https://cloud.google.com/sdk/gcloud/reference/topic/datetimes for
         information on duration formats.z-Clear timeout for TCP established connectionsztcp-transitory-idle-timeoutz         Timeout for TCP transitory connections. See
         https://cloud.google.com/sdk/gcloud/reference/topic/datetimes for
         information on duration formats.z,Clear timeout for TCP transitory connectionsztcp-time-wait-timeoutz         Timeout for TCP connections in the TIME_WAIT state. See
         https://cloud.google.com/sdk/gcloud/reference/topic/datetimes for
         information on duration formats.z8Clear timeout for TCP connections in the TIME_WAIT stateN)_AddClearableArgumentr   DurationrB   rC   rR   s     r!   rK   rK   *  s    ,k.B.B.Doo - . *+ -{/C/C/Eoo - . +, 8oo - . 67 79M9M9Ooo - . 56 1;3G3G3Ioo - . ABr    c           	      r    [         R                  " S5      n[        XS[        R                  " SS9US5        g)zGAdds an argument to specify the minimum number of ports per VM for NAT.z  Minimum ports to be allocated to a VM.

  If Dynamic Port Allocation is disabled, this defaults to 64.

  If Dynamic Port Allocation is enabled, this defaults to 32 and must be set
  to a power of 2 that is at least 32 and lower than maxPortsPerVm.
  zmin-ports-per-vmr   )lower_boundz+Clear minimum ports to be allocated to a VMN)rB   rC   r{   r   
BoundedInt)r/   rS   r1   s      r!   rL   rL   R  s8    oo  ) ,>#..1=yEGr    c           
          [         R                  " S5      n[        U US[        R                  " SSS9US5        [         R                  " S5      nU R                  S[        R                  US	9  g
)zaAdds arguments for Dynamic Port Allocation to specify the maximum number of ports per VM for NAT.z  Maximum ports to be allocated to a VM.

  This field can only be set when Dynamic Port Allocation is enabled and
  defaults to 65536. It must be set to a power of 2 that is greater than
  minPortsPerVm and at most 65536.
  zmax-ports-per-vm@   i   )r~   upper_boundz+Clear maximum ports to be allocated to a VMzi  Enable dynamic port allocation.

  If not specified, Dynamic Port Allocation is disabled by default.
  z --enable-dynamic-port-allocation)r]   r*   N)rB   rC   r{   r   r   r.   StoreTrueFalseAction)r/   rS   max_ports_help_textdpa_help_texts       r!   rQ   rQ   a  sz     ! )  ?3 // # -
 	(--  r    c                     [         R                  " S5      n[         R                  " S5      nSSSS.nU R                  SSS	US
9  U R                  SX#S9  g	)z(Adds arguments to configure NAT logging.z    Enable logging for the NAT. Logs will be exported to Stackdriver. NAT
    logging is disabled by default.
    To disable logging for the NAT, use
    $ {parent_command} update MY-NAT --no-enable-logging --router ROUTER
      --region REGIONz    Filter for logs exported to stackdriver.

    The default is ALL.

    If logging is not enabled, filter settings will be persisted but will have
    no effect.

    Use --[no-]enable-logging to enable and disable logging.
z4Export logs for all connections handled by this NAT.z)Export logs for connection failures only.z,Export logs for successful connections only.)ALLERRORS_ONLYTRANSLATIONS_ONLYz--enable-loggingr\   Nr]   r^   r*   z--log-filter)r*   r8   rB   rC   r.   )r/   enable_logging_help_textlog_filter_help_textfilter_choicess       r!   rM   rM   ~  s|    %__ .  " 	* 	 D@I.
 	#	  %
 	/  Ir    c                 l    U R                  SS9n[        R                  XS9  UR                  SSSSS9  g )NFr[   )r`   z"--clear-nat-external-drain-ip-poolr\   zClear the drained NAT IPsr   )rb   DRAIN_NAT_IP_ADDRESSES_ARGrd   r.   )r/   drain_ips_groups     r!   rO   rO     sE    777G/(((M*&	  (r    c                 T    [         R                  " S5      nU R                  SSS US9  g )Nz  Enable endpoint-independent mapping for the NAT (as defined in RFC 5128).

  If not specified, NATs have endpoint-independent mapping disabled by default.

  Use `--no-enable-endpoint-independent-mapping` to disable endpoint-independent
  mapping.
  z%--enable-endpoint-independent-mappingr\   r   r   )r/   r1   s     r!   rN   rN     s6    oo  ) 	-	  r    c                     U(       a!  U R                  SR                  U5      X4US9  gU R                  SS9nUR                  SR                  U5      X4US9  UR                  SR                  U5      SSUS9  g)	z>Adds an argument for a field that can be cleared in an update.z--{})r7   r*   r8   Fr[   z
--clear-{}r\   r   N)r.   r-   rb   )r/   rS   arg_namearg_typearg_help
clear_helpr8   mutexs           r!   r{   r{     s     
hhw  P ///?E	hhw  P	H%	  r    )z
operate onF)F)N)&__doc__
__future__r   r   r   enumrB   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer   compute_flags$googlecloudsdk.command_lib.util.apisr   ResourceArgumentrc   rC   r   Enumr   r#   DEFAULT_LIST_FORMATr3   r;   rE   rT   rP   rG   rH   rI   rJ   rK   rL   rQ   rM   rO   rN   r{   r   r    r!   <module>r      s   : &  '   / E : 11	!;+  +;;	'// # 
 + 499 tyy 
	 ((<4$
&D 9x%P%BPG:I@(, #'r    