
    
                        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                  ej                   j"                  ej                   j$                         G d
 dej&                               Zy)z)Command to tail logs for a job execution.    )absolute_import)division)unicode_literals)base)read)flags)	streaming)
propertiesc                   0    e Zd ZdZdddZed        Zd Zy)Tailz'Tail logs for Cloud Run job executions.z          {command} tails log-entries for a particular
          Cloud Run job exeuction in real time.  The log entries are formatted for
          consumption in a terminal.
          a            To tail log entries for a Cloud Run job exeuction, run:

            $ {command} my-job-execution

          To tail log entries with severity ERROR or higher, run:

            $ {command} my-job-execution --log-filter="severity>=ERROR"

          Detailed information about filters can be found at:
          [](https://cloud.google.com/logging/docs/view/advanced_filters)
          )DESCRIPTIONEXAMPLESc                 T    | j                  dd       t        j                  |        y )N	executionzName for a Cloud Run job.)help)add_argumentread_logs_libLogFilterArgs)parsers    ,lib/surface/run/jobs/executions/logs/tail.pyArgsz	Tail.Args4   s$    
*EF'    c                     g }|j                  d      r|j                  |j                         |j                  ddz         |j                  d|j                  z         |j                  dt	        j
                  |d      z         |j                  d       t        j                  j                  j                  j                  d	      }d
j                  |      }t        j                         } ||d|      }| j                  |      S )N
log_filterzresource.type=%scloud_run_jobz-labels."run.googleapis.com/execution_name"=%szresource.labels.location=%sT)promptzseverity>=DEFAULT)required run)
project_id
log_formatr   )IsSpecifiedappendr   r   r   	GetRegionr
   VALUEScoreprojectGetjoinr	   LogStreamingWrapper _DefaultOperationResponseHandler)selfargsfiltersr    
filter_strcommand_executorresponses          r   RunzTail.Run9   s    G%nnT__%NN%78NN7$..H NN%T(JJ NN&'""''//33T3BJ'"J 446%JH 00::r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r2    r   r   r   r      s/    /
-( ( (;r   r   N)r6   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.logsr   r   googlecloudsdk.command_lib.runr   r	   googlecloudsdk.corer
   ReleaseTracksReleaseTrackALPHABETABinaryBackedCommandr   r9   r   r   <module>rD      sk    0 &  ' ( A 0 4 * D%%++T->->-C-CD.;4## .; E.;r   