google-maps-routeoptimization 0.1.4__tar.gz → 0.1.6__tar.gz
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.
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/MANIFEST.in +1 -1
- {google_maps_routeoptimization-0.1.4/google_maps_routeoptimization.egg-info → google_maps_routeoptimization-0.1.6}/PKG-INFO +3 -1
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/async_client.py +1 -5
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/client.py +4 -42
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/transports/base.py +5 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc_asyncio.py +20 -2
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/transports/rest.py +148 -151
- google_maps_routeoptimization-0.1.6/google/maps/routeoptimization_v1/services/route_optimization/transports/rest_base.py +243 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6/google_maps_routeoptimization.egg-info}/PKG-INFO +3 -1
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google_maps_routeoptimization.egg-info/SOURCES.txt +1 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google_maps_routeoptimization.egg-info/requires.txt +3 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/setup.py +4 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/tests/unit/gapic/routeoptimization_v1/test_route_optimization.py +596 -583
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/LICENSE +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/README.rst +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization/py.typed +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/gapic_metadata.json +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/py.typed +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/transports/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/types/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google/maps/routeoptimization_v1/types/route_optimization_service.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google_maps_routeoptimization.egg-info/dependency_links.txt +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google_maps_routeoptimization.egg-info/not-zip-safe +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/google_maps_routeoptimization.egg-info/top_level.txt +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/setup.cfg +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/tests/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/tests/unit/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/tests/unit/gapic/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.4 → google_maps_routeoptimization-0.1.6}/tests/unit/gapic/routeoptimization_v1/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-maps-routeoptimization
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Google Maps Routeoptimization API client library
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-maps-routeoptimization
|
|
6
6
|
Author: Google LLC
|
|
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
22
|
Classifier: Operating System :: OS Independent
|
|
22
23
|
Classifier: Topic :: Internet
|
|
23
24
|
Requires-Python: >=3.7
|
|
@@ -25,6 +26,7 @@ License-File: LICENSE
|
|
|
25
26
|
Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0dev,>=1.34.1
|
|
26
27
|
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
|
|
27
28
|
Requires-Dist: proto-plus<2.0.0dev,>=1.22.3
|
|
29
|
+
Requires-Dist: proto-plus<2.0.0dev,>=1.25.0; python_version >= "3.13"
|
|
28
30
|
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.2
|
|
29
31
|
|
|
30
32
|
Python Client for Route Optimization API
|
|
@@ -558,11 +558,7 @@ class RouteOptimizationAsyncClient:
|
|
|
558
558
|
|
|
559
559
|
# Wrap the RPC method; this adds retry and timeout information,
|
|
560
560
|
# and friendly error handling.
|
|
561
|
-
rpc =
|
|
562
|
-
self._client._transport.get_operation,
|
|
563
|
-
default_timeout=None,
|
|
564
|
-
client_info=DEFAULT_CLIENT_INFO,
|
|
565
|
-
)
|
|
561
|
+
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]
|
|
566
562
|
|
|
567
563
|
# Certain fields should be provided within the metadata header;
|
|
568
564
|
# add these here.
|
|
@@ -465,36 +465,6 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
465
465
|
raise ValueError("Universe Domain cannot be an empty string.")
|
|
466
466
|
return universe_domain
|
|
467
467
|
|
|
468
|
-
@staticmethod
|
|
469
|
-
def _compare_universes(
|
|
470
|
-
client_universe: str, credentials: ga_credentials.Credentials
|
|
471
|
-
) -> bool:
|
|
472
|
-
"""Returns True iff the universe domains used by the client and credentials match.
|
|
473
|
-
|
|
474
|
-
Args:
|
|
475
|
-
client_universe (str): The universe domain configured via the client options.
|
|
476
|
-
credentials (ga_credentials.Credentials): The credentials being used in the client.
|
|
477
|
-
|
|
478
|
-
Returns:
|
|
479
|
-
bool: True iff client_universe matches the universe in credentials.
|
|
480
|
-
|
|
481
|
-
Raises:
|
|
482
|
-
ValueError: when client_universe does not match the universe in credentials.
|
|
483
|
-
"""
|
|
484
|
-
|
|
485
|
-
default_universe = RouteOptimizationClient._DEFAULT_UNIVERSE
|
|
486
|
-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
|
|
487
|
-
|
|
488
|
-
if client_universe != credentials_universe:
|
|
489
|
-
raise ValueError(
|
|
490
|
-
"The configured universe domain "
|
|
491
|
-
f"({client_universe}) does not match the universe domain "
|
|
492
|
-
f"found in the credentials ({credentials_universe}). "
|
|
493
|
-
"If you haven't configured the universe domain explicitly, "
|
|
494
|
-
f"`{default_universe}` is the default."
|
|
495
|
-
)
|
|
496
|
-
return True
|
|
497
|
-
|
|
498
468
|
def _validate_universe_domain(self):
|
|
499
469
|
"""Validates client's and credentials' universe domains are consistent.
|
|
500
470
|
|
|
@@ -504,13 +474,9 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
504
474
|
Raises:
|
|
505
475
|
ValueError: If the configured universe domain is not valid.
|
|
506
476
|
"""
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
self.universe_domain, self.transport._credentials
|
|
511
|
-
)
|
|
512
|
-
)
|
|
513
|
-
return self._is_universe_domain_valid
|
|
477
|
+
|
|
478
|
+
# NOTE (b/349488459): universe validation is disabled until further notice.
|
|
479
|
+
return True
|
|
514
480
|
|
|
515
481
|
@property
|
|
516
482
|
def api_endpoint(self):
|
|
@@ -971,11 +937,7 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
971
937
|
|
|
972
938
|
# Wrap the RPC method; this adds retry and timeout information,
|
|
973
939
|
# and friendly error handling.
|
|
974
|
-
rpc =
|
|
975
|
-
self._transport.get_operation,
|
|
976
|
-
default_timeout=None,
|
|
977
|
-
client_info=DEFAULT_CLIENT_INFO,
|
|
978
|
-
)
|
|
940
|
+
rpc = self._transport._wrapped_methods[self._transport.get_operation]
|
|
979
941
|
|
|
980
942
|
# Certain fields should be provided within the metadata header;
|
|
981
943
|
# add these here.
|
|
@@ -148,6 +148,11 @@ class RouteOptimizationTransport(abc.ABC):
|
|
|
148
148
|
default_timeout=None,
|
|
149
149
|
client_info=client_info,
|
|
150
150
|
),
|
|
151
|
+
self.get_operation: gapic_v1.method.wrap_method(
|
|
152
|
+
self.get_operation,
|
|
153
|
+
default_timeout=None,
|
|
154
|
+
client_info=client_info,
|
|
155
|
+
),
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
def close(self):
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
+
import inspect
|
|
16
17
|
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
|
17
18
|
import warnings
|
|
18
19
|
|
|
@@ -250,6 +251,9 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
250
251
|
)
|
|
251
252
|
|
|
252
253
|
# Wrap messages. This must be done after self._grpc_channel exists
|
|
254
|
+
self._wrap_with_kind = (
|
|
255
|
+
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
|
256
|
+
)
|
|
253
257
|
self._prep_wrapped_messages(client_info)
|
|
254
258
|
|
|
255
259
|
@property
|
|
@@ -378,7 +382,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
378
382
|
def _prep_wrapped_messages(self, client_info):
|
|
379
383
|
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
|
|
380
384
|
self._wrapped_methods = {
|
|
381
|
-
self.optimize_tours:
|
|
385
|
+
self.optimize_tours: self._wrap_method(
|
|
382
386
|
self.optimize_tours,
|
|
383
387
|
default_retry=retries.AsyncRetry(
|
|
384
388
|
initial=1.0,
|
|
@@ -392,16 +396,30 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
392
396
|
default_timeout=3600.0,
|
|
393
397
|
client_info=client_info,
|
|
394
398
|
),
|
|
395
|
-
self.batch_optimize_tours:
|
|
399
|
+
self.batch_optimize_tours: self._wrap_method(
|
|
396
400
|
self.batch_optimize_tours,
|
|
397
401
|
default_timeout=None,
|
|
398
402
|
client_info=client_info,
|
|
399
403
|
),
|
|
404
|
+
self.get_operation: self._wrap_method(
|
|
405
|
+
self.get_operation,
|
|
406
|
+
default_timeout=None,
|
|
407
|
+
client_info=client_info,
|
|
408
|
+
),
|
|
400
409
|
}
|
|
401
410
|
|
|
411
|
+
def _wrap_method(self, func, *args, **kwargs):
|
|
412
|
+
if self._wrap_with_kind: # pragma: NO COVER
|
|
413
|
+
kwargs["kind"] = self.kind
|
|
414
|
+
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
|
415
|
+
|
|
402
416
|
def close(self):
|
|
403
417
|
return self.grpc_channel.close()
|
|
404
418
|
|
|
419
|
+
@property
|
|
420
|
+
def kind(self) -> str:
|
|
421
|
+
return "grpc_asyncio"
|
|
422
|
+
|
|
405
423
|
@property
|
|
406
424
|
def get_operation(
|
|
407
425
|
self,
|
|
@@ -16,43 +16,33 @@
|
|
|
16
16
|
|
|
17
17
|
import dataclasses
|
|
18
18
|
import json # type: ignore
|
|
19
|
-
import re
|
|
20
19
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
|
21
20
|
import warnings
|
|
22
21
|
|
|
23
|
-
from google.api_core import
|
|
24
|
-
gapic_v1,
|
|
25
|
-
operations_v1,
|
|
26
|
-
path_template,
|
|
27
|
-
rest_helpers,
|
|
28
|
-
rest_streaming,
|
|
29
|
-
)
|
|
22
|
+
from google.api_core import gapic_v1, operations_v1, rest_helpers, rest_streaming
|
|
30
23
|
from google.api_core import exceptions as core_exceptions
|
|
31
24
|
from google.api_core import retry as retries
|
|
32
25
|
from google.auth import credentials as ga_credentials # type: ignore
|
|
33
|
-
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
34
26
|
from google.auth.transport.requests import AuthorizedSession # type: ignore
|
|
27
|
+
from google.longrunning import operations_pb2 # type: ignore
|
|
35
28
|
from google.protobuf import json_format
|
|
36
|
-
import grpc # type: ignore
|
|
37
29
|
from requests import __version__ as requests_version
|
|
38
30
|
|
|
31
|
+
from google.maps.routeoptimization_v1.types import route_optimization_service
|
|
32
|
+
|
|
33
|
+
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
|
34
|
+
from .rest_base import _BaseRouteOptimizationRestTransport
|
|
35
|
+
|
|
39
36
|
try:
|
|
40
37
|
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
|
|
41
38
|
except AttributeError: # pragma: NO COVER
|
|
42
39
|
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
43
40
|
|
|
44
41
|
|
|
45
|
-
from google.longrunning import operations_pb2 # type: ignore
|
|
46
|
-
|
|
47
|
-
from google.maps.routeoptimization_v1.types import route_optimization_service
|
|
48
|
-
|
|
49
|
-
from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO
|
|
50
|
-
from .base import RouteOptimizationTransport
|
|
51
|
-
|
|
52
42
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
53
43
|
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
|
54
44
|
grpc_version=None,
|
|
55
|
-
rest_version=requests_version,
|
|
45
|
+
rest_version=f"requests@{requests_version}",
|
|
56
46
|
)
|
|
57
47
|
|
|
58
48
|
|
|
@@ -174,8 +164,8 @@ class RouteOptimizationRestStub:
|
|
|
174
164
|
_interceptor: RouteOptimizationRestInterceptor
|
|
175
165
|
|
|
176
166
|
|
|
177
|
-
class RouteOptimizationRestTransport(
|
|
178
|
-
"""REST backend transport for RouteOptimization.
|
|
167
|
+
class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
168
|
+
"""REST backend synchronous transport for RouteOptimization.
|
|
179
169
|
|
|
180
170
|
A service for optimizing vehicle tours.
|
|
181
171
|
|
|
@@ -206,7 +196,6 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
206
196
|
and call it.
|
|
207
197
|
|
|
208
198
|
It sends JSON representations of protocol buffers over HTTP/1.1
|
|
209
|
-
|
|
210
199
|
"""
|
|
211
200
|
|
|
212
201
|
def __init__(
|
|
@@ -260,21 +249,12 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
260
249
|
# TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
|
|
261
250
|
# TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
|
|
262
251
|
# credentials object
|
|
263
|
-
maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
|
|
264
|
-
if maybe_url_match is None:
|
|
265
|
-
raise ValueError(
|
|
266
|
-
f"Unexpected hostname structure: {host}"
|
|
267
|
-
) # pragma: NO COVER
|
|
268
|
-
|
|
269
|
-
url_match_items = maybe_url_match.groupdict()
|
|
270
|
-
|
|
271
|
-
host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
|
|
272
|
-
|
|
273
252
|
super().__init__(
|
|
274
253
|
host=host,
|
|
275
254
|
credentials=credentials,
|
|
276
255
|
client_info=client_info,
|
|
277
256
|
always_use_jwt_access=always_use_jwt_access,
|
|
257
|
+
url_scheme=url_scheme,
|
|
278
258
|
api_audience=api_audience,
|
|
279
259
|
)
|
|
280
260
|
self._session = AuthorizedSession(
|
|
@@ -320,19 +300,35 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
320
300
|
# Return the client from cache.
|
|
321
301
|
return self._operations_client
|
|
322
302
|
|
|
323
|
-
class _BatchOptimizeTours(
|
|
303
|
+
class _BatchOptimizeTours(
|
|
304
|
+
_BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours,
|
|
305
|
+
RouteOptimizationRestStub,
|
|
306
|
+
):
|
|
324
307
|
def __hash__(self):
|
|
325
|
-
return hash("BatchOptimizeTours")
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
308
|
+
return hash("RouteOptimizationRestTransport.BatchOptimizeTours")
|
|
309
|
+
|
|
310
|
+
@staticmethod
|
|
311
|
+
def _get_response(
|
|
312
|
+
host,
|
|
313
|
+
metadata,
|
|
314
|
+
query_params,
|
|
315
|
+
session,
|
|
316
|
+
timeout,
|
|
317
|
+
transcoded_request,
|
|
318
|
+
body=None,
|
|
319
|
+
):
|
|
320
|
+
uri = transcoded_request["uri"]
|
|
321
|
+
method = transcoded_request["method"]
|
|
322
|
+
headers = dict(metadata)
|
|
323
|
+
headers["Content-Type"] = "application/json"
|
|
324
|
+
response = getattr(session, method)(
|
|
325
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
326
|
+
timeout=timeout,
|
|
327
|
+
headers=headers,
|
|
328
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
329
|
+
data=body,
|
|
330
|
+
)
|
|
331
|
+
return response
|
|
336
332
|
|
|
337
333
|
def __call__(
|
|
338
334
|
self,
|
|
@@ -367,54 +363,34 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
367
363
|
|
|
368
364
|
"""
|
|
369
365
|
|
|
370
|
-
http_options
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
"uri": "/v1/{parent=projects/*/locations/*}:batchOptimizeTours",
|
|
374
|
-
"body": "*",
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
"method": "post",
|
|
378
|
-
"uri": "/v1/{parent=projects/*}:batchOptimizeTours",
|
|
379
|
-
"body": "*",
|
|
380
|
-
},
|
|
381
|
-
]
|
|
366
|
+
http_options = (
|
|
367
|
+
_BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours._get_http_options()
|
|
368
|
+
)
|
|
382
369
|
request, metadata = self._interceptor.pre_batch_optimize_tours(
|
|
383
370
|
request, metadata
|
|
384
371
|
)
|
|
385
|
-
|
|
386
|
-
request
|
|
372
|
+
transcoded_request = _BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours._get_transcoded_request(
|
|
373
|
+
http_options, request
|
|
387
374
|
)
|
|
388
|
-
transcoded_request = path_template.transcode(http_options, pb_request)
|
|
389
|
-
|
|
390
|
-
# Jsonify the request body
|
|
391
375
|
|
|
392
|
-
body =
|
|
393
|
-
transcoded_request
|
|
376
|
+
body = _BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours._get_request_body_json(
|
|
377
|
+
transcoded_request
|
|
394
378
|
)
|
|
395
|
-
uri = transcoded_request["uri"]
|
|
396
|
-
method = transcoded_request["method"]
|
|
397
379
|
|
|
398
380
|
# Jsonify the query params
|
|
399
|
-
query_params =
|
|
400
|
-
|
|
401
|
-
transcoded_request["query_params"],
|
|
402
|
-
use_integers_for_enums=True,
|
|
403
|
-
)
|
|
381
|
+
query_params = _BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours._get_query_params_json(
|
|
382
|
+
transcoded_request
|
|
404
383
|
)
|
|
405
|
-
query_params.update(self._get_unset_required_fields(query_params))
|
|
406
|
-
|
|
407
|
-
query_params["$alt"] = "json;enum-encoding=int"
|
|
408
384
|
|
|
409
385
|
# Send the request
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
386
|
+
response = RouteOptimizationRestTransport._BatchOptimizeTours._get_response(
|
|
387
|
+
self._host,
|
|
388
|
+
metadata,
|
|
389
|
+
query_params,
|
|
390
|
+
self._session,
|
|
391
|
+
timeout,
|
|
392
|
+
transcoded_request,
|
|
393
|
+
body,
|
|
418
394
|
)
|
|
419
395
|
|
|
420
396
|
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
@@ -428,19 +404,35 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
428
404
|
resp = self._interceptor.post_batch_optimize_tours(resp)
|
|
429
405
|
return resp
|
|
430
406
|
|
|
431
|
-
class _OptimizeTours(
|
|
407
|
+
class _OptimizeTours(
|
|
408
|
+
_BaseRouteOptimizationRestTransport._BaseOptimizeTours,
|
|
409
|
+
RouteOptimizationRestStub,
|
|
410
|
+
):
|
|
432
411
|
def __hash__(self):
|
|
433
|
-
return hash("OptimizeTours")
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
412
|
+
return hash("RouteOptimizationRestTransport.OptimizeTours")
|
|
413
|
+
|
|
414
|
+
@staticmethod
|
|
415
|
+
def _get_response(
|
|
416
|
+
host,
|
|
417
|
+
metadata,
|
|
418
|
+
query_params,
|
|
419
|
+
session,
|
|
420
|
+
timeout,
|
|
421
|
+
transcoded_request,
|
|
422
|
+
body=None,
|
|
423
|
+
):
|
|
424
|
+
uri = transcoded_request["uri"]
|
|
425
|
+
method = transcoded_request["method"]
|
|
426
|
+
headers = dict(metadata)
|
|
427
|
+
headers["Content-Type"] = "application/json"
|
|
428
|
+
response = getattr(session, method)(
|
|
429
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
430
|
+
timeout=timeout,
|
|
431
|
+
headers=headers,
|
|
432
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
433
|
+
data=body,
|
|
434
|
+
)
|
|
435
|
+
return response
|
|
444
436
|
|
|
445
437
|
def __call__(
|
|
446
438
|
self,
|
|
@@ -474,50 +466,32 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
474
466
|
|
|
475
467
|
"""
|
|
476
468
|
|
|
477
|
-
http_options
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
"uri": "/v1/{parent=projects/*/locations/*}:optimizeTours",
|
|
481
|
-
"body": "*",
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
"method": "post",
|
|
485
|
-
"uri": "/v1/{parent=projects/*}:optimizeTours",
|
|
486
|
-
"body": "*",
|
|
487
|
-
},
|
|
488
|
-
]
|
|
469
|
+
http_options = (
|
|
470
|
+
_BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_http_options()
|
|
471
|
+
)
|
|
489
472
|
request, metadata = self._interceptor.pre_optimize_tours(request, metadata)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
# Jsonify the request body
|
|
473
|
+
transcoded_request = _BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_transcoded_request(
|
|
474
|
+
http_options, request
|
|
475
|
+
)
|
|
494
476
|
|
|
495
|
-
body =
|
|
496
|
-
transcoded_request
|
|
477
|
+
body = _BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_request_body_json(
|
|
478
|
+
transcoded_request
|
|
497
479
|
)
|
|
498
|
-
uri = transcoded_request["uri"]
|
|
499
|
-
method = transcoded_request["method"]
|
|
500
480
|
|
|
501
481
|
# Jsonify the query params
|
|
502
|
-
query_params =
|
|
503
|
-
|
|
504
|
-
transcoded_request["query_params"],
|
|
505
|
-
use_integers_for_enums=True,
|
|
506
|
-
)
|
|
482
|
+
query_params = _BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_query_params_json(
|
|
483
|
+
transcoded_request
|
|
507
484
|
)
|
|
508
|
-
query_params.update(self._get_unset_required_fields(query_params))
|
|
509
|
-
|
|
510
|
-
query_params["$alt"] = "json;enum-encoding=int"
|
|
511
485
|
|
|
512
486
|
# Send the request
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
487
|
+
response = RouteOptimizationRestTransport._OptimizeTours._get_response(
|
|
488
|
+
self._host,
|
|
489
|
+
metadata,
|
|
490
|
+
query_params,
|
|
491
|
+
self._session,
|
|
492
|
+
timeout,
|
|
493
|
+
transcoded_request,
|
|
494
|
+
body,
|
|
521
495
|
)
|
|
522
496
|
|
|
523
497
|
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
@@ -558,7 +532,34 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
558
532
|
def get_operation(self):
|
|
559
533
|
return self._GetOperation(self._session, self._host, self._interceptor) # type: ignore
|
|
560
534
|
|
|
561
|
-
class _GetOperation(
|
|
535
|
+
class _GetOperation(
|
|
536
|
+
_BaseRouteOptimizationRestTransport._BaseGetOperation, RouteOptimizationRestStub
|
|
537
|
+
):
|
|
538
|
+
def __hash__(self):
|
|
539
|
+
return hash("RouteOptimizationRestTransport.GetOperation")
|
|
540
|
+
|
|
541
|
+
@staticmethod
|
|
542
|
+
def _get_response(
|
|
543
|
+
host,
|
|
544
|
+
metadata,
|
|
545
|
+
query_params,
|
|
546
|
+
session,
|
|
547
|
+
timeout,
|
|
548
|
+
transcoded_request,
|
|
549
|
+
body=None,
|
|
550
|
+
):
|
|
551
|
+
uri = transcoded_request["uri"]
|
|
552
|
+
method = transcoded_request["method"]
|
|
553
|
+
headers = dict(metadata)
|
|
554
|
+
headers["Content-Type"] = "application/json"
|
|
555
|
+
response = getattr(session, method)(
|
|
556
|
+
"{host}{uri}".format(host=host, uri=uri),
|
|
557
|
+
timeout=timeout,
|
|
558
|
+
headers=headers,
|
|
559
|
+
params=rest_helpers.flatten_query_params(query_params, strict=True),
|
|
560
|
+
)
|
|
561
|
+
return response
|
|
562
|
+
|
|
562
563
|
def __call__(
|
|
563
564
|
self,
|
|
564
565
|
request: operations_pb2.GetOperationRequest,
|
|
@@ -582,32 +583,27 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
582
583
|
operations_pb2.Operation: Response from GetOperation method.
|
|
583
584
|
"""
|
|
584
585
|
|
|
585
|
-
http_options
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
"uri": "/v1/{name=projects/*/locations/*/operations/*}",
|
|
589
|
-
},
|
|
590
|
-
]
|
|
591
|
-
|
|
586
|
+
http_options = (
|
|
587
|
+
_BaseRouteOptimizationRestTransport._BaseGetOperation._get_http_options()
|
|
588
|
+
)
|
|
592
589
|
request, metadata = self._interceptor.pre_get_operation(request, metadata)
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
uri = transcoded_request["uri"]
|
|
597
|
-
method = transcoded_request["method"]
|
|
590
|
+
transcoded_request = _BaseRouteOptimizationRestTransport._BaseGetOperation._get_transcoded_request(
|
|
591
|
+
http_options, request
|
|
592
|
+
)
|
|
598
593
|
|
|
599
594
|
# Jsonify the query params
|
|
600
|
-
query_params =
|
|
595
|
+
query_params = _BaseRouteOptimizationRestTransport._BaseGetOperation._get_query_params_json(
|
|
596
|
+
transcoded_request
|
|
597
|
+
)
|
|
601
598
|
|
|
602
599
|
# Send the request
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
timeout
|
|
609
|
-
|
|
610
|
-
params=rest_helpers.flatten_query_params(query_params),
|
|
600
|
+
response = RouteOptimizationRestTransport._GetOperation._get_response(
|
|
601
|
+
self._host,
|
|
602
|
+
metadata,
|
|
603
|
+
query_params,
|
|
604
|
+
self._session,
|
|
605
|
+
timeout,
|
|
606
|
+
transcoded_request,
|
|
611
607
|
)
|
|
612
608
|
|
|
613
609
|
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
|
|
@@ -615,8 +611,9 @@ class RouteOptimizationRestTransport(RouteOptimizationTransport):
|
|
|
615
611
|
if response.status_code >= 400:
|
|
616
612
|
raise core_exceptions.from_http_response(response)
|
|
617
613
|
|
|
614
|
+
content = response.content.decode("utf-8")
|
|
618
615
|
resp = operations_pb2.Operation()
|
|
619
|
-
resp = json_format.Parse(
|
|
616
|
+
resp = json_format.Parse(content, resp)
|
|
620
617
|
resp = self._interceptor.post_get_operation(resp)
|
|
621
618
|
return resp
|
|
622
619
|
|