
    Z                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddl
mZ ddlmZ dd	lmZ d
Z G d dej"                        Zdddde_        y)zAbort operation command.    )absolute_import)division)unicode_literals)
exceptions)util)base)log)
console_iozCancelation of operation {0} has been requested. Please use gcloud container operations describe {1} to check if the operation has been canceled successfully.c                   &    e Zd ZdZed        Zd Zy)CancelzCancel an operation.c                 *    | j                  dd       y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    operation_idzThe operation id to cancel.)helpN)add_argument)parsers    *lib/surface/container/operations/cancel.pyArgszCancel.Args&   s     -JK    c                    | j                   d   }| j                   d   } ||      }|j                  |j                  |      }	 |j                  |      }t        j                  dj                  |j                        dd       	 |j                  |       t        j                   j#                  t$        j                  |j                  |j                               |j                  |      S # t        j
                  $ r)}t        j                  |t        j                        d}~ww xY w# t        j
                  $ r}t        j                  |      d}~ww xY w)zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    api_adapterlocation_getNz.Are you sure you want to cancel operation {0}?T)messagethrow_if_unattendedcancel_on_no)contextParseOperationr   GetOperationapitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATr
   PromptContinueformatnameCancelOperationr	   statusPrintCANCEL_OPERATION_MESSAGE)selfargsadapterr   locationop_refoperrors           r   Runz
Cancel.Run0   s1    ll=)G<</LD!H##D$5$5x@FD'b @GGGG 	,f%	jj
"
)
)$*;*;T=N=N
OQ!!&)) (( D$$UD,B,BCCD (( ,$$U++,s1   C0 A(D/ 0D,$D''D,/EEEN)__name__
__module____qualname____doc__staticmethodr   r0    r   r   r   r   #   s    L L,r   r   zCancel a running operation.a  
        Cancel a running operation.

Cancel is a best-effort method for aborting a running operation. Operations that
have already completed can not be cancelled. If the operation has passed the
"point of no-return", cancel will have no effect.

An example of "point of no-return" in the context of Upgrade operations would
be if all the nodes have been upgraded but the operation hasn't been marked as
complete.
zX        To cancel an operation, run:

          $ {command} sample-operation-id
        )briefDESCRIPTIONEXAMPLESN)r4   
__future__r   r   r   apitools.base.pyr   r    googlecloudsdk.api_lib.containerr   googlecloudsdk.callioper   googlecloudsdk.corer	   googlecloudsdk.core.consoler
   r(   Commandr   detailed_helpr6   r   r   <module>rB      sY     &  ' > 1 ( . # 2= ,,T\\ ,,b 	&
		! r   