
    C                        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                   G d d	ej                                              Zd
dde_        y)z'logging redact' command.    )absolute_import)division)unicode_literals)util)base)
console_ioc                   ,    e Zd ZdZed        Zd Zd Zy)RedactzRedact log entries.c                     | j                  dd       | j                  ddd       | j                  dd	d
       | j                  ddd       t        j                  | d       y)z Register flags for this command.	bucket_idz,Log bucket from which to redact log entries.)helpz
--locationTzLocation of the bucket.)requiredr   z--log-filterFzA filter specifying which log entries to Redact. The filter must be no more than 20k characters. An empty filter matches all log entries.z--reasonzThe reason for the redaction. This field will be recorded in redacted log entries and should omit sensitive information. Required to be less than 1024 characters.zlog entries to redactN)add_argumentr   AddParentArgs)parsers    lib/surface/logging/redact.pyArgszRedact.Args    s     ;   t*C   7	   9	   	v67    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)filternamereason)
log_filterr   PromptContinuer   CreateResourceNameGetParentFromArgslocationr   GetMessagesRedactLogEntriesRequestr   	GetCliententriesr
   )selfargsbucket_namerequests       r   _RunzRedact._Run?   s    ??
44 ))""4(+t}}	
 	K  88[ 9 G >>##**733r   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 redact_log_entries operation.
    )r)   )r%   r&   s     r   Runz
Redact.RunS   s     99T?r   N)__name__
__module____qualname____doc__staticmethodr   r)   r+    r   r   r
   r
      s#     8 8<4(
r   r
   zR        {command} starts the process to redact log entries from a log bucket.
    a          To start a redact log entries operation, run:

          $ {command} "BUCKET_ID --location=LOCATION --reason='redacting logs'"

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

          $ {command} "BUCKET_ID  --location=LOCATION --reason='redacting logs within a window' --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GAHiddenCommandr
   detailed_helpr1   r   r   <module>r?      s      &  ' / ( 2 D%%(()@T\\ @  * @H	 r   