
                            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  \R                  R                  4S	 jr\R                  R"                  4S
 jr\R                  R                  4S jr\R                  R                  4S jr\R                  R                  4S jr " S S\	R,                  5      r " S S\	R,                  5      rg)z3Utilities for calling the Metastore Operations API.    )absolute_import)division)unicode_literals)util)waiter)base)logc                 >    [         R                  " U S9R                  $ )Nrelease_track)api_utilGetClientInstanceprojects_locations_operationsr   s    7lib/googlecloudsdk/api_lib/metastore/operations_util.pyGetOperationr      s    		#	#!
!!"    c                 p    [        US9R                  [        R                  " US9R	                  U S95      $ )a4  Calls the Metastore Operations.Cancel method.

Args:
  relative_resource_name: str, the relative resource name of the Metastore
    operation to cancel.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Dataproc Metastore client library will be used.

Returns:
  Empty
r   name)r   Cancelr   GetMessagesModule1MetastoreProjectsLocationsOperationsCancelRequestrelative_resource_namer   s     r   r   r   !   @     
M	2	9	9  %99% 	: 	
 r   c                 p    [        US9R                  [        R                  " US9R	                  U S95      $ )a4  Calls the Metastore Operations.Delete method.

Args:
  relative_resource_name: str, the relative resource name of the Metastore
    operation to delete.
  release_track: base.ReleaseTrack, the release track of command. Will dictate
    which Dataproc Metastore client library will be used.

Returns:
  Empty
r   r   )r   Deleter   r   1MetastoreProjectsLocationsOperationsDeleteRequestr   s     r   r   r   6   r   r   c                 T    [         R                  " [        US9U R                  USSS9$ )aA  Waits for an operation to complete and return it.

Polls the operation at least every 15 seconds, showing a progress indicator.
Returns when the operation has completed. The timeout periods of this
operation is one hour.

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 Metastore client library will be used.

Returns:
  poller.GetResult(operation).
r   6 :  max_wait_mswait_ceiling_ms)r   WaitFor_OperationPollerWithErrorr   	operationmessager   s      r   PollAndReturnOperationr*   K   s-    & 
m<nn
 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 Metastore client library will be used.
r   r    r!   r"   N)r   r%   _OperationPollerr   r'   s      r   WaitForOperationr-   g   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 Metastore longrunning Operations.c                 >   > [         [        U ]  [        US9S 5        g )Nr   c                     U $ N xs    r   <lambda>+_OperationPoller.__init__.<locals>.<lambda>       Qr   )superr,   __init__r   selfr   	__class__s     r   r:   _OperationPoller.__init__   s    	
D*=1;r   c                     UR                   (       d  gUR                  (       a5  [        R                  " UR                  UR                  R
                  5      eg)NFT)doneerrorr   OperationErrorr   r)   )r<   r(   s     r   IsDone_OperationPoller.IsDone   s7    >>##INNIOO4K4KLLr   r3   __name__
__module____qualname____firstlineno____doc__r   ReleaseTrackGAr:   rC   __static_attributes____classcell__r=   s   @r   r,   r,   }   s$    ;#'#4#4#7#7 
 r   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&      zDClass for polling Metastore longrunning Operations and print errors.c                 >   > [         [        U ]  [        US9S 5        g )Nr   c                     U $ r2   r3   r4   s    r   r6   4_OperationPollerWithError.__init__.<locals>.<lambda>   r8   r   )r9   r&   r:   r   r;   s     r   r:   "_OperationPollerWithError.__init__   s    	
#T3=1;r   c                 "   UR                   (       d  gUR                  (       Gak  UR                  R                  (       a4  [        R                  R                  SUR                  R                  5        UR                  R                  (       a4  [        R                  R                  SUR                  R                  5        UR                  R                  (       a  UR                  R                  S   R                   Hj  nUR                  S:X  d  M  [        R                  R                  SUR                  R                  R                  S   R                  R                  5        Ml     [        R                  " UR                   S5      eg)	NFzStatus Code:zError message:r   detailszError details: T)r@   rA   coder	   statusPrintr)   rW   additionalPropertieskeyvalueobject_value
propertiesstring_valuer   rB   r   )r<   r(   r)   s      r   rC    _OperationPollerWithError.IsDone   s    >>			

)=)=>		 	 

)9??+B+BC		 	  ..q1FFG[[I%JJ **55a8>>KK G ##INNB77r   r3   rE   rO   s   @r   r&   r&      s$    L#'#4#4#7#7 
 r   r&   N)rJ   
__future__r   r   r    googlecloudsdk.api_lib.metastorer   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.corer	   rK   rL   r   ALPHAr   r   r*   r-   CloudOperationPollerNoResourcesr,   r&   r3   r   r   <module>rj      s    : &  ' = . ( #  $0033 " 261B1B1H1H * 261B1B1E1E , '+&7&7&:&:8 8<7H7H7K7K ,v==   F F r   