
                         h   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 Zej$                   ej&                  ej(                  j*                  ej(                  j,                        ej.                   G d dej0                                             Zy)zList PipelineRuns and TaskRuns.    )absolute_import)division)unicode_literals)
exceptions)
list_pager)client_util)base)	run_flags)
properties)	resourcesc                     t         j                  j                  | j                  dt        j
                        }|j                         S )Nz%cloudbuild.projects.locations.results)
collectionapi_version)r   REGISTRYParseRelativeNamenamer   GA_API_VERSIONSelfLink)resourceresults     lib/surface/builds/runs/list.py_GetResultURIr      s?    //mm8,, 0 .& 
	    c                   &    e Zd ZdZed        Zd Zy)Listz4List all Cloud Build runs in a Google Cloud project.c                     | j                   j                  t               t        j                  | d       t
        j                  j                  | d       | j                   j                  d       y )NF2   a  
        table(
            recordSummaries[0].recordData.name.segment(5).yesno(no="-"):label=ID,
            name.segment(3):label=REGION,
            recordSummaries[0].createTime.date('%Y-%m-%dT%H:%M:%S%Oz', undefined='-'),
            result_duration(undefined='-').slice(2:).join("").yesno(no="-"):label=DURATION,
            recordSummaries[0].recordData.workflow.segment(5).yesno(no="-"):label=WORKFLOW,
            result_status():label=STATUS
        )
    )	display_info
AddUriFuncr   r
   AddsRegionResourceArgr	   
LIMIT_FLAG
SetDefault	AddFormat)parsers    r   Argsz	List.Args,   sS    
""=1##FE2OOvr*
!!		r   c           	   #   `  K   t        j                         }t        j                         }|j                  j                  j                         }|r|j                         g}n|j                  xs2 t        j                  j                  j                  j                         }t        j                  |      }t        |j                  D cg c]  }|j                   c}      }|j                   }	g }
|D ]`  }	 t#        j$                  |j&                  |j)                  ||j*                        d|j,                  d|	      }|D ]  }| |	
|	dz  }	 b |
r$t/        j4                  dj7                  |
            yc c}w # t.        j0                  $ r |
j3                  |       Y w xY ww)z9This is what gets called when the user runs this command.)parentfilterresultspageSize)field
batch_sizebatch_size_attributelimitN   zUnable to fetch data from: {})r   GetClientInstanceGetMessagesModuleCONCEPTSregionParseRelativeNameprojectr   VALUEScore	GetOrFailListLocationssorted	locationsr   r.   r   YieldFromListprojects_locations_results-CloudbuildProjectsLocationsResultsListRequestr(   	page_sizer   	HttpErrorappendErrorformat)selfargsclientmessages
region_refparentsr6   responselocationtotal_limitparent_errorspr)   rs                 r   RunzList.Run>   s    **,F,,.H%%++-J((*+g J
 1 1 6 6 > > H H Jg**73hh6H6HI6H(6HIJg **KM  **--BB C .~~!+ A'$1K  " 
)
0
0
?A A 3 J, !!  Q s=   C	F.E?F.9AFF.F.$F+(F.*F++F.N)__name__
__module____qualname____doc__staticmethodr%   rQ    r   r   r   r   &   s     = "'Ar   r   N)rU   
__future__r   r   r   apitools.base.pyr   r   $googlecloudsdk.api_lib.cloudbuild.v2r   googlecloudsdk.callioper	   %googlecloudsdk.command_lib.cloudbuildr
   googlecloudsdk.corer   r   r   HiddenReleaseTracksReleaseTrackALPHABETAUniverseCompatibleListCommandr   rW   r   r   <module>re      s    & &  ' ' ' < ( ; * ) D%%++T->->-C-CD<A4 <A  E <Ar   