
    g                     R    d Z ddlmZ ddlmZ ddlmZ d Zd Z	d Z
d Z	 	 	 dd
Zy	)z1A library that is used to support trace commands.    )encoding)apis)logc                     | dk(  rdS dS )zXReturns the correct API version.

  Args:
    release_track: base.ReleaseTrack object
  GAv1v1beta1 release_tracks    3lib/googlecloudsdk/api_lib/colab_enterprise/util.pyApiVersionSelectorr      s     $&5I5    c                 @    t        j                  dt        |             S )z%Returns the client for the trace API.
aiplatform)	core_apisGetClientInstancer   r   s    r   	GetClientr           		$	$&}5
 r   c                 @    t        j                  dt        |             S )z'Returns the messages for the trace API.r   )r   GetMessagesModuler   r   s    r   GetMessagesr   &   r   r   c                     | j                   S )z2Returns whether the user specified the async flag.)async_)argss    r   GetAsyncConfigr   -   s    	r   Nc                 6   t         j                  t         j                  t         j                  d}|r ||   |j                  |d       |S | j                  |||      j                  }	|	t        j                  |	      }
d|
v r|
d   } ||   ||d       |	S )a>  Waits for an operation if asynchronous flag is off.

  Args:
    operations_client: api_lib.ai.operations.OperationsClient, the client via
      which to poll.
    op: Cloud AI Platform operation, the operation to poll.
    op_ref: The operation reference to the operation resource. It's the result
      by calling resources.REGISTRY.Parse
    log_method: Logging method used for operation.
    kind: str, the resource kind (eg runtime template), which will be passed to
      logging function.
    asynchronous: bool, whether to wait for the operation or return immediately
    message: str, the message to display while waiting for the operation.
    resource: str, name of the resource the operation is acting on

  Returns:
    The result of the operation if asynchronous is true, or the Operation
      message otherwise.
  )createdeleteupdateT)resourcekindis_async)messagenameF)	r   CreatedResourceDeletedResourceUpdatedResourcer%   WaitForOperationresponser   MessageToPyValue)operations_clientopop_ref
log_methodr"   asynchronousr$   r!   logging_functionresponse_msgr*   s              r   WaitForOpMayber3   2   s    < ######
  Z "''tLI #33&' 4 H  ((6H&!h:dU 
r   )FNN)__doc__apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer   r   r   r   r   r3   r
   r   r   <module>r8      s7    8 % 9 #6 1r   