
    g                     T    S 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g	)z1A library that is used to support trace commands.    )encoding)apis)logc                     U S:X  a  S$ S$ )zRReturns 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                 B    [         R                  " S[        U 5      5      $ )z%Returns the client for the trace API.
aiplatform)	core_apisGetClientInstancer   r   s    r   	GetClientr           		$	$&}5
 r   c                 B    [         R                  " S[        U 5      5      $ )z'Returns the messages for the trace API.r   )r   GetMessagesModuler   r   s    r   GetMessagesr   &   r   r   c                     U R                   $ )z2Returns whether the user specified the async flag.)async_)argss    r   GetAsyncConfigr   -   s    	r   Nc                 .   [         R                  [         R                  [         R                  S.nU(       a  X   " UR                  USS9  U$ U R                  XUS9R                  n	U	b!  [        R                  " U	5      n
SU
;   a  U
S   nX   " XtSS9  U	$ )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    < ######
  "''tLI #33' 4 H  ((6H&!hU 
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   