
                            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  e
j                  e
j                  j                  e
j                  j                         e
j"                   G d	 d
e
j$                                      Z e
j                  e
j                  j(                        e
j"                   G d de
j$                                      Zy)z0Command to list tasks for a specified Batch job.    )absolute_import)division)unicode_literals)
list_pager)tasks)base)resource_argsc                   &    e Zd ZdZed        Zd Zy)List  List tasks for a specified Batch job.

  Currently, since Batch only supports one taskGroup, group0, the command
  takes --job as the required argument and will list all tasks
  in group0 of the job.

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

  ## EXAMPLES

  To print all tasks in the job with name
  `projects/foo/locations/us-central1/jobs/bar`, run:

    $ {command} --job projects/foo/locations/us-central1/jobs/bar
  c                     t        j                  |        t        j                  j	                  |        | j
                  j                  d       y Nztable(name, status.state)r	   AddJobFlagResourceArgsr   URI_FLAGRemoveFromParserdisplay_info	AddFormatparsers    lib/surface/batch/tasks/list.pyArgsz	List.Args1   7    ((0MM""6*
!!"=>    c                    | j                         }t        j                  |      }|j                  j                  j                         }t        j                  |j                  |j                  j                  |j                         dz   |j                  |j                        |j                  d|j                  d      S )N/taskGroups/group0)parentpageSizefilterr   r   
batch_sizefieldlimitbatch_size_attribute)ReleaseTrackr   TasksClientCONCEPTSjobParser   YieldFromListservicemessages4BatchProjectsLocationsJobsTaskGroupsTasksListRequestRelativeName	page_sizer   r#   selfargsrelease_trackclientjob_refs        r   RunzList.Run7   s    %%'M}-Fmm%%'G##LL''),@@^^;; 	M 	

 >>jj' r   N__name__
__module____qualname____doc__staticmethodr   r6    r   r   r   r      s     $ ? ?
r   r   c                   &    e Zd ZdZed        Zd Zy)	ListAlphar   c                     t        j                  |        t        j                  j	                  |        | j
                  j                  d       y r   r   r   s    r   r   zListAlpha.Args`   r   r   c                 r   | j                         }t        j                  |      }|j                  j                  j                         }t        j                  |j                  |j                  j                  |j                         dz   |j                        |j                  d|j                  d      S )a  Alpha version method to list tasks for a specified Batch job.

    Args:
      args: The command line arguments of the list command including job
        resource, page size, filter, limit and sort-by.
    Returns:
      The list of tasks for the job.

    r   )r   r   r   r   r    )r%   r   r&   r'   r(   r)   r   r*   r+   r,   r-   r.   r/   r#   r0   s        r   r6   zListAlpha.Runf   s     %%'M}-Fmm%%'G##LL''),@@^^ 	M 	
 >>jj'
 
r   Nr7   r=   r   r   r?   r?   K   s     $ ? ?
r   r?   N)r;   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.batchr   googlecloudsdk.callioper    googlecloudsdk.command_lib.batchr	   ReleaseTracksr%   GABETAUniverseCompatibleListCommandr   ALPHAr?   r=   r   r   <module>rM      s     7 &  ' ' . ( : D%%(($*;*;*@*@A*4 *  B*Z D%%++,2   2  -2r   