
                             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S
KJr   " S S\R"                  5      r " S S\
R&                  5      rg)z8Base class for gkemulticloud API clients for operations.    )absolute_import)division)unicode_literals)encoding)client)waiter)	constants)log)progress_trackerc                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )OperationsClient   zClient for managing LROs.c                 r   > [         [        U ]
  " S0 UD6  U R                  R                  U l        SU l        g )N
operations )superr   __init___clientprojects_locations_operations_service_list_result_field)selfkwargs	__class__s     @lib/googlecloudsdk/api_lib/container/gkemulticloud/operations.pyr   OperationsClient.__init__   s/    	
D*4V4LL>>DM*D    c                     [        U R                  5      n[        R                  " UU[        R
                  " UUR                  SR                  U5      S9[        R                  [        R                  S9  g)zWaits for an LRO to complete.

Args:
  operation_ref: object, passed to operation poller poll method.
  message: str, string to display for the progress tracker.
z Aborting wait for operation {}.
)messagedetail_message_callbackaborted_message)polleroperation_refcustom_trackerwait_ceiling_msmax_wait_msN)_Pollerr   r   WaitForr   ProgressTrackerGetDetailMessageformatr	   MAX_LRO_POLL_INTERVAL_MSMAX_LRO_WAIT_MS)r   r#   r   r"   s       r   WaitOperationsClient.Wait$   sc     T]]#F
NN#'77$*$;$;?FF
 "::--r   c                     U R                   R                  S5      nU R                   R                  U" UR                  5       S95        g)z[Cancels an ongoing LRO.

Args:
  operation_ref: object, operation resource to be canceled.
CancelnameN)r   GetRequestTyper1   RelativeName)r   r#   request_types      r   r1   OperationsClient.Cancel:   s8     ==//9LMM=+E+E+GHIr   )r   r   )
__name__
__module____qualname____firstlineno____doc__r   r.   r1   __static_attributes____classcell__)r   s   @r   r   r      s    !+
,J Jr   r   c                   *    \ rS rSrSrS rS rS rSrg)r'   D   zPoller for Anthos Multi-cloud operations.

The poller stores the status detail from the operation message to update
the progress tracker.
c                 ,    Xl         SU l        SU l        g)See base class.N)operation_servicestatus_detaillast_error_detail)r   rC   s     r   r   _Poller.__init__K   s    .D!Dr   c                 |   U R                   R                  S5      nU R                   R                  U" UR                  5       S95      nUR                  bf  [
        R                  " UR                  5      nSU;   a
  US   U l        SU;   a0  US   nXPR                  :w  a  [        R                  " U5        XPl        U$ )rB   Getr2   statusDetailerrorDetail)rC   r4   rH   r5   metadatar   MessageToPyValuerD   rE   r
   error)r   r#   r6   	operationrK   error_details         r   Poll_Poller.PollQ   s    ))88?L&&**-4467I %**9+=+=>h	8	#%n5	(	".111
))L
!!-r   c                     U R                   $ )N)rD   )r   s    r   r*   _Poller.GetDetailMessageb   s    r   )rE   rC   rD   N)	r8   r9   r:   r;   r<   r   rP   r*   r=   r   r   r   r'   r'   D   s    ""r   r'   N)r<   
__future__r   r   r   apitools.base.pyr   .googlecloudsdk.api_lib.container.gkemulticloudr   googlecloudsdk.api_lib.utilr   2googlecloudsdk.command_lib.container.gkemulticloudr	   googlecloudsdk.corer
   googlecloudsdk.core.consoler   
ClientBaser   CloudOperationPollerNoResourcesr'   r   r   r   <module>r]      sL    ? &  ' % A . H # 8%Jv(( %JPf44 r   