
    
                     8   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  e
j"                  e
j$                  j&                  e
j$                  j(                        e
j*                   G d de
j,                                      Zy)z6Implementation of gcloud dataflow jobs cancel command.    )absolute_import)division)unicode_literals)apis)
exceptions)base)	job_utils)log)
console_ioc                   &    e Zd ZdZed        Zd Zy)Cancelz7Cancels all jobs that match the command line arguments.c                 Z    t        j                  | d       | j                  ddd       y)z Register flags for this command.+)nargsz--force
store_truezForcibly cancels a Dataflow job. Regular cancel must have been attempted at least 30 minutes prior for a job to be force cancelled.)actionhelpN)r	   ArgsForJobRefsadd_argument)parsers    #lib/surface/dataflow/jobs/cancel.pyArgszCancel.Args"   s2     V3/
	      c           	      x   t        j                  |      D ]  }	 |j                  rt        j                  dd       t
        j                  j                  |j                  |j                  |j                  |j                         t        j                  j                  dj                  |j                                y# t        j                   $ rc}t        j                  j                  dj                  |j                  |j"                  j$                  |j                               Y d}~d}~ww xY w)zThis is what gets called when the user runs this command.

    Args:
      args: all the arguments that were provided to this command invocation.
    zeForce cancellation will leak VMs the cancelled Dataflow job created that must be manually cleaned up.T)messagecancel_on_no)
project_id	region_idzCancelled job [{0}]zFailed to cancel job [{0}]: {1} Ensure that you have permission to access the job and that the `--region` flag, {2}, matches the job's region.N)r	   ExtractJobRefsforcer   PromptContinuer   Jobsr   jobId	projectIdlocationr
   statusPrintformatr   HttpExceptionpayloadstatus_message)selfargsjob_referrors       r   Runz
Cancel.Run0   s     ++D1
::

#
#} 			MMJJ((&&	 	 	(
 	

.55gmmDE 2 %% 


#Vu}};;W=M=M	
 	

s   B&CD9AD44D9N)__name__
__module____qualname____doc__staticmethodr   r0    r   r   r   r      s     @ 
r   r   N)r4   
__future__r   r   r   googlecloudsdk.api_lib.dataflowr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.dataflowr	   googlecloudsdk.corer
   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackBETAGADefaultUniverseOnlyCommandr   r6   r   r   <module>rD      sz    = &  ' 0 2 ( 9 # 2 D%%**D,=,=,@,@A+
T\\ +
  B+
r   