
    ~F                     *   S 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  SS
KJr  SSKJr  SrSrSr " S S\R0                  5      rS"S jrS#S jrS$S jrS$S jrS%S jrS rS r S r!S r"S r#S r$S r%S r&S r'S r(S  r)g!)&z7Flags and helpers for the compute subnetworks commands.    )absolute_import)division)unicode_literals)utils)apis)arg_parsers)
completers)flags)scope)	arg_utilszm    table(
      name,
      region.basename(),
      network.basename(),
      ipCidrRange:label=RANGE
    )z    table(
      name,
      region.basename(),
      network.basename(),
      ipCidrRange:label=RANGE,
      stackType,
      ipv6AccessType,
      internalIpv6Prefix,
      externalIpv6Prefix
    )z    table(
      name,
      region.basename(),
      network.basename(),
      ipCidrRange:label=RANGE,
      stackType,
      ipv6AccessType,
      internalIpv6Prefix,
      externalIpv6Prefix,
      utilizationDetails
    )c                   (   ^  \ rS rSrU 4S jrSrU =r$ )SubnetworksCompleter?   c                 6   > [         [        U ]
  " SSSSS.UD6  g )Ncompute.subnetworksz(beta compute networks subnets list --uribeta)
collectionlist_commandapi_version )superr   __init__)selfkwargs	__class__s     @lib/googlecloudsdk/command_lib/compute/networks/subnets/flags.pyr   SubnetworksCompleter.__init__A   s+    	
. (? 	    r   )__name__
__module____qualname____firstlineno__r   __static_attributes____classcell__)r   s   @r   r   r   ?   s     r   r   c           	      X    [         R                  " S[        UU S[         R                  S9$ )N
subnetworkr   )resource_name	completerpluralrequiredregional_collectionregion_explanation)compute_flagsResourceArgumentr   REGION_PROPERTY_EXPLANATION)r*   r)   s     r   SubnetworkArgumentr0   I   s/    		'	' $/&BB
D Dr   c                 ^    [         R                  " SS[        SU SSR                  U5      SS9$ )Nr&   z--subnetworkFr   z*The subnetwork of the interface being {0}.z<If not specified it will be set to the region of the router.r'   namer(   r)   r*   r+   
short_helpr,   )r-   r.   r   format)r*   operation_types     r   SubnetworkArgumentForRouterr7   S   s@    		'	' $/=DD
 I

K 
Kr   c                 @    [         R                  " SS[        SU SSSS9$ )Nr&   z--nat-subnetsTr   z;The subnetworks provided by service producer to use for NATzIIf not specified, it will be set to the region of the service attachment.r2   r-   r.   r   r*   s    r   &SubnetworkArgumentForServiceAttachmentr;   a   s/    		'	' $/N

 
r   c           
      >    [         R                  " SS[        SU SSS9$ )Nr&   z	--subnetsTr   z:The subnetworks provided by the consumer for the producers)r'   r3   r(   r)   r*   r+   r4   r9   r:   s    r   &SubnetworkArgumentForNetworkAttachmentr=   o   s,    		'	' $/M
O Or   c           
      6    [         R                  " SSU SSSSS9$ )NipCollectionz--ip-collectionzcompute.publicDelegatedPrefixesTz0Resource reference to a public delegated prefix.z
          Resource reference to a public delegated prefix. The
          PublicDelegatedPrefix must be a sub-prefix in
          EXTERNAL_IPV6_SUBNETWORK_CREATION or INTERNAL_IPV6_SUBNETWORK_CREATION
          mode.
          )r'   r3   r*   r+   region_hiddenr4   detailed_help)r-   r.   r:   s    r   IpCollectionArgumentrB   z   s,    		'	'";C
 r   c                  v    [         R                  R                  S[        R                  R
                  S05      $ )Nr&   r   )r-   ResourceResolverFromMapcompute_scope	ScopeEnumREGIONr   r   r   SubnetworkResolverrI      s2    		'	'	/	/],,335JK
 r   c                    [         R                  " S[        R                  5      nU R	                  5       nUR                  S[        R                  SS9  UR                  S[        R                  " SS9SS	S
S9  U R                  S[        R                  " SS9SSSS9  U R                  SSS9  U R                  SSS9  UR                  S[        R                  " SS9SS	SS9  UR                  S[        R                  SS9  U(       a  UR                  S[        R                  SS9  [        X5        U R                  S[        R                  " SSS9SS9  [        X5        U R                  S S!S9  U R                  S"[        R                  " 5       S#S$S%S&9  U(       a_  [         R                  " S[        R                  5      n[        X5        U R                  S'[        R                  " SSS9S(S9  [        X5        UR                  S)S*S+0S, S-S.9  U R                  S/[        R                   " S0S19S0S2S39  S4S50nS6nU(       a  S7US8'   S9US4'   S:nUR                  S;US< US.9  U R                  S=S>S?S@.["        R$                  SAS.9  SBSCSD.n	U R                  SEU	["        R$                  SFS.9  [         R                  " SU5      n['        U5      R(                  R+                  U5        g$)GaD  Add args to the parser for subnet update.

Args:
  parser: The argparse parser.
  include_alpha_logging: Include alpha-specific logging args.
  include_allow_cidr_routes_overlap: Include CIDR routes overlap args.
  api_version: The api version of the request.
  update_purpose_to_private: Allow updating purpose to private.
computez!--enable-private-ip-google-accesszfEnable/disable access to Google Cloud APIs from this subnet for instances without a public ip address.)actionhelpz--add-secondary-ranges   )
min_lengthappendzPROPERTY=VALUEa4        Adds secondary IP ranges to the subnetwork for use in IP aliasing.

      For example, `--add-secondary-ranges range1=192.168.64.0/24` adds
      a secondary range 192.168.64.0/24 with name range1.

      * `RANGE_NAME` - Name of the secondary range.
      * `RANGE` - `IP range in CIDR format.`
      )typerL   metavarrM   z3--add-secondary-ranges-with-reserved-internal-rangezRANGE_NAME=INTERNAL_RANGE_URLa         Adds secondary IP ranges that are associated with internal range
       resources.

       For example, `--add-secondary-ranges-with-reserved-internal-range
       range1=//networkconnectivity.googleapis.com/projects/PROJECT/locations/global/internalRanges/RANGE`
       adds a secondary range with the reserved internal range resource.

       * `RANGE_NAME` - Name of the secondary range.
       * `INTERNAL_RANGE_URL` - `URL of an internal range resource.`
       z--external-ipv6-prefixa  
      The /64 external IPv6 CIDR range to assign to this subnet. The range must
      be associated with an IPv6 BYOIP sub-prefix that is defined by the
      --ip-collection flag. If you specify --ip-collection but not
      --external-ipv6-prefix, a random /64 range is allocated from
      the sub-prefix.

      For example, `--external-ipv6-prefix=2600:1901:0:0:0:0:0:0/64`
      )rM   z--internal-ipv6-prefixa  
      The /64 internal IPv6 CIDR range to assign to this subnet. The range must
      be associated with an IPv6 BYOIP sub-prefix that is defined by the
      --ip-collection flag. If you specify --ip-collection but not
      --internal-ipv6-prefix, a random /64 range is allocated from the
      sub-prefix.

      For example, `--internal-ipv6-prefix 2600:1901:0:0:0:0:0:0/64`
      z--remove-secondary-rangesz      Removes secondary ranges from the subnetwork.

      For example, `--remove-secondary-ranges range2,range3` removes the
      secondary ranges with names range2 and range3.
      z--enable-flow-logszEnable/disable VPC Flow Logs for this subnet. If the subnet does  not support VPC Flow Logs, this flag has no effect. For  more information, see https://cloud.google.com/vpc/docs/using-flow-logs.z--allow-cidr-routes-overlapz[Allow/disallow this subnetwork's IP address ranges to conflict with existing static routes.z--logging-flow-samplingg        g      ?)lower_boundupper_boundaj        Can only be specified if VPC Flow logs for this subnetwork is
      enabled. The value of the field must be in [0, 1]. Set the sampling rate
      of VPC flow logs within the subnetwork where 1.0 means all collected
      logs are reported and 0.0 means no logs are reported. Default is 0.5
      which means half of all collected logs are reported.
      )rQ   rM   z--logging-filter-exprz      Can only be specified if VPC Flow Logs for this subnetwork is enabled.
      Export filter used to define which logs should be generated.
      z--logging-metadata-fieldsMETADATA_FIELDNz      Can only be specified if VPC Flow Logs for this subnetwork is enabled
      and "metadata" is set to CUSTOM_METADATA. The comma-separated list of
      metadata fields that should be added to reported logs.
      )rQ   rR   defaultrM   z--flow-samplingav          Can only be specified if VPC Flow Logs for this subnetwork is enabled.
        The value of the field must be in [0, 1]. Set the sampling rate of
        VPC Flow Logs within the subnetwork where 1.0 means all collected
        logs are reported and 0.0 means no logs are reported. Default is 0.5
        which means half of all collected logs are reported.
        z--roleACTIVEz)The ACTIVE subnet that is currently used.c                 B    U R                  SS5      R                  5       $ N-_replaceupperxs    r   <lambda>AddUpdateArgs.<locals>.<lambda>5      QYYsC(..0r   aZ  The role is set to ACTIVE to update a BACKUP reserved address range to
be the new ACTIVE address range. Note that the only supported value for
this flag is ACTIVE since setting an address range to BACKUP is not
supported. 

This field is only valid when updating a reserved IP address range used
for the purpose of Internal HTTP(S) Load Balancer.)choicesrQ   rM   z--drain-timeout0s)rS   a          The time period for draining traffic from Internal HTTP(S) Load Balancer
        proxies that are assigned addresses in the current ACTIVE subnetwork.
        For example, ``1h'', ``60m'' and ``3600s'' each specify a duration of
        1 hour for draining the traffic. Longer times reduce the number of
        proxies that are draining traffic at any one time, and so improve
        the availability of proxies for load balancing. The drain timeout is
        only applicable when the [--role=ACTIVE] flag is being used.
        )rQ   rV   rM   REGIONAL_MANAGED_PROXYz;The proxy-only subnet for regional HTTP(S) load balancers. zxThe purpose of the subnetwork is set to REGIONAL_MANAGED_PROXY to migrate from the INTERNAL_HTTPS_LOAD_BALANCER purpose.zOThe default subnet type. Only PEER_MIGRATION subnets can be changed to PRIVATE.PRIVATEzThe proxy-only subnet for regional HTTP(S) load balancers. Only INTERNAL_HTTPS_LOAD_BALANCER subnets can be changed to REGIONAL_MANAGED_PROXY.z@The purpose of the subnetwork can be changed in a few scenarios.z	--purposec                 B    U R                  SS5      R                  5       $ rY   r\   r_   s    r   ra   rb   c  rc   r   z--stack-typez;New VMs in this subnet will only be assigned IPv4 addressesz<New VMs in this subnet can have both IPv4 and IPv6 addresses)	IPV4_ONLY	IPV4_IPV6zLThe stack type for this subnet. Determines if IPv6 is enabled on the subnet.z*VMs in this subnet can have external IPv6.z*VMs in this subnet can have internal IPv6.)EXTERNALINTERNALz--ipv6-access-typezIPv6 access type can be specified only when the subnet is created, or when the subnet is first updated to have a stack type of IPV4_IPV6. Once set, the access type is immutable.)r   GetMessagesModulecompute_apiCOMPUTE_GA_API_VERSIONadd_mutually_exclusive_groupadd_argumentr   StoreTrueFalseActionArgDictArgListAddLoggingAggregationIntervalBoundedFloatAddLoggingMetadataCOMPUTE_ALPHA_API_VERSION'AddLoggingAggregationIntervalDeprecatedAddLoggingMetadataDeprecatedDurationr   ChoiceToEnumName(GetPrivateIpv6GoogleAccessTypeFlagMapper
choice_argAddToParser)
parserinclude_alpha_logging!include_allow_cidr_routes_overlapr   update_purpose_to_privatemessagesupdated_fieldrd   	help_textipv6_access_type_choicess
             r   AddUpdateArgsr      s     ##I$/$F$FH( 557-)--5  7 !,
   	;!,-
  $ 	
  
 	
   !!,
  
 --A  C '%//+	    1##E
  	 V&
   	! 
  	 %%i&1&K&KMH+F=
%%#3G  	 !2DE0	  
 	D1	   
G'
@  	 I
	" $% 	K  0	   	 LL	 %%  
 ?> 	&%%I	  K ##I{;(*84??KKr   c                 `    [         R                  " SU R                  R                  SSSS.SS9$ )Nz!--private-ipv6-google-access-typedisablezenable-bidirectional-accesszenable-outbound-vm-access)DISABLE_GOOGLE_ACCESS%ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE#ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLEz?The private IPv6 google access type for the VMs in this subnet.custom_mappingshelp_str)r   ChoiceEnumMapper
Subnetwork&PrivateIpv6GoogleAccessValueValuesEnumr   s    r   r}   r}     s=    		#	#)@@ +) Q
 r   c                 f    [         R                  " SU R                  R                  SSSSSSS.S	S
9$ )Nz--logging-aggregation-intervalinterval-5-secinterval-30-secinterval-1-mininterval-5-mininterval-10-mininterval-15-minINTERVAL_5_SECINTERVAL_30_SECINTERVAL_1_MININTERVAL_5_MININTERVAL_10_MININTERVAL_15_MINO          Can only be specified if VPC Flow Logs for this subnetwork is
        enabled. Toggles the aggregation interval for collecting flow logs.
        Increasing the interval time will reduce the amount of generated flow
        logs for long lasting connections. Default is an interval of 5 seconds
        per connection.
        r   r   r   SubnetworkLogConfig"AggregationIntervalValueValuesEnumr   s    r    GetLoggingAggregationIntervalArgr     sC    		#	#&""EE,.,,..
 r   c                 L    [        U5      R                  R                  U 5        g N)r   r~   r   r   r   s     r   ru   ru     s    "8,77CCFKr   c                 f    [         R                  " SU R                  R                  SSSSSSS.S	S
9$ )Nz--aggregation-intervalr   r   r   r   r   r   r   r   r   r   r   s    r   *GetLoggingAggregationIntervalArgDeprecatedr     sC    		#	#""EE,.,,..
 r   c                 L    [        U5      R                  R                  U 5        g r   )r   r~   r   r   s     r   ry   ry     s    ,X6AAMMr   c                 `    [         R                  " SU R                  R                  SSSS.SS9$ )Nz--logging-metadatazinclude-allzexclude-allcustom)INCLUDE_ALL_METADATAEXCLUDE_ALL_METADATACUSTOM_METADATA        Can only be specified if VPC Flow Logs for this subnetwork is
        enabled. Configures whether metadata fields should be added to the
        reported logs. Default is to exclude all metadata.
        r   r   r   r   MetadataValueValuesEnumr   s    r   GetLoggingMetadataArgr     s:    		#	#""::"/"/%

 r   c                 L    [        U5      R                  R                  U 5        g r   )r   r~   r   r   s     r   rw   rw     s    !,,88@r   c                 ^    [         R                  " SU R                  R                  SSS.SS9$ )Nz
--metadatazinclude-all-metadatazexclude-all-metadata)r   r   r   r   r   r   s    r   GetLoggingMetadataArgDeprecatedr     s7    		#	#""::"8"8
 r   c                 L    [        U5      R                  R                  U 5        g r   )r   r~   r   r   s     r   rz   rz     s    !(+66BB6Jr   N)TF)Fadded)T)F)*__doc__
__future__r   r   r   googlecloudsdk.api_lib.computer   rn   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   compute_completersr
   r-   r   rF   $googlecloudsdk.command_lib.util.apisr   DEFAULT_LIST_FORMAT#DEFAULT_LIST_FORMAT_WITH_IPV6_FIELD*DEFAULT_LIST_FORMAT_WITH_UTILIZATION_FIELDListCommandCompleterr   r0   r7   r;   r=   rB   rI   r   r}   r   ru   r   ry   r   rw   r   rz   r   r   r   <module>r      s    > &  ' ? , / O E E :	 
'	 #.	 *-BB DKO"od *L*
 AKr   