google-maps-routeoptimization 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. google/maps/routeoptimization/__init__.py +85 -0
  2. google/maps/routeoptimization/gapic_version.py +16 -0
  3. google/maps/routeoptimization/py.typed +2 -0
  4. google/maps/routeoptimization_v1/__init__.py +83 -0
  5. google/maps/routeoptimization_v1/gapic_metadata.json +58 -0
  6. google/maps/routeoptimization_v1/gapic_version.py +16 -0
  7. google/maps/routeoptimization_v1/py.typed +2 -0
  8. google/maps/routeoptimization_v1/services/__init__.py +15 -0
  9. google/maps/routeoptimization_v1/services/route_optimization/__init__.py +22 -0
  10. google/maps/routeoptimization_v1/services/route_optimization/async_client.py +588 -0
  11. google/maps/routeoptimization_v1/services/route_optimization/client.py +992 -0
  12. google/maps/routeoptimization_v1/services/route_optimization/transports/__init__.py +36 -0
  13. google/maps/routeoptimization_v1/services/route_optimization/transports/base.py +200 -0
  14. google/maps/routeoptimization_v1/services/route_optimization/transports/grpc.py +381 -0
  15. google/maps/routeoptimization_v1/services/route_optimization/transports/grpc_asyncio.py +408 -0
  16. google/maps/routeoptimization_v1/services/route_optimization/transports/rest.py +631 -0
  17. google/maps/routeoptimization_v1/types/__init__.py +72 -0
  18. google/maps/routeoptimization_v1/types/route_optimization_service.py +4029 -0
  19. google_maps_routeoptimization-0.1.0.dist-info/LICENSE +202 -0
  20. google_maps_routeoptimization-0.1.0.dist-info/METADATA +137 -0
  21. google_maps_routeoptimization-0.1.0.dist-info/RECORD +23 -0
  22. google_maps_routeoptimization-0.1.0.dist-info/WHEEL +5 -0
  23. google_maps_routeoptimization-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,588 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+ from collections import OrderedDict
17
+ import functools
18
+ import re
19
+ from typing import (
20
+ Callable,
21
+ Dict,
22
+ Mapping,
23
+ MutableMapping,
24
+ MutableSequence,
25
+ Optional,
26
+ Sequence,
27
+ Tuple,
28
+ Type,
29
+ Union,
30
+ )
31
+
32
+ from google.api_core import exceptions as core_exceptions
33
+ from google.api_core import gapic_v1
34
+ from google.api_core import retry_async as retries
35
+ from google.api_core.client_options import ClientOptions
36
+ from google.auth import credentials as ga_credentials # type: ignore
37
+ from google.oauth2 import service_account # type: ignore
38
+
39
+ from google.maps.routeoptimization_v1 import gapic_version as package_version
40
+
41
+ try:
42
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
43
+ except AttributeError: # pragma: NO COVER
44
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore
45
+
46
+ from google.api_core import operation # type: ignore
47
+ from google.api_core import operation_async # type: ignore
48
+ from google.longrunning import operations_pb2 # type: ignore
49
+
50
+ from google.maps.routeoptimization_v1.types import route_optimization_service
51
+
52
+ from .client import RouteOptimizationClient
53
+ from .transports.base import DEFAULT_CLIENT_INFO, RouteOptimizationTransport
54
+ from .transports.grpc_asyncio import RouteOptimizationGrpcAsyncIOTransport
55
+
56
+
57
+ class RouteOptimizationAsyncClient:
58
+ """A service for optimizing vehicle tours.
59
+
60
+ Validity of certain types of fields:
61
+
62
+ - ``google.protobuf.Timestamp``
63
+
64
+ - Times are in Unix time: seconds since
65
+ 1970-01-01T00:00:00+00:00.
66
+ - seconds must be in [0, 253402300799], i.e. in
67
+ [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
68
+ - nanos must be unset or set to 0.
69
+
70
+ - ``google.protobuf.Duration``
71
+
72
+ - seconds must be in [0, 253402300799], i.e. in
73
+ [1970-01-01T00:00:00+00:00, 9999-12-31T23:59:59+00:00].
74
+ - nanos must be unset or set to 0.
75
+
76
+ - ``google.type.LatLng``
77
+
78
+ - latitude must be in [-90.0, 90.0].
79
+ - longitude must be in [-180.0, 180.0].
80
+ - at least one of latitude and longitude must be non-zero.
81
+ """
82
+
83
+ _client: RouteOptimizationClient
84
+
85
+ # Copy defaults from the synchronous client for use here.
86
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
87
+ DEFAULT_ENDPOINT = RouteOptimizationClient.DEFAULT_ENDPOINT
88
+ DEFAULT_MTLS_ENDPOINT = RouteOptimizationClient.DEFAULT_MTLS_ENDPOINT
89
+ _DEFAULT_ENDPOINT_TEMPLATE = RouteOptimizationClient._DEFAULT_ENDPOINT_TEMPLATE
90
+ _DEFAULT_UNIVERSE = RouteOptimizationClient._DEFAULT_UNIVERSE
91
+
92
+ common_billing_account_path = staticmethod(
93
+ RouteOptimizationClient.common_billing_account_path
94
+ )
95
+ parse_common_billing_account_path = staticmethod(
96
+ RouteOptimizationClient.parse_common_billing_account_path
97
+ )
98
+ common_folder_path = staticmethod(RouteOptimizationClient.common_folder_path)
99
+ parse_common_folder_path = staticmethod(
100
+ RouteOptimizationClient.parse_common_folder_path
101
+ )
102
+ common_organization_path = staticmethod(
103
+ RouteOptimizationClient.common_organization_path
104
+ )
105
+ parse_common_organization_path = staticmethod(
106
+ RouteOptimizationClient.parse_common_organization_path
107
+ )
108
+ common_project_path = staticmethod(RouteOptimizationClient.common_project_path)
109
+ parse_common_project_path = staticmethod(
110
+ RouteOptimizationClient.parse_common_project_path
111
+ )
112
+ common_location_path = staticmethod(RouteOptimizationClient.common_location_path)
113
+ parse_common_location_path = staticmethod(
114
+ RouteOptimizationClient.parse_common_location_path
115
+ )
116
+
117
+ @classmethod
118
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
119
+ """Creates an instance of this client using the provided credentials
120
+ info.
121
+
122
+ Args:
123
+ info (dict): The service account private key info.
124
+ args: Additional arguments to pass to the constructor.
125
+ kwargs: Additional arguments to pass to the constructor.
126
+
127
+ Returns:
128
+ RouteOptimizationAsyncClient: The constructed client.
129
+ """
130
+ return RouteOptimizationClient.from_service_account_info.__func__(RouteOptimizationAsyncClient, info, *args, **kwargs) # type: ignore
131
+
132
+ @classmethod
133
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
134
+ """Creates an instance of this client using the provided credentials
135
+ file.
136
+
137
+ Args:
138
+ filename (str): The path to the service account private key json
139
+ file.
140
+ args: Additional arguments to pass to the constructor.
141
+ kwargs: Additional arguments to pass to the constructor.
142
+
143
+ Returns:
144
+ RouteOptimizationAsyncClient: The constructed client.
145
+ """
146
+ return RouteOptimizationClient.from_service_account_file.__func__(RouteOptimizationAsyncClient, filename, *args, **kwargs) # type: ignore
147
+
148
+ from_service_account_json = from_service_account_file
149
+
150
+ @classmethod
151
+ def get_mtls_endpoint_and_cert_source(
152
+ cls, client_options: Optional[ClientOptions] = None
153
+ ):
154
+ """Return the API endpoint and client cert source for mutual TLS.
155
+
156
+ The client cert source is determined in the following order:
157
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
158
+ client cert source is None.
159
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
160
+ default client cert source exists, use the default one; otherwise the client cert
161
+ source is None.
162
+
163
+ The API endpoint is determined in the following order:
164
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
165
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
166
+ default mTLS endpoint; if the environment variable is "never", use the default API
167
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
168
+ use the default API endpoint.
169
+
170
+ More details can be found at https://google.aip.dev/auth/4114.
171
+
172
+ Args:
173
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
174
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
175
+ in this method.
176
+
177
+ Returns:
178
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
179
+ client cert source to use.
180
+
181
+ Raises:
182
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
183
+ """
184
+ return RouteOptimizationClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
185
+
186
+ @property
187
+ def transport(self) -> RouteOptimizationTransport:
188
+ """Returns the transport used by the client instance.
189
+
190
+ Returns:
191
+ RouteOptimizationTransport: The transport used by the client instance.
192
+ """
193
+ return self._client.transport
194
+
195
+ @property
196
+ def api_endpoint(self):
197
+ """Return the API endpoint used by the client instance.
198
+
199
+ Returns:
200
+ str: The API endpoint used by the client instance.
201
+ """
202
+ return self._client._api_endpoint
203
+
204
+ @property
205
+ def universe_domain(self) -> str:
206
+ """Return the universe domain used by the client instance.
207
+
208
+ Returns:
209
+ str: The universe domain used
210
+ by the client instance.
211
+ """
212
+ return self._client._universe_domain
213
+
214
+ get_transport_class = functools.partial(
215
+ type(RouteOptimizationClient).get_transport_class, type(RouteOptimizationClient)
216
+ )
217
+
218
+ def __init__(
219
+ self,
220
+ *,
221
+ credentials: Optional[ga_credentials.Credentials] = None,
222
+ transport: Optional[
223
+ Union[
224
+ str,
225
+ RouteOptimizationTransport,
226
+ Callable[..., RouteOptimizationTransport],
227
+ ]
228
+ ] = "grpc_asyncio",
229
+ client_options: Optional[ClientOptions] = None,
230
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
231
+ ) -> None:
232
+ """Instantiates the route optimization async client.
233
+
234
+ Args:
235
+ credentials (Optional[google.auth.credentials.Credentials]): The
236
+ authorization credentials to attach to requests. These
237
+ credentials identify the application to the service; if none
238
+ are specified, the client will attempt to ascertain the
239
+ credentials from the environment.
240
+ transport (Optional[Union[str,RouteOptimizationTransport,Callable[..., RouteOptimizationTransport]]]):
241
+ The transport to use, or a Callable that constructs and returns a new transport to use.
242
+ If a Callable is given, it will be called with the same set of initialization
243
+ arguments as used in the RouteOptimizationTransport constructor.
244
+ If set to None, a transport is chosen automatically.
245
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
246
+ Custom options for the client.
247
+
248
+ 1. The ``api_endpoint`` property can be used to override the
249
+ default endpoint provided by the client when ``transport`` is
250
+ not explicitly provided. Only if this property is not set and
251
+ ``transport`` was not explicitly provided, the endpoint is
252
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
253
+ variable, which have one of the following values:
254
+ "always" (always use the default mTLS endpoint), "never" (always
255
+ use the default regular endpoint) and "auto" (auto-switch to the
256
+ default mTLS endpoint if client certificate is present; this is
257
+ the default value).
258
+
259
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
260
+ is "true", then the ``client_cert_source`` property can be used
261
+ to provide a client certificate for mTLS transport. If
262
+ not provided, the default SSL client certificate will be used if
263
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
264
+ set, no client certificate will be used.
265
+
266
+ 3. The ``universe_domain`` property can be used to override the
267
+ default "googleapis.com" universe. Note that ``api_endpoint``
268
+ property still takes precedence; and ``universe_domain`` is
269
+ currently not supported for mTLS.
270
+
271
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
272
+ The client info used to send a user-agent string along with
273
+ API requests. If ``None``, then default info will be used.
274
+ Generally, you only need to set this if you're developing
275
+ your own client library.
276
+
277
+ Raises:
278
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
279
+ creation failed for any reason.
280
+ """
281
+ self._client = RouteOptimizationClient(
282
+ credentials=credentials,
283
+ transport=transport,
284
+ client_options=client_options,
285
+ client_info=client_info,
286
+ )
287
+
288
+ async def optimize_tours(
289
+ self,
290
+ request: Optional[
291
+ Union[route_optimization_service.OptimizeToursRequest, dict]
292
+ ] = None,
293
+ *,
294
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
295
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
296
+ metadata: Sequence[Tuple[str, str]] = (),
297
+ ) -> route_optimization_service.OptimizeToursResponse:
298
+ r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
299
+ and returns an ``OptimizeToursResponse`` containing
300
+ ``ShipmentRoute``\ s, which are a set of routes to be performed
301
+ by vehicles minimizing the overall cost.
302
+
303
+ A ``ShipmentModel`` model consists mainly of ``Shipment``\ s
304
+ that need to be carried out and ``Vehicle``\ s that can be used
305
+ to transport the ``Shipment``\ s. The ``ShipmentRoute``\ s
306
+ assign ``Shipment``\ s to ``Vehicle``\ s. More specifically,
307
+ they assign a series of ``Visit``\ s to each vehicle, where a
308
+ ``Visit`` corresponds to a ``VisitRequest``, which is a pickup
309
+ or delivery for a ``Shipment``.
310
+
311
+ The goal is to provide an assignment of ``ShipmentRoute``\ s to
312
+ ``Vehicle``\ s that minimizes the total cost where cost has many
313
+ components defined in the ``ShipmentModel``.
314
+
315
+ .. code-block:: python
316
+
317
+ # This snippet has been automatically generated and should be regarded as a
318
+ # code template only.
319
+ # It will require modifications to work:
320
+ # - It may require correct/in-range values for request initialization.
321
+ # - It may require specifying regional endpoints when creating the service
322
+ # client as shown in:
323
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
324
+ from google.maps import routeoptimization_v1
325
+
326
+ async def sample_optimize_tours():
327
+ # Create a client
328
+ client = routeoptimization_v1.RouteOptimizationAsyncClient()
329
+
330
+ # Initialize request argument(s)
331
+ request = routeoptimization_v1.OptimizeToursRequest(
332
+ parent="parent_value",
333
+ )
334
+
335
+ # Make the request
336
+ response = await client.optimize_tours(request=request)
337
+
338
+ # Handle the response
339
+ print(response)
340
+
341
+ Args:
342
+ request (Optional[Union[google.maps.routeoptimization_v1.types.OptimizeToursRequest, dict]]):
343
+ The request object. Request to be given to a tour
344
+ optimization solver which defines the
345
+ shipment model to solve as well as
346
+ optimization parameters.
347
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
348
+ should be retried.
349
+ timeout (float): The timeout for this request.
350
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
351
+ sent along with the request as metadata.
352
+
353
+ Returns:
354
+ google.maps.routeoptimization_v1.types.OptimizeToursResponse:
355
+ Response after solving a tour
356
+ optimization problem containing the
357
+ routes followed by each vehicle, the
358
+ shipments which have been skipped and
359
+ the overall cost of the solution.
360
+
361
+ """
362
+ # Create or coerce a protobuf request object.
363
+ # - Use the request object if provided (there's no risk of modifying the input as
364
+ # there are no flattened fields), or create one.
365
+ if not isinstance(request, route_optimization_service.OptimizeToursRequest):
366
+ request = route_optimization_service.OptimizeToursRequest(request)
367
+
368
+ # Wrap the RPC method; this adds retry and timeout information,
369
+ # and friendly error handling.
370
+ rpc = self._client._transport._wrapped_methods[
371
+ self._client._transport.optimize_tours
372
+ ]
373
+
374
+ # Certain fields should be provided within the metadata header;
375
+ # add these here.
376
+ metadata = tuple(metadata) + (
377
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
378
+ )
379
+
380
+ # Validate the universe domain.
381
+ self._client._validate_universe_domain()
382
+
383
+ # Send the request.
384
+ response = await rpc(
385
+ request,
386
+ retry=retry,
387
+ timeout=timeout,
388
+ metadata=metadata,
389
+ )
390
+
391
+ # Done; return the response.
392
+ return response
393
+
394
+ async def batch_optimize_tours(
395
+ self,
396
+ request: Optional[
397
+ Union[route_optimization_service.BatchOptimizeToursRequest, dict]
398
+ ] = None,
399
+ *,
400
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
401
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
402
+ metadata: Sequence[Tuple[str, str]] = (),
403
+ ) -> operation_async.AsyncOperation:
404
+ r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
405
+ messages as a batch.
406
+
407
+ This method is a Long Running Operation (LRO). The inputs for
408
+ optimization (``OptimizeToursRequest`` messages) and outputs
409
+ (``OptimizeToursResponse`` messages) are read/written from/to
410
+ Cloud Storage in user-specified format. Like the
411
+ ``OptimizeTours`` method, each ``OptimizeToursRequest`` contains
412
+ a ``ShipmentModel`` and returns an ``OptimizeToursResponse``
413
+ containing ``ShipmentRoute``\ s, which are a set of routes to be
414
+ performed by vehicles minimizing the overall cost.
415
+
416
+ .. code-block:: python
417
+
418
+ # This snippet has been automatically generated and should be regarded as a
419
+ # code template only.
420
+ # It will require modifications to work:
421
+ # - It may require correct/in-range values for request initialization.
422
+ # - It may require specifying regional endpoints when creating the service
423
+ # client as shown in:
424
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
425
+ from google.maps import routeoptimization_v1
426
+
427
+ async def sample_batch_optimize_tours():
428
+ # Create a client
429
+ client = routeoptimization_v1.RouteOptimizationAsyncClient()
430
+
431
+ # Initialize request argument(s)
432
+ model_configs = routeoptimization_v1.AsyncModelConfig()
433
+ model_configs.input_config.gcs_source.uri = "uri_value"
434
+ model_configs.input_config.data_format = "PROTO_TEXT"
435
+ model_configs.output_config.gcs_destination.uri = "uri_value"
436
+ model_configs.output_config.data_format = "PROTO_TEXT"
437
+
438
+ request = routeoptimization_v1.BatchOptimizeToursRequest(
439
+ parent="parent_value",
440
+ model_configs=model_configs,
441
+ )
442
+
443
+ # Make the request
444
+ operation = client.batch_optimize_tours(request=request)
445
+
446
+ print("Waiting for operation to complete...")
447
+
448
+ response = (await operation).result()
449
+
450
+ # Handle the response
451
+ print(response)
452
+
453
+ Args:
454
+ request (Optional[Union[google.maps.routeoptimization_v1.types.BatchOptimizeToursRequest, dict]]):
455
+ The request object. Request to batch optimize tours as an asynchronous
456
+ operation. Each input file should contain one
457
+ ``OptimizeToursRequest``, and each output file will
458
+ contain one ``OptimizeToursResponse``. The request
459
+ contains information to read/write and parse the files.
460
+ All the input and output files should be under the same
461
+ project.
462
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
463
+ should be retried.
464
+ timeout (float): The timeout for this request.
465
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
466
+ sent along with the request as metadata.
467
+
468
+ Returns:
469
+ google.api_core.operation_async.AsyncOperation:
470
+ An object representing a long-running operation.
471
+
472
+ The result type for the operation will be :class:`google.maps.routeoptimization_v1.types.BatchOptimizeToursResponse` Response to a BatchOptimizeToursRequest. This is returned in
473
+ the Long Running Operation after the operation is
474
+ complete.
475
+
476
+ """
477
+ # Create or coerce a protobuf request object.
478
+ # - Use the request object if provided (there's no risk of modifying the input as
479
+ # there are no flattened fields), or create one.
480
+ if not isinstance(
481
+ request, route_optimization_service.BatchOptimizeToursRequest
482
+ ):
483
+ request = route_optimization_service.BatchOptimizeToursRequest(request)
484
+
485
+ # Wrap the RPC method; this adds retry and timeout information,
486
+ # and friendly error handling.
487
+ rpc = self._client._transport._wrapped_methods[
488
+ self._client._transport.batch_optimize_tours
489
+ ]
490
+
491
+ # Certain fields should be provided within the metadata header;
492
+ # add these here.
493
+ metadata = tuple(metadata) + (
494
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
495
+ )
496
+
497
+ # Validate the universe domain.
498
+ self._client._validate_universe_domain()
499
+
500
+ # Send the request.
501
+ response = await rpc(
502
+ request,
503
+ retry=retry,
504
+ timeout=timeout,
505
+ metadata=metadata,
506
+ )
507
+
508
+ # Wrap the response in an operation future.
509
+ response = operation_async.from_gapic(
510
+ response,
511
+ self._client._transport.operations_client,
512
+ route_optimization_service.BatchOptimizeToursResponse,
513
+ metadata_type=route_optimization_service.BatchOptimizeToursMetadata,
514
+ )
515
+
516
+ # Done; return the response.
517
+ return response
518
+
519
+ async def get_operation(
520
+ self,
521
+ request: Optional[operations_pb2.GetOperationRequest] = None,
522
+ *,
523
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
524
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
525
+ metadata: Sequence[Tuple[str, str]] = (),
526
+ ) -> operations_pb2.Operation:
527
+ r"""Gets the latest state of a long-running operation.
528
+
529
+ Args:
530
+ request (:class:`~.operations_pb2.GetOperationRequest`):
531
+ The request object. Request message for
532
+ `GetOperation` method.
533
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
534
+ if any, should be retried.
535
+ timeout (float): The timeout for this request.
536
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
537
+ sent along with the request as metadata.
538
+ Returns:
539
+ ~.operations_pb2.Operation:
540
+ An ``Operation`` object.
541
+ """
542
+ # Create or coerce a protobuf request object.
543
+ # The request isn't a proto-plus wrapped type,
544
+ # so it must be constructed via keyword expansion.
545
+ if isinstance(request, dict):
546
+ request = operations_pb2.GetOperationRequest(**request)
547
+
548
+ # Wrap the RPC method; this adds retry and timeout information,
549
+ # and friendly error handling.
550
+ rpc = gapic_v1.method_async.wrap_method(
551
+ self._client._transport.get_operation,
552
+ default_timeout=None,
553
+ client_info=DEFAULT_CLIENT_INFO,
554
+ )
555
+
556
+ # Certain fields should be provided within the metadata header;
557
+ # add these here.
558
+ metadata = tuple(metadata) + (
559
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
560
+ )
561
+
562
+ # Validate the universe domain.
563
+ self._client._validate_universe_domain()
564
+
565
+ # Send the request.
566
+ response = await rpc(
567
+ request,
568
+ retry=retry,
569
+ timeout=timeout,
570
+ metadata=metadata,
571
+ )
572
+
573
+ # Done; return the response.
574
+ return response
575
+
576
+ async def __aenter__(self) -> "RouteOptimizationAsyncClient":
577
+ return self
578
+
579
+ async def __aexit__(self, exc_type, exc, tb):
580
+ await self.transport.close()
581
+
582
+
583
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
584
+ gapic_version=package_version.__version__
585
+ )
586
+
587
+
588
+ __all__ = ("RouteOptimizationAsyncClient",)