
                            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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.    )absolute_import)division)unicode_literals)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+   3   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   GetParentForRuntimer3   <   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/   r5   r)   r+   r0   r!   r1   )r2   r5   s     r   GetParentForInstancer6   C   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/   r8   r)   r+   r0   r!   r1   )r2   r8   s     r   GetParentForEnvironmentr9   J   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   GetProjectResourcer;   Q   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*   r1   r   IsExplicitlySet)r2   r&   s     r   GetParentFromArgsr>   X   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   GetOperationResourcerC   b   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.
)rC   rB   r   r   CloudOperationPollerNoResourcesprojects_locations_operationsCloudOperationPollerWaitFor)	operationmessageservicer   	is_deleteoperation_refclientpollers           r   WaitForOperationrP   i   sf    * 'y~~}E-]#&33,,.F ((557F	w	77r   )N)F)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   r   r   googlecloudsdk.callioper   googlecloudsdk.corer	   r
   r   r   r   r   r   r+   r3   r6   r9   r;   r>   rC   rP    r   r   <module>rW      s    8 &  ' 9 . ( * ) !--00 H #//22 H1BCF' 5  %	8r   