
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJr  SSKJr  \R                  R                   4S	 jr\R                  R                   4S
 jr\R                  R                   4S jr\R(                  \R                  R                   4S jr\R                  R                   4S jr " S S\
R.                  5      rg)z2Utilities for calling the Composer Operations API.    )absolute_import)division)unicode_literalsN)util)waiter)basec                 >    [         R                  " U S9R                  $ )Nrelease_track)api_utilGetClientInstanceprojects_locations_operationsr
   s    6lib/googlecloudsdk/api_lib/composer/operations_util.py
GetServicer      s    		#	#!
##@#@A    c                     [        US9R                  [        R                  " US9R	                  U R                  5       S95      $ )a  Calls the Composer Operations.Delete method.

Args:
  operation_resource: Resource, the Composer operation resource to
      delete.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
      which Composer client library will be used.

Returns:
  Empty
r
   name)r   Deleter   GetMessagesModule0ComposerProjectsLocationsOperationsDeleteRequestRelativeNameoperation_resourcer   s     r   r   r   #   sF     
-	0	7	7  }=77!..0 8 2
3 3r   c                     [        US9R                  [        R                  " US9R	                  U R                  5       S95      $ )a4  Calls the Composer Operations.Get method.

Args:
  operation_resource: Resource, the Composer operation resource to
      retrieve.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
      which Composer client library will be used.

Returns:
  Operation: the requested operation
r
   r   )r   Getr   r   -ComposerProjectsLocationsOperationsGetRequestr   r   s     r   r   r   5   sF     
-	0	4	4  }=44!..0 5 2
3 3r   c           
      |    [         R                  " [         R                  " US9R                  [	        US9U SUUSS9$ )a*  Lists Composer Operations across all locations.

Uses a hardcoded list of locations, as there is way to dynamically
discover the list of supported locations. Support for new locations
will be aligned with Cloud SDK releases.

Args:
  location_refs: [core.resources.Resource], a list of resource reference to
      locations in which to list operations.
  page_size: An integer specifying the maximum number of resources to be
    returned in a single list call.
  limit: An integer specifying the maximum number of operations to list.
      None if all available operations should be returned.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
      which Composer client library will be used.

Returns:
  list: a generator over Operations within the locations in `location_refs`.
r
   
operationsr   )limitlocation_attribute)r   AggregateListResultsr   .ComposerProjectsLocationsOperationsListRequestr   )location_refs	page_sizer    r   s       r   Listr&   G   sB    . 
	&	&  }=55}-
! !r   c                 V    [         R                  " [        US9U R                  USSS9  g)a  Waits for an operation to complete.

Polls the operation at least every 15 seconds, showing a progress indicator.
Returns when the operation has completed.

Args:
  operation: Operation Message, the operation to poll
  message: str, a message to display with the progress indicator. For
      example, 'Waiting for deletion of [some resource]'.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
      which Composer client library will be used.
r
   i6 i:  )max_wait_mswait_ceiling_msN)r   WaitFor_OperationPollerr   )	operationmessager   s      r   WaitForOperationr.   i   s(     	..]3nn!r   c                   `   ^  \ rS rSrSr\R                  R                  4U 4S jjrS r	Sr
U =r$ )r+   ~   z3Class for polling Composer longrunning Operations. c                 >   > [         [        U ]  [        US9S 5        g )Nr
   c                     U $ )N )xs    r   <lambda>+_OperationPoller.__init__.<locals>.<lambda>   s    1r   )superr+   __init__r   )selfr   	__class__s     r   r8   _OperationPoller.__init__   s    	
D*/>r   c                     UR                   (       aG  UR                  (       a5  [        R                  " UR                  UR                  R
                  5      egg)NTF)doneerrorcommand_utilOperationErrorr   r-   )r9   r,   s     r   IsDone_OperationPoller.IsDone   s>    ~~	)))..*3//*A*AC 	Cr   r3   )__name__
__module____qualname____firstlineno____doc__r   ReleaseTrackGAr8   rA   __static_attributes____classcell__)r:   s   @r   r+   r+   ~   s$    <#'#4#4#7#7 > r   r+   )rG   
__future__r   r   r   sysgooglecloudsdk.api_lib.composerr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.composerr?   rH   rI   r   r   r   maxsizer&   r.   CloudOperationPollerNoResourcesr+   r3   r   r   <module>rT      s    9 &  ' 
 < . ( D "..11 A
 .2->->-A-A 3$ +/*;*;*>*> 3( {{((++!D 8<7H7H7K7K !*v== r   