
                            d Z ddlmZ ddlmZ ddlmZ ddlZddl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  G d dej*                        Zej.                   ej0                  ej2                  j4                         G d dej6                                      Zej:                   ej0                  ej2                  j<                         G d de                    Zy)zCommand to list Transfer jobs.    )absolute_import)division)unicode_literalsN)
list_pager)apis)arg_parsers)base)	list_util)	name_util)
properties)resource_printerc                       e Zd ZdZdZdZy)JobTypezThe type of the job.transferreplicationN)__name__
__module____qualname____doc__TRANSFERREPLICATION     !lib/surface/transfer/jobs/list.pyr   r   "   s    (+r   r   c                   6    e Zd ZdZdddZed        Zd Zd Zy)	List$List Transfer Service transfer jobs.z}      List Transfer Service transfer jobs in a given project to show their
      configurations and latest operations.
      a        To list all jobs in your current project, run:

        $ {command}

      To list all disabled jobs in your project, run:

        $ {command} --job-statuses=disabled

      To list jobs 'foo' and 'bar', run:

        $ {command} --job-names=foo,bar

      To list all information about all jobs formatted as JSON, run:

        $ {command} --format=json

      To list all information about jobs 'foo' and 'bar' formatted as YAML, run:

        $ {command} --job-names=foo,bar --format=YAML
      )DESCRIPTIONEXAMPLESc                    | j                  d       t        j                  |        | j                  dt	        j
                         dd       | j                  dt	        j
                         dd       | j                  d	d
d       y )NFz--job-names	JOB_NAMESzThe names of the jobs you want to list. Separate multiple job names with commas (e.g., --job-names=foo,bar). If not specified, all jobs will be listed.)typemetavarhelpz--job-statusesJOB_STATUSESzList only jobs with the statuses you specify. Options include 'enabled', 'disabled', 'deleted' (case insensitive). Separate multiple statuses with commas (e.g., --job-statuses=enabled,deleted). If not specified, all jobs will be listed.z--expand-table
store_truezInclude additional table columns (job name, source, destination, frequency, lastest operation name, job status) in command output. Tip: increase the size of your terminal before running the command.)actionr$   )SetSortArgsr
   add_common_list_flagsadd_argumentr   ArgListparsers    r   Argsz	List.ArgsK   s    
u##F+
  "$	  %   "	   O  Pr   c                 n    |j                   rd}nd}t        j                  ||j                  xs |       y)zAPI response display logic.a  table(
          name.slice(13:).join(sep=''),
          firstof(transferSpec, replicationSpec).firstof(
            gcsDataSource, awsS3DataSource, httpDataSource,
            azureBlobStorageDataSource, posixDataSource, hdfsDataSource
          ).firstof(
            bucketName, listUrl, container, rootDirectory, path
          ).trailoff(45):label=SOURCE,
          firstof(transferSpec, replicationSpec).firstof(
              gcsDataSink, posixDataSink
          ).firstof(
              bucketName, rootDirectory
          ).trailoff(45):label=DESTINATION,
          latestOperationName.slice(19:).join(sep=''),
          status)
      zltable(
          name.slice(13:).join(sep=''),
          latestOperationName.slice(19:).join(sep=''))
      N)expand_tabler   Printformat)selfargs	resourcesformat_strings       r   DisplayzList.Displayf   s4    
m"
m 9dkk&B]Cr   c                    t        j                  dd      }t        j                  dd      }|j                  r t	        j
                  |j                        }nd}|j                  xs d}||t        j                  j                  j                  j                         d}| j                         t        j                  j                  u r,|j                  t         j"                  j$                  k(  rd|d<   t'        j(                  |      }t+        j,                  |j.                  |j1                  |      |j2                  dd	|j4                  
      }t7        j8                  || j:                  |       y)zCommand execution logic.r   v1N)jobNamesjobStatuses	projectIdQUERY_REPLICATION_CONFIGSdataBackend)filterpageSizetransferJobs)
batch_sizebatch_size_attributefieldlimit)r   GetClientInstanceGetMessagesModule	job_namesr   add_job_prefixjob_statusesr   VALUEScoreprojectGetReleaseTrackr	   ALPHAjob_typer   r   valuejsondumpsr   YieldFromListrA   &StoragetransferTransferJobsListRequest	page_sizerE   r
   !print_transfer_resources_iteratorr7   )	r3   r4   clientmessagesformatted_job_namesrJ   filter_dictionaryfilter_stringresources_iterators	            r   RunzList.Run   s6   ##J5F%%j$7H~~%44T^^D $$,L (#&&++33779 	t00666MMW00666 *E&JJ01M#1177}7M>>'jj //0B04dDr   N)	r   r   r   r   detailed_helpstaticmethodr.   r7   r_   r   r   r   r   r   (   s:     -


-< P P4D6!Dr   r   c                        e Zd ZdZed        Zy)	ListAlphar   c                     t         j                  |        | j                  dt        j                  j
                  t        j                  j
                  gt        j                  j
                  d       y )Nz
--job-typez%The type of the job you want to list.)choicesdefaultr$   )r   r.   r*   r   r   rR   r   r,   s    r   r.   zListAlpha.Args   sV    IIf
!!'')<)<)B)BC  &&4	  r   N)r   r   r   r   ra   r.   r   r   r   rc   rc      s     - r   rc   ) r   
__future__r   r   r   enumrS   apitools.base.pyr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r	   #googlecloudsdk.command_lib.transferr
   r   googlecloudsdk.corer   googlecloudsdk.core.resourcer   Enumr   UniverseCompatibleReleaseTracksrO   GACommandr   DefaultUniverseOnlyrP   rc   r   r   r   <module>ru      s    % &  '   ' , / ( 9 9 * 9dii  D%%(()xD4<< xD * xDv D%%++,  - r   