
                         R   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
 ej                   ej                  ej                  j                  ej                  j                  ej                  j                          G d d	ej"                                      Zd
dde_        y)z'logging copy' command.    )absolute_import)division)unicode_literals)util)base)
console_ioc                   ,    e Zd ZdZed        Zd Zd Zy)CopyzCopy log entries.c                     | j                  dd       | j                  dd       | j                  ddd	       | j                  d
dd	       t        j                  | d       y)z Register flags for this command.	bucket_idz:Id of the log bucket to copy logs from. Example: my-bucket)helpdestinationzjDestination to copy logs to. Example: Cloud Storage bucket: storage.googleapis.com/my-cloud-storage-bucketz
--locationTzLocation of the log bucket.)requiredr   z--log-filterFzA filter specifying which log entries to copy. The filter must be no more than 20k characters. An empty filter matches all log entries.zlog entries to copyN)add_argumentr   AddParentArgs)parsers    lib/surface/logging/copy.pyArgsz	Copy.Args!   s     I   >   t*G   7	   	v45    c                    |j                   st        j                  dd       t        j                  t        j                  t        j
                  |      d|j                        d|j                        }t        j                         j                  |j                  |j                   |      }t        j                         j                  j                  |      S )Nz(An empty filter matches all log entries.T)cancel_on_no	locationsbuckets)r   filtername)
log_filterr   PromptContinuer   CreateResourceNameGetParentFromArgslocationr   GetMessagesCopyLogEntriesRequestr   	GetCliententriesr
   )selfargsparent_namerequests       r   _Runz	Copy._Run>   s    ??
44I ))""4(+t}}	F4>>#K  66$$T__; 7 PG >>##((11r   c                 $    | j                  |      S )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:
      A copy_log_entries operation.

    )r)   )r%   r&   s     r   RunzCopy.RunL   s     99T?r   N)__name__
__module____qualname____doc__staticmethodr   r)   r+    r   r   r
   r
      s#    
 6 682r   r
   za        {command} starts the process to copy log entries from a log bucket to a destination.
    aN          To start a copy log entries operation, run:

          $ {command} BUCKET_ID DESTINATION --location=LOCATION

        To copy log entries in a specific time window, run:

          $ {command} BUCKET_ID DESTINATION --location=LOCATION --log-filter='timestamp<="2021-05-31T23:59:59Z" AND timestamp>="2021-05-31T00:00:00Z"'
    )DESCRIPTIONEXAMPLESN)r/   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   googlecloudsdk.core.consoler   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETAGACommandr
   detailed_helpr1   r   r   <module>r@      s     &  ' / ( 2 T..33T5F5F5I5I94<< 9 9z		 r   