
    g                     n    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  G d dej                        Z
y	)
z?Client for interaction with Operations CRUD on API Gateway API.    )absolute_import)division)unicode_literals)base)waiterc                   &    e Zd ZdZddZd ZddZy)OperationsClientz6Client for operation objects on Cloud API Gateway API.Nc                     t         j                  j                  | |dd       | j                          | j	                  dd       y )N%ApigatewayProjectsLocationsOperationsprojects_locations_operations)clientmessage_baseservice_name
operationsT)is_operations)r   
BaseClient__init__	DefineGet
DefineList)selfr   s     4lib/googlecloudsdk/api_lib/api_gateway/operations.pyr   zOperationsClient.__init__   sA    OO<4	  6 	NNOOLO5    c                     | j                   j                  |j                               }| j                  j	                  |      S )zCancel an operation.

    Args:
      operation_ref: The message to process (expected to be of type Operation)

    Returns:
      (Empty) The response message.
    )name)messages2ApigatewayProjectsLocationsOperationsCancelRequestRelativeNameserviceCancel)r   operation_refreqs      r   r   zOperationsClient.Cancel'   sA     --
J
J'') K +C <<s##r   c                     | t        j                  | j                        }n t        j                  || j                        }|dj	                  |j                               }t        j                  |||      S )a  Waits for the given google.longrunning.Operation to complete.

    Args:
      operation_ref: 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 Operation or the Resource the Operation is associated with.
    z&Waiting for Operation [{}] to complete)r   CloudOperationPollerNoResourcesr   CloudOperationPollerformatr   WaitFor)r   r    messager   pollers        r   WaitForOperationz!OperationsClient.WaitForOperation5   st    0 55
,,f **

,,f 8??

$
$
&(g >>&-99r   )N)NN)__name__
__module____qualname____doc__r   r   r)    r   r   r	   r	      s    >6$$:r   r	   N)r-   
__future__r   r   r   "googlecloudsdk.api_lib.api_gatewayr   googlecloudsdk.api_lib.utilr   r   r	   r.   r   r   <module>r2      s*     F &  ' 3 .?:t ?:r   