
                         j    S r SSKJr  SSKJr  SSKJr  SSKJr  Sr	S r
SS	 jrS
 rS rS rS rS rg)zHUseful commands for interacting with the Cloud Firestore Operations API.    )
list_pager)	api_utils)waiter)	resourcesd   c                  @    [         R                  " 5       R                  $ )z@Returns the service for interacting with the Operations service.)r   	GetClientprojects_databases_operations     2lib/googlecloudsdk/api_lib/firestore/operations.py_GetOperationServicer      s    					<	<<r   Nc           	          [         R                  " 5       R                  USR                  X5      S9nU(       a  UO[        n[
        R                  " [        5       UUUSSS9$ )a  Lists all of the Firestore operations.

Args:
  project: the project to list operations for, a string.
  database: the database to list operations for, a string. Defaults to the
    default database.
  limit: the maximum number of operations to return, an integer. Defaults to
    positive infinity if unset.
  operation_filter: a filter to apply to operations, a string.

Returns:
  a generator of Operations.
zprojects/{0}/databases/{1})filtername
operationspageSize)limit
batch_sizefieldbatch_size_attribute)r   GetMessages/FirestoreProjectsDatabasesOperationsListRequestformatDEFAULT_PAGE_SIZEr   YieldFromListr   )projectdatabaser   operation_filterlist_requestr   s         r   ListOperationsr!      sk     MM!+227E N   u#4*		!	!%
 r   c                 t    [        5       R                  [        R                  " 5       R	                  U S95      $ )z=Returns the google.longrunning.Operation with the given name.r   )r   Getr   r   .FirestoreProjectsDatabasesOperationsGetRequestr#   s    r   GetOperationr&   >   s8    			#	#LL M 
 r   c                 t    [        5       R                  [        R                  " 5       R	                  U S95      $ )z*Cancels the Operation with the given name.r#   )r   Cancelr   r   1FirestoreProjectsDatabasesOperationsCancelRequestr#   s    r   CancelOperationr*   G   8    			&	&OO P 
 r   c                 t    [        5       R                  [        R                  " 5       R	                  U S95      $ )z*Deletes the Operation with the given name.r#   )r   Deleter   r   1FirestoreProjectsDatabasesOperationsDeleteRequestr#   s    r   DeleteOperationr/   P   r+   r   c                 \    [         R                  " 5       R                  U S9n[        U5      $ )*Waits for the given Operation to complete.r#   )r   r   GoogleLongrunningOperationWaitForOperation)operation_name	operations     r   WaitForOperationWithNamer6   Y   s1    ##%@@ A ) 
)	$$r   c                    [         R                  R                  U R                  S[        R
                  S9n[        R                  " [        5       S 5      n[        R                  " X!SR                  UR                  5       5      5      $ )r1   z'firestore.projects.databases.operations)
collectionapi_versionc                 "    U R                  5       $ )N)RelativeName)xs    r   <lambda>"WaitForOperation.<locals>.<lambda>i   s    (8r   zWaiting for [{0}] to finish)r   REGISTRYParser   r   FIRESTORE_API_VERSIONr   CloudOperationPollerNoResourcesr   WaitForr   r;   )r5   operation_refpollers      r   r3   r3   b   sz    $$**nn:11 + 3- 118& 
#**=+E+E+GH
J Jr   )NN)__doc__apitools.base.pyr    googlecloudsdk.api_lib.firestorer   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r   r   r!   r&   r*   r/   r6   r3   r   r   r   <module>rK      sC    O ( 6 . ) =
>%Jr   