
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	K
Jr  SS
KJr   " S S\	R                  5      rg)z5Implementation of gcloud dataflow logs list command.
    )absolute_import)division)unicode_literals)apis)arg_parsers)base)dataflow_util)	job_utils)timesc                   .    \ rS rSrSr\S 5       rS rSrg)List   a  Retrieve the job logs for a specific job.

Retrieves the job logs from a specified job using the Dataflow Messages API
with at least the specified importance level. Can also be used to display
logs between a given time period using the --before and --after flags. These
logs are produced by the service and are distinct from worker logs. Worker
logs can be found in Cloud Logging.

## EXAMPLES

Retrieve only error logs:

  $ {command} --importance=error

Retrieve all logs after some date:

  $ {command} --after="2016-08-12 00:00:00"

Retrieve logs from this year:

  $ {command} --after=2018-01-01

Retrieve logs more than a week old:

  $ {command} --before=-P1W
c                 r   [         R                  " U 5        [        R                  R	                  U 5        [        R
                  R	                  U 5        [        R                  R	                  U 5        [        R                  R	                  U 5        U R                  S[        R                  R                  SS9  U R                  S[        R                  R                  SS9  U R                  S/ SQSS	S
9  U R                  R                  S5        SSSSSS.0nU R                  R                  U5        g )Nz--afterzOnly display messages logged after the given time. See $ gcloud topic datetimes for information on time formats. For example, `2018-01-01` is the first day of the year, and `-P2W` is 2 weeks ago.)typehelpz--beforezqOnly display messages logged before the given time. See $ gcloud topic datetimes for information on time formats.z--importance)debugdetailedwarningerrorr   z7Minimum importance a message must have to be displayed.)choicesdefaultr   z
          table[no-heading,pad=1](
            messageImportance.enum(dataflow.JobMessage),
            time.date(tz=LOCAL):label=TIME,
            id,
            messageText:label=TEXT
          )
    zdataflow.JobMessage::enumdDWE)JOB_MESSAGE_DETAILEDJOB_MESSAGE_DEBUGJOB_MESSAGE_WARNINGJOB_MESSAGE_ERROR)r
   ArgsForJobRefr   SORT_BY_FLAGRemoveFromParserURI_FLAG
ASYNC_FLAGPAGE_SIZE_FLAGadd_argumentr   DatetimeParsedisplay_info	AddFormatAddTransforms)parsersymbolss     !lib/surface/dataflow/logs/list.pyArgs	List.Args:   s$   F#&&v.MM""6*OO$$V,((0
!!'''  ) !!''N  P
 9F	  H !! # 	 + # " 	- G %%g.    c                    [         R                  " U5      n[        R                  R                  R
                  nUR                  UR                  UR                  UR                  S.n[        R                  R	                  UR                  UR                  UR                  UR                  =(       a    XAR                     UR                  =(       a     [        R                   " UR                  5      UR"                  =(       a     [        R                   " UR"                  5      S9n[$        R&                  " UR                  UR                  UR                  [        R                  R)                  5       UUR*                  SSS9$ )zThis is what gets called when the user runs this command.

Args:
  args: all the arguments that were provided to this command invocation.

Returns:
  None on success, or a string containing the error message.
)r   r   r   r   )	projectIdjobIdlocationminimumImportance	startTimeendTimepageSizejobMessages)job_id
project_id	region_idservicerequest
batch_sizebatch_size_attributefield)r
   ExtractJobRefr   MessagesLIST_REQUEST MinimumImportanceValueValuesEnumr   r   r   r   r3   r4   r5   
importanceafterr   FormatDateTimebeforer	   YieldFromList
GetServicelimit)selfargsjob_refimportance_enumimportance_mapr?   s         r.   RunList.Rung   s)    %%d+G 	""CC  !22#88 22"66	N mm((##mm!!??N~oo/N **A!5!5djj!AA 4 4T[[ A ) 	CG &&}}$$""((*::' r1    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr/   rS   __static_attributes__rU   r1   r.   r   r      s!    6 */ */X'r1   r   N)rZ   
__future__r   r   r   googlecloudsdk.api_lib.dataflowr   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.dataflowr	   r
   googlecloudsdk.core.utilr   ListCommandr   rU   r1   r.   <module>rc      s;    '  ' 0 / ( = 9 *p4 pr1   