
                             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 r
\R                  R                  4S jr\R                  R                  4S	 jrSS jrS rS rS rSS jr SS jrg
)z1A library that is used to support trace commands.    )apis)waiter)base)
properties)	resourcesc                     A g)zRReturns the correct API version.

Args:
  release_track: base.ReleaseTrack object
v2 release_tracks    ,lib/googlecloudsdk/api_lib/workbench/util.pyApiVersionSelectorr      s
     	    c                 B    [         R                  " S[        U 5      5      $ )z%Returns the client for the trace API.	notebooks)	core_apisGetClientInstancer   r   s    r   	GetClientr   #   !    		$	$[%7%F
H H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   Nc                     U(       d1  [         R                  R                  R                  R	                  SS9n[
        R                  R                  U SU0SS9$ )NTrequired
projectsIdznotebooks.projects.locations)params
collection)r   VALUEScoreprojectGetr   REGISTRYParse)locationr!   s     r   GetLocationResourcer&   /   sV    	$$,,00$0?G				!	!G$/ 
" 
1 1r   c                     U R                  S5      (       aR  U R                  R                  R                  5       n[	        UR
                  UR                  5      R                  5       $ g )Ninstance)IsSpecifiedCONCEPTSr(   r$   r&   locationsIdr   RelativeName)argsr(   s     r   GetParentForInstancer.   8   sV    	j!!}}%%++-Hx33'2244@LNC "r   c                     [         R                  R                  U =(       d1    [        R                  R
                  R                  R                  SS9SS9$ )z-Returns the resource for the current project.Tr   znotebooks.projects)r   )r   r#   r$   r   r   r    r!   r"   )r!   s    r   GetProjectResourcer0   ?   sK    				!	!B""''//33T3B% 
" 
' 'r   c                    [         R                  R                  R                  R	                  SS9nU R                  S5      (       a$  [        U R                  U5      R                  5       $ [         R                  R                  R                  R                  5       (       aI  [        [         R                  R                  R                  R	                  SS9U5      R                  5       $ [        S5      e)zGets the parent resource for the command.

Args:
  args: The args object containing the command arguments.

Returns:
  The resource name of the parent resource.

Raises:
  ValueError: If neither `--location` nor the `location` property is
  specified.
Tr   r%   z9One of --location or location property must be specified.)r   r   r    r!   r"   r)   r&   r%   r,   r   IsExplicitlySet
ValueError)r-   r!   s     r   GetParentFromArgsr4   F   s     ""**...='	j!!t}}g6CCEE""++;;==##,,00$0?ln C r   c                 R    [         R                  R                  U S[        U5      S9$ )Nz'notebooks.projects.locations.operations)r   api_version)r   r#   ParseRelativeNamer   )namer   s     r   GetOperationResourcer9   `   s.    				-	-
:$]3 
. 
 r   c                    [        U R                  U5      n[        U5      nU(       a!  [        R                  " UR
                  5      nO [        R                  " X&R
                  5      n[        R                  " XuU5      $ )a  Waits for the given google.longrunning.Operation to complete.

Args:
  operation: The operation to poll.
  message: String to display for default progress_tracker.
  service: The service to get the resource after the long running operation
    completes.
  release_track: base.ReleaseTrack object.
  is_delete: Bool indicating is Poller should fetch resource post operation.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error

Returns:
  The created Environment resource.
)r9   r8   r   r   CloudOperationPollerNoResourcesprojects_locations_operationsCloudOperationPollerWaitFor)	operationmessageservicer   	is_deleteoperation_refclientpollers           r   WaitForOperationrF   h   sf    & 'y~~}E-]#&33,,.F ((557F	w	77r   )N)F)__doc__googlecloudsdk.api_lib.utilr   r   r   googlecloudsdk.callioper   googlecloudsdk.corer   r   r   ReleaseTrackGAr   r   r&   r.   r0   r4   r9   rF   r
   r   r   <module>rM      ss    8 : . ( * ) !--00 H #//22 H1C'4 ;@8r   