• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2import grpc
3
4from dependencies.longrunning import operations_pb2 as dependencies_dot_longrunning_dot_operations__pb2
5from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
6
7
8class OperationsStub(object):
9  """Manages long-running operations with an API service.
10
11  When an API method normally takes long time to complete, it can be designed
12  to return [Operation][google.longrunning.Operation] to the client, and the client can use this
13  interface to receive the real response asynchronously by polling the
14  operation resource, or pass the operation resource to another API (such as
15  Google Cloud Pub/Sub API) to receive the response.  Any API service that
16  returns long-running operations should implement the `Operations` interface
17  so developers can have a consistent client experience.
18  """
19
20  def __init__(self, channel):
21    """Constructor.
22
23    Args:
24      channel: A grpc.Channel.
25    """
26    self.ListOperations = channel.unary_unary(
27        '/google.longrunning.Operations/ListOperations',
28        request_serializer=dependencies_dot_longrunning_dot_operations__pb2.ListOperationsRequest.SerializeToString,
29        response_deserializer=dependencies_dot_longrunning_dot_operations__pb2.ListOperationsResponse.FromString,
30        )
31    self.GetOperation = channel.unary_unary(
32        '/google.longrunning.Operations/GetOperation',
33        request_serializer=dependencies_dot_longrunning_dot_operations__pb2.GetOperationRequest.SerializeToString,
34        response_deserializer=dependencies_dot_longrunning_dot_operations__pb2.Operation.FromString,
35        )
36    self.DeleteOperation = channel.unary_unary(
37        '/google.longrunning.Operations/DeleteOperation',
38        request_serializer=dependencies_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.SerializeToString,
39        response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
40        )
41    self.CancelOperation = channel.unary_unary(
42        '/google.longrunning.Operations/CancelOperation',
43        request_serializer=dependencies_dot_longrunning_dot_operations__pb2.CancelOperationRequest.SerializeToString,
44        response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
45        )
46    self.WaitOperation = channel.unary_unary(
47        '/google.longrunning.Operations/WaitOperation',
48        request_serializer=dependencies_dot_longrunning_dot_operations__pb2.WaitOperationRequest.SerializeToString,
49        response_deserializer=dependencies_dot_longrunning_dot_operations__pb2.Operation.FromString,
50        )
51
52
53class OperationsServicer(object):
54  """Manages long-running operations with an API service.
55
56  When an API method normally takes long time to complete, it can be designed
57  to return [Operation][google.longrunning.Operation] to the client, and the client can use this
58  interface to receive the real response asynchronously by polling the
59  operation resource, or pass the operation resource to another API (such as
60  Google Cloud Pub/Sub API) to receive the response.  Any API service that
61  returns long-running operations should implement the `Operations` interface
62  so developers can have a consistent client experience.
63  """
64
65  def ListOperations(self, request, context):
66    """Lists operations that match the specified filter in the request. If the
67    server doesn't support this method, it returns `UNIMPLEMENTED`.
68
69    NOTE: the `name` binding below allows API services to override the binding
70    to use different resource name schemes, such as `users/*/operations`.
71    """
72    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
73    context.set_details('Method not implemented!')
74    raise NotImplementedError('Method not implemented!')
75
76  def GetOperation(self, request, context):
77    """Gets the latest state of a long-running operation.  Clients can use this
78    method to poll the operation result at intervals as recommended by the API
79    service.
80    """
81    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
82    context.set_details('Method not implemented!')
83    raise NotImplementedError('Method not implemented!')
84
85  def DeleteOperation(self, request, context):
86    """Deletes a long-running operation. This method indicates that the client is
87    no longer interested in the operation result. It does not cancel the
88    operation. If the server doesn't support this method, it returns
89    `google.rpc.Code.UNIMPLEMENTED`.
90    """
91    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
92    context.set_details('Method not implemented!')
93    raise NotImplementedError('Method not implemented!')
94
95  def CancelOperation(self, request, context):
96    """Starts asynchronous cancellation on a long-running operation.  The server
97    makes a best effort to cancel the operation, but success is not
98    guaranteed.  If the server doesn't support this method, it returns
99    `google.rpc.Code.UNIMPLEMENTED`.  Clients can use
100    [Operations.GetOperation][google.longrunning.Operations.GetOperation] or
101    other methods to check whether the cancellation succeeded or whether the
102    operation completed despite cancellation. On successful cancellation,
103    the operation is not deleted; instead, it becomes an operation with
104    an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
105    corresponding to `Code.CANCELLED`.
106    """
107    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
108    context.set_details('Method not implemented!')
109    raise NotImplementedError('Method not implemented!')
110
111  def WaitOperation(self, request, context):
112    """Waits for the specified long-running operation until it is done or reaches
113    at most a specified timeout, returning the latest state.  If the operation
114    is already done, the latest state is immediately returned.  If the timeout
115    specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
116    timeout is used.  If the server does not support this method, it returns
117    `google.rpc.Code.UNIMPLEMENTED`.
118    Note that this method is on a best-effort basis.  It may return the latest
119    state before the specified timeout (including immediately), meaning even an
120    immediate response is no guarantee that the operation is done.
121    """
122    context.set_code(grpc.StatusCode.UNIMPLEMENTED)
123    context.set_details('Method not implemented!')
124    raise NotImplementedError('Method not implemented!')
125
126
127def add_OperationsServicer_to_server(servicer, server):
128  rpc_method_handlers = {
129      'ListOperations': grpc.unary_unary_rpc_method_handler(
130          servicer.ListOperations,
131          request_deserializer=dependencies_dot_longrunning_dot_operations__pb2.ListOperationsRequest.FromString,
132          response_serializer=dependencies_dot_longrunning_dot_operations__pb2.ListOperationsResponse.SerializeToString,
133      ),
134      'GetOperation': grpc.unary_unary_rpc_method_handler(
135          servicer.GetOperation,
136          request_deserializer=dependencies_dot_longrunning_dot_operations__pb2.GetOperationRequest.FromString,
137          response_serializer=dependencies_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
138      ),
139      'DeleteOperation': grpc.unary_unary_rpc_method_handler(
140          servicer.DeleteOperation,
141          request_deserializer=dependencies_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.FromString,
142          response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
143      ),
144      'CancelOperation': grpc.unary_unary_rpc_method_handler(
145          servicer.CancelOperation,
146          request_deserializer=dependencies_dot_longrunning_dot_operations__pb2.CancelOperationRequest.FromString,
147          response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
148      ),
149      'WaitOperation': grpc.unary_unary_rpc_method_handler(
150          servicer.WaitOperation,
151          request_deserializer=dependencies_dot_longrunning_dot_operations__pb2.WaitOperationRequest.FromString,
152          response_serializer=dependencies_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
153      ),
154  }
155  generic_handler = grpc.method_handlers_generic_handler(
156      'google.longrunning.Operations', rpc_method_handlers)
157  server.add_generic_rpc_handlers((generic_handler,))
158