
    G                         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	\R                  5      r " S
 S\R                  5      rg)z8Base class for gkemulticloud API clients for operations.    )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   GetRequestTyper.   RelativeName)r   r    request_types      r   r.   OperationsClient.Cancel7   s8     ==//9LMM=+E+E+GHIr   )r   r   )
__name__
__module____qualname____firstlineno____doc__r   r+   r.   __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$   A   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   r@   s     r   r   _Poller.__init__H   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$ )r?   Getr/   statusDetailerrorDetail)r@   r1   rE   r2   metadatar   MessageToPyValuerA   rB   r   error)r   r    r3   	operationrH   error_details         r   Poll_Poller.PollN   s    ))88?L&&**-4467I %**9+=+=>h	8	#%n5	(	".111
))L
!!-r   c                     U R                   $ )N)rA   )r   s    r   r'   _Poller.GetDetailMessage_   s    r   )rB   r@   rA   N)	r5   r6   r7   r8   r9   r   rM   r'   r:   r   r   r   r$   r$   A   s    ""r   r$   N)r9   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>rY      sC    ? % A . H # 8%Jv(( %JPf44 r   