google-maps-routeoptimization 0.1.6__tar.gz → 0.1.7__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.6/google_maps_routeoptimization.egg-info → google_maps_routeoptimization-0.1.7}/PKG-INFO +1 -1
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/async_client.py +47 -9
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/client.py +52 -9
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc.py +94 -6
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc_asyncio.py +91 -6
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/rest.py +187 -16
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7/google_maps_routeoptimization.egg-info}/PKG-INFO +1 -1
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/unit/gapic/routeoptimization_v1/test_route_optimization.py +10 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/LICENSE +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/MANIFEST.in +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/README.rst +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization/py.typed +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/gapic_metadata.json +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/py.typed +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/base.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/services/route_optimization/transports/rest_base.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/types/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google/maps/routeoptimization_v1/types/route_optimization_service.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google_maps_routeoptimization.egg-info/SOURCES.txt +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google_maps_routeoptimization.egg-info/dependency_links.txt +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google_maps_routeoptimization.egg-info/not-zip-safe +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google_maps_routeoptimization.egg-info/requires.txt +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/google_maps_routeoptimization.egg-info/top_level.txt +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/setup.cfg +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/setup.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/unit/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/unit/gapic/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/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.7
|
|
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
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
16
|
from collections import OrderedDict
|
|
17
|
+
import logging as std_logging
|
|
17
18
|
import re
|
|
18
19
|
from typing import (
|
|
19
20
|
Callable,
|
|
@@ -52,6 +53,15 @@ from .client import RouteOptimizationClient
|
|
|
52
53
|
from .transports.base import DEFAULT_CLIENT_INFO, RouteOptimizationTransport
|
|
53
54
|
from .transports.grpc_asyncio import RouteOptimizationGrpcAsyncIOTransport
|
|
54
55
|
|
|
56
|
+
try:
|
|
57
|
+
from google.api_core import client_logging # type: ignore
|
|
58
|
+
|
|
59
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
60
|
+
except ImportError: # pragma: NO COVER
|
|
61
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
62
|
+
|
|
63
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
64
|
+
|
|
55
65
|
|
|
56
66
|
class RouteOptimizationAsyncClient:
|
|
57
67
|
"""A service for optimizing vehicle tours.
|
|
@@ -282,6 +292,28 @@ class RouteOptimizationAsyncClient:
|
|
|
282
292
|
client_info=client_info,
|
|
283
293
|
)
|
|
284
294
|
|
|
295
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
296
|
+
std_logging.DEBUG
|
|
297
|
+
): # pragma: NO COVER
|
|
298
|
+
_LOGGER.debug(
|
|
299
|
+
"Created client `google.maps.routeoptimization_v1.RouteOptimizationAsyncClient`.",
|
|
300
|
+
extra={
|
|
301
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
302
|
+
"universeDomain": getattr(
|
|
303
|
+
self._client._transport._credentials, "universe_domain", ""
|
|
304
|
+
),
|
|
305
|
+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
|
|
306
|
+
"credentialsInfo": getattr(
|
|
307
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
308
|
+
)(),
|
|
309
|
+
}
|
|
310
|
+
if hasattr(self._client._transport, "_credentials")
|
|
311
|
+
else {
|
|
312
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
313
|
+
"credentialsType": None,
|
|
314
|
+
},
|
|
315
|
+
)
|
|
316
|
+
|
|
285
317
|
async def optimize_tours(
|
|
286
318
|
self,
|
|
287
319
|
request: Optional[
|
|
@@ -290,7 +322,7 @@ class RouteOptimizationAsyncClient:
|
|
|
290
322
|
*,
|
|
291
323
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
292
324
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
293
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
325
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
294
326
|
) -> route_optimization_service.OptimizeToursResponse:
|
|
295
327
|
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
|
|
296
328
|
and returns an ``OptimizeToursResponse`` containing
|
|
@@ -344,8 +376,10 @@ class RouteOptimizationAsyncClient:
|
|
|
344
376
|
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
345
377
|
should be retried.
|
|
346
378
|
timeout (float): The timeout for this request.
|
|
347
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
348
|
-
sent along with the request as metadata.
|
|
379
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
380
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
381
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
382
|
+
be of type `bytes`.
|
|
349
383
|
|
|
350
384
|
Returns:
|
|
351
385
|
google.maps.routeoptimization_v1.types.OptimizeToursResponse:
|
|
@@ -396,7 +430,7 @@ class RouteOptimizationAsyncClient:
|
|
|
396
430
|
*,
|
|
397
431
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
398
432
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
399
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
433
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
400
434
|
) -> operation_async.AsyncOperation:
|
|
401
435
|
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
|
|
402
436
|
messages as a batch.
|
|
@@ -473,8 +507,10 @@ class RouteOptimizationAsyncClient:
|
|
|
473
507
|
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
|
|
474
508
|
should be retried.
|
|
475
509
|
timeout (float): The timeout for this request.
|
|
476
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
477
|
-
sent along with the request as metadata.
|
|
510
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
511
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
512
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
513
|
+
be of type `bytes`.
|
|
478
514
|
|
|
479
515
|
Returns:
|
|
480
516
|
google.api_core.operation_async.AsyncOperation:
|
|
@@ -533,7 +569,7 @@ class RouteOptimizationAsyncClient:
|
|
|
533
569
|
*,
|
|
534
570
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
535
571
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
536
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
572
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
537
573
|
) -> operations_pb2.Operation:
|
|
538
574
|
r"""Gets the latest state of a long-running operation.
|
|
539
575
|
|
|
@@ -544,8 +580,10 @@ class RouteOptimizationAsyncClient:
|
|
|
544
580
|
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
|
|
545
581
|
if any, should be retried.
|
|
546
582
|
timeout (float): The timeout for this request.
|
|
547
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
548
|
-
sent along with the request as metadata.
|
|
583
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
584
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
585
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
586
|
+
be of type `bytes`.
|
|
549
587
|
Returns:
|
|
550
588
|
~.operations_pb2.Operation:
|
|
551
589
|
An ``Operation`` object.
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
16
|
from collections import OrderedDict
|
|
17
|
+
import logging as std_logging
|
|
17
18
|
import os
|
|
18
19
|
import re
|
|
19
20
|
from typing import (
|
|
@@ -48,6 +49,15 @@ try:
|
|
|
48
49
|
except AttributeError: # pragma: NO COVER
|
|
49
50
|
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
50
51
|
|
|
52
|
+
try:
|
|
53
|
+
from google.api_core import client_logging # type: ignore
|
|
54
|
+
|
|
55
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
56
|
+
except ImportError: # pragma: NO COVER
|
|
57
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
58
|
+
|
|
59
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
60
|
+
|
|
51
61
|
from google.api_core import operation # type: ignore
|
|
52
62
|
from google.api_core import operation_async # type: ignore
|
|
53
63
|
from google.longrunning import operations_pb2 # type: ignore
|
|
@@ -586,6 +596,10 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
586
596
|
# Initialize the universe domain validation.
|
|
587
597
|
self._is_universe_domain_valid = False
|
|
588
598
|
|
|
599
|
+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
|
|
600
|
+
# Setup logging.
|
|
601
|
+
client_logging.initialize_logging()
|
|
602
|
+
|
|
589
603
|
api_key_value = getattr(self._client_options, "api_key", None)
|
|
590
604
|
if api_key_value and credentials:
|
|
591
605
|
raise ValueError(
|
|
@@ -652,6 +666,29 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
652
666
|
api_audience=self._client_options.api_audience,
|
|
653
667
|
)
|
|
654
668
|
|
|
669
|
+
if "async" not in str(self._transport):
|
|
670
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
671
|
+
std_logging.DEBUG
|
|
672
|
+
): # pragma: NO COVER
|
|
673
|
+
_LOGGER.debug(
|
|
674
|
+
"Created client `google.maps.routeoptimization_v1.RouteOptimizationClient`.",
|
|
675
|
+
extra={
|
|
676
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
677
|
+
"universeDomain": getattr(
|
|
678
|
+
self._transport._credentials, "universe_domain", ""
|
|
679
|
+
),
|
|
680
|
+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
|
|
681
|
+
"credentialsInfo": getattr(
|
|
682
|
+
self.transport._credentials, "get_cred_info", lambda: None
|
|
683
|
+
)(),
|
|
684
|
+
}
|
|
685
|
+
if hasattr(self._transport, "_credentials")
|
|
686
|
+
else {
|
|
687
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
688
|
+
"credentialsType": None,
|
|
689
|
+
},
|
|
690
|
+
)
|
|
691
|
+
|
|
655
692
|
def optimize_tours(
|
|
656
693
|
self,
|
|
657
694
|
request: Optional[
|
|
@@ -660,7 +697,7 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
660
697
|
*,
|
|
661
698
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
662
699
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
663
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
700
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
664
701
|
) -> route_optimization_service.OptimizeToursResponse:
|
|
665
702
|
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
|
|
666
703
|
and returns an ``OptimizeToursResponse`` containing
|
|
@@ -714,8 +751,10 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
714
751
|
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
715
752
|
should be retried.
|
|
716
753
|
timeout (float): The timeout for this request.
|
|
717
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
718
|
-
sent along with the request as metadata.
|
|
754
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
755
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
756
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
757
|
+
be of type `bytes`.
|
|
719
758
|
|
|
720
759
|
Returns:
|
|
721
760
|
google.maps.routeoptimization_v1.types.OptimizeToursResponse:
|
|
@@ -764,7 +803,7 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
764
803
|
*,
|
|
765
804
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
766
805
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
767
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
806
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
768
807
|
) -> operation.Operation:
|
|
769
808
|
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
|
|
770
809
|
messages as a batch.
|
|
@@ -841,8 +880,10 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
841
880
|
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
842
881
|
should be retried.
|
|
843
882
|
timeout (float): The timeout for this request.
|
|
844
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
845
|
-
sent along with the request as metadata.
|
|
883
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
884
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
885
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
886
|
+
be of type `bytes`.
|
|
846
887
|
|
|
847
888
|
Returns:
|
|
848
889
|
google.api_core.operation.Operation:
|
|
@@ -912,7 +953,7 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
912
953
|
*,
|
|
913
954
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
914
955
|
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
|
|
915
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
956
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
916
957
|
) -> operations_pb2.Operation:
|
|
917
958
|
r"""Gets the latest state of a long-running operation.
|
|
918
959
|
|
|
@@ -923,8 +964,10 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
923
964
|
retry (google.api_core.retry.Retry): Designation of what errors,
|
|
924
965
|
if any, should be retried.
|
|
925
966
|
timeout (float): The timeout for this request.
|
|
926
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
927
|
-
sent along with the request as metadata.
|
|
967
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
968
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
969
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
970
|
+
be of type `bytes`.
|
|
928
971
|
Returns:
|
|
929
972
|
~.operations_pb2.Operation:
|
|
930
973
|
An ``Operation`` object.
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
+
import json
|
|
17
|
+
import logging as std_logging
|
|
18
|
+
import pickle
|
|
16
19
|
from typing import Callable, Dict, Optional, Sequence, Tuple, Union
|
|
17
20
|
import warnings
|
|
18
21
|
|
|
@@ -21,12 +24,90 @@ import google.auth # type: ignore
|
|
|
21
24
|
from google.auth import credentials as ga_credentials # type: ignore
|
|
22
25
|
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
23
26
|
from google.longrunning import operations_pb2 # type: ignore
|
|
27
|
+
from google.protobuf.json_format import MessageToJson
|
|
28
|
+
import google.protobuf.message
|
|
24
29
|
import grpc # type: ignore
|
|
30
|
+
import proto # type: ignore
|
|
25
31
|
|
|
26
32
|
from google.maps.routeoptimization_v1.types import route_optimization_service
|
|
27
33
|
|
|
28
34
|
from .base import DEFAULT_CLIENT_INFO, RouteOptimizationTransport
|
|
29
35
|
|
|
36
|
+
try:
|
|
37
|
+
from google.api_core import client_logging # type: ignore
|
|
38
|
+
|
|
39
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
40
|
+
except ImportError: # pragma: NO COVER
|
|
41
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
42
|
+
|
|
43
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER
|
|
47
|
+
def intercept_unary_unary(self, continuation, client_call_details, request):
|
|
48
|
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
49
|
+
std_logging.DEBUG
|
|
50
|
+
)
|
|
51
|
+
if logging_enabled: # pragma: NO COVER
|
|
52
|
+
request_metadata = client_call_details.metadata
|
|
53
|
+
if isinstance(request, proto.Message):
|
|
54
|
+
request_payload = type(request).to_json(request)
|
|
55
|
+
elif isinstance(request, google.protobuf.message.Message):
|
|
56
|
+
request_payload = MessageToJson(request)
|
|
57
|
+
else:
|
|
58
|
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
|
|
59
|
+
|
|
60
|
+
request_metadata = {
|
|
61
|
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
|
62
|
+
for key, value in request_metadata
|
|
63
|
+
}
|
|
64
|
+
grpc_request = {
|
|
65
|
+
"payload": request_payload,
|
|
66
|
+
"requestMethod": "grpc",
|
|
67
|
+
"metadata": dict(request_metadata),
|
|
68
|
+
}
|
|
69
|
+
_LOGGER.debug(
|
|
70
|
+
f"Sending request for {client_call_details.method}",
|
|
71
|
+
extra={
|
|
72
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
73
|
+
"rpcName": client_call_details.method,
|
|
74
|
+
"request": grpc_request,
|
|
75
|
+
"metadata": grpc_request["metadata"],
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
response = continuation(client_call_details, request)
|
|
80
|
+
if logging_enabled: # pragma: NO COVER
|
|
81
|
+
response_metadata = response.trailing_metadata()
|
|
82
|
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
|
83
|
+
metadata = (
|
|
84
|
+
dict([(k, str(v)) for k, v in response_metadata])
|
|
85
|
+
if response_metadata
|
|
86
|
+
else None
|
|
87
|
+
)
|
|
88
|
+
result = response.result()
|
|
89
|
+
if isinstance(result, proto.Message):
|
|
90
|
+
response_payload = type(result).to_json(result)
|
|
91
|
+
elif isinstance(result, google.protobuf.message.Message):
|
|
92
|
+
response_payload = MessageToJson(result)
|
|
93
|
+
else:
|
|
94
|
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
|
|
95
|
+
grpc_response = {
|
|
96
|
+
"payload": response_payload,
|
|
97
|
+
"metadata": metadata,
|
|
98
|
+
"status": "OK",
|
|
99
|
+
}
|
|
100
|
+
_LOGGER.debug(
|
|
101
|
+
f"Received response for {client_call_details.method}.",
|
|
102
|
+
extra={
|
|
103
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
104
|
+
"rpcName": client_call_details.method,
|
|
105
|
+
"response": grpc_response,
|
|
106
|
+
"metadata": grpc_response["metadata"],
|
|
107
|
+
},
|
|
108
|
+
)
|
|
109
|
+
return response
|
|
110
|
+
|
|
30
111
|
|
|
31
112
|
class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
32
113
|
"""gRPC backend transport for RouteOptimization.
|
|
@@ -203,7 +284,12 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
203
284
|
],
|
|
204
285
|
)
|
|
205
286
|
|
|
206
|
-
|
|
287
|
+
self._interceptor = _LoggingClientInterceptor()
|
|
288
|
+
self._logged_channel = grpc.intercept_channel(
|
|
289
|
+
self._grpc_channel, self._interceptor
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# Wrap messages. This must be done after self._logged_channel exists
|
|
207
293
|
self._prep_wrapped_messages(client_info)
|
|
208
294
|
|
|
209
295
|
@classmethod
|
|
@@ -267,7 +353,9 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
267
353
|
"""
|
|
268
354
|
# Quick check: Only create a new client if we do not already have one.
|
|
269
355
|
if self._operations_client is None:
|
|
270
|
-
self._operations_client = operations_v1.OperationsClient(
|
|
356
|
+
self._operations_client = operations_v1.OperationsClient(
|
|
357
|
+
self._logged_channel
|
|
358
|
+
)
|
|
271
359
|
|
|
272
360
|
# Return the client from cache.
|
|
273
361
|
return self._operations_client
|
|
@@ -309,7 +397,7 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
309
397
|
# gRPC handles serialization and deserialization, so we just need
|
|
310
398
|
# to pass in the functions for each.
|
|
311
399
|
if "optimize_tours" not in self._stubs:
|
|
312
|
-
self._stubs["optimize_tours"] = self.
|
|
400
|
+
self._stubs["optimize_tours"] = self._logged_channel.unary_unary(
|
|
313
401
|
"/google.maps.routeoptimization.v1.RouteOptimization/OptimizeTours",
|
|
314
402
|
request_serializer=route_optimization_service.OptimizeToursRequest.serialize,
|
|
315
403
|
response_deserializer=route_optimization_service.OptimizeToursResponse.deserialize,
|
|
@@ -361,7 +449,7 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
361
449
|
# gRPC handles serialization and deserialization, so we just need
|
|
362
450
|
# to pass in the functions for each.
|
|
363
451
|
if "batch_optimize_tours" not in self._stubs:
|
|
364
|
-
self._stubs["batch_optimize_tours"] = self.
|
|
452
|
+
self._stubs["batch_optimize_tours"] = self._logged_channel.unary_unary(
|
|
365
453
|
"/google.maps.routeoptimization.v1.RouteOptimization/BatchOptimizeTours",
|
|
366
454
|
request_serializer=route_optimization_service.BatchOptimizeToursRequest.serialize,
|
|
367
455
|
response_deserializer=operations_pb2.Operation.FromString,
|
|
@@ -369,7 +457,7 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
369
457
|
return self._stubs["batch_optimize_tours"]
|
|
370
458
|
|
|
371
459
|
def close(self):
|
|
372
|
-
self.
|
|
460
|
+
self._logged_channel.close()
|
|
373
461
|
|
|
374
462
|
@property
|
|
375
463
|
def get_operation(
|
|
@@ -381,7 +469,7 @@ class RouteOptimizationGrpcTransport(RouteOptimizationTransport):
|
|
|
381
469
|
# gRPC handles serialization and deserialization, so we just need
|
|
382
470
|
# to pass in the functions for each.
|
|
383
471
|
if "get_operation" not in self._stubs:
|
|
384
|
-
self._stubs["get_operation"] = self.
|
|
472
|
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
|
385
473
|
"/google.longrunning.Operations/GetOperation",
|
|
386
474
|
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
|
387
475
|
response_deserializer=operations_pb2.Operation.FromString,
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
16
|
import inspect
|
|
17
|
+
import json
|
|
18
|
+
import logging as std_logging
|
|
19
|
+
import pickle
|
|
17
20
|
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
|
|
18
21
|
import warnings
|
|
19
22
|
|
|
@@ -23,14 +26,93 @@ from google.api_core import retry_async as retries
|
|
|
23
26
|
from google.auth import credentials as ga_credentials # type: ignore
|
|
24
27
|
from google.auth.transport.grpc import SslCredentials # type: ignore
|
|
25
28
|
from google.longrunning import operations_pb2 # type: ignore
|
|
29
|
+
from google.protobuf.json_format import MessageToJson
|
|
30
|
+
import google.protobuf.message
|
|
26
31
|
import grpc # type: ignore
|
|
27
32
|
from grpc.experimental import aio # type: ignore
|
|
33
|
+
import proto # type: ignore
|
|
28
34
|
|
|
29
35
|
from google.maps.routeoptimization_v1.types import route_optimization_service
|
|
30
36
|
|
|
31
37
|
from .base import DEFAULT_CLIENT_INFO, RouteOptimizationTransport
|
|
32
38
|
from .grpc import RouteOptimizationGrpcTransport
|
|
33
39
|
|
|
40
|
+
try:
|
|
41
|
+
from google.api_core import client_logging # type: ignore
|
|
42
|
+
|
|
43
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
44
|
+
except ImportError: # pragma: NO COVER
|
|
45
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
46
|
+
|
|
47
|
+
_LOGGER = std_logging.getLogger(__name__)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class _LoggingClientAIOInterceptor(
|
|
51
|
+
grpc.aio.UnaryUnaryClientInterceptor
|
|
52
|
+
): # pragma: NO COVER
|
|
53
|
+
async def intercept_unary_unary(self, continuation, client_call_details, request):
|
|
54
|
+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
55
|
+
std_logging.DEBUG
|
|
56
|
+
)
|
|
57
|
+
if logging_enabled: # pragma: NO COVER
|
|
58
|
+
request_metadata = client_call_details.metadata
|
|
59
|
+
if isinstance(request, proto.Message):
|
|
60
|
+
request_payload = type(request).to_json(request)
|
|
61
|
+
elif isinstance(request, google.protobuf.message.Message):
|
|
62
|
+
request_payload = MessageToJson(request)
|
|
63
|
+
else:
|
|
64
|
+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
|
|
65
|
+
|
|
66
|
+
request_metadata = {
|
|
67
|
+
key: value.decode("utf-8") if isinstance(value, bytes) else value
|
|
68
|
+
for key, value in request_metadata
|
|
69
|
+
}
|
|
70
|
+
grpc_request = {
|
|
71
|
+
"payload": request_payload,
|
|
72
|
+
"requestMethod": "grpc",
|
|
73
|
+
"metadata": dict(request_metadata),
|
|
74
|
+
}
|
|
75
|
+
_LOGGER.debug(
|
|
76
|
+
f"Sending request for {client_call_details.method}",
|
|
77
|
+
extra={
|
|
78
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
79
|
+
"rpcName": str(client_call_details.method),
|
|
80
|
+
"request": grpc_request,
|
|
81
|
+
"metadata": grpc_request["metadata"],
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
response = await continuation(client_call_details, request)
|
|
85
|
+
if logging_enabled: # pragma: NO COVER
|
|
86
|
+
response_metadata = await response.trailing_metadata()
|
|
87
|
+
# Convert gRPC metadata `<class 'grpc.aio._metadata.Metadata'>` to list of tuples
|
|
88
|
+
metadata = (
|
|
89
|
+
dict([(k, str(v)) for k, v in response_metadata])
|
|
90
|
+
if response_metadata
|
|
91
|
+
else None
|
|
92
|
+
)
|
|
93
|
+
result = await response
|
|
94
|
+
if isinstance(result, proto.Message):
|
|
95
|
+
response_payload = type(result).to_json(result)
|
|
96
|
+
elif isinstance(result, google.protobuf.message.Message):
|
|
97
|
+
response_payload = MessageToJson(result)
|
|
98
|
+
else:
|
|
99
|
+
response_payload = f"{type(result).__name__}: {pickle.dumps(result)}"
|
|
100
|
+
grpc_response = {
|
|
101
|
+
"payload": response_payload,
|
|
102
|
+
"metadata": metadata,
|
|
103
|
+
"status": "OK",
|
|
104
|
+
}
|
|
105
|
+
_LOGGER.debug(
|
|
106
|
+
f"Received response to rpc {client_call_details.method}.",
|
|
107
|
+
extra={
|
|
108
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
109
|
+
"rpcName": str(client_call_details.method),
|
|
110
|
+
"response": grpc_response,
|
|
111
|
+
"metadata": grpc_response["metadata"],
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
return response
|
|
115
|
+
|
|
34
116
|
|
|
35
117
|
class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
36
118
|
"""gRPC AsyncIO backend transport for RouteOptimization.
|
|
@@ -250,10 +332,13 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
250
332
|
],
|
|
251
333
|
)
|
|
252
334
|
|
|
253
|
-
|
|
335
|
+
self._interceptor = _LoggingClientAIOInterceptor()
|
|
336
|
+
self._grpc_channel._unary_unary_interceptors.append(self._interceptor)
|
|
337
|
+
self._logged_channel = self._grpc_channel
|
|
254
338
|
self._wrap_with_kind = (
|
|
255
339
|
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
|
|
256
340
|
)
|
|
341
|
+
# Wrap messages. This must be done after self._logged_channel exists
|
|
257
342
|
self._prep_wrapped_messages(client_info)
|
|
258
343
|
|
|
259
344
|
@property
|
|
@@ -276,7 +361,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
276
361
|
# Quick check: Only create a new client if we do not already have one.
|
|
277
362
|
if self._operations_client is None:
|
|
278
363
|
self._operations_client = operations_v1.OperationsAsyncClient(
|
|
279
|
-
self.
|
|
364
|
+
self._logged_channel
|
|
280
365
|
)
|
|
281
366
|
|
|
282
367
|
# Return the client from cache.
|
|
@@ -319,7 +404,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
319
404
|
# gRPC handles serialization and deserialization, so we just need
|
|
320
405
|
# to pass in the functions for each.
|
|
321
406
|
if "optimize_tours" not in self._stubs:
|
|
322
|
-
self._stubs["optimize_tours"] = self.
|
|
407
|
+
self._stubs["optimize_tours"] = self._logged_channel.unary_unary(
|
|
323
408
|
"/google.maps.routeoptimization.v1.RouteOptimization/OptimizeTours",
|
|
324
409
|
request_serializer=route_optimization_service.OptimizeToursRequest.serialize,
|
|
325
410
|
response_deserializer=route_optimization_service.OptimizeToursResponse.deserialize,
|
|
@@ -372,7 +457,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
372
457
|
# gRPC handles serialization and deserialization, so we just need
|
|
373
458
|
# to pass in the functions for each.
|
|
374
459
|
if "batch_optimize_tours" not in self._stubs:
|
|
375
|
-
self._stubs["batch_optimize_tours"] = self.
|
|
460
|
+
self._stubs["batch_optimize_tours"] = self._logged_channel.unary_unary(
|
|
376
461
|
"/google.maps.routeoptimization.v1.RouteOptimization/BatchOptimizeTours",
|
|
377
462
|
request_serializer=route_optimization_service.BatchOptimizeToursRequest.serialize,
|
|
378
463
|
response_deserializer=operations_pb2.Operation.FromString,
|
|
@@ -414,7 +499,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
414
499
|
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)
|
|
415
500
|
|
|
416
501
|
def close(self):
|
|
417
|
-
return self.
|
|
502
|
+
return self._logged_channel.close()
|
|
418
503
|
|
|
419
504
|
@property
|
|
420
505
|
def kind(self) -> str:
|
|
@@ -430,7 +515,7 @@ class RouteOptimizationGrpcAsyncIOTransport(RouteOptimizationTransport):
|
|
|
430
515
|
# gRPC handles serialization and deserialization, so we just need
|
|
431
516
|
# to pass in the functions for each.
|
|
432
517
|
if "get_operation" not in self._stubs:
|
|
433
|
-
self._stubs["get_operation"] = self.
|
|
518
|
+
self._stubs["get_operation"] = self._logged_channel.unary_unary(
|
|
434
519
|
"/google.longrunning.Operations/GetOperation",
|
|
435
520
|
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
|
|
436
521
|
response_deserializer=operations_pb2.Operation.FromString,
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
|
-
|
|
17
16
|
import dataclasses
|
|
18
17
|
import json # type: ignore
|
|
18
|
+
import logging
|
|
19
19
|
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
|
|
20
20
|
import warnings
|
|
21
21
|
|
|
@@ -38,6 +38,14 @@ try:
|
|
|
38
38
|
except AttributeError: # pragma: NO COVER
|
|
39
39
|
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
|
|
40
40
|
|
|
41
|
+
try:
|
|
42
|
+
from google.api_core import client_logging # type: ignore
|
|
43
|
+
|
|
44
|
+
CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
|
|
45
|
+
except ImportError: # pragma: NO COVER
|
|
46
|
+
CLIENT_LOGGING_SUPPORTED = False
|
|
47
|
+
|
|
48
|
+
_LOGGER = logging.getLogger(__name__)
|
|
41
49
|
|
|
42
50
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
43
51
|
gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
|
|
@@ -86,9 +94,10 @@ class RouteOptimizationRestInterceptor:
|
|
|
86
94
|
def pre_batch_optimize_tours(
|
|
87
95
|
self,
|
|
88
96
|
request: route_optimization_service.BatchOptimizeToursRequest,
|
|
89
|
-
metadata: Sequence[Tuple[str, str]],
|
|
97
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
90
98
|
) -> Tuple[
|
|
91
|
-
route_optimization_service.BatchOptimizeToursRequest,
|
|
99
|
+
route_optimization_service.BatchOptimizeToursRequest,
|
|
100
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
92
101
|
]:
|
|
93
102
|
"""Pre-rpc interceptor for batch_optimize_tours
|
|
94
103
|
|
|
@@ -111,9 +120,10 @@ class RouteOptimizationRestInterceptor:
|
|
|
111
120
|
def pre_optimize_tours(
|
|
112
121
|
self,
|
|
113
122
|
request: route_optimization_service.OptimizeToursRequest,
|
|
114
|
-
metadata: Sequence[Tuple[str, str]],
|
|
123
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
115
124
|
) -> Tuple[
|
|
116
|
-
route_optimization_service.OptimizeToursRequest,
|
|
125
|
+
route_optimization_service.OptimizeToursRequest,
|
|
126
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
117
127
|
]:
|
|
118
128
|
"""Pre-rpc interceptor for optimize_tours
|
|
119
129
|
|
|
@@ -136,8 +146,10 @@ class RouteOptimizationRestInterceptor:
|
|
|
136
146
|
def pre_get_operation(
|
|
137
147
|
self,
|
|
138
148
|
request: operations_pb2.GetOperationRequest,
|
|
139
|
-
metadata: Sequence[Tuple[str, str]],
|
|
140
|
-
) -> Tuple[
|
|
149
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
150
|
+
) -> Tuple[
|
|
151
|
+
operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]]
|
|
152
|
+
]:
|
|
141
153
|
"""Pre-rpc interceptor for get_operation
|
|
142
154
|
|
|
143
155
|
Override in a subclass to manipulate the request or metadata
|
|
@@ -336,7 +348,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
336
348
|
*,
|
|
337
349
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
338
350
|
timeout: Optional[float] = None,
|
|
339
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
351
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
340
352
|
) -> operations_pb2.Operation:
|
|
341
353
|
r"""Call the batch optimize tours method over HTTP.
|
|
342
354
|
|
|
@@ -352,8 +364,10 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
352
364
|
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
353
365
|
should be retried.
|
|
354
366
|
timeout (float): The timeout for this request.
|
|
355
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
356
|
-
sent along with the request as metadata.
|
|
367
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
368
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
369
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
370
|
+
be of type `bytes`.
|
|
357
371
|
|
|
358
372
|
Returns:
|
|
359
373
|
~.operations_pb2.Operation:
|
|
@@ -366,6 +380,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
366
380
|
http_options = (
|
|
367
381
|
_BaseRouteOptimizationRestTransport._BaseBatchOptimizeTours._get_http_options()
|
|
368
382
|
)
|
|
383
|
+
|
|
369
384
|
request, metadata = self._interceptor.pre_batch_optimize_tours(
|
|
370
385
|
request, metadata
|
|
371
386
|
)
|
|
@@ -382,6 +397,33 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
382
397
|
transcoded_request
|
|
383
398
|
)
|
|
384
399
|
|
|
400
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
401
|
+
logging.DEBUG
|
|
402
|
+
): # pragma: NO COVER
|
|
403
|
+
request_url = "{host}{uri}".format(
|
|
404
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
405
|
+
)
|
|
406
|
+
method = transcoded_request["method"]
|
|
407
|
+
try:
|
|
408
|
+
request_payload = json_format.MessageToJson(request)
|
|
409
|
+
except:
|
|
410
|
+
request_payload = None
|
|
411
|
+
http_request = {
|
|
412
|
+
"payload": request_payload,
|
|
413
|
+
"requestMethod": method,
|
|
414
|
+
"requestUrl": request_url,
|
|
415
|
+
"headers": dict(metadata),
|
|
416
|
+
}
|
|
417
|
+
_LOGGER.debug(
|
|
418
|
+
f"Sending request for google.maps.routeoptimization_v1.RouteOptimizationClient.BatchOptimizeTours",
|
|
419
|
+
extra={
|
|
420
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
421
|
+
"rpcName": "BatchOptimizeTours",
|
|
422
|
+
"httpRequest": http_request,
|
|
423
|
+
"metadata": http_request["headers"],
|
|
424
|
+
},
|
|
425
|
+
)
|
|
426
|
+
|
|
385
427
|
# Send the request
|
|
386
428
|
response = RouteOptimizationRestTransport._BatchOptimizeTours._get_response(
|
|
387
429
|
self._host,
|
|
@@ -401,7 +443,29 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
401
443
|
# Return the response
|
|
402
444
|
resp = operations_pb2.Operation()
|
|
403
445
|
json_format.Parse(response.content, resp, ignore_unknown_fields=True)
|
|
446
|
+
|
|
404
447
|
resp = self._interceptor.post_batch_optimize_tours(resp)
|
|
448
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
449
|
+
logging.DEBUG
|
|
450
|
+
): # pragma: NO COVER
|
|
451
|
+
try:
|
|
452
|
+
response_payload = json_format.MessageToJson(resp)
|
|
453
|
+
except:
|
|
454
|
+
response_payload = None
|
|
455
|
+
http_response = {
|
|
456
|
+
"payload": response_payload,
|
|
457
|
+
"headers": dict(response.headers),
|
|
458
|
+
"status": response.status_code,
|
|
459
|
+
}
|
|
460
|
+
_LOGGER.debug(
|
|
461
|
+
"Received response for google.maps.routeoptimization_v1.RouteOptimizationClient.batch_optimize_tours",
|
|
462
|
+
extra={
|
|
463
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
464
|
+
"rpcName": "BatchOptimizeTours",
|
|
465
|
+
"metadata": http_response["headers"],
|
|
466
|
+
"httpResponse": http_response,
|
|
467
|
+
},
|
|
468
|
+
)
|
|
405
469
|
return resp
|
|
406
470
|
|
|
407
471
|
class _OptimizeTours(
|
|
@@ -440,7 +504,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
440
504
|
*,
|
|
441
505
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
442
506
|
timeout: Optional[float] = None,
|
|
443
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
507
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
444
508
|
) -> route_optimization_service.OptimizeToursResponse:
|
|
445
509
|
r"""Call the optimize tours method over HTTP.
|
|
446
510
|
|
|
@@ -453,8 +517,10 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
453
517
|
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
454
518
|
should be retried.
|
|
455
519
|
timeout (float): The timeout for this request.
|
|
456
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
457
|
-
sent along with the request as metadata.
|
|
520
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
521
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
522
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
523
|
+
be of type `bytes`.
|
|
458
524
|
|
|
459
525
|
Returns:
|
|
460
526
|
~.route_optimization_service.OptimizeToursResponse:
|
|
@@ -469,6 +535,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
469
535
|
http_options = (
|
|
470
536
|
_BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_http_options()
|
|
471
537
|
)
|
|
538
|
+
|
|
472
539
|
request, metadata = self._interceptor.pre_optimize_tours(request, metadata)
|
|
473
540
|
transcoded_request = _BaseRouteOptimizationRestTransport._BaseOptimizeTours._get_transcoded_request(
|
|
474
541
|
http_options, request
|
|
@@ -483,6 +550,33 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
483
550
|
transcoded_request
|
|
484
551
|
)
|
|
485
552
|
|
|
553
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
554
|
+
logging.DEBUG
|
|
555
|
+
): # pragma: NO COVER
|
|
556
|
+
request_url = "{host}{uri}".format(
|
|
557
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
558
|
+
)
|
|
559
|
+
method = transcoded_request["method"]
|
|
560
|
+
try:
|
|
561
|
+
request_payload = type(request).to_json(request)
|
|
562
|
+
except:
|
|
563
|
+
request_payload = None
|
|
564
|
+
http_request = {
|
|
565
|
+
"payload": request_payload,
|
|
566
|
+
"requestMethod": method,
|
|
567
|
+
"requestUrl": request_url,
|
|
568
|
+
"headers": dict(metadata),
|
|
569
|
+
}
|
|
570
|
+
_LOGGER.debug(
|
|
571
|
+
f"Sending request for google.maps.routeoptimization_v1.RouteOptimizationClient.OptimizeTours",
|
|
572
|
+
extra={
|
|
573
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
574
|
+
"rpcName": "OptimizeTours",
|
|
575
|
+
"httpRequest": http_request,
|
|
576
|
+
"metadata": http_request["headers"],
|
|
577
|
+
},
|
|
578
|
+
)
|
|
579
|
+
|
|
486
580
|
# Send the request
|
|
487
581
|
response = RouteOptimizationRestTransport._OptimizeTours._get_response(
|
|
488
582
|
self._host,
|
|
@@ -504,7 +598,33 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
504
598
|
pb_resp = route_optimization_service.OptimizeToursResponse.pb(resp)
|
|
505
599
|
|
|
506
600
|
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
601
|
+
|
|
507
602
|
resp = self._interceptor.post_optimize_tours(resp)
|
|
603
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
604
|
+
logging.DEBUG
|
|
605
|
+
): # pragma: NO COVER
|
|
606
|
+
try:
|
|
607
|
+
response_payload = (
|
|
608
|
+
route_optimization_service.OptimizeToursResponse.to_json(
|
|
609
|
+
response
|
|
610
|
+
)
|
|
611
|
+
)
|
|
612
|
+
except:
|
|
613
|
+
response_payload = None
|
|
614
|
+
http_response = {
|
|
615
|
+
"payload": response_payload,
|
|
616
|
+
"headers": dict(response.headers),
|
|
617
|
+
"status": response.status_code,
|
|
618
|
+
}
|
|
619
|
+
_LOGGER.debug(
|
|
620
|
+
"Received response for google.maps.routeoptimization_v1.RouteOptimizationClient.optimize_tours",
|
|
621
|
+
extra={
|
|
622
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
623
|
+
"rpcName": "OptimizeTours",
|
|
624
|
+
"metadata": http_response["headers"],
|
|
625
|
+
"httpResponse": http_response,
|
|
626
|
+
},
|
|
627
|
+
)
|
|
508
628
|
return resp
|
|
509
629
|
|
|
510
630
|
@property
|
|
@@ -566,7 +686,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
566
686
|
*,
|
|
567
687
|
retry: OptionalRetry = gapic_v1.method.DEFAULT,
|
|
568
688
|
timeout: Optional[float] = None,
|
|
569
|
-
metadata: Sequence[Tuple[str, str]] = (),
|
|
689
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
|
|
570
690
|
) -> operations_pb2.Operation:
|
|
571
691
|
r"""Call the get operation method over HTTP.
|
|
572
692
|
|
|
@@ -576,8 +696,10 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
576
696
|
retry (google.api_core.retry.Retry): Designation of what errors, if any,
|
|
577
697
|
should be retried.
|
|
578
698
|
timeout (float): The timeout for this request.
|
|
579
|
-
metadata (Sequence[Tuple[str, str]]):
|
|
580
|
-
sent along with the request as metadata.
|
|
699
|
+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
|
|
700
|
+
sent along with the request as metadata. Normally, each value must be of type `str`,
|
|
701
|
+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
|
|
702
|
+
be of type `bytes`.
|
|
581
703
|
|
|
582
704
|
Returns:
|
|
583
705
|
operations_pb2.Operation: Response from GetOperation method.
|
|
@@ -586,6 +708,7 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
586
708
|
http_options = (
|
|
587
709
|
_BaseRouteOptimizationRestTransport._BaseGetOperation._get_http_options()
|
|
588
710
|
)
|
|
711
|
+
|
|
589
712
|
request, metadata = self._interceptor.pre_get_operation(request, metadata)
|
|
590
713
|
transcoded_request = _BaseRouteOptimizationRestTransport._BaseGetOperation._get_transcoded_request(
|
|
591
714
|
http_options, request
|
|
@@ -596,6 +719,33 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
596
719
|
transcoded_request
|
|
597
720
|
)
|
|
598
721
|
|
|
722
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
723
|
+
logging.DEBUG
|
|
724
|
+
): # pragma: NO COVER
|
|
725
|
+
request_url = "{host}{uri}".format(
|
|
726
|
+
host=self._host, uri=transcoded_request["uri"]
|
|
727
|
+
)
|
|
728
|
+
method = transcoded_request["method"]
|
|
729
|
+
try:
|
|
730
|
+
request_payload = json_format.MessageToJson(request)
|
|
731
|
+
except:
|
|
732
|
+
request_payload = None
|
|
733
|
+
http_request = {
|
|
734
|
+
"payload": request_payload,
|
|
735
|
+
"requestMethod": method,
|
|
736
|
+
"requestUrl": request_url,
|
|
737
|
+
"headers": dict(metadata),
|
|
738
|
+
}
|
|
739
|
+
_LOGGER.debug(
|
|
740
|
+
f"Sending request for google.maps.routeoptimization_v1.RouteOptimizationClient.GetOperation",
|
|
741
|
+
extra={
|
|
742
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
743
|
+
"rpcName": "GetOperation",
|
|
744
|
+
"httpRequest": http_request,
|
|
745
|
+
"metadata": http_request["headers"],
|
|
746
|
+
},
|
|
747
|
+
)
|
|
748
|
+
|
|
599
749
|
# Send the request
|
|
600
750
|
response = RouteOptimizationRestTransport._GetOperation._get_response(
|
|
601
751
|
self._host,
|
|
@@ -615,6 +765,27 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
615
765
|
resp = operations_pb2.Operation()
|
|
616
766
|
resp = json_format.Parse(content, resp)
|
|
617
767
|
resp = self._interceptor.post_get_operation(resp)
|
|
768
|
+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
769
|
+
logging.DEBUG
|
|
770
|
+
): # pragma: NO COVER
|
|
771
|
+
try:
|
|
772
|
+
response_payload = json_format.MessageToJson(resp)
|
|
773
|
+
except:
|
|
774
|
+
response_payload = None
|
|
775
|
+
http_response = {
|
|
776
|
+
"payload": response_payload,
|
|
777
|
+
"headers": dict(response.headers),
|
|
778
|
+
"status": response.status_code,
|
|
779
|
+
}
|
|
780
|
+
_LOGGER.debug(
|
|
781
|
+
"Received response for google.maps.routeoptimization_v1.RouteOptimizationAsyncClient.GetOperation",
|
|
782
|
+
extra={
|
|
783
|
+
"serviceName": "google.maps.routeoptimization.v1.RouteOptimization",
|
|
784
|
+
"rpcName": "GetOperation",
|
|
785
|
+
"httpResponse": http_response,
|
|
786
|
+
"metadata": http_response["headers"],
|
|
787
|
+
},
|
|
788
|
+
)
|
|
618
789
|
return resp
|
|
619
790
|
|
|
620
791
|
@property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-maps-routeoptimization
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
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
|
|
@@ -1719,6 +1719,7 @@ def test_optimize_tours_rest_required_fields(
|
|
|
1719
1719
|
|
|
1720
1720
|
response_value._content = json_return_value.encode("UTF-8")
|
|
1721
1721
|
req.return_value = response_value
|
|
1722
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
1722
1723
|
|
|
1723
1724
|
response = client.optimize_tours(request)
|
|
1724
1725
|
|
|
@@ -1844,6 +1845,7 @@ def test_batch_optimize_tours_rest_required_fields(
|
|
|
1844
1845
|
|
|
1845
1846
|
response_value._content = json_return_value.encode("UTF-8")
|
|
1846
1847
|
req.return_value = response_value
|
|
1848
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
1847
1849
|
|
|
1848
1850
|
response = client.batch_optimize_tours(request)
|
|
1849
1851
|
|
|
@@ -2115,6 +2117,7 @@ def test_optimize_tours_rest_bad_request(
|
|
|
2115
2117
|
response_value.status_code = 400
|
|
2116
2118
|
response_value.request = mock.Mock()
|
|
2117
2119
|
req.return_value = response_value
|
|
2120
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2118
2121
|
client.optimize_tours(request)
|
|
2119
2122
|
|
|
2120
2123
|
|
|
@@ -2150,6 +2153,7 @@ def test_optimize_tours_rest_call_success(request_type):
|
|
|
2150
2153
|
json_return_value = json_format.MessageToJson(return_value)
|
|
2151
2154
|
response_value.content = json_return_value.encode("UTF-8")
|
|
2152
2155
|
req.return_value = response_value
|
|
2156
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2153
2157
|
response = client.optimize_tours(request)
|
|
2154
2158
|
|
|
2155
2159
|
# Establish that the response is the type that we expect.
|
|
@@ -2190,6 +2194,7 @@ def test_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2190
2194
|
|
|
2191
2195
|
req.return_value = mock.Mock()
|
|
2192
2196
|
req.return_value.status_code = 200
|
|
2197
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2193
2198
|
return_value = route_optimization_service.OptimizeToursResponse.to_json(
|
|
2194
2199
|
route_optimization_service.OptimizeToursResponse()
|
|
2195
2200
|
)
|
|
@@ -2236,6 +2241,7 @@ def test_batch_optimize_tours_rest_bad_request(
|
|
|
2236
2241
|
response_value.status_code = 400
|
|
2237
2242
|
response_value.request = mock.Mock()
|
|
2238
2243
|
req.return_value = response_value
|
|
2244
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2239
2245
|
client.batch_optimize_tours(request)
|
|
2240
2246
|
|
|
2241
2247
|
|
|
@@ -2266,6 +2272,7 @@ def test_batch_optimize_tours_rest_call_success(request_type):
|
|
|
2266
2272
|
json_return_value = json_format.MessageToJson(return_value)
|
|
2267
2273
|
response_value.content = json_return_value.encode("UTF-8")
|
|
2268
2274
|
req.return_value = response_value
|
|
2275
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2269
2276
|
response = client.batch_optimize_tours(request)
|
|
2270
2277
|
|
|
2271
2278
|
# Establish that the response is the type that we expect.
|
|
@@ -2307,6 +2314,7 @@ def test_batch_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2307
2314
|
|
|
2308
2315
|
req.return_value = mock.Mock()
|
|
2309
2316
|
req.return_value.status_code = 200
|
|
2317
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2310
2318
|
return_value = json_format.MessageToJson(operations_pb2.Operation())
|
|
2311
2319
|
req.return_value.content = return_value
|
|
2312
2320
|
|
|
@@ -2353,6 +2361,7 @@ def test_get_operation_rest_bad_request(
|
|
|
2353
2361
|
response_value.status_code = 400
|
|
2354
2362
|
response_value.request = Request()
|
|
2355
2363
|
req.return_value = response_value
|
|
2364
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2356
2365
|
client.get_operation(request)
|
|
2357
2366
|
|
|
2358
2367
|
|
|
@@ -2383,6 +2392,7 @@ def test_get_operation_rest(request_type):
|
|
|
2383
2392
|
response_value.content = json_return_value.encode("UTF-8")
|
|
2384
2393
|
|
|
2385
2394
|
req.return_value = response_value
|
|
2395
|
+
req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"}
|
|
2386
2396
|
|
|
2387
2397
|
response = client.get_operation(request)
|
|
2388
2398
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/__init__.py
RENAMED
|
File without changes
|
{google_maps_routeoptimization-0.1.6 → google_maps_routeoptimization-0.1.7}/tests/unit/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|