
                             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 ej&                   G d dej(                               Zy)zList builds command.    )absolute_import)division)unicode_literals)
list_pager)cloudbuild_util)filter_rewrite)base)flags)
properties)	resources)resource_projection_specc                   0    e Zd ZdZdddZed        Zd Zy)ListzList builds.z
            To list all completed builds in the current project:

                $ {command}

            To list all builds in the current project in
            QUEUED or WORKING status.:

                $ {command} --ongoing
            )DESCRIPTIONEXAMPLESc                    t        j                  |        | j                  ddd       t        j                  j                  | d       t        j                  j                  | d       t        j                  j                  |        t        j                  ddd	t        j                  d
      j                  |        | j                  j                  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.
    z	--ongoingz6Only list builds that are currently QUEUED or WORKING.
store_true)helpaction2      z--filter
EXPRESSIONFah          Apply a Boolean filter EXPRESSION to each resource item to be listed.
        If the expression evaluates True, then that item is listed. For more
        details and examples of filter expressions, run $ gcloud topic filters.
        This flag interacts with other flags that are applied in this order:
        --flatten, --sort-by, --filter, --limit.)metavarrequire_coverage_in_testscategoryr   at  
        table(
            id,
            createTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'),
            duration(start=startTime,end=finishTime,precision=0,calendar=false,undefined="  -").slice(2:).join(""):label=DURATION,
            build_source(undefined="-"):label=SOURCE,
            build_images(undefined="-"):label=IMAGES,
            status
        )
    N)r
   AddRegionFlagadd_argumentr	   
LIMIT_FLAG
SetDefaultPAGE_SIZE_FLAGFILTER_FLAGRemoveFromParserArgumentLIST_COMMAND_FLAGSAddToParserdisplay_info	AddFormat)parsers    lib/surface/builds/list.pyArgsz	List.Args1   s     

E   	OOvr*""62. 	%%f-MM"'((4
5 6A[5H
!! 	# 		    c                 H   |j                   xsD t        j                  j                  j                   j	                         xs t
        j                  }t        j                         }t        j                         }t        j                  j                  j                  j                         }t        j                  j                  d||      }|j                         }t!        j"                  |j$                  |j&                        }t)        j*                  |j,                        j/                  |j0                  |      \  |_        }	t3        j4                  |j6                  |j9                  |j;                         |j<                  |	      d|j<                  d      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.
    zcloudbuild.projects.locations)
collection
projectsIdlocationsId)symbolsaliases)defaults)parentpageSizefilterbuildsr4   )field
batch_sizebatch_size_attribute)regionr   VALUESr6   Getr   DEFAULT_REGIONGetClientInstanceGetMessagesModulecoreproject	GetOrFailr   REGISTRYCreateGetDisplayInfor   ProjectionSpec
transformsr1   r   BackendongoingRewriter5   r   YieldFromListprojects_locations_builds,CloudbuildProjectsLocationsBuildsListRequestRelativeName	page_size)
selfargsbuild_regionclientmessages
project_idparent_resourcer&   r2   server_filters
             r)   RunzList.Run[   s`    	 	*##**..0	*))  ..0F002H""''//99;J((//2  0 "O
 &&(L'66''1E1EGH!/!7!7!E!M!Mh "N "(DK ##((=="//1^^  	> 	" >>') )r+   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr*   rX    r+   r)   r   r      s0     $	- '	 '	R')r+   r   N)r\   
__future__r   r   r   apitools.base.pyr   !googlecloudsdk.api_lib.cloudbuildr   r   googlecloudsdk.callioper	   !googlecloudsdk.command_lib.buildsr
   googlecloudsdk.corer   r   googlecloudsdk.core.resourcer   UniverseCompatibleListCommandr   r_   r+   r)   <module>ri      sU     &  ' ' = < ( 3 * ) A b)4 b) b)r+   