|
16 | 16 | from collections import OrderedDict |
17 | 17 | import functools |
18 | 18 | import re |
19 | | -from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union |
20 | | -import pkg_resources |
| 19 | +from typing import ( |
| 20 | + Dict, |
| 21 | + Mapping, |
| 22 | + MutableMapping, |
| 23 | + MutableSequence, |
| 24 | + Optional, |
| 25 | + Sequence, |
| 26 | + Tuple, |
| 27 | + Type, |
| 28 | + Union, |
| 29 | +) |
| 30 | + |
| 31 | +from google.cloud.optimization_v1 import gapic_version as package_version |
21 | 32 |
|
22 | 33 | from google.api_core.client_options import ClientOptions |
23 | 34 | from google.api_core import exceptions as core_exceptions |
@@ -177,9 +188,9 @@ def transport(self) -> FleetRoutingTransport: |
177 | 188 | def __init__( |
178 | 189 | self, |
179 | 190 | *, |
180 | | - credentials: ga_credentials.Credentials = None, |
| 191 | + credentials: Optional[ga_credentials.Credentials] = None, |
181 | 192 | transport: Union[str, FleetRoutingTransport] = "grpc_asyncio", |
182 | | - client_options: ClientOptions = None, |
| 193 | + client_options: Optional[ClientOptions] = None, |
183 | 194 | client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, |
184 | 195 | ) -> None: |
185 | 196 | """Instantiates the fleet routing client. |
@@ -223,10 +234,10 @@ def __init__( |
223 | 234 |
|
224 | 235 | async def optimize_tours( |
225 | 236 | self, |
226 | | - request: Union[fleet_routing.OptimizeToursRequest, dict] = None, |
| 237 | + request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None, |
227 | 238 | *, |
228 | 239 | retry: OptionalRetry = gapic_v1.method.DEFAULT, |
229 | | - timeout: float = None, |
| 240 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
230 | 241 | metadata: Sequence[Tuple[str, str]] = (), |
231 | 242 | ) -> fleet_routing.OptimizeToursResponse: |
232 | 243 | r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel`` |
@@ -273,7 +284,7 @@ async def sample_optimize_tours(): |
273 | 284 | print(response) |
274 | 285 |
|
275 | 286 | Args: |
276 | | - request (Union[google.cloud.optimization_v1.types.OptimizeToursRequest, dict]): |
| 287 | + request (Optional[Union[google.cloud.optimization_v1.types.OptimizeToursRequest, dict]]): |
277 | 288 | The request object. Request to be given to a tour |
278 | 289 | optimization solver which defines the shipment model to |
279 | 290 | solve as well as optimization parameters. |
@@ -331,10 +342,10 @@ async def sample_optimize_tours(): |
331 | 342 |
|
332 | 343 | async def batch_optimize_tours( |
333 | 344 | self, |
334 | | - request: Union[fleet_routing.BatchOptimizeToursRequest, dict] = None, |
| 345 | + request: Optional[Union[fleet_routing.BatchOptimizeToursRequest, dict]] = None, |
335 | 346 | *, |
336 | 347 | retry: OptionalRetry = gapic_v1.method.DEFAULT, |
337 | | - timeout: float = None, |
| 348 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, |
338 | 349 | metadata: Sequence[Tuple[str, str]] = (), |
339 | 350 | ) -> operation_async.AsyncOperation: |
340 | 351 | r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest`` |
@@ -379,13 +390,13 @@ async def sample_batch_optimize_tours(): |
379 | 390 |
|
380 | 391 | print("Waiting for operation to complete...") |
381 | 392 |
|
382 | | - response = await operation.result() |
| 393 | + response = (await operation).result() |
383 | 394 |
|
384 | 395 | # Handle the response |
385 | 396 | print(response) |
386 | 397 |
|
387 | 398 | Args: |
388 | | - request (Union[google.cloud.optimization_v1.types.BatchOptimizeToursRequest, dict]): |
| 399 | + request (Optional[Union[google.cloud.optimization_v1.types.BatchOptimizeToursRequest, dict]]): |
389 | 400 | The request object. Request to batch optimize tours as |
390 | 401 | an asynchronous operation. Each input file should |
391 | 402 | contain one `OptimizeToursRequest`, and each output file |
@@ -459,14 +470,9 @@ async def __aexit__(self, exc_type, exc, tb): |
459 | 470 | await self.transport.close() |
460 | 471 |
|
461 | 472 |
|
462 | | -try: |
463 | | - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
464 | | - gapic_version=pkg_resources.get_distribution( |
465 | | - "google-cloud-optimization", |
466 | | - ).version, |
467 | | - ) |
468 | | -except pkg_resources.DistributionNotFound: |
469 | | - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() |
| 473 | +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( |
| 474 | + gapic_version=package_version.__version__ |
| 475 | +) |
470 | 476 |
|
471 | 477 |
|
472 | 478 | __all__ = ("FleetRoutingAsyncClient",) |
0 commit comments