
                             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dlmZ ddlmZ ddlmZ ddlmZ ej&                   G d dej(                               Zy)z!Command for canceling executions.    )absolute_import)division)unicode_literals)base)cancellation)connection_context)flags)pretty_print)resource_args)serverless_operations)concept_parsers)presentation_specs)
console_ioc                   @    e Zd ZdZdddZed        Zed        Zd Zy)	CancelCancel an execution.z#
          {description}
          zU
          To cancel an execution:

              $ {command} my-execution
          )DESCRIPTIONEXAMPLESc                     t        j                  dt        j                         ddd      }t	        j
                  | d       t        j                  |g      j                  |        y )N	EXECUTIONzExecution to cancel.TF)requiredprefixes)default_async_for_cluster)	r   ResourcePresentationSpecr   GetExecutionResourceSpecr	   AddAsyncFlagr   ConceptParserAddToParser)parserexecution_presentations     )lib/surface/run/jobs/executions/cancel.py
CommonArgszCancel.CommonArgs0   s_    /HH..0 
$ !!#9":;GGO    c                 .    t         j                  |        y )N)r   r"   )r   s    r!   ArgszCancel.Args>   s    
fr#   c                    t        j                  |t        j                  j                  | j                               }|j                  j                  j                         }t        j                  dj                  |j                        dd       t        j                  |      5 }t        j                   ||j"                  |j$                  |j&                         ddd       |j&                  r/t)        j*                  dj                  |j                               yt)        j*                  dj                  |j                               y# 1 sw Y   sxY w)r   z!Execution [{}] will be cancelled.T)messagethrow_if_unattendedcancel_on_noNz"Execution [{}] is being cancelled.zCancelled execution [{}].)r   GetConnectionContextr	   ProductRUNReleaseTrackCONCEPTS	executionParser   PromptContinueformatexecutionsIdr   Connectr   r   GetExecutionCancelExecutionasync_r
   Success)selfargsconn_contextex_refclients        r!   Runz
Cancel.RunB   s   %::emm!2!2!4L ]]$$**,F3::6;N;NO  
	&	&|	4
&%%v'='=t{{ 
5 {{
.
5
5f6I6I
J 
%
,
,V-@-@
A 
5	4s   (7EEN)	__name__
__module____qualname____doc__detailed_helpstaticmethodr"   r%   r>    r#   r!   r   r   !   sE    		- P P  r#   r   N)rB   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.runr   r   r	   r
   r   r   (googlecloudsdk.command_lib.util.conceptsr   r   googlecloudsdk.core.consoler   UniverseCompatibleCommandr   rE   r#   r!   <module>rM      sV    ( &  ' ( 7 = 0 7 8 @ D G 2 8T\\ 8 8r#   