
    }                         S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSK	Jr   " S	 S
\
R                  5      r " S S\R                  5      rS rS rS rg)zCRM operations utilities.    )absolute_import)division)unicode_literals)tags)waiter)
exceptions)	resourcesc                       \ rS rSrSrg)OperationError    N)__name__
__module____qualname____firstlineno____static_attributes__r       =lib/googlecloudsdk/command_lib/resource_manager/operations.pyr   r      s    r   r   c                   $    \ rS rSrSrS rS rSrg)ReturnOperationPoller   zPolls for operations that retrieve the operation rather than the resource.

This is needed for Delete operations, where the response is Empty. It is also
needed for services that do not have a Get* method, such as TagBindings.
c                     Xl         g)zSets up poller for polling operations.

Args:
  operation_service: apitools.base.py.base_api.BaseApiService, api service
    for retrieving information about ongoing operation.
Noperation_service)selfr   s     r   __init__ReturnOperationPoller.__init__&   s
     /r   c                     U$ )a.  Overrides.

Response for Deletion Operation is of type google.protobuf.Empty and hence
we can return the operation itself as the result. For operations without a
Get[Resource] method, we have no choice but to return the operation.

Args:
  operation: api_name_messages.Operation.

Returns:
  operation
r   )r   	operations     r   	GetResultReturnOperationPoller.GetResult/   s
     r   r   N)r   r   r   r   __doc__r   r    r   r   r   r   r   r      s    /r   r   c                 V    [        [        R                  " 5       5      n[        XU5      $ )a  Waits for the given google.longrunning.Operation to complete.

Args:
  operation: The operation to poll.
  message: String to display for default progress_tracker.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error

Returns:
  operation
)r   r   OperationsService_WaitForOperation)r   messagepollers      r   WaitForReturnOperationr(   ?   s$     !!7!7!9:&	9v	66r   c                 n    [         R                  " U[        R                  " 5       5      n[	        XU5      $ )ax  Waits for the given google.longrunning.Operation to complete.

Args:
  operation: The operation to poll.
  message: String to display for default progress_tracker.
  service: The service to get the resource after the long running operation
    completes.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error

Returns:
  The TagKey or TagValue resource.
)r   CloudOperationPollerr   r$   r%   )r   r&   servicer'   s       r   WaitForOperationr,   P   s,     &&w0F0F0HI&	9v	66r   c                     UR                  U 5      (       a  UR                  U 5      $ [        R                  R	                  U R
                  SS9n[        R                  " X#U5      $ )Nzcloudresourcemanager.operations)
collection)IsDoner    r	   REGISTRYParsenamer   WaitFor)r   r&   r'   operation_refs       r   r%   r%   c   s[    ]]9 I&&$$**nn!B + D-	w	77r   N)r"   
__future__r   r   r   'googlecloudsdk.api_lib.resource_managerr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r	   Errorr   r*   r   r(   r,   r%   r   r   r   <module>r:      sS      &  ' 8 . * )Z%% F77 @7"7&8r   