
    a                     j   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  \
R                  \
R                  " \
R                   R"                  \
R                   R$                  \
R                   R&                  5       " S
 S\
R(                  5      5       5       rSSS.\l        g)z'logging read' command.    )absolute_import)division)unicode_literals)common)util)arg_parsers)base)readc                   4    \ rS rSrSr\S 5       rS rS rSr	g)Read   zRead log entries.c                 z   [         R                  " U 5        [         R                  " U 5        U R                  5       nUR	                  S[
        R                  " 5       SSS9  UR                  SS9nUR	                  SSS	S
S9  UR	                  SSSS9  UR	                  SSSS9  [        R                  " U S5        g)z Register flags for this command.z--resource-namesRESOURCEa!  Resource name(s) to read logs from. A resource can either be an top-level resource (e.g., "projects/my-project") or a full log view resource path (e.g., "projects/my-project/locations/my-location/buckets/my-bucket/views/my-view"). Multiple resources can be specified, separated by a comma.)typemetavarhelpzUThese arguments are used in conjunction with the parent to construct a view resource.)r   z
--locationTLOCATIONzmLocation of the log bucket. If this argument is provided then `--bucket` and `--view` must also be specified.)requiredr   r   z--bucketziId of the log bucket. If this argument is provided then `--location` and `--view` must also be specified.)r   r   z--viewzeId of the view. If this argument is provided then `--location` and `--bucket` must also be specified.zlog entries to readN)
read_logs_libLogFilterPositionalArgsLoggingReadArgsadd_mutually_exclusive_groupadd_argumentr   ArgListadd_argument_groupr   AddParentArgs)parsertarget_group
view_groups      lib/surface/logging/read.pyArgs	Read.Args#   s     ))&1!!&)668L  "	  	 00% 1 &J :	  ; <  =
 >  ?
 	v45    c           	         [         R                  " U5      nX!R                  (       a  UR                  /O/ -  nUR                  S5      (       aw  [        R
                  " [        R
                  " [        R
                  " [        R                  " U5      SUR                  5      SUR                  5      SUR                  5      nO/UR                  S5      (       a  S nO[        R                  " U5      n[        R                  " [         R                  " USS9=(       d    S UR                  UR                  UUR                  S9$ )	Nlocation	locationsbucketsviewsresource_namesAND)operator)order_bylimitparentr)   )r   MakeTimestampFilters
log_filterIsSpecifiedr   CreateResourceNameGetParentFromArgsr%   bucketviewr   	FetchLogsJoinFiltersorderr-   r)   )selfargsfilter_clausesr.   s       r    _Run	Read._RunH   s    "77=N??t'BN
##&&

!
!%%((.T]]L& (/			;f
 
		*	+	+f %%d+f!!.5AITjj**, ,r#   c                 $    U R                  U5      $ )zThis is what gets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  The list of log entries.
)r<   )r9   r:   s     r    RunRead.Runa   s     99T?r#    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr!   r<   r?   __static_attributes__rA   r#   r    r   r      s$    
 "6 "6H,2
r#   r   a"          {command} reads log entries.  Log entries matching *log-filter* are
        returned in order of decreasing timestamps, most-recent entries first.
        If the log entries come from multiple logs, then entries from different
        logs might be intermingled in the results.
    a,          To read log entries from Google Compute Engine instances, run:

          $ {command} "resource.type=gce_instance"

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

          $ {command} "severity>=ERROR"

        To read log entries written in a specific time window, run:

          $ {command} 'timestamp<="2015-05-31T23:59:59Z" AND timestamp>="2015-05-31T00:00:00Z"'

        To read up to 10 log entries in your project's syslog log from Compute
        Engine instances containing payloads that include the word `SyncAddress`
        and format the output in `JSON` format, run:

          $ {command} "resource.type=gce_instance AND logName=projects/[PROJECT_ID]/logs/syslog AND textPayload:SyncAddress" --limit=10 --format=json

        To read a log entry from a folder, run:

          $ {command} "resource.type=global" --folder=[FOLDER_ID] --limit=1

        To read a log entry from a global log bucket, run:

          $ {command} --bucket=<bucket-id> --location=[LOCATION] --limit=1

        To read a log entry from the global ```_Required``` log bucket using the bucket's ```_Default``` log view:

          $ {command} "" --bucket=_Required --location=global --view=_Default --limit=1

        To read a log entry from a log bucket using the bucket's ```_AllLogs``` log view:

          $ {command} "" --bucket=[BUCKET_ID] --location=[LOCATION] --view=_AllLogs --limit=1

        To read a log entry from a log bucket using a custom log view that you have created for the bucket:

          $ {command} "" --bucket=[BUCKET_ID] --location=[LOCATION] --view=[VIEW_ID] --limit=1

        To read log entries from multiple resources, specify them as a
        comma-delimeted sequence with --resource-names. Each resource name can
        be specified either as a top-level resource (e.g.,
        projects/[PROJECT_ID], folders/[FOLDER_ID], etc.) or as a Log View
        resource (e.g.,
        projects/[PROJECT_ID]/locations/[LOCATION]/buckets/[BUCKET_NAME]/views/[VIEW_ID]).

          $ {command} "" --resource-names=[RESOURCE-1],[RESOURCE-2]

    )DESCRIPTIONEXAMPLESN)rF   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   r   googlecloudsdk.callioper   r	   googlecloudsdk.command_lib.logsr
   r   UniverseCompatibleReleaseTracksReleaseTrackALPHABETAGACommandr   detailed_helprA   r#   r    <module>rW      s     &  ' 1 / / ( A T..33T5F5F5I5IK4<< K K`	0	: r#   