
    
                         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 e
j                   G d
 de
j                                Zy)z<Command to list jobs for a specified Batch project/location.    )absolute_import)division)unicode_literals)
list_pager)jobs)base)resource_args)
propertiesc                   &    e Zd ZdZed        Zd Zy)Lista  List jobs for a specified Batch project/location.

  This command can fail for the following reasons:
  * The project/location specified do not exist.
  * The active account does not have permission to access the given
  project/location.

  ## EXAMPLES
  To print all the jobs under all available locations for the default project,
  run:

    $ {command}

  To print all the jobs under projects/location
  `projects/foo/locations/us-central1`, run:

    $ {command} --project=foo --location=us-central1
  c                     t        j                  |        t        j                  j	                  |        | j
                  j                  d       y )Nz9table(name, name.segment(3):label=LOCATION, status.state))r	   AddLocationResourceArgsr   URI_FLAGRemoveFromParserdisplay_info	AddFormat)parsers    lib/surface/batch/jobs/list.pyArgsz	List.Args2   s9    ))&1MM""6*
!!C    c                 V   | j                         }t        j                  |      }|j                  xs2 t        j
                  j                  j                  j                         }|j                  xs2 t        j
                  j                  j                  j                         }|rdj                  ||      }ndj                  |d      }t        j                  |j                  |j                  j!                  ||j"                        |j"                  d|j$                  d      S )Nzprojects/{}/locations/{}-)parentpageSizer   r   )
batch_sizefieldlimitbatch_size_attribute)ReleaseTrackr   
JobsClientlocationr
   VALUESbatchGetprojectcore	GetOrFailformatr   YieldFromListservicemessages%BatchProjectsLocationsJobsListRequest	page_sizer   )selfargsrelease_trackclientr!   r%   r   s          r   RunzList.Run:   s    %%'M__]+F}}F
 1 1 7 7 @ @ D D FHllHj//44<<FFHG)00(Cf)00#>f##==^^ 	> 	
 >>jj'
 
r   N)__name__
__module____qualname____doc__staticmethodr   r2    r   r   r   r      s     &  r   r   N)r6   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.batchr   googlecloudsdk.callioper    googlecloudsdk.command_lib.batchr	   googlecloudsdk.corer
   UniverseCompatibleListCommandr   r8   r   r   <module>rA      sJ     C &  ' ' - ( : * 14 1 1r   