
                         t    S r SSKJr  SSK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g)z%colab-enterprise runtimes api helper.    )
properties)	resourcesc                 j    U R                   R                  R                  5       nUR                  5       $ )zGet the parent Location resource name for the runtime.

Args:
  args: Argparse object from Command.Run

Returns:
  The resource name in the form projects/{project}/locations/{location}.
)CONCEPTSregionParseRelativeName)argsr   s     7lib/googlecloudsdk/api_lib/colab_enterprise/runtimes.pyGetParentForRuntimer      s+     ==%%'&				    c                     SU ;   a   [         R                  R                  U SS9$ [         R                  R                  U SS9$ ! [         R                   a     N4f = f)zParse operation relative resource name to the operation reference object.

Args:
  operation_name: The operation resource name

Returns:
  The operation reference object
z/notebookRuntimes/z9aiplatform.projects.locations.notebookRuntimes.operations)
collectionz(aiplatform.projects.locations.operations)r   REGISTRYParseRelativeName WrongResourceCollectionException)operation_names    r   ParseRuntimeOperationr   #   su     ^+11
I 2   
			-	-!K 
. 
  55 
s   A AAc                 r    [         R                  R                  U R                  SS9nUR	                  5       $ )z(Transform a runtime resource into a URL.z.aiplatform.projects.locations.notebookRuntimes)relative_namer   )r   r   r   nameSelfLink)resourceruntimes     r   GetRuntimeUrir   ;   s8    00MMA 1 ' 
			r   c                     U R                  S5      (       aV  UR                  R                  nU" U R                  R	                  5        VVs/ s H  u  p4UR                  X4S9PM     snnS9$ gs  snnf )zConstructs the labels from command line args.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the aiplatform API.

Returns:
  Labels for the runtime.
labels)keyvalue)additionalPropertiesN)IsSpecified+GoogleCloudAiplatformV1beta1NotebookRuntimeLabelsValuer   itemsAdditionalProperty)r
   messageslabels_messager   r   s        r   GetLabelsFromArgsr(   D   s|     
h<<HH   #kk//1
1
 --#-C1
  

s   A.
c                     U R                  S5      (       a  U R                  $ [        R                  R                  R
                  R                  5       $ )zGets runtime user from command line args if provided; else default to caller.

Args:
  args: Argparse object from Command.Run

Returns:
  Runtime user of the runtime.
runtime_user)r!   r*   r   VALUEScoreaccountGetr
   s    r   "GetRuntimeUserFromArgsOrPropertiesr0   [   sB     
n%%!!))--//r   c                 f    U R                   R                  R                  5       R                  5       $ )zGet the resource name for the notebook runtime.

Args:
  args: Argparse object from Command.Run

Returns:
  The resource name in the form
  projects/{project}/locations/{location}/notebookRuntimes/{runtime_id}.
)r   r   r   r	   r/   s    r   GetRuntimeResourceNamer2   k   s&     
			$	$	&	3	3	55r   c           
          UR                  U R                  [        U 5      U R                  U R                  [        X5      S9$ )zCreates the NotebookRuntime message for the AssignNotebookRuntime request.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the NotebookRuntime message.
)r   runtimeUserdisplayNamedescriptionr   )r"   
runtime_idr0   display_namer6   r(   r
   r&   s     r   CreateRuntimeMessager:   x   sE     
	=	=??4T:##""t. 
> 
 r   c                     [        U 5      n[        X5      nUR                  UR                  UU R                  U R
                  R                  R                  5       R                  5       S9US9$ )zBuilds a AssignNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the AssignNotebookRuntimeRequest message.
)notebookRuntimenotebookRuntimeIdnotebookRuntimeTemplate)8googleCloudAiplatformV1beta1AssignNotebookRuntimeRequestparent)	r   r:   8AiplatformProjectsLocationsNotebookRuntimesAssignRequest8GoogleCloudAiplatformV1beta1AssignNotebookRuntimeRequestr7   r   runtime_templater   r	   )r
   r&   r@   r   s       r   !CreateRuntimeAssignRequestMessagerD      s}     t$& 0'		J	J?G  @A  @A! OO"&--"@"@"F"F"H"U"U"W @A @
  
K 
 r   c                 2    UR                  [        U 5      S9$ )zBuilds a GetNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the GetNotebookRuntimeRequest message.
r   )5AiplatformProjectsLocationsNotebookRuntimesGetRequestr2   r9   s     r   CreateRuntimeGetRequestMessagerH      s%     
	G	G!$' 
H 
 r   c                 2    UR                  [        U 5      S9$ )zBuilds a ListNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the ListNotebookRuntimeRequest message.
)r@   )6AiplatformProjectsLocationsNotebookRuntimesListRequestr   r9   s     r   CreateRuntimeListRequestMessagerK      s%     
	H	H & 
I 
 r   c                 2    UR                  [        U 5      S9$ )zBuilds a DeleteNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the DeleteNotebookRuntimeRequest message.
rF   )8AiplatformProjectsLocationsNotebookRuntimesDeleteRequestr2   r9   s     r   !CreateRuntimeDeleteRequestMessagerN      s%     
	J	J!$' 
K 
 r   c                 P    UR                  UR                  5       [        U 5      S9$ )zBuilds a UpgradeNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the UpgradeNotebookRuntimeRequest message.
)9googleCloudAiplatformV1beta1UpgradeNotebookRuntimeRequestr   )9AiplatformProjectsLocationsNotebookRuntimesUpgradeRequest9GoogleCloudAiplatformV1beta1UpgradeNotebookRuntimeRequestr2   r9   s     r   "CreateRuntimeUpgradeRequestMessagerS      s=     
	K	K@H  AC  AC  AE!$' 
L 
 r   c                 P    UR                  UR                  5       [        U 5      S9$ )zBuilds a StartNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the StartNotebookRuntimeRequest message.
)7googleCloudAiplatformV1beta1StartNotebookRuntimeRequestr   )7AiplatformProjectsLocationsNotebookRuntimesStartRequest7GoogleCloudAiplatformV1beta1StartNotebookRuntimeRequestr2   r9   s     r    CreateRuntimeStartRequestMessagerX      s4     
	I	I>F>~>~  ?A!$' 
J 
 r   c                 P    UR                  UR                  5       [        U 5      S9$ )zBuilds a StopNotebookRuntimeRequest message.

Args:
  args: Argparse object from Command.Run
  messages: Module containing messages definition for the specified API.

Returns:
  Instance of the StopNotebookRuntimeRequest message.
)6googleCloudAiplatformV1beta1StopNotebookRuntimeRequestr   )6AiplatformProjectsLocationsNotebookRuntimesStopRequest6GoogleCloudAiplatformV1beta1StopNotebookRuntimeRequestr2   r9   s     r   CreateRuntimeStopRequestMessager]      s1     
	H	H=E=|=|=~!$' 
I 
 r   N)__doc__googlecloudsdk.corer   r   r   r   r   r(   r0   r2   r:   rD   rH   rK   rN   rS   rX   r]    r   r   <module>ra      sV    , * )0.0 
6&0   ""r   