
                             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Zej                    G d dej"                               Zy)zCancel build command.    )absolute_import)division)unicode_literals)cloudbuild_util)base)flags)log)
properties)	resourcesNc                   0    e Zd ZdZdddZed        Zd Zy)CancelzCancel an ongoing build.z
            To cancel a build `123-456-789`:

                $ {command} '123-456-789'

            You may also cancel multiple builds at the same time:

                $ {command} '123-456-789', '987-654-321'
            )DESCRIPTIONEXAMPLESc                     t        j                  |        | j                  dt         j                  dd       | j                  j                  d        y )Nbuilds+zIDs of builds to cancel)	completernargshelp)r   AddRegionFlagadd_argumentBuildsCompleterdisplay_info	AddFormat)parsers    lib/surface/builds/cancel.pyArgszCancel.Args0   sK    	
''&	  (
 !!$'    c                    |j                   xsD t        j                  j                  j                   j	                         xs t
        j                  }t        j                         }t        j                         }g }|j                  D ]  }t        j                  j                  |t        j                  j                  j                  j                  ||dd      }|j                  j!                  |j#                  |j%                         |j&                  |j(                              }t*        j,                  j/                  dj1                  t3        j4                  |                   |j7                  |        |S )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.
    )
projectsIdlocationsIdbuildsIdz$cloudbuild.projects.locations.builds)params
collection)name	projectIdidzCancelled [{r}].
)r)regionr
   VALUESr   Getr   DEFAULT_REGIONGetClientInstanceGetMessagesModuler   REGISTRYParsecoreproject	GetOrFailprojects_locations_buildsr   CancelBuildRequestRelativeNamer    r"   r	   statuswriteformatsix	text_typeappend)	selfargsbuild_regionclientmessages	cancelledbuild	build_refcancelled_builds	            r   Runz
Cancel.Run:   sF    	 	*##**..0	*))  ..0F002HI$$**
&--22::DD)
 < + =i 88??

%
%))+!,,## & o 
jj+22S]]95M2NO'! " r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   rF    r   r   r   r      s/      %- ( (%r   r   )rJ   
__future__r   r   r   !googlecloudsdk.api_lib.cloudbuildr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.buildsr   googlecloudsdk.corer	   r
   r   r:   UniverseCompatibleCommandr   rM   r   r   <module>rU      sP     &  ' = ( 3 # * ) 
 @T\\ @ @r   