| 1 |
# Copyright 2020 Google LLC |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
| 16 |
|
| 17 |
"""Client and server classes corresponding to protobuf-defined services.""" |
| 18 |
|
| 19 |
import grpc |
| 20 |
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 |
| 21 |
|
| 22 |
from google.longrunning import ( |
| 23 |
operations_proto_pb2 as google_dot_longrunning_dot_operations__pb2, |
| 24 |
) |
| 25 |
|
| 26 |
|
| 27 |
class OperationsStub(object): |
| 28 |
"""Manages long-running operations with an API service. |
| 29 |
|
| 30 |
When an API method normally takes long time to complete, it can be designed |
| 31 |
to return [Operation][google.longrunning.Operation] to the client, and the client can use this |
| 32 |
interface to receive the real response asynchronously by polling the |
| 33 |
operation resource, or pass the operation resource to another API (such as |
| 34 |
Google Cloud Pub/Sub API) to receive the response. Any API service that |
| 35 |
returns long-running operations should implement the `Operations` interface |
| 36 |
so developers can have a consistent client experience. |
| 37 |
""" |
| 38 |
|
| 39 |
def __init__(self, channel): |
| 40 |
"""Constructor. |
| 41 |
|
| 42 |
Args: |
| 43 |
channel: A grpc.Channel. |
| 44 |
""" |
| 45 |
self.ListOperations = channel.unary_unary( |
| 46 |
"/google.longrunning.Operations/ListOperations", |
| 47 |
request_serializer=google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.SerializeToString, |
| 48 |
response_deserializer=google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.FromString, |
| 49 |
) |
| 50 |
self.GetOperation = channel.unary_unary( |
| 51 |
"/google.longrunning.Operations/GetOperation", |
| 52 |
request_serializer=google_dot_longrunning_dot_operations__pb2.GetOperationRequest.SerializeToString, |
| 53 |
response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, |
| 54 |
) |
| 55 |
self.DeleteOperation = channel.unary_unary( |
| 56 |
"/google.longrunning.Operations/DeleteOperation", |
| 57 |
request_serializer=google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.SerializeToString, |
| 58 |
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, |
| 59 |
) |
| 60 |
self.CancelOperation = channel.unary_unary( |
| 61 |
"/google.longrunning.Operations/CancelOperation", |
| 62 |
request_serializer=google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.SerializeToString, |
| 63 |
response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, |
| 64 |
) |
| 65 |
self.WaitOperation = channel.unary_unary( |
| 66 |
"/google.longrunning.Operations/WaitOperation", |
| 67 |
request_serializer=google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.SerializeToString, |
| 68 |
response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, |
| 69 |
) |
| 70 |
|
| 71 |
|
| 72 |
class OperationsServicer(object): |
| 73 |
"""Manages long-running operations with an API service. |
| 74 |
|
| 75 |
When an API method normally takes long time to complete, it can be designed |
| 76 |
to return [Operation][google.longrunning.Operation] to the client, and the client can use this |
| 77 |
interface to receive the real response asynchronously by polling the |
| 78 |
operation resource, or pass the operation resource to another API (such as |
| 79 |
Google Cloud Pub/Sub API) to receive the response. Any API service that |
| 80 |
returns long-running operations should implement the `Operations` interface |
| 81 |
so developers can have a consistent client experience. |
| 82 |
""" |
| 83 |
|
| 84 |
def ListOperations(self, request, context): |
| 85 |
"""Lists operations that match the specified filter in the request. If the |
| 86 |
server doesn't support this method, it returns `UNIMPLEMENTED`. |
| 87 |
|
| 88 |
NOTE: the `name` binding allows API services to override the binding |
| 89 |
to use different resource name schemes, such as `users/*/operations`. To |
| 90 |
override the binding, API services can add a binding such as |
| 91 |
`"/v1/{name=users/*}/operations"` to their service configuration. |
| 92 |
For backwards compatibility, the default name includes the operations |
| 93 |
collection id, however overriding users must ensure the name binding |
| 94 |
is the parent resource, without the operations collection id. |
| 95 |
""" |
| 96 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 97 |
context.set_details("Method not implemented!") |
| 98 |
raise NotImplementedError("Method not implemented!") |
| 99 |
|
| 100 |
def GetOperation(self, request, context): |
| 101 |
"""Gets the latest state of a long-running operation. Clients can use this |
| 102 |
method to poll the operation result at intervals as recommended by the API |
| 103 |
service. |
| 104 |
""" |
| 105 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 106 |
context.set_details("Method not implemented!") |
| 107 |
raise NotImplementedError("Method not implemented!") |
| 108 |
|
| 109 |
def DeleteOperation(self, request, context): |
| 110 |
"""Deletes a long-running operation. This method indicates that the client is |
| 111 |
no longer interested in the operation result. It does not cancel the |
| 112 |
operation. If the server doesn't support this method, it returns |
| 113 |
`google.rpc.Code.UNIMPLEMENTED`. |
| 114 |
""" |
| 115 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 116 |
context.set_details("Method not implemented!") |
| 117 |
raise NotImplementedError("Method not implemented!") |
| 118 |
|
| 119 |
def CancelOperation(self, request, context): |
| 120 |
"""Starts asynchronous cancellation on a long-running operation. The server |
| 121 |
makes a best effort to cancel the operation, but success is not |
| 122 |
guaranteed. If the server doesn't support this method, it returns |
| 123 |
`google.rpc.Code.UNIMPLEMENTED`. Clients can use |
| 124 |
[Operations.GetOperation][google.longrunning.Operations.GetOperation] or |
| 125 |
other methods to check whether the cancellation succeeded or whether the |
| 126 |
operation completed despite cancellation. On successful cancellation, |
| 127 |
the operation is not deleted; instead, it becomes an operation with |
| 128 |
an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, |
| 129 |
corresponding to `Code.CANCELLED`. |
| 130 |
""" |
| 131 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 132 |
context.set_details("Method not implemented!") |
| 133 |
raise NotImplementedError("Method not implemented!") |
| 134 |
|
| 135 |
def WaitOperation(self, request, context): |
| 136 |
"""Waits until the specified long-running operation is done or reaches at most |
| 137 |
a specified timeout, returning the latest state. If the operation is |
| 138 |
already done, the latest state is immediately returned. If the timeout |
| 139 |
specified is greater than the default HTTP/RPC timeout, the HTTP/RPC |
| 140 |
timeout is used. If the server does not support this method, it returns |
| 141 |
`google.rpc.Code.UNIMPLEMENTED`. |
| 142 |
Note that this method is on a best-effort basis. It may return the latest |
| 143 |
state before the specified timeout (including immediately), meaning even an |
| 144 |
immediate response is no guarantee that the operation is done. |
| 145 |
""" |
| 146 |
context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 147 |
context.set_details("Method not implemented!") |
| 148 |
raise NotImplementedError("Method not implemented!") |
| 149 |
|
| 150 |
|
| 151 |
def add_OperationsServicer_to_server(servicer, server): |
| 152 |
rpc_method_handlers = { |
| 153 |
"ListOperations": grpc.unary_unary_rpc_method_handler( |
| 154 |
servicer.ListOperations, |
| 155 |
request_deserializer=google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.FromString, |
| 156 |
response_serializer=google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.SerializeToString, |
| 157 |
), |
| 158 |
"GetOperation": grpc.unary_unary_rpc_method_handler( |
| 159 |
servicer.GetOperation, |
| 160 |
request_deserializer=google_dot_longrunning_dot_operations__pb2.GetOperationRequest.FromString, |
| 161 |
response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, |
| 162 |
), |
| 163 |
"DeleteOperation": grpc.unary_unary_rpc_method_handler( |
| 164 |
servicer.DeleteOperation, |
| 165 |
request_deserializer=google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.FromString, |
| 166 |
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, |
| 167 |
), |
| 168 |
"CancelOperation": grpc.unary_unary_rpc_method_handler( |
| 169 |
servicer.CancelOperation, |
| 170 |
request_deserializer=google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.FromString, |
| 171 |
response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, |
| 172 |
), |
| 173 |
"WaitOperation": grpc.unary_unary_rpc_method_handler( |
| 174 |
servicer.WaitOperation, |
| 175 |
request_deserializer=google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.FromString, |
| 176 |
response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, |
| 177 |
), |
| 178 |
} |
| 179 |
generic_handler = grpc.method_handlers_generic_handler( |
| 180 |
"google.longrunning.Operations", rpc_method_handlers |
| 181 |
) |
| 182 |
server.add_generic_rpc_handlers((generic_handler,)) |
| 183 |
|
| 184 |
|
| 185 |
# This class is part of an EXPERIMENTAL API. |
| 186 |
class Operations(object): |
| 187 |
"""Manages long-running operations with an API service. |
| 188 |
|
| 189 |
When an API method normally takes long time to complete, it can be designed |
| 190 |
to return [Operation][google.longrunning.Operation] to the client, and the client can use this |
| 191 |
interface to receive the real response asynchronously by polling the |
| 192 |
operation resource, or pass the operation resource to another API (such as |
| 193 |
Google Cloud Pub/Sub API) to receive the response. Any API service that |
| 194 |
returns long-running operations should implement the `Operations` interface |
| 195 |
so developers can have a consistent client experience. |
| 196 |
""" |
| 197 |
|
| 198 |
@staticmethod |
| 199 |
def ListOperations( |
| 200 |
request, |
| 201 |
target, |
| 202 |
options=(), |
| 203 |
channel_credentials=None, |
| 204 |
call_credentials=None, |
| 205 |
insecure=False, |
| 206 |
compression=None, |
| 207 |
wait_for_ready=None, |
| 208 |
timeout=None, |
| 209 |
metadata=None, |
| 210 |
): |
| 211 |
return grpc.experimental.unary_unary( |
| 212 |
request, |
| 213 |
target, |
| 214 |
"/google.longrunning.Operations/ListOperations", |
| 215 |
google_dot_longrunning_dot_operations__pb2.ListOperationsRequest.SerializeToString, |
| 216 |
google_dot_longrunning_dot_operations__pb2.ListOperationsResponse.FromString, |
| 217 |
options, |
| 218 |
channel_credentials, |
| 219 |
insecure, |
| 220 |
call_credentials, |
| 221 |
compression, |
| 222 |
wait_for_ready, |
| 223 |
timeout, |
| 224 |
metadata, |
| 225 |
) |
| 226 |
|
| 227 |
@staticmethod |
| 228 |
def GetOperation( |
| 229 |
request, |
| 230 |
target, |
| 231 |
options=(), |
| 232 |
channel_credentials=None, |
| 233 |
call_credentials=None, |
| 234 |
insecure=False, |
| 235 |
compression=None, |
| 236 |
wait_for_ready=None, |
| 237 |
timeout=None, |
| 238 |
metadata=None, |
| 239 |
): |
| 240 |
return grpc.experimental.unary_unary( |
| 241 |
request, |
| 242 |
target, |
| 243 |
"/google.longrunning.Operations/GetOperation", |
| 244 |
google_dot_longrunning_dot_operations__pb2.GetOperationRequest.SerializeToString, |
| 245 |
google_dot_longrunning_dot_operations__pb2.Operation.FromString, |
| 246 |
options, |
| 247 |
channel_credentials, |
| 248 |
insecure, |
| 249 |
call_credentials, |
| 250 |
compression, |
| 251 |
wait_for_ready, |
| 252 |
timeout, |
| 253 |
metadata, |
| 254 |
) |
| 255 |
|
| 256 |
@staticmethod |
| 257 |
def DeleteOperation( |
| 258 |
request, |
| 259 |
target, |
| 260 |
options=(), |
| 261 |
channel_credentials=None, |
| 262 |
call_credentials=None, |
| 263 |
insecure=False, |
| 264 |
compression=None, |
| 265 |
wait_for_ready=None, |
| 266 |
timeout=None, |
| 267 |
metadata=None, |
| 268 |
): |
| 269 |
return grpc.experimental.unary_unary( |
| 270 |
request, |
| 271 |
target, |
| 272 |
"/google.longrunning.Operations/DeleteOperation", |
| 273 |
google_dot_longrunning_dot_operations__pb2.DeleteOperationRequest.SerializeToString, |
| 274 |
google_dot_protobuf_dot_empty__pb2.Empty.FromString, |
| 275 |
options, |
| 276 |
channel_credentials, |
| 277 |
insecure, |
| 278 |
call_credentials, |
| 279 |
compression, |
| 280 |
wait_for_ready, |
| 281 |
timeout, |
| 282 |
metadata, |
| 283 |
) |
| 284 |
|
| 285 |
@staticmethod |
| 286 |
def CancelOperation( |
| 287 |
request, |
| 288 |
target, |
| 289 |
options=(), |
| 290 |
channel_credentials=None, |
| 291 |
call_credentials=None, |
| 292 |
insecure=False, |
| 293 |
compression=None, |
| 294 |
wait_for_ready=None, |
| 295 |
timeout=None, |
| 296 |
metadata=None, |
| 297 |
): |
| 298 |
return grpc.experimental.unary_unary( |
| 299 |
request, |
| 300 |
target, |
| 301 |
"/google.longrunning.Operations/CancelOperation", |
| 302 |
google_dot_longrunning_dot_operations__pb2.CancelOperationRequest.SerializeToString, |
| 303 |
google_dot_protobuf_dot_empty__pb2.Empty.FromString, |
| 304 |
options, |
| 305 |
channel_credentials, |
| 306 |
insecure, |
| 307 |
call_credentials, |
| 308 |
compression, |
| 309 |
wait_for_ready, |
| 310 |
timeout, |
| 311 |
metadata, |
| 312 |
) |
| 313 |
|
| 314 |
@staticmethod |
| 315 |
def WaitOperation( |
| 316 |
request, |
| 317 |
target, |
| 318 |
options=(), |
| 319 |
channel_credentials=None, |
| 320 |
call_credentials=None, |
| 321 |
insecure=False, |
| 322 |
compression=None, |
| 323 |
wait_for_ready=None, |
| 324 |
timeout=None, |
| 325 |
metadata=None, |
| 326 |
): |
| 327 |
return grpc.experimental.unary_unary( |
| 328 |
request, |
| 329 |
target, |
| 330 |
"/google.longrunning.Operations/WaitOperation", |
| 331 |
google_dot_longrunning_dot_operations__pb2.WaitOperationRequest.SerializeToString, |
| 332 |
google_dot_longrunning_dot_operations__pb2.Operation.FromString, |
| 333 |
options, |
| 334 |
channel_credentials, |
| 335 |
insecure, |
| 336 |
call_credentials, |
| 337 |
compression, |
| 338 |
wait_for_ready, |
| 339 |
timeout, |
| 340 |
metadata, |
| 341 |
) |