
    vh                     >   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SKJr  SSKJ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 r+S  r,S! r-S" r.S# r/S$ r0S% r1g&)(z0Utilities for flags for `gcloud tasks` commands.    )absolute_import)division)unicode_literals)arg_parsers)base)concepts)deps)flags)resource_args)	arg_utils)concept_parsers)
completers)
propertiesc                 R    S n[         R                  R                  SU" 5       U SS9$ )6Constructs and returns the Location Resource Argument.c                  ^    S n [         R                  " SSS[         R                  U " 5       S9$ )r   c                      [         R                  " SS[        R                  " [        R
                  R                  R                  5      /S9$ )NlocationzTGoogle Cloud locationhttps://cloud.google.com/compute/docs/regions-zones/#locations.name	help_textfallthroughsr    ResourceParameterAttributeConfigr	   PropertyFallthroughr   VALUES	notebooksr        1lib/googlecloudsdk/command_lib/workbench/flags.pyLocationAttributeConfigXGetLocationResourceArg.<locals>.GetLocationResourceSpec.<locals>.LocationAttributeConfig'   E    66P &&z'8'8'B'B'K'KL	 	r   znotebooks.projects.locationsr   v2)resource_nameapi_version
projectsIdlocationsIdr   ResourceSpec DEFAULT_PROJECT_ATTRIBUTE_CONFIG)r!   s    r    GetLocationResourceSpec7GetLocationResourceArg.<locals>.GetLocationResourceSpec%   s4    
   & <<+-/ /r   
--locationTrequiredr   ConceptParserForResource)r   r,   s     r    GetLocationResourceArgr4   "   s6    /* 
	&	&	2	2+-y4 
3 
I Ir   c                 Z   ^  U 4S jn[         R                  R                  SU" 5       T SS9$ )z6Constructs and returns the Instance Resource Argument.c            
      z   > U4S jn S n[         R                  " SSSU " 5       U" 5       [         R                  SS9$ )z?Constructs and returns the Resource specification for Instance.c                  .   > [         R                  " ST S9$ )Ninstance)r   r   )r   r   r   s   r    InstanceAttributeConfigXGetInstanceResourceArg.<locals>.GetInstanceResourceSpec.<locals>.InstanceAttributeConfigD   s    66Y0 0r   c                      [         R                  " SS[        R                  " [        R
                  R                  R                  5      /S9$ )Nr   iGoogle Cloud location of this environment https://cloud.google.com/compute/docs/regions-zones/#locations.r   r   r   r   r    r!   XGetInstanceResourceArg.<locals>.GetInstanceResourceSpec.<locals>.LocationAttributeConfigH   r#   r   z&notebooks.projects.locations.instancesr8   r$   F)r%   r&   instancesIdr(   r'   disable_auto_completersr)   )r:   r!   r   s     r    GetInstanceResourceSpec7GetInstanceResourceArg.<locals>.GetInstanceResourceSpecA   sC    0
   0 +-+-<< %' 'r   r8   Tr/   r1   )r   rA   s   ` r    GetInstanceResourceArgrC   >   s7    '8 
	&	&	2	2)+Y 
3 
G Gr   c                 |   ^  U 4S jn[         R                  R                  SU" 5       T 5      R                  U5        g)z,Adds Resource arg for network to the parser.c                  f   > U4S jn [         R                  " SSU " 5       [         R                  SS9$ )=Constructs and returns the Resource specification for Subnet.c                  L   > [         R                  " ST [        R                  S9$ )Nnetworkr   r   	completer)r   r   compute_network_flagsNetworksCompleterr9   s   r    NetworkAttributeConfigRAddNetworkArgument.<locals>.GetNetworkResourceSpec.<locals>.NetworkAttributeConfigg   s%    66);;= =r   zcompute.networksrH   F)r%   rH   projectr@   r)   )rM   r   s    r    GetNetworkResourceSpec2AddNetworkArgument.<locals>.GetNetworkResourceSpecd   s5    =   &(99 %' 'r   z	--networkNr   r2   r3   AddToParser)r   parserrP   s   `  r    AddNetworkArgumentrU   a   s3    '  ++K,B,D,577B{67Jr   c                 |   ^  U 4S jn[         R                  R                  SU" 5       T 5      R                  U5        g)z/Adds Resource arg for subnetwork to the parser.c            	      x   > U4S jn S n[         R                  " SSU " 5       U" 5       [         R                  SS9$ )rF   c                  L   > [         R                  " ST [        R                  S9$ )NsubnetrI   )r   r   compute_subnet_flagsSubnetworksCompleterr9   s   r    SubnetAttributeConfigOAddSubnetArgument.<locals>.GetSubnetResourceSpec.<locals>.SubnetAttributeConfig   s%    66(==? ?r   c                  J    [         R                  " SS[        R                  S9$ )Nzsubnet-regionzfGoogle Cloud region of this subnetwork https://cloud.google.com/compute/docs/regions-zones/#locations.rI   )r   r   r   RegionCompleterr   r   r    RegionAttributeConfigOAddSubnetArgument.<locals>.GetSubnetResourceSpec.<locals>.RegionAttributeConfig   s)    66P ..0 0r   zcompute.subnetworks
subnetworkF)r%   rb   regionrO   r@   r)   )r\   r`   r   s     r    GetSubnetResourceSpec0AddSubnetArgument.<locals>.GetSubnetResourceSpec|   s@    ?0   "(*$&99 %' 'r   z--subnetNrR   )r   rT   rd   s   `  r    AddSubnetArgumentrf   y   s3    '4 ++J8M8O,577B{67Jr   c                     [        S5      R                  U 5        U(       a   [        R                  R                  U 5        g g )NzUser-defined unique name of this instance. The instance name must be 1 to 63 characters long and contain only lowercase letters, numeric characters, and dashes. The first character must be a lowercase letter and the last character cannot be a dash.)rC   rS   r   
ASYNC_FLAG)rT   add_async_flags     r    AddInstanceResourcerj      s6    24 5@K4GOO' r   c           	          U R                  SSSSS9  U R                  SSSS	S9  U R                  S
SSS	SR                  U5      S	S9  U R                  SSSS	SR                  U5      S	S9  U R                  SSSS	SS	S9  g)z'Adds Diagnostic config flags to parser.z--gcs-bucket
gcs_bucketzThe Cloud Storage bucket where the log files generated from the diagnose command will be stored. storage.buckets.writer permissions must be given to project's service account or user credential. Format: gs://`{gcs_bucket}` T)desthelpr0   z--relative-pathrelative_pathzDefines the relative storage path in the Cloud Storage bucket where the diagnostic logs will be written. Default path will be the root directory of the Cloud Storage bucketFormat of full path: gs://`{gcs_bucket}`/`{relative_path}`/ Fz--enable-repair
store_trueenable_repairz%Enables flag to repair service for {})actionrm   defaultrn   r0   z--enable-packet-captureenable_packet_capturez:Enables flag to capture packets from the {} for 30 secondsz--enable-copy-home-filesenable_copy_home_filesz8Enables flag to copy all `/home/jupyter` folder contentsN)add_argumentformat)rT   vm_types     r    AddDiagnosticConfigFlagsry      s    <    	K    	3::7C   	"$$*F7O   	 #F  r   c           	      b    [         R                  " SU R                  R                  SSSSS.SS9$ )	N--reservation-typeFnoneanyspecific)RESERVATION_NONERESERVATION_ANYRESERVATION_SPECIFICType of the reservation.)r0   custom_mappingshelp_str)r   ChoiceEnumMapperReservationAffinity%ConsumeReservationTypeValueValuesEnum)messagess    r    GetReservationTypeMapperr      s=    		#	#""HH$"",
 *

 
r   c                 \   / SQn/ SQnSS/nSS/n/ SQn[        U5        UR                  SS	9nUR                  S
SSS9  UR                  SSS	9  UR                  SS	9nUR                  SSUSS9  UR                  SS[        S9  UR                  SS	9n	U	R                  SSS	9  UR                  SS9n
U
R                  5       nUR                  SSSS9  UR                  SSS9nUR                  S S!S	9  UR                  S"S#S	9  U
R                  5       nUR                  S$S%SS&9  UR                  S'S(S	9  UR                  S)S	9nUR                  S*USS+S,9  UR                  S-[        S.S/9  UR                  S0USS1S,9  S2S3S4S5.n[        R
                  " US6S7US89  UR                  S9S	9nUR                  S:USS;S,9  UR                  S<[        S=S/9  UR                  S>USS?S,9  S@SASBS5.nUR                  SCSD[        R                  " 5       SESF9  [        R
                  " USGSHUS89  UR                  SIS	9nUR                  SJSK[        S9  UR                  SLSM[        S9  UR                  SNSO[        S9  UR                  SPSQ[        S9  UR                  SRS	9nUR                  SSSTSUSVSW9  UR                  SXSYS	9  UR                  SZS	9n[        S[U5        [        S\U5        UR                  S]S^USS9  UR                  S_STS`SaSW9  UR                  SbSTScSdSW9  UR                  SeSTSfSgSW9  UR                  ShSi[        R                  " 5       SjSF9  UR                  SkSlSm[        R                  " 5       Sn9  UR                  SoS	9nUR                  SpSqUSrS9  UR                  SsSt[        S9  UR                  SuSvSw[        R                  " 5       Sx9  UR                  SySTSzS{SW9  U (       a  UR                  S|STS}S~SW9  UR                  SS[        R                  " 5       SjSF9  UR                  SSS	9  g)zConstruct groups and arguments specific to the instance creation.

Args:
  support_managed_euc: Whether to support managed euc.
  parser: The parser to add the flags to.
NVIDIA_TESLA_K80NVIDIA_TESLA_P100NVIDIA_TESLA_V100NVIDIA_TESLA_P4NVIDIA_TESLA_T4NVIDIA_TESLA_A100NVIDIA_A100_80GBNVIDIA_TESLA_T4_VWSNVIDIA_TESLA_P100_VWSNVIDIA_TESLA_P4_VWS	NVIDIA_L4NVIDIA_H100_80GBNVIDIA_H100_MEGA_80GB)PD_STANDARDPD_SSDPD_BALANCED
PD_EXTREMEGMEKCMEKVIRTIGO_NETGVNIC)r|   r}   r~   Gce Setup for the instancern   --machine-typexThe [Compute Engine machine type](https://cloud.google.com/sdk/gcloud/reference/compute/machine-types) of this instance.zn1-standard-4)rn   rs   z--min-cpu-platformzThe minimum CPU platform to use for this instance. The list of valid values can be found in https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#availablezoneszThe hardware accelerator used on this instance. If you use accelerators, make sure that your configuration has [enough vCPUs and memory to support the `machine_type` you have selected](/compute/docs/gpus/#gpus-list).--accelerator-typeType of this accelerator.Nrn   choicesrs   --accelerator-core-count#Count of cores of this accelerator.rn   typea_  The service account on this instance, giving access to other Google Cloud services. You can use any service account within the same project, but you must grant the service account user permission to use the instance. If not specified, the [Compute Engine default service account](/compute/docs/access/service-accounts#default_service_account) is used.z--service-account-emailT)mutexz--vm-image-projectzbThe ID of the Google Cloud project that this VM image belongs to. Format: projects/`{project_id}`.zcloud-notebooks-managed)r   r0   z--vm-image-namez)Use this VM image name to find the image.z--vm-image-familyzYUse this VM image family to find the image; the newest image in this family will be used.--container-repository^The path to the container image repository. For example: gcr.io/`{project_id}`/`{image_name}`.rn   r0   --container-tagRThe tag of the container image. If not specified, this defaults to the latest tag.zBoot disk configurations.z--boot-disk-typezbType of boot disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).)r   rs   rn   --boot-disk-sizezSize of boot disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not specified, this defaults to 100.r   rn   z--boot-disk-encryptionz?Disk encryption method used on the boot disk, defaults to GMEK.z"--boot-disk-encryption-key-keyringz#--boot-disk-encryption-key-locationz"--boot-disk-encryption-key-project)zkms-keyringzkms-locationzkms-project	boot_diskz--boot-disk-kms-key)rT   resourcer   flag_overrideszData disk configurations.z--data-disk-typezbType of data disk attached to this instance, defaults to standard persistent disk (`PD_STANDARD`).--data-disk-sizezSize of data disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). The minimum recommended value is 100 GB. If not specified, this defaults to 100.z--data-disk-encryptionz?Disk encryption method used on the data disk, defaults to GMEK.z"--data-disk-encryption-key-keyringz#--data-disk-encryption-key-locationz"--data-disk-encryption-key-projectz--data-disk-resource-policieszuResource policies to apply to the data disk. Format: `projects/{project}/regions/{region}/resourcePolicies/{policy}`.RESOURCE_POLICIESrn   r   metavar	data_diskz--data-disk-kms-keyShielded VM configurations.--shielded-secure-bootSBoolean. Boot instance with secure boot enabled. Supported values: `true`, `false`.--shielded-vtpmeBoolean. Boot instance with TPM (Trusted Platform Module) enabled. Supported values: `true`, `false`.--shielded-integrity-monitoringdBoolean. Enable monitoring of the boot integrity of the instance. Supported values: `true`, `false`.z--confidential-compute-typezTString. VM instance with CC (Confidential Compute) of type. Supported values: `SEV`.GPU driver configurations.--install-gpu-driverrp   install_gpu_driverzWhether the end user authorizes Google Cloud to install a GPU driver on this instance. If this field is empty or set to false, the GPU driver won't be installed. Only applicable to instances with GPUs.)rr   rm   rn   --custom-gpu-driver-pathzSpecify a custom Cloud Storage path where the GPU driver is stored. If not specified, we'll automatically choose from official GPU drivers.zNetwork configs.zmThe name of the VPC that this instance is in. Format: projects/`{project_id}`/global/networks/`{network_id}`.zThe name of the subnet that this instance is in. Format: projects/`{project_id}`/regions/`{region}`/subnetworks/`{subnetwork_id}`.z
--nic-typez#Type of the network interface card.z--disable-public-ipdisable_public_ipz?  If specified, no public IP will be assigned to this instance.z--enable-ip-forwardingenable_ip_forwardingz@  If specified, IP forwarding will be enabled for this instance.z--disable-proxy-accessdisable_proxy_accesszB  If true, the notebook instance will not register with the proxy.
--metadata*Custom metadata to apply to this instance.	KEY=VALUE--tagsTAGSTags to apply to this instance.)r   rn   r   zReservation configs.r{   r   r}   z--reservation-keyzThe label key of a reservation resource. To target a specific reservation by name, use compute.googleapis.com/reservation-name as the key and specify the name of your reservation as its value.z--reservation-valueszThe label value of a reservation resource. To target a specific reservation by name, use compute.googleapis.com/reservation-name as the key and specify the name of your reservation as its value.r   )rn   r   r   z--enable-third-party-identityenable_third_party_identityz^If true, the notebook instance provide a proxy endpoint which allows for third party identity.z--enable-managed-eucenable_managed_euczZIf true, the notebook instance will be created with managed end  user credentials enabled.--labelsVLabels to apply to this instance. These can be later modified by the setLabels method.z--instance-ownerszThe owners of this instance after creation. Format: `alias@example.com`. Currently supports one owner only. If not specified, all of the service account users of the VM instance's service account can use the instance.)rj   	add_grouprv   intkms_resource_argsAddKmsKeyResourceArgr   ArgListstrrU   rf   ArgDict)support_managed_eucrT   accelerator_choicesdisk_choicesencryption_choicesnic_type_choicesreservation_type_choicesgce_setup_groupaccelerator_groupservice_account_groupimage_groupvm_source_groupvm_mutex_groupcontainer_group
boot_groupboot_kms_flag_overrides
data_groupdata_kms_flag_overridesshielded_vm_group	gpu_groupnetwork_groupreservation_groups                         r    AddCreateInstanceFlagsr      s    H,'#W- f$$
& % )/     d  f &//- 0 /   &!	 ! 
    0 !  *33& 4 	 $$& % 
  )))5+))+/- (   #,,4$,G.I   &    ))+/?    -   ((.I(J*6   ?	    L	   :;9
 (( ,	 ((.I(J*6   ?	    L	   :;9
 %N  !   (( ,	 &//( 0      !    /  !    '/  !  #%    ''-I'J)P  	     "++1C+D-D  M  0	   C	   !D	   	!F	   7 	   , 	   &//! 0    %&	 !    4
  ! 	   4
   ! 
 	%('   
!*   	%     	3  r   c                     [        U SS9  g NF)ri   rj   rT   s    r    AddDescribeInstanceFlagsr   Y      fU3r   c                     [        U 5        g Nr   r   s    r    AddDeleteInstanceFlagsr   ]  
    fr   c                 B    U R                  S[        R                  SS9  g )Nr.   r=   )rJ   rn   )rv   r   LocationCompleterr   s    r    AddListInstanceFlagsr   a  s(    ,,N  Pr   c                     [        U 5        g r   r   r   s    r    AddRegisterInstanceFlagsr   i  r   r   c                     [        U 5        g r   r   r   s    r    AddResetInstanceFlagsr  m  r   r   c                     [        U 5        g r   r   r   s    r    AddStartInstanceFlagsr  q  r   r   c                     [        U 5        g r   r   r   s    r    AddStopInstanceFlagsr  u  r   r   c                     [        U SS9  g r   r   r   s    r    AddGetHealthInstanceFlagsr  y  r   r   c                     [        U SS9  g r   r   r   s    r    AddIsUpgradeableInstanceFlagsr
  }  r   r   c                     [        U 5        g r   r   r   s    r    AddUpgradeInstanceFlagsr    r   r   c                 <    [        U 5        U R                  SSSS9  g )Nz--target-snapshotz"The saved snapshot to rollback to.Tr   )rj   rv   r   s    r    AddRollbackInstanceFlagsr    s&    f/  r   c                    / SQn[        U 5        U R                  SS9nUR                  SS9nUR                  SSUSS9  UR                  S	S
[        S9  UR                  SS9nUR                  SS[        S9  UR                  SS[
        S9  UR                  SS9nUR                  SS[
        S9  UR                  SS[
        S9  UR                  SS[
        S9  U R                  SS[        R                  " 5       SS9  UR                  SS[        R                  " 5       SS9  UR                  SSS9  UR                  S S![        R                  " 5       S"S9  UR                  S#S9nUR                  S$S%S&S'9  UR                  S(S)S9  g)*zIAdds accelerator, labels and machine type flags to the parser for update.r   r   r   zAccelerator configurations.r   r   Nr   r   r   r   r   r   zInstall gpu driverr   zcustom gpu driver pathr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   zContainer image configurations.r   r   Tr   r   r   )	rj   r   rv   r   boolr   r   r   r   )rT   r   r   r   r   r   r   s          r    AddUpdateInstanceFlagsr    sM    f$$
& % )/ &//( 0    &!	 ! 
    0 !  ''-I'J)    #   &//( 0      !    /  !    '/  !  	'    7 	  
     , 	   $--, . / ?    -  r   c                 2    [        U 5        [        U S5        g)zCConstruct groups and arguments specific to the instance diagnosing.r8   N)rj   ry   r   s    r    AddDiagnoseInstanceFlagsr    s    f6:.r   c                     [        U 5        U R                  SSSS9nUR                  S[        SS9  UR                  S[        SS9  g	)
z=Construct groups and arguments specific to the disk resizing.zODisk resizing configurations Amount needs to be greater than the existing size.T)rn   r   r0   r   zWSize of boot disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB).r   r   zXSize of data disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). N)rj   r   rv   r   )rT   
disk_groups     r    AddResizeDiskFlagsr    sl    f    * +	   ,	  r   c                 ~    [        U 5        U R                  SSS9nUR                  SSSS9  UR                  SSSS9  g)	z.Adds snapshot flags to the parser for restore.z#Snapshot source to be restored fromTr   z--snapshot-projectz3The project id of the snapshot to be restored from.z
--snapshotz&The snapshot name to be restored from.N)rj   r   rv   )rT   snapshot_groups     r    AddRestoreInstanceFlagsr    sa    f##
/	 $ . @   3  r   N)T)2__doc__
__future__r   r   r   googlecloudsdk.callioper   r    googlecloudsdk.calliope.conceptsr   r	   +googlecloudsdk.command_lib.compute.networksr
   rK   3googlecloudsdk.command_lib.compute.networks.subnetsrZ   googlecloudsdk.command_lib.kmsr   r   $googlecloudsdk.command_lib.util.apisr   (googlecloudsdk.command_lib.util.conceptsr   $googlecloudsdk.command_lib.workbenchr   googlecloudsdk.corer   r4   rC   rU   rf   rj   ry   r   r   r   r   r   r   r  r  r  r  r
  r  r  r  r  r  r  r   r   r    <module>r%     s    7 &  ' / ( 5 1 V ] M : D ; *I8 GFK0KB('Tzz4P44bJ/:r   