
                             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 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                 B    U [         R                  R                  :X  a  gg)zRReturns the correct API version.

Args:
  release_track: base.ReleaseTrack object
v1v1beta1)r   ReleaseTrackGArelease_tracks    ,lib/googlecloudsdk/api_lib/notebooks/util.pyApiVersionSelectorr      s     d''***	    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(   0   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runtime)IsSpecifiedCONCEPTSr*   r&   r(   locationsIdr   RelativeName)argsr*   s     r   GetParentForRuntimer0   9   sV    	i  mm##))+Gw22&1133?<>B !r   c                     U R                  S5      (       aR  U R                  R                  R                  5       n[	        UR
                  UR                  5      R                  5       $ g )Ninstance)r+   r,   r2   r&   r(   r-   r   r.   )r/   r2   s     r   GetParentForInstancer3   @   sV    	j!!}}%%++-Hx33'2244@LNC "r   c                     U R                  S5      (       aR  U R                  R                  R                  5       n[	        UR
                  UR                  5      R                  5       $ g )Nenvironment)r+   r,   r5   r&   r(   r-   r   r.   )r/   r5   s     r   GetParentForEnvironmentr6   G   sV    	m$$--++113K{66*5577C|~F %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   GetProjectResourcer8   N   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       $ g )NTr   r'   )r   r!   r"   r#   r$   r+   r(   r'   r.   r   IsExplicitlySet)r/   r#   s     r   GetParentFromArgsr;   U   s    ""**...='	j!!t}}g6CCEE""++;;==##,,00$0?  >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   GetOperationResourcer@   _   s.    				-	-
:$]3 
. 
5 5r   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.
)r@   r?   r   r   CloudOperationPollerNoResourcesprojects_locations_operationsCloudOperationPollerWaitFor)	operationmessageservicer   	is_deleteoperation_refclientpollers           r   WaitForOperationrM   f   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   r   r   r   r   r(   r0   r3   r6   r8   r;   r@   rM    r   r   <module>rS      s~    8 : . ( * ) !--00 H #//22 H1BCF' 5  %	8r   