
    p                     t    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 r
S	 rS
 rSS jrS rS rS rS rg)zHUseful commands for interacting with the Cloud Datastore Operations API.    )
list_pager)apis)waiter)	resourcesv1d   c                  8    [         R                  " S[        5      $ )z2Returns the Cloud Datastore client for operations.	datastore)r   GetClientInstance_OPERATIONS_API_VERSION     2lib/googlecloudsdk/api_lib/datastore/operations.py	GetClientr          			-D	EEr   c                  *    [        5       R                  $ )z@Returns the service for interacting with the Operations service.)r   projects_operationsr   r   r   
GetServicer   !   s    		(	((r   c                  8    [         R                  " S[        5      $ )z=Import and return the appropriate operations messages module.r
   )r   GetMessagesModuler   r   r   r   GetMessagesr   &   r   r   Nc           	          [        5       R                  USR                  U 5      S9nU(       a  UO[        n[        R
                  " [        5       UUUSSS9$ )aM  Lists all of the Datastore operations.

Args:
  project: the project to list operations for, a string.
  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 google.longrunning.Operations.
zprojects/{0})filtername
operationspageSize)limit
batch_sizefieldbatch_size_attribute)r   &DatastoreProjectsOperationsListRequestformatDEFAULT_PAGE_SIZEr   YieldFromListr   )projectr   operation_filterlist_requestr   s        r   ListOperationsr(   +   s^     EEN$9$9'$B F D,u#4*		!	!l%
' 'r   c                 ^    [        5       R                  [        5       R                  U S95      $ )z=Returns the google.longrunning.Operation with the given name.r   )r   Getr   %DatastoreProjectsOperationsGetRequestr*   s    r   GetOperationr-   C   s,    			m99t9D
F Fr   c                 ^    [        5       R                  [        5       R                  U S95      $ )z=Cancels the google.longrunning.Operation with the given name.r*   )r   Cancelr   (DatastoreProjectsOperationsCancelRequestr*   s    r   CancelOperationr1   I   ,    			m<<$<G
I Ir   c                 ^    [        5       R                  [        5       R                  U S95      $ )z=Deletes the google.longrunning.Operation with the given name.r*   )r   Deleter   (DatastoreProjectsOperationsDeleteRequestr*   s    r   DeleteOperationr6   O   r2   r   c                     [         R                  R                  U R                  SS9n[        R
                  " [        5       5      n[        R                  " X!SR                  UR                  5       5      5      $ )z=Waits for the given google.longrunning.Operation to complete.zdatastore.projects.operations)
collectionzWaiting for [{0}] to finish)
r   REGISTRYParser   r   CloudOperationPollerNoResourcesr   WaitForr"   RelativeName)	operationoperation_refpollers      r   WaitForOperationrA   U   sg    $$**nn!@ + B-11*,?&	#**=+E+E+GH
J Jr   )NN)__doc__apitools.base.pyr   googlecloudsdk.api_lib.utilr   r   googlecloudsdk.corer   r   r#   r   r   r   r(   r-   r1   r6   rA   r   r   r   <module>rF      sU    O ( , . )   F
)
F
'0FIIJr   