
                             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 d
Z G d de
j                        Zy)z+service-management operations list command.    )absolute_import)division)unicode_literals)
list_pager)services_util)base)arg_parsers)common_flagsa  Apply a Boolean filter _EXPRESSION_ to each resource item to be listed.
If the expression evaluates as True then that item is listed.

The available filter fields are startTime and done. Unrecognized fields will
cause an error.

startTime is an ISO 8601 datetime and supports >=, >, <=, and < operators. The
datetime value must be wrapped in quotation marks. For example:

  --filter='startTime < "2017-03-20T16:02:32"'

done is a boolean value and supports = and != operators.c                   &    e Zd ZdZed        Zd Zy)Lista  List operations for a project.

     This command will list operations for a service, optionally matching
     a particular filter.

     ## EXAMPLES
     To list all operations for a service named
     `api.endpoints.proj.cloud.goog`, run:

       $ {command} --service=api.endpoints.proj.cloud.goog

     To list only operations which are complete, add the `--filter` argument
     with a status filter:

       $ {command} --service=api.endpoints.proj.cloud.goog --filter='done = true'

     To list only operations begun after a certain point in time, add the
     `--filter` argument with an ISO 8601 datetime startTime filter:

       $ {command} --service=api.endpoints.proj.cloud.goog --filter='startTime >= "2017-02-01"'
  c                 *   t        j                  dd      j                  |        t        j                  j                  |        | j                  ddt               | j                  j                  d       | j                  j                  d       y)	zArgs is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go
          on the command line after this command. Positional arguments are
          allowed.
    zfor which to list operationsz	--service)suffix	flag_namez--filter
EXPRESSION)metavarhelpz4table(name, done, metadata.startTime.date(tz=LOCAL))N)r
   producer_service_flagAddToParserr   FILTER_FLAGRemoveFromParseradd_argument_FILTER_HELPdisplay_info	AddFormatAddCacheUpdater)parsers    (lib/surface/endpoints/operations/list.pyArgsz	List.ArgsG   s     &&-*{62%%f-
L   !!>@
''-    c                    t        j                         }t        j                         }t        j                  |j
                        }dj                  |      }|j                  r%|dj                  |j                        z  }d|_        |j                  |      }t        j                  |j                  ||j                  d|j                  d      S )zRun 'service-management operations list'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      The list of operations for this project.
    zserviceName="{0}"z
 AND ({0})N)filterpageSize
operations)limitbatch_size_attribute
batch_sizefield)r   GetMessagesModuleGetClientInstancer	   GetServiceNameFromArgserviceformatr!   &ServicemanagementOperationsListRequestr   YieldFromListr#   r$   	page_size)selfargsmessagesclientr+   
msg_filtermsgs          r   RunzList.Run[   s     ..0H,,.F//=G$++G4J{{L''44jdk

9
9
9
LC##jj'>> r   N)__name__
__module____qualname____doc__staticmethodr   r6    r   r   r   r   .   s     . . .&r   r   N)r:   
__future__r   r   r   apitools.base.pyr    googlecloudsdk.api_lib.endpointsr   googlecloudsdk.callioper   $googlecloudsdk.command_lib.endpointsr	   r
   r   ListCommandr   r<   r   r   <module>rC      s=     2 &  ' ' : ( < = H4 Hr   