
    C                        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
  \R                  \R                  " \R                  R                  5      \R                   " S S	\R                   5      5       5       5       rS
SS.\l        g)z'logging redact' command.    )absolute_import)division)unicode_literals)util)base)
console_ioc                   4    \ rS rSrSr\S 5       rS rS rSr	g)Redact   zRedact log entries.c                     U R                  SSS9  U R                  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.	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ArgsRedact.Args    s     ;   t*C   7	   9	   	v67    c                    UR                   (       d  [        R                  " SSS9  [        R                  " [        R                  " [        R
                  " U5      SUR                  5      SUR                  5      n[        R                  " 5       R                  UR                   X!R                  S9n[        R                  " 5       R                  R                  U5      $ )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   _RunRedact._Run?   s    ??
44 ))""4(+t}}	
 	K  88[ 9 G >>##**733r   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:
  A redact_log_entries operation.
)r+   )r'   r(   s     r   Run
Redact.RunS   s     99T?r    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   r+   r.   __static_attributes__r0   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)r5   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   googlecloudsdk.core.consoler   DefaultUniverseOnlyReleaseTracksReleaseTrackGAHiddenCommandr
   detailed_helpr0   r   r   <module>rE      s      &  ' / ( 2 D%%(()@T\\ @  * @H	 r   