
                         j   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                  e	j                   j"                  e	j                   j$                  e	j                   j&                         G d
 de	j(                                      Zddde_        y)z"'logging operations list' command.    )absolute_import)division)unicode_literals)util)arg_parsers)base)log)resource_projectorc                   ,    e Zd ZdZed        Zd Zd Zy)ListzList long running operations.c                 V   | j                  ddd       | j                  ddt        j                  dd             | j                  d	t        d
       t        j
                  j                  |        t        j                  j                  |        t        j                  | d       y)z Register flags for this command.z
--locationTzLocation of the operations.)requiredhelpz--operation-filterz:Filter expression that specifies the operations to return.z'Not all operation types are supported.
)defaultuniverse_helpz--page-tokenzHThe next_page_token value returned from a previous List request, if any.)typer   zoperations to listN)
add_argumentr   UniverseHelpTextstrr   URI_FLAGRemoveFromParserFILTER_FLAGr   AddParentArgs)parsers    &lib/surface/logging/operations/list.pyArgsz	List.Args#   s     t*G  I
))LD	
  	 	   	MM""6*%%f-v34    c              #   X  K   t        j                  t        j                  |      d|j                        }t        j                         j                  ||j                  |j                  |j                        }t        j                         j                  j                  |      }d| _        |j                  D ]O  }| | j                  rt        j                  |      }|j!                  di       j!                  dd      | _        Q |j"                  r|j"                   yyw)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.

    Yields:
      A list of operations.
    	locations)namefilterpageSize	pageTokenFmetadatacancellationRequested N)r   CreateResourceNameGetParentFromArgslocationGetMessages-LoggingProjectsLocationsOperationsListRequestoperation_filter	page_size
page_token	GetClientprojects_locations_operationsr   _cancellation_requested
operationsr
   MakeSerializablegetnextPageToken)selfargsoperation_namerequestresult	operationserialize_ops          r   RunzList.Run?   s      ,,t$k4==BN  NN$$//	 O G ^^;;@@IF#(D &&	o)))::9E'3'7'7
B'G'K'K#R()$	 '     s   CD*AD*c                 \    | j                   r t        j                  j                  d       y y )NzzNote: Cancellation happens asynchronously. It may take up to 10 minutes for the operation's status to change to cancelled.)r1   r	   statusPrint)r6   resources_were_displayeds     r   EpilogzList.Epilog^   s)    ##	jjGH $r   N)__name__
__module____qualname____doc__staticmethodr   r=   rB    r   r   r   r      s$    
 &5 56!>Hr   r   a+  
        Return a list of long running operations in the given LOCATION. The
        operations were scheduled by other gcloud commands.

        For example, a CopyLogEntries operation may be scheduled by the command:
        `gcloud logging copy BUCKET_ID DESTINATION --location=LOCATION`.

        The `--operation-filter` flag is required and must specify the
        `request_type`. Supported request types include but are not limited to:
        `CopyLogEntries`, `CreateBucket` and `UpdateBucket`.

        Additional supported filter expressions include: `operation_start_time`,
        `operation_finish_time` and `operation_state`. These can be combined
        with the case-sensitive keyword `AND` between them.

        For `operation_start_time` and `operation_end_time`, the operators >=,
        >, <=, and < are supported.

        Timestamps must be in either RFC3339 or ISO8601 formats. If the
        timestamp contains a time value, then it must be quoted. For examples:
        "YYYY-MM-DDTHH:MM:SSZ", "YYYY-MM-DDTHH:MM:SS.mmmZ", "YY-MM-DD",
        "YYYY-MM-DDTHH:MM:SS-0000", "YYYY-MM-DDTHH:MM+0000", "YYYY-MM-DD",
        YYYY-MM-DD, YY-MM-DD, etc.

        The `operation_state` filter expression can be used to filter for
        operations that are in a specific state. The value can be one of the
        following: `SCHEDULED`, `WAITING_FOR_PRECONDITIONS`, `RUNNING`,
        `SUCCESS`, `FAILURE`, `CANCELLED`, `PENDING`.

        For `operation_state`, the operators = and != are supported.

        Other filter options are not supported.
        a          To list CopyLogEntries operations, run:

            $ {command} --location=LOCATION --operation-filter='request_type=CopyLogEntries'

        To list CopyLogEntries operations that started after a specified time, run:

            $ {command} --location=LOCATION --operation-filter='request_type=CopyLogEntries AND operation_start_time>="2023-11-20T00:00:00Z"'

        To list CopyLogEntries operations that finished before a specified time, run:

            $ {command} --location=LOCATION --operation-filter='request_type=CopyLogEntries AND operation_finish_time<="2023-11-20T00:00:00Z"'

        To list CopyLogEntries operations that completed successfully, run:

            $ {command} --location=LOCATION --operation-filter='request_type=CopyLogEntries AND operation_state=SUCCESS'

        To list CopyLogEntries operations that have not failed, run:

            $ {command} --location=LOCATION --operation-filter='request_type=CopyLogEntries AND operation_state!=FAILURE'
        )DESCRIPTIONEXAMPLESN)rF   
__future__r   r   r   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   r   googlecloudsdk.corer	   googlecloudsdk.core.resourcer
   UniverseCompatibleReleaseTracksReleaseTrackGABETAALPHAListCommandr   detailed_helprH   r   r   <module>rX      s    ) &  ' / / ( # ; $++00$2C2C2I2IBH4 BH BHL BE7 r   