
    L                     J   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SKJr  SSKJr  / SQr/ SQr/ SQrS rS rS rS rS r S r!S r"S 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/S$ r0S% r1S& r2S' r3S( r4g))+z;Utilities for flags for `gcloud colab-enterprise` commands.    )runtime_templates)runtimes)arg_parsers)base)concepts)deps)
completers)flags)iam_util)concept_parsers)
properties)NVIDIA_TESLA_V100NVIDIA_TESLA_T4NVIDIA_TESLA_A100NVIDIA_A100_80GB	NVIDIA_L4)PD_STANDARDPD_SSDPD_BALANCED
PD_EXTREME)(POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIEDRUN_ONCERUN_EVERY_STARTDOWNLOAD_AND_RUN_EVERY_STARTc                      [         R                  " SS[        R                  " [        R
                  R                  R                  5      /S9$ )zeGet the attribute config for the region resource.

Returns:
  The resource attribute for the region.
regionz Cloud region for the {resource}.)name	help_textfallthroughs)r    ResourceParameterAttributeConfigr   PropertyFallthroughr   VALUEScolabr        8lib/googlecloudsdk/command_lib/colab_enterprise/flags.pyGetRegionAttributeConfigr'   .   s@     
	2	22,,Z->->-D-D-K-KLM
 r%   c           
          SS jnU(       a	  SnSnSnSnOSnSnSS0nSS	/0n[         R                  R                  UU" 5       S
R                  U5      SUUUS9R	                  U 5        g)zAdd a resource argument for a runtime template to the parser.

Args:
  parser: argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
  is_positional: bool, True for if arg is positional; False if flag.
c                 ^    [         R                  " SU [         R                  [        5       SS9$ )Nz6aiplatform.projects.locations.notebookRuntimeTemplatesTresource_name
projectsIdlocationsIddisable_auto_completersr   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIGr'   r+   s    r&   GetRuntimeTemplateResourceSpecEAddRuntimeTemplateResourceArg.<locals>.GetRuntimeTemplateResourceSpecD   s-      @#<<,. $ r%   runtime_templateFNz--runtime-templateTr    --regionzUnique name of the runtime template {}. This was optionally provided by setting --runtime-template-id in the create runtime-template command, or was system-generated if unspecified.)requiredprefixesflag_name_overridescommand_level_fallthroughs)zruntime templater   ConceptParserForResourceformatAddToParser)parserverbis_positionalr3   arg_namer9   r:   r   s           r&   AddRuntimeTemplateResourceArgrE   ;   s     !HHL#HH#R.zl+L++$&117-!- , 
 Kr%   c                     SS jn[         R                  R                  SU" 5       SR                  U5      SS9R	                  U 5        g)zAdd a resource argument for a runtime template to the parser.

Args:
  parser: argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
runtimec                 ^    [         R                  " SU [         R                  [        5       SS9$ )Nz.aiplatform.projects.locations.notebookRuntimesTr*   r/   r2   s    r&   GetRuntimeResourceSpec5AddRuntimeResourceArg.<locals>.GetRuntimeResourceSpecl   s-      8#<<,. $ r%   zUnique name of the runtime {}. This was optionally provided by setting --runtime-id in the create runtime command, or was system-generated if unspecified.Tr8   N)rG   r<   )rA   rB   rI   s      r&   AddRuntimeResourceArgrL   d   sH     ++fTl ,  Kr%   c                     [         R                  " SS[        5       [         R                  SS9n[        R
                  R                  SUSR                  U5      SS9R                  U 5        g)	zAdd a resource argument for a Vertex AI region to the parser.

Args:
  parser: argparse parser for the command.
  verb: str, the verb to describe the resource, such as 'to update'.
zaiplatform.projects.locationsr   T)r+   r-   r,   r.   r7   zkCloud region {}. Please see  https://cloud.google.com/colab/docs/locations for a list of supported regions.rK   N)	r   r0   r'   r1   r   r=   r>   r?   r@   )rA   rB   region_resource_specs      r&   AddRegionResourceArgrO      sk     "..%*,::" ++&, ,  Kr%   c                 |   ^  U 4S jn[         R                  R                  SU" 5       T 5      R                  U5        g)zAdds Resource arg for network to the parser.

Args:
  help_text: str, the help text for the flag.
  parser: argparse parser for the command.
c                  f   > U4S jn [         R                  " SSU " 5       [         R                  SS9$ )z>Constructs and returns the Resource specification for network.c                  L   > [         R                  " ST [        R                  S9$ )Nnetworkr   r   	completer)r   r    compute_network_flagsNetworksCompleterr   s   r&   NetworkAttributeConfigUAddNetworkResourceArg.<locals>.GetNetworkResourceSpec.<locals>.NetworkAttributeConfig   s%    66);; r%   zcompute.networksrS   F)r+   rS   projectr.   r   r0   r1   )rY   r   s    r&   GetNetworkResourceSpec5AddNetworkResourceArg.<locals>.GetNetworkResourceSpec   s5       &(99 % r%   z	--networkNr   r=   r>   r@   )r   rA   r]   s   `  r&   AddNetworkResourceArgr`      s3    $ ++)+YKr%   c                 |   ^  U 4S jn[         R                  R                  SU" 5       T 5      R                  U5        g)zAdds Resource arg for subnetwork to the parser.

Args:
  help_text: str, the help text for the flag.
  parser: argparse parser for the command.
c                  v   > U4S jn S n[         R                  " SSU " 5       U" 5       [         R                  S9$ )z=Constructs and returns the Resource specification for Subnet.c                  L   > [         R                  " ST [        R                  S9$ )N
subnetworkrT   )r   r    compute_subnet_flagsSubnetworksCompleterrX   s   r&   SubnetAttributeConfigVAddSubnetworkResourceArg.<locals>.GetSubnetResourceSpec.<locals>.SubnetAttributeConfig   s%    66(== r%   c                  J    [         R                  " SS[        R                  S9$ )Nzsubnetwork-regionzfGoogle Cloud region of this subnetwork https://cloud.google.com/compute/docs/regions-zones/#locations.rT   )r   r    r	   RegionCompleterr$   r%   r&   RegionAttributeConfigVAddSubnetworkResourceArg.<locals>.GetSubnetResourceSpec.<locals>.RegionAttributeConfig   s)    66"P .. r%   zcompute.subnetworksrd   )r+   rd   r   r[   r\   )rg   rk   r   s     r&   GetSubnetResourceSpec7AddSubnetworkResourceArg.<locals>.GetSubnetResourceSpec   s=       "(*$&99 r%   z--subnetworkNr_   )r   rA   rm   s   `  r&   AddSubnetworkResourceArgro      s3    8 +++-yKr%   c                 r    S n[         R                  R                  SU" 5       USS9R                  U 5        g)zAdds Resource arg for KMS key to the parser.

Args:
  parser: argparse parser for the command.
  help_text: str, the help text for the flag.
c            	      t    S n S nS nS n[         R                  " SSU " 5       U" 5       U" 5       U" 5       S9$ )Nc                  *    [         R                  " SS9$ )Nzkms-key)r   r   r    r$   r%   r&   KmsKeyAttributeConfigRAddKmsKeyResourceArg.<locals>.GetKmsKeyResourceSpec.<locals>.KmsKeyAttributeConfig   s    66IFFr%   c                  ,    [         R                  " SSS9$ )Nzkms-keyringz!KMS keyring id of the {resource}.r   r   rs   r$   r%   r&   KmsKeyringAttributeConfigVAddKmsKeyResourceArg.<locals>.GetKmsKeyResourceSpec.<locals>.KmsKeyringAttributeConfig   s    66(K r%   c                  ,    [         R                  " SSS9$ )Nzkms-locationz"Cloud location for the {resource}.rw   rs   r$   r%   r&   KmsLocationAttributeConfigWAddKmsKeyResourceArg.<locals>.GetKmsKeyResourceSpec.<locals>.KmsLocationAttributeConfig   s    66)M r%   c                  ,    [         R                  " SSS9$ )Nzkms-projectz$Cloud project id for the {resource}.rw   rs   r$   r%   r&   KmsProjectAttributeConfigVAddKmsKeyResourceArg.<locals>.GetKmsKeyResourceSpec.<locals>.KmsProjectAttributeConfig   s    66(N r%   z/cloudkms.projects.locations.keyRings.cryptoKeyskey)r+   cryptoKeysId
keyRingsIdr-   r,   )r   r0   )rt   rx   r{   r~   s       r&   GetKmsKeyResourceSpec3AddKmsKeyResourceArg.<locals>.GetKmsKeyResourceSpec   sJ    G


   9*,,..0,. r%   z	--kms-keyFrK   Nr_   )rA   r   r   s      r&   AddKmsKeyResourceArgr      s=    < ++	 , 
 Kr%   c                 B    [         R                  R                  U 5        g)z+Adds the --async flags to the given parser.N)r   
ASYNC_FLAGr@   rA   s    r&   AddAsyncFlagr     s    //f%r%   c           	         U(       a  SOSnU R                  SU S3S9nUR                  SSSU S3S	S
9  UR                  SSU S3[        SS9  UR                  S[        SS9  U R                  SU S3S9nUR                  SS[        SS9  UR                  SSU S3[        SS9  U R                  SU S3S9n[        SU S3US9  [        S U S3US9  UR                  S!S"S#S$S%U S3S&9  g)'zConstruct args to provide a custom compute spec for notebook execution.

Args:
  parser: argparse parser for the command.
  workbench_execution: bool, true if these flags are for creating a Workbench
    execution.
zexecution environmentrG   z!The machine configuration of the .helpz--machine-typeFz1The Compute Engine machine type selected for the ze2-standard-4)r8   r   defaultz--accelerator-typez-The type of hardware accelerator used by the z;. If specified, --accelerator-count must also be specified.N)r   choicesr   z--accelerator-countz/The number of accelerators used by the runtime.)typer   z+The configuration for the data disk of the z--disk-typez The type of the persistent disk.r   z--disk-size-gbzThe disk size of the zr in GB. If specified, the --disk-type must also be specified. The minimum size is 10GB and the maximum is 65536GB.d   r   r   r   z"The network configuration for the zThe name of the VPC that this z is in.)r   rA   z%The name of the subnetwork that this z--enable-internet-access
store_trueenable_internet_accessTz&Enable public internet access for the )actiondestr   r   )	add_groupadd_argument_accelerator_choicesint_disk_choicesr`   ro   )rA   workbench_executionvm_namemachine_spec_groupdisk_spec_groupnetwork_spec_groups         r&   AddCustomEnvSpecFlagsr     s    "5) 
 ''.wiq9 (  !!>wiqI	 "  !!:7) D@ @" "  !!< " 
 $$7y
B % /
 -	   "7) ,     ''/y: (  0	A 1''
B	 !! #3G9A> " r%   c                     U R                  SSS9nUR                  SSSS9  UR                  SSS	S9  UR                  S
SS[        S9  UR                  SSS[        R                  " 5       SS9  g)z5Adds Resource arg for runtime template to the parser.Tz3The software configuration of the runtime template.)hiddenr   z--post-startup-scriptFz<Post startup script in raw string to execute on the runtime.r8   r   z--post-startup-script-urlzPost startup script URL to execute on the runtime. This can be a public or private Google Cloud Storage object. In the form of gs://bucket/object or https://storage.googleapis.com/bucket/object.z--post-startup-script-behaviorzfThe behavior of the post startup script. The default if passing a post-startup-script-url is RUN_ONCE.)r8   r   r   z--set-env-varsz.Set environment variables used by the runtime.	KEY=VALUE)r8   r   r   metavarN)r   r   %_post_startup_script_behavior_choicesr   ArgDict)rA   software_config_groups     r&   %AddRuntimeTemplateSoftwareConfigFlagsr   f  s     !**@ +  $$I % 
 $$!;	 % 	 $$&2 4 %  $$;  % r%   c                 $   [        U S5        U R                  SSSS9  U R                  SSSS9  U R                  S	S
9nUR                  SSSS9  [        U5        [	        U5        UR                  SS[
        R                  " 5       SS9  UR                  SS[
        R                  " 5       SS9  UR                  SSSSSS9  UR                  SSSSSS9  UR                  S[
        R                  " 5       SSS 9  [        US!5        [        U 5        g")#zEConstruct groups and arguments specific to runtime template creation.zto create runtime templatez--runtime-template-idFzPThe id of the runtime template. If not specified, a random id will be generated.r   --display-nameTz)The display name of the runtime template.z%Configuration of the runtime templater   --descriptionz(The description of the runtime template.--labels6Add labels to identify and group the runtime template.r   r   r   r   z--idle-shutdown-timeoutzThe duration after which the runtime is automatically shut down. An input of 0s disables the idle shutdown feature, and a valid range is [10m, 24h]. See '$ gcloud topic datetimes' for details on formatting the input duration.3hr   z--enable-eucr   
enable_eucz2Enable end user credential access for the runtime.)r   r   r   r   z--enable-secure-bootenable_secure_bootz9Enables secure boot for the runtime. Disabled by default.z--network-tagsTAGSz5Applies the given Compute Engine tags to the runtime.)r   r   r   zThe Cloud KMS encryption key (customer-managed encryption key) used to protect the runtime. The key must be in the same region as the runtime. If not specified, Google-managed encryption keys will be used.N)rO   r   r   r   r   r   r   DurationArgListr   r   )rA   runtime_template_groups     r&   AddCreateRuntimeTemplateFlagsr     s}    v;<   	6  
 "++2 ,  %%5 & 
 ./'(>?%%C 	 &  %%,
 ! & 
 %%? &  %%F &  %% B	 &  H vr%   c                 0    [        U SSS9  [        U 5        g)zEConstruct groups and arguments specific to runtime template deletion.	to deleteTrC   N)rE   r   r   s    r&   AddDeleteRuntimeTemplateFlagsr     s    4Hvr%   c                     [        U SSS9  g)zIConstruct groups and arguments specific to describing a runtime template.to describeTr   NrE   r   s    r&   AddDescribeRuntimeTemplateFlagsr     s    TJr%   c                 n    [        U S5        U R                  R                  [        R                  5        g)zEConstruct groups and arguments specific to listing runtime templates.z'for which to list all runtime templatesN)rO   display_info
AddUriFuncruntime_templates_utilGetRuntimeTemplateUrir   s    r&   AddListRuntimeTemplatesFlagsr     s(    vHI  !7!M!MNr%   c                 F    [        U SSS9  [        R                  " U 5        g)zKConstruct arguments for adding an IAM policy binding to a runtime template.zto add IAM policy binding toTr   N)rE   r   AddArgsForAddIamPolicyBindingr   s    r&   AddFlagsToAddIamPolicyBindingr     s"    ,D ((0r%   c                     [        U SSS9  g)zFConstruct arguments for getting the IAM policy for a runtime template.zto get IAM policy forTr   Nr   r   s    r&   AddGetIamPolicyFlagsr     s    %Tr%   c                 F    [        U SSS9  [        R                  " U 5        g)zFConstruct arguments for setting the IAM policy for a runtime template.zto set IAM policy forTr   N)rE   r   AddArgForPolicyFiler   s    r&   AddSetIamPolicyBindingFlagsr     s"    %T v&r%   c                 F    [        U SSS9  [        R                  " U 5        g)zOConstruct arguments for removing an IAM policy binding from a runtime template.zto remove IAM policy fromTr   N)rE   r    AddArgsForRemoveIamPolicyBindingr   s    r&   AddRemoveIamPolicyBindingFlagsr     s"    ) ++F3r%   c                    [        U SS9  [        U SSS9  U R                  SSSS9  U R                  S	S
SS9  U R                  SSSS9  U R                  SSSS9  U R                  SS[        R                  " 5       SS9  [        U 5        g)z+Construct arguments for creating a runtime.zto create runtimerB   zto configure the runtime withFr   z--runtime-idzQThe id of the runtime to create. If not specified, a random id will be generated.r   r   Tz*The display name of the runtime to create.r   zThe descriptionz--runtime-userzUser email for the runtime owner. Runtimes can only be used by the owner. If a user is not provided, the gcloud user will be assumed to be the owner. The user cannot be a service account.r   r   r   r   N)rO   rE   r   r   r   r   r   s    r&   AddCreateRuntimeFlagsr     s     v$78-U 		   	7  
 	o<MND	   	C 	   vr%   c                     [        U SS9  g)z5Construct arguments specific to describing a runtime.r   r   N)rL   r   s    r&   AddDescribeRuntimeFlagsr   .  s    ]3r%   c                 j    [        U SS9  U R                  R                  [        R                  5        g)z1Construct arguments specific to listing runtimes.zfor which to list all runtimesr   N)rO   r   r   runtimes_utilGetRuntimeUrir   s    r&   AddListRuntimeFlagsr   3  s'    v$DE  !<!<=r%   c                 .    [        U SS9  [        U 5        g)z3Construct arguments specific to deleting a runtime.r   r   NrL   r   r   s    r&   AddDeleteRuntimeFlagsr   9  s    [1vr%   c                 .    [        U SS9  [        U 5        g)z4Construct arguments specific to upgrading a runtime.z
to upgrader   Nr   r   s    r&   AddUpgradeRuntimeFlagsr   ?  s    \2vr%   c                 .    [        U SS9  [        U 5        g)z;Construct arguments specific to starting a stopped runtime.zto startr   Nr   r   s    r&   AddStartRuntimeFlagsr   E  s    Z0vr%   c                 .    [        U SS9  [        U 5        g)z3Construct arguments specific to stopping a runtime.zto stopr   Nr   r   s    r&   AddStopRuntimeFlagsr   K  s    Y/vr%   N)F)5__doc__'googlecloudsdk.api_lib.colab_enterpriser   r   r   r   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   r   +googlecloudsdk.command_lib.colab_enterpriser	   +googlecloudsdk.command_lib.compute.networksr
   rV   3googlecloudsdk.command_lib.compute.networks.subnetsre   googlecloudsdk.command_lib.iamr   (googlecloudsdk.command_lib.util.conceptsr   googlecloudsdk.corer   r   r   r   r'   rE   rL   rO   r`   ro   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r$   r%   r&   <module>r      s    B _ M / ( 5 1 B V ] 3 D *  G) %
&R64>&R+\&L^%PDNK
O1'4&R4
>r%   