
                             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d
lmZ  G d de	j                         Zy)z-The gcloud firestore operations list command.    )absolute_import)division)unicode_literals)
operations)rewrite_backend)base)flags)
properties)resource_projection_specc                   4    e Zd ZdZddiZed        Zd Zd Zy)Lista)  List pending Cloud Firestore admin operations and their status.

  Filters are case-sensitive and have the following syntax:

    field = value [AND [field = value]] ...

  Only the logical `AND` operator is
  supported; space-separated items are treated as having an implicit `AND`
  operator.
  EXAMPLESz          To retrieve information about recent operations, run:

            $ {command}

          To only list operations that are done, run:

            $ {command} --filter="done:true"
      c                     t         j                  j                  | t        j                         t         j
                  j                  | t        j                         t        j                  |        y)z Register flags for this command.N)r   PAGE_SIZE_FLAG
SetDefaultr   DEFAULT_PAGE_SIZE
LIMIT_FLAGr	   AddDatabaseIdFlag)parsers    (lib/surface/firestore/operations/list.pyArgsz	List.Args6   sH     	""6:+G+GHOOvz'C'CD	F#    c                    | j                  |j                  |      \  }}||_        t        j                  t        j
                  j                  j                  j                  d      |j                  |j                  |      S )NT)required)projectdatabaselimitoperation_filter)_ConvertFilterfilterr   ListOperationsr
   VALUEScorer   Getr   r   )selfargsfrontend_filterbackend_filters       r   RunzList.Run=   sk    &*&9&9$++t&L#O^!DK$$!!&&..22D2Ajj'	) )r   c                     t        j                         }|j                         }t        j                  |j
                  |j                        }|j                  ||      S )aT  Translates user-provided filter spec into one our backend understands.

    Args:
      expression: a filter spec to translate
      args: the args namespace object
    Returns:
      A tuple of string filter specs. The first is the frontend spec for post
      filtering, the second is a spec that the Firestore Admin API understands.
    )symbolsaliases)defaults)r   OperationsRewriteBackendGetDisplayInfor   ProjectionSpec
transformsr,   Rewrite)r%   
expressionr&   operation_rewrite_backenddisplay_infor-   s         r   r   zList._ConvertFilterG   sY     !0 H H J&&(L'66''1E1EGH$,,Z(,KKr   N)	__name__
__module____qualname____doc__detailed_helpstaticmethodr   r)   r    r   r   r   r      s7    	 
- $ $)Lr   r   N)r9   
__future__r   r   r    googlecloudsdk.api_lib.firestorer   r   googlecloudsdk.callioper   $googlecloudsdk.command_lib.firestorer	   googlecloudsdk.corer
   googlecloudsdk.core.resourcer   ListCommandr   r<   r   r   <module>rD      s9    4 &  ' 7 < ( 6 * A8L4 8Lr   