
    	                     |    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	rS
 rS rS rSS jrg)z%Common utility functions for Updater.    )absolute_import)division)unicode_literals)apis)	time_util)progress_tracker)resource_printerz;ResponseError: code={status_code}, message={status_message}c                  0    [         R                  " SS5      $ Nreplicapoolupdaterv1beta1)	core_apisGetClientInstance     :lib/googlecloudsdk/api_lib/compute/rolling_updates_util.pyGetApiClientInstancer          		$	$%99	EEr   c                  0    [         R                  " SS5      $ r   )r   GetMessagesModuler   r   r   GetApiMessagesr   #   r   r   c           	         [         R                  " USS9 n U R                  R                  U R                  R                  UR                  UR                  UR                  S95      nUR                  (       a
   SSS5        gUR                  S:X  a
   SSS5        gUR                  5         [        R                  " S5        M  ! , (       d  f       g= f)a3  Waits until the given operation finishes.

Wait loop terminates when the operation's status becomes 'DONE'.

Args:
  client: interface to the Cloud Updater API
  operation_ref: operation to poll
  message: message to be displayed by progress tracker

Returns:
  True iff the operation finishes with success
F)autotickT)projectzone	operationNDONE   )r   ProgressTrackerzoneOperationsGetMESSAGES_MODULE*ReplicapoolupdaterZoneOperationsGetRequestr   r   r   errorstatusTickr   Sleep)clientoperation_refmessageptr   s        r   WaitForOperationr,   '   s     ''%@B
''++

 
 
K
K#++ %%%// L 12i
 
 A@ 
		V	# A@ 	ggiooa  A@s   A&CC(C
Cc                 0    [         R                  " U /US9  g)zPrints the given resource.)	resourcesprint_formatN)r	   Print)resourcer/   s     r   PrettyPrintr2   C   s    H:LIr   N)json)__doc__
__future__r   r   r   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.command_lib.utilr   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer	   HTTP_ERROR_FORMATr   r   r,   r2   r   r   r   <module>r;      sA    , &  ' 9 5 8 9 B FF8Jr   