google-maps-routeoptimization 0.1.7__tar.gz → 0.1.9__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.7/google_maps_routeoptimization.egg-info → google_maps_routeoptimization-0.1.9}/PKG-INFO +97 -8
- google_maps_routeoptimization-0.1.9/README.rst +197 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/gapic_version.py +1 -1
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/client.py +42 -9
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/rest.py +61 -4
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9/google_maps_routeoptimization.egg-info}/PKG-INFO +97 -8
- google_maps_routeoptimization-0.1.9/google_maps_routeoptimization.egg-info/requires.txt +7 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/setup.py +5 -5
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/tests/unit/gapic/routeoptimization_v1/test_route_optimization.py +64 -0
- google_maps_routeoptimization-0.1.7/README.rst +0 -108
- google_maps_routeoptimization-0.1.7/google_maps_routeoptimization.egg-info/requires.txt +0 -7
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/LICENSE +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/MANIFEST.in +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization/py.typed +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/gapic_metadata.json +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/py.typed +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/async_client.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/base.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/grpc_asyncio.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/services/route_optimization/transports/rest_base.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/types/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google/maps/routeoptimization_v1/types/route_optimization_service.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google_maps_routeoptimization.egg-info/SOURCES.txt +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google_maps_routeoptimization.egg-info/dependency_links.txt +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google_maps_routeoptimization.egg-info/not-zip-safe +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/google_maps_routeoptimization.egg-info/top_level.txt +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/setup.cfg +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/tests/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/tests/unit/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/tests/unit/gapic/__init__.py +0 -0
- {google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/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.9
|
|
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
|
|
@@ -23,11 +23,11 @@ Classifier: Operating System :: OS Independent
|
|
|
23
23
|
Classifier: Topic :: Internet
|
|
24
24
|
Requires-Python: >=3.7
|
|
25
25
|
License-File: LICENSE
|
|
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.
|
|
27
|
-
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.
|
|
28
|
-
Requires-Dist: proto-plus<2.0.
|
|
29
|
-
Requires-Dist: proto-plus<2.0.
|
|
30
|
-
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<
|
|
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.0,>=1.34.1
|
|
27
|
+
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
28
|
+
Requires-Dist: proto-plus<2.0.0,>=1.22.3
|
|
29
|
+
Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
|
|
30
|
+
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
|
|
31
31
|
|
|
32
32
|
Python Client for Route Optimization API
|
|
33
33
|
========================================
|
|
@@ -57,12 +57,12 @@ In order to use this library, you first need to go through the following steps:
|
|
|
57
57
|
1. `Select or create a Cloud Platform project.`_
|
|
58
58
|
2. `Enable billing for your project.`_
|
|
59
59
|
3. `Enable the Route Optimization API.`_
|
|
60
|
-
4. `
|
|
60
|
+
4. `Set up Authentication.`_
|
|
61
61
|
|
|
62
62
|
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
63
63
|
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
64
64
|
.. _Enable the Route Optimization API.: https://developers.google.com/maps/documentation/route-optimization
|
|
65
|
-
..
|
|
65
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
66
66
|
|
|
67
67
|
Installation
|
|
68
68
|
~~~~~~~~~~~~
|
|
@@ -137,3 +137,92 @@ Next Steps
|
|
|
137
137
|
|
|
138
138
|
.. _Route Optimization API Product documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
139
139
|
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
140
|
+
|
|
141
|
+
Logging
|
|
142
|
+
-------
|
|
143
|
+
|
|
144
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
145
|
+
Note the following:
|
|
146
|
+
|
|
147
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
148
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
149
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
150
|
+
|
|
151
|
+
Simple, environment-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
155
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
156
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
157
|
+
event.
|
|
158
|
+
|
|
159
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
160
|
+
|
|
161
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
162
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
163
|
+
|
|
164
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
165
|
+
|
|
166
|
+
Environment-Based Examples
|
|
167
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
168
|
+
|
|
169
|
+
- Enabling the default handler for all Google-based loggers
|
|
170
|
+
|
|
171
|
+
.. code-block:: console
|
|
172
|
+
|
|
173
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
174
|
+
|
|
175
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
176
|
+
|
|
177
|
+
.. code-block:: console
|
|
178
|
+
|
|
179
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
Advanced, code-based configuration
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
184
|
+
|
|
185
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
186
|
+
|
|
187
|
+
Code-Based Examples
|
|
188
|
+
^^^^^^^^^^^^^^^^^^^
|
|
189
|
+
|
|
190
|
+
- Configuring a handler for all Google-based loggers
|
|
191
|
+
|
|
192
|
+
.. code-block:: python
|
|
193
|
+
|
|
194
|
+
import logging
|
|
195
|
+
|
|
196
|
+
from google.cloud.translate_v3 import translate
|
|
197
|
+
|
|
198
|
+
base_logger = logging.getLogger("google")
|
|
199
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
200
|
+
base_logger.setLevel(logging.DEBUG)
|
|
201
|
+
|
|
202
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
203
|
+
|
|
204
|
+
.. code-block:: python
|
|
205
|
+
|
|
206
|
+
import logging
|
|
207
|
+
|
|
208
|
+
from google.cloud.translate_v3 import translate
|
|
209
|
+
|
|
210
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
211
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
212
|
+
base_logger.setLevel(logging.DEBUG)
|
|
213
|
+
|
|
214
|
+
Logging details
|
|
215
|
+
~~~~~~~~~~~~~~~
|
|
216
|
+
|
|
217
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
218
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
219
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
220
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
221
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
222
|
+
|
|
223
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
224
|
+
if the code -based configuration gets applied first.
|
|
225
|
+
|
|
226
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
227
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
228
|
+
(This is the reason for 2.i. above.)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Python Client for Route Optimization API
|
|
2
|
+
========================================
|
|
3
|
+
|
|
4
|
+
|preview| |pypi| |versions|
|
|
5
|
+
|
|
6
|
+
`Route Optimization API`_: he Route Optimization API assigns tasks and routes to a vehicle fleet, optimizing against the objectives and constraints that you supply for your transportation goals.
|
|
7
|
+
|
|
8
|
+
- `Client Library Documentation`_
|
|
9
|
+
- `Product Documentation`_
|
|
10
|
+
|
|
11
|
+
.. |preview| image:: https://img.shields.io/badge/support-preview-orange.svg
|
|
12
|
+
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
|
|
13
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/google-maps-routeoptimization.svg
|
|
14
|
+
:target: https://pypi.org/project/google-maps-routeoptimization/
|
|
15
|
+
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-maps-routeoptimization.svg
|
|
16
|
+
:target: https://pypi.org/project/google-maps-routeoptimization/
|
|
17
|
+
.. _Route Optimization API: https://developers.google.com/maps/documentation/route-optimization
|
|
18
|
+
.. _Client Library Documentation: https://googleapis.dev/python/google-maps-routeoptimization/latest
|
|
19
|
+
.. _Product Documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
20
|
+
|
|
21
|
+
Quick Start
|
|
22
|
+
-----------
|
|
23
|
+
|
|
24
|
+
In order to use this library, you first need to go through the following steps:
|
|
25
|
+
|
|
26
|
+
1. `Select or create a Cloud Platform project.`_
|
|
27
|
+
2. `Enable billing for your project.`_
|
|
28
|
+
3. `Enable the Route Optimization API.`_
|
|
29
|
+
4. `Set up Authentication.`_
|
|
30
|
+
|
|
31
|
+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
32
|
+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
33
|
+
.. _Enable the Route Optimization API.: https://developers.google.com/maps/documentation/route-optimization
|
|
34
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
35
|
+
|
|
36
|
+
Installation
|
|
37
|
+
~~~~~~~~~~~~
|
|
38
|
+
|
|
39
|
+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
|
|
40
|
+
creates isolated Python environments. These isolated environments can have separate
|
|
41
|
+
versions of Python packages, which allows you to isolate one project's dependencies
|
|
42
|
+
from the dependencies of other projects.
|
|
43
|
+
|
|
44
|
+
With `venv`_, it's possible to install this library without needing system
|
|
45
|
+
install permissions, and without clashing with the installed system
|
|
46
|
+
dependencies.
|
|
47
|
+
|
|
48
|
+
.. _`venv`: https://docs.python.org/3/library/venv.html
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Code samples and snippets
|
|
52
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
53
|
+
|
|
54
|
+
Code samples and snippets live in the `samples/`_ folder.
|
|
55
|
+
|
|
56
|
+
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-maps-routeoptimization/samples
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Supported Python Versions
|
|
60
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
61
|
+
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
62
|
+
Python.
|
|
63
|
+
|
|
64
|
+
Python >= 3.7
|
|
65
|
+
|
|
66
|
+
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
67
|
+
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
68
|
+
|
|
69
|
+
Unsupported Python Versions
|
|
70
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
71
|
+
Python <= 3.6
|
|
72
|
+
|
|
73
|
+
If you are using an `end-of-life`_
|
|
74
|
+
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
75
|
+
|
|
76
|
+
.. _end-of-life: https://devguide.python.org/devcycle/#end-of-life-branches
|
|
77
|
+
|
|
78
|
+
Mac/Linux
|
|
79
|
+
^^^^^^^^^
|
|
80
|
+
|
|
81
|
+
.. code-block:: console
|
|
82
|
+
|
|
83
|
+
python3 -m venv <your-env>
|
|
84
|
+
source <your-env>/bin/activate
|
|
85
|
+
pip install google-maps-routeoptimization
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Windows
|
|
89
|
+
^^^^^^^
|
|
90
|
+
|
|
91
|
+
.. code-block:: console
|
|
92
|
+
|
|
93
|
+
py -m venv <your-env>
|
|
94
|
+
.\<your-env>\Scripts\activate
|
|
95
|
+
pip install google-maps-routeoptimization
|
|
96
|
+
|
|
97
|
+
Next Steps
|
|
98
|
+
~~~~~~~~~~
|
|
99
|
+
|
|
100
|
+
- Read the `Client Library Documentation`_ for Route Optimization API
|
|
101
|
+
to see other available methods on the client.
|
|
102
|
+
- Read the `Route Optimization API Product documentation`_ to learn
|
|
103
|
+
more about the product and see How-to Guides.
|
|
104
|
+
- View this `README`_ to see the full list of Cloud
|
|
105
|
+
APIs that we cover.
|
|
106
|
+
|
|
107
|
+
.. _Route Optimization API Product documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
108
|
+
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
109
|
+
|
|
110
|
+
Logging
|
|
111
|
+
-------
|
|
112
|
+
|
|
113
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
114
|
+
Note the following:
|
|
115
|
+
|
|
116
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
117
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
118
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
119
|
+
|
|
120
|
+
Simple, environment-based configuration
|
|
121
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
122
|
+
|
|
123
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
124
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
125
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
126
|
+
event.
|
|
127
|
+
|
|
128
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
129
|
+
|
|
130
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
131
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
132
|
+
|
|
133
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
134
|
+
|
|
135
|
+
Environment-Based Examples
|
|
136
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
137
|
+
|
|
138
|
+
- Enabling the default handler for all Google-based loggers
|
|
139
|
+
|
|
140
|
+
.. code-block:: console
|
|
141
|
+
|
|
142
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
143
|
+
|
|
144
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
145
|
+
|
|
146
|
+
.. code-block:: console
|
|
147
|
+
|
|
148
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Advanced, code-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
155
|
+
|
|
156
|
+
Code-Based Examples
|
|
157
|
+
^^^^^^^^^^^^^^^^^^^
|
|
158
|
+
|
|
159
|
+
- Configuring a handler for all Google-based loggers
|
|
160
|
+
|
|
161
|
+
.. code-block:: python
|
|
162
|
+
|
|
163
|
+
import logging
|
|
164
|
+
|
|
165
|
+
from google.cloud.translate_v3 import translate
|
|
166
|
+
|
|
167
|
+
base_logger = logging.getLogger("google")
|
|
168
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
169
|
+
base_logger.setLevel(logging.DEBUG)
|
|
170
|
+
|
|
171
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
172
|
+
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
import logging
|
|
176
|
+
|
|
177
|
+
from google.cloud.translate_v3 import translate
|
|
178
|
+
|
|
179
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
180
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
181
|
+
base_logger.setLevel(logging.DEBUG)
|
|
182
|
+
|
|
183
|
+
Logging details
|
|
184
|
+
~~~~~~~~~~~~~~~
|
|
185
|
+
|
|
186
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
187
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
188
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
189
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
190
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
191
|
+
|
|
192
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
193
|
+
if the code -based configuration gets applied first.
|
|
194
|
+
|
|
195
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
196
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
197
|
+
(This is the reason for 2.i. above.)
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
#
|
|
16
16
|
from collections import OrderedDict
|
|
17
|
+
from http import HTTPStatus
|
|
18
|
+
import json
|
|
17
19
|
import logging as std_logging
|
|
18
20
|
import os
|
|
19
21
|
import re
|
|
@@ -488,6 +490,33 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
488
490
|
# NOTE (b/349488459): universe validation is disabled until further notice.
|
|
489
491
|
return True
|
|
490
492
|
|
|
493
|
+
def _add_cred_info_for_auth_errors(
|
|
494
|
+
self, error: core_exceptions.GoogleAPICallError
|
|
495
|
+
) -> None:
|
|
496
|
+
"""Adds credential info string to error details for 401/403/404 errors.
|
|
497
|
+
|
|
498
|
+
Args:
|
|
499
|
+
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
|
|
500
|
+
"""
|
|
501
|
+
if error.code not in [
|
|
502
|
+
HTTPStatus.UNAUTHORIZED,
|
|
503
|
+
HTTPStatus.FORBIDDEN,
|
|
504
|
+
HTTPStatus.NOT_FOUND,
|
|
505
|
+
]:
|
|
506
|
+
return
|
|
507
|
+
|
|
508
|
+
cred = self._transport._credentials
|
|
509
|
+
|
|
510
|
+
# get_cred_info is only available in google-auth>=2.35.0
|
|
511
|
+
if not hasattr(cred, "get_cred_info"):
|
|
512
|
+
return
|
|
513
|
+
|
|
514
|
+
# ignore the type check since pypy test fails when get_cred_info
|
|
515
|
+
# is not available
|
|
516
|
+
cred_info = cred.get_cred_info() # type: ignore
|
|
517
|
+
if cred_info and hasattr(error._details, "append"):
|
|
518
|
+
error._details.append(json.dumps(cred_info))
|
|
519
|
+
|
|
491
520
|
@property
|
|
492
521
|
def api_endpoint(self):
|
|
493
522
|
"""Return the API endpoint used by the client instance.
|
|
@@ -991,16 +1020,20 @@ class RouteOptimizationClient(metaclass=RouteOptimizationClientMeta):
|
|
|
991
1020
|
# Validate the universe domain.
|
|
992
1021
|
self._validate_universe_domain()
|
|
993
1022
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1023
|
+
try:
|
|
1024
|
+
# Send the request.
|
|
1025
|
+
response = rpc(
|
|
1026
|
+
request,
|
|
1027
|
+
retry=retry,
|
|
1028
|
+
timeout=timeout,
|
|
1029
|
+
metadata=metadata,
|
|
1030
|
+
)
|
|
1001
1031
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1032
|
+
# Done; return the response.
|
|
1033
|
+
return response
|
|
1034
|
+
except core_exceptions.GoogleAPICallError as e:
|
|
1035
|
+
self._add_cred_info_for_auth_errors(e)
|
|
1036
|
+
raise e
|
|
1004
1037
|
|
|
1005
1038
|
|
|
1006
1039
|
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
|
|
@@ -111,12 +111,35 @@ class RouteOptimizationRestInterceptor:
|
|
|
111
111
|
) -> operations_pb2.Operation:
|
|
112
112
|
"""Post-rpc interceptor for batch_optimize_tours
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
DEPRECATED. Please use the `post_batch_optimize_tours_with_metadata`
|
|
115
|
+
interceptor instead.
|
|
116
|
+
|
|
117
|
+
Override in a subclass to read or manipulate the response
|
|
115
118
|
after it is returned by the RouteOptimization server but before
|
|
116
|
-
it is returned to user code.
|
|
119
|
+
it is returned to user code. This `post_batch_optimize_tours` interceptor runs
|
|
120
|
+
before the `post_batch_optimize_tours_with_metadata` interceptor.
|
|
117
121
|
"""
|
|
118
122
|
return response
|
|
119
123
|
|
|
124
|
+
def post_batch_optimize_tours_with_metadata(
|
|
125
|
+
self,
|
|
126
|
+
response: operations_pb2.Operation,
|
|
127
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
128
|
+
) -> Tuple[operations_pb2.Operation, Sequence[Tuple[str, Union[str, bytes]]]]:
|
|
129
|
+
"""Post-rpc interceptor for batch_optimize_tours
|
|
130
|
+
|
|
131
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
132
|
+
is returned by the RouteOptimization server but before it is returned to user code.
|
|
133
|
+
|
|
134
|
+
We recommend only using this `post_batch_optimize_tours_with_metadata`
|
|
135
|
+
interceptor in new development instead of the `post_batch_optimize_tours` interceptor.
|
|
136
|
+
When both interceptors are used, this `post_batch_optimize_tours_with_metadata` interceptor runs after the
|
|
137
|
+
`post_batch_optimize_tours` interceptor. The (possibly modified) response returned by
|
|
138
|
+
`post_batch_optimize_tours` will be passed to
|
|
139
|
+
`post_batch_optimize_tours_with_metadata`.
|
|
140
|
+
"""
|
|
141
|
+
return response, metadata
|
|
142
|
+
|
|
120
143
|
def pre_optimize_tours(
|
|
121
144
|
self,
|
|
122
145
|
request: route_optimization_service.OptimizeToursRequest,
|
|
@@ -137,12 +160,38 @@ class RouteOptimizationRestInterceptor:
|
|
|
137
160
|
) -> route_optimization_service.OptimizeToursResponse:
|
|
138
161
|
"""Post-rpc interceptor for optimize_tours
|
|
139
162
|
|
|
140
|
-
|
|
163
|
+
DEPRECATED. Please use the `post_optimize_tours_with_metadata`
|
|
164
|
+
interceptor instead.
|
|
165
|
+
|
|
166
|
+
Override in a subclass to read or manipulate the response
|
|
141
167
|
after it is returned by the RouteOptimization server but before
|
|
142
|
-
it is returned to user code.
|
|
168
|
+
it is returned to user code. This `post_optimize_tours` interceptor runs
|
|
169
|
+
before the `post_optimize_tours_with_metadata` interceptor.
|
|
143
170
|
"""
|
|
144
171
|
return response
|
|
145
172
|
|
|
173
|
+
def post_optimize_tours_with_metadata(
|
|
174
|
+
self,
|
|
175
|
+
response: route_optimization_service.OptimizeToursResponse,
|
|
176
|
+
metadata: Sequence[Tuple[str, Union[str, bytes]]],
|
|
177
|
+
) -> Tuple[
|
|
178
|
+
route_optimization_service.OptimizeToursResponse,
|
|
179
|
+
Sequence[Tuple[str, Union[str, bytes]]],
|
|
180
|
+
]:
|
|
181
|
+
"""Post-rpc interceptor for optimize_tours
|
|
182
|
+
|
|
183
|
+
Override in a subclass to read or manipulate the response or metadata after it
|
|
184
|
+
is returned by the RouteOptimization server but before it is returned to user code.
|
|
185
|
+
|
|
186
|
+
We recommend only using this `post_optimize_tours_with_metadata`
|
|
187
|
+
interceptor in new development instead of the `post_optimize_tours` interceptor.
|
|
188
|
+
When both interceptors are used, this `post_optimize_tours_with_metadata` interceptor runs after the
|
|
189
|
+
`post_optimize_tours` interceptor. The (possibly modified) response returned by
|
|
190
|
+
`post_optimize_tours` will be passed to
|
|
191
|
+
`post_optimize_tours_with_metadata`.
|
|
192
|
+
"""
|
|
193
|
+
return response, metadata
|
|
194
|
+
|
|
146
195
|
def pre_get_operation(
|
|
147
196
|
self,
|
|
148
197
|
request: operations_pb2.GetOperationRequest,
|
|
@@ -445,6 +494,10 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
445
494
|
json_format.Parse(response.content, resp, ignore_unknown_fields=True)
|
|
446
495
|
|
|
447
496
|
resp = self._interceptor.post_batch_optimize_tours(resp)
|
|
497
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
498
|
+
resp, _ = self._interceptor.post_batch_optimize_tours_with_metadata(
|
|
499
|
+
resp, response_metadata
|
|
500
|
+
)
|
|
448
501
|
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
449
502
|
logging.DEBUG
|
|
450
503
|
): # pragma: NO COVER
|
|
@@ -600,6 +653,10 @@ class RouteOptimizationRestTransport(_BaseRouteOptimizationRestTransport):
|
|
|
600
653
|
json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True)
|
|
601
654
|
|
|
602
655
|
resp = self._interceptor.post_optimize_tours(resp)
|
|
656
|
+
response_metadata = [(k, str(v)) for k, v in response.headers.items()]
|
|
657
|
+
resp, _ = self._interceptor.post_optimize_tours_with_metadata(
|
|
658
|
+
resp, response_metadata
|
|
659
|
+
)
|
|
603
660
|
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
|
|
604
661
|
logging.DEBUG
|
|
605
662
|
): # pragma: NO COVER
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-maps-routeoptimization
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
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
|
|
@@ -23,11 +23,11 @@ Classifier: Operating System :: OS Independent
|
|
|
23
23
|
Classifier: Topic :: Internet
|
|
24
24
|
Requires-Python: >=3.7
|
|
25
25
|
License-File: LICENSE
|
|
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.
|
|
27
|
-
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.
|
|
28
|
-
Requires-Dist: proto-plus<2.0.
|
|
29
|
-
Requires-Dist: proto-plus<2.0.
|
|
30
|
-
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<
|
|
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.0,>=1.34.1
|
|
27
|
+
Requires-Dist: google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
28
|
+
Requires-Dist: proto-plus<2.0.0,>=1.22.3
|
|
29
|
+
Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
|
|
30
|
+
Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
|
|
31
31
|
|
|
32
32
|
Python Client for Route Optimization API
|
|
33
33
|
========================================
|
|
@@ -57,12 +57,12 @@ In order to use this library, you first need to go through the following steps:
|
|
|
57
57
|
1. `Select or create a Cloud Platform project.`_
|
|
58
58
|
2. `Enable billing for your project.`_
|
|
59
59
|
3. `Enable the Route Optimization API.`_
|
|
60
|
-
4. `
|
|
60
|
+
4. `Set up Authentication.`_
|
|
61
61
|
|
|
62
62
|
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
63
63
|
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
64
64
|
.. _Enable the Route Optimization API.: https://developers.google.com/maps/documentation/route-optimization
|
|
65
|
-
..
|
|
65
|
+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
66
66
|
|
|
67
67
|
Installation
|
|
68
68
|
~~~~~~~~~~~~
|
|
@@ -137,3 +137,92 @@ Next Steps
|
|
|
137
137
|
|
|
138
138
|
.. _Route Optimization API Product documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
139
139
|
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
140
|
+
|
|
141
|
+
Logging
|
|
142
|
+
-------
|
|
143
|
+
|
|
144
|
+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
|
|
145
|
+
Note the following:
|
|
146
|
+
|
|
147
|
+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
|
|
148
|
+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
|
|
149
|
+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
|
|
150
|
+
|
|
151
|
+
Simple, environment-based configuration
|
|
152
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
153
|
+
|
|
154
|
+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
|
|
155
|
+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
|
|
156
|
+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
|
|
157
|
+
event.
|
|
158
|
+
|
|
159
|
+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
|
|
160
|
+
|
|
161
|
+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
|
|
162
|
+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
|
|
163
|
+
|
|
164
|
+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
|
|
165
|
+
|
|
166
|
+
Environment-Based Examples
|
|
167
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
168
|
+
|
|
169
|
+
- Enabling the default handler for all Google-based loggers
|
|
170
|
+
|
|
171
|
+
.. code-block:: console
|
|
172
|
+
|
|
173
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
|
|
174
|
+
|
|
175
|
+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
176
|
+
|
|
177
|
+
.. code-block:: console
|
|
178
|
+
|
|
179
|
+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
Advanced, code-based configuration
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
184
|
+
|
|
185
|
+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
|
|
186
|
+
|
|
187
|
+
Code-Based Examples
|
|
188
|
+
^^^^^^^^^^^^^^^^^^^
|
|
189
|
+
|
|
190
|
+
- Configuring a handler for all Google-based loggers
|
|
191
|
+
|
|
192
|
+
.. code-block:: python
|
|
193
|
+
|
|
194
|
+
import logging
|
|
195
|
+
|
|
196
|
+
from google.cloud.translate_v3 import translate
|
|
197
|
+
|
|
198
|
+
base_logger = logging.getLogger("google")
|
|
199
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
200
|
+
base_logger.setLevel(logging.DEBUG)
|
|
201
|
+
|
|
202
|
+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
|
|
203
|
+
|
|
204
|
+
.. code-block:: python
|
|
205
|
+
|
|
206
|
+
import logging
|
|
207
|
+
|
|
208
|
+
from google.cloud.translate_v3 import translate
|
|
209
|
+
|
|
210
|
+
base_logger = logging.getLogger("google.cloud.library_v1")
|
|
211
|
+
base_logger.addHandler(logging.StreamHandler())
|
|
212
|
+
base_logger.setLevel(logging.DEBUG)
|
|
213
|
+
|
|
214
|
+
Logging details
|
|
215
|
+
~~~~~~~~~~~~~~~
|
|
216
|
+
|
|
217
|
+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
|
|
218
|
+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
|
|
219
|
+
:code:`logging.getLogger("google").propagate = True` in your code.
|
|
220
|
+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
|
|
221
|
+
one library, but decide you need to also set up environment-based logging configuration for another library.
|
|
222
|
+
|
|
223
|
+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
|
|
224
|
+
if the code -based configuration gets applied first.
|
|
225
|
+
|
|
226
|
+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
|
|
227
|
+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
|
|
228
|
+
(This is the reason for 2.i. above.)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
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.0,>=1.34.1
|
|
2
|
+
google-auth!=2.24.0,!=2.25.0,<3.0.0,>=2.14.1
|
|
3
|
+
proto-plus<2.0.0,>=1.22.3
|
|
4
|
+
protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
|
|
5
|
+
|
|
6
|
+
[:python_version >= "3.13"]
|
|
7
|
+
proto-plus<2.0.0,>=1.25.0
|
|
@@ -41,13 +41,13 @@ else:
|
|
|
41
41
|
release_status = "Development Status :: 5 - Production/Stable"
|
|
42
42
|
|
|
43
43
|
dependencies = [
|
|
44
|
-
"google-api-core[grpc] >= 1.34.1, <3.0.
|
|
44
|
+
"google-api-core[grpc] >= 1.34.1, <3.0.0,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
|
|
45
45
|
# Exclude incompatible versions of `google-auth`
|
|
46
46
|
# See https://github.com/googleapis/google-cloud-python/issues/12364
|
|
47
|
-
"google-auth >= 2.14.1, <3.0.
|
|
48
|
-
"proto-plus >= 1.22.3, <2.0.
|
|
49
|
-
"proto-plus >= 1.25.0, <2.0.
|
|
50
|
-
"protobuf>=3.20.2,<
|
|
47
|
+
"google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0",
|
|
48
|
+
"proto-plus >= 1.22.3, <2.0.0",
|
|
49
|
+
"proto-plus >= 1.25.0, <2.0.0; python_version >= '3.13'",
|
|
50
|
+
"protobuf>=3.20.2,<7.0.0,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
|
|
51
51
|
]
|
|
52
52
|
extras = {}
|
|
53
53
|
url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-maps-routeoptimization"
|
|
@@ -72,6 +72,13 @@ from google.maps.routeoptimization_v1.services.route_optimization import (
|
|
|
72
72
|
)
|
|
73
73
|
from google.maps.routeoptimization_v1.types import route_optimization_service
|
|
74
74
|
|
|
75
|
+
CRED_INFO_JSON = {
|
|
76
|
+
"credential_source": "/path/to/file",
|
|
77
|
+
"credential_type": "service account credentials",
|
|
78
|
+
"principal": "service-account@example.com",
|
|
79
|
+
}
|
|
80
|
+
CRED_INFO_STRING = json.dumps(CRED_INFO_JSON)
|
|
81
|
+
|
|
75
82
|
|
|
76
83
|
async def mock_async_gen(data, chunk_size=1):
|
|
77
84
|
for i in range(0, len(data)): # pragma: NO COVER
|
|
@@ -339,6 +346,49 @@ def test__get_universe_domain():
|
|
|
339
346
|
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
|
|
340
347
|
|
|
341
348
|
|
|
349
|
+
@pytest.mark.parametrize(
|
|
350
|
+
"error_code,cred_info_json,show_cred_info",
|
|
351
|
+
[
|
|
352
|
+
(401, CRED_INFO_JSON, True),
|
|
353
|
+
(403, CRED_INFO_JSON, True),
|
|
354
|
+
(404, CRED_INFO_JSON, True),
|
|
355
|
+
(500, CRED_INFO_JSON, False),
|
|
356
|
+
(401, None, False),
|
|
357
|
+
(403, None, False),
|
|
358
|
+
(404, None, False),
|
|
359
|
+
(500, None, False),
|
|
360
|
+
],
|
|
361
|
+
)
|
|
362
|
+
def test__add_cred_info_for_auth_errors(error_code, cred_info_json, show_cred_info):
|
|
363
|
+
cred = mock.Mock(["get_cred_info"])
|
|
364
|
+
cred.get_cred_info = mock.Mock(return_value=cred_info_json)
|
|
365
|
+
client = RouteOptimizationClient(credentials=cred)
|
|
366
|
+
client._transport._credentials = cred
|
|
367
|
+
|
|
368
|
+
error = core_exceptions.GoogleAPICallError("message", details=["foo"])
|
|
369
|
+
error.code = error_code
|
|
370
|
+
|
|
371
|
+
client._add_cred_info_for_auth_errors(error)
|
|
372
|
+
if show_cred_info:
|
|
373
|
+
assert error.details == ["foo", CRED_INFO_STRING]
|
|
374
|
+
else:
|
|
375
|
+
assert error.details == ["foo"]
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
@pytest.mark.parametrize("error_code", [401, 403, 404, 500])
|
|
379
|
+
def test__add_cred_info_for_auth_errors_no_get_cred_info(error_code):
|
|
380
|
+
cred = mock.Mock([])
|
|
381
|
+
assert not hasattr(cred, "get_cred_info")
|
|
382
|
+
client = RouteOptimizationClient(credentials=cred)
|
|
383
|
+
client._transport._credentials = cred
|
|
384
|
+
|
|
385
|
+
error = core_exceptions.GoogleAPICallError("message", details=[])
|
|
386
|
+
error.code = error_code
|
|
387
|
+
|
|
388
|
+
client._add_cred_info_for_auth_errors(error)
|
|
389
|
+
assert error.details == []
|
|
390
|
+
|
|
391
|
+
|
|
342
392
|
@pytest.mark.parametrize(
|
|
343
393
|
"client_class,transport_name",
|
|
344
394
|
[
|
|
@@ -2178,10 +2228,13 @@ def test_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2178
2228
|
) as transcode, mock.patch.object(
|
|
2179
2229
|
transports.RouteOptimizationRestInterceptor, "post_optimize_tours"
|
|
2180
2230
|
) as post, mock.patch.object(
|
|
2231
|
+
transports.RouteOptimizationRestInterceptor, "post_optimize_tours_with_metadata"
|
|
2232
|
+
) as post_with_metadata, mock.patch.object(
|
|
2181
2233
|
transports.RouteOptimizationRestInterceptor, "pre_optimize_tours"
|
|
2182
2234
|
) as pre:
|
|
2183
2235
|
pre.assert_not_called()
|
|
2184
2236
|
post.assert_not_called()
|
|
2237
|
+
post_with_metadata.assert_not_called()
|
|
2185
2238
|
pb_message = route_optimization_service.OptimizeToursRequest.pb(
|
|
2186
2239
|
route_optimization_service.OptimizeToursRequest()
|
|
2187
2240
|
)
|
|
@@ -2207,6 +2260,10 @@ def test_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2207
2260
|
]
|
|
2208
2261
|
pre.return_value = request, metadata
|
|
2209
2262
|
post.return_value = route_optimization_service.OptimizeToursResponse()
|
|
2263
|
+
post_with_metadata.return_value = (
|
|
2264
|
+
route_optimization_service.OptimizeToursResponse(),
|
|
2265
|
+
metadata,
|
|
2266
|
+
)
|
|
2210
2267
|
|
|
2211
2268
|
client.optimize_tours(
|
|
2212
2269
|
request,
|
|
@@ -2218,6 +2275,7 @@ def test_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2218
2275
|
|
|
2219
2276
|
pre.assert_called_once()
|
|
2220
2277
|
post.assert_called_once()
|
|
2278
|
+
post_with_metadata.assert_called_once()
|
|
2221
2279
|
|
|
2222
2280
|
|
|
2223
2281
|
def test_batch_optimize_tours_rest_bad_request(
|
|
@@ -2298,10 +2356,14 @@ def test_batch_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2298
2356
|
), mock.patch.object(
|
|
2299
2357
|
transports.RouteOptimizationRestInterceptor, "post_batch_optimize_tours"
|
|
2300
2358
|
) as post, mock.patch.object(
|
|
2359
|
+
transports.RouteOptimizationRestInterceptor,
|
|
2360
|
+
"post_batch_optimize_tours_with_metadata",
|
|
2361
|
+
) as post_with_metadata, mock.patch.object(
|
|
2301
2362
|
transports.RouteOptimizationRestInterceptor, "pre_batch_optimize_tours"
|
|
2302
2363
|
) as pre:
|
|
2303
2364
|
pre.assert_not_called()
|
|
2304
2365
|
post.assert_not_called()
|
|
2366
|
+
post_with_metadata.assert_not_called()
|
|
2305
2367
|
pb_message = route_optimization_service.BatchOptimizeToursRequest.pb(
|
|
2306
2368
|
route_optimization_service.BatchOptimizeToursRequest()
|
|
2307
2369
|
)
|
|
@@ -2325,6 +2387,7 @@ def test_batch_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2325
2387
|
]
|
|
2326
2388
|
pre.return_value = request, metadata
|
|
2327
2389
|
post.return_value = operations_pb2.Operation()
|
|
2390
|
+
post_with_metadata.return_value = operations_pb2.Operation(), metadata
|
|
2328
2391
|
|
|
2329
2392
|
client.batch_optimize_tours(
|
|
2330
2393
|
request,
|
|
@@ -2336,6 +2399,7 @@ def test_batch_optimize_tours_rest_interceptors(null_interceptor):
|
|
|
2336
2399
|
|
|
2337
2400
|
pre.assert_called_once()
|
|
2338
2401
|
post.assert_called_once()
|
|
2402
|
+
post_with_metadata.assert_called_once()
|
|
2339
2403
|
|
|
2340
2404
|
|
|
2341
2405
|
def test_get_operation_rest_bad_request(
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
Python Client for Route Optimization API
|
|
2
|
-
========================================
|
|
3
|
-
|
|
4
|
-
|preview| |pypi| |versions|
|
|
5
|
-
|
|
6
|
-
`Route Optimization API`_: he Route Optimization API assigns tasks and routes to a vehicle fleet, optimizing against the objectives and constraints that you supply for your transportation goals.
|
|
7
|
-
|
|
8
|
-
- `Client Library Documentation`_
|
|
9
|
-
- `Product Documentation`_
|
|
10
|
-
|
|
11
|
-
.. |preview| image:: https://img.shields.io/badge/support-preview-orange.svg
|
|
12
|
-
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
|
|
13
|
-
.. |pypi| image:: https://img.shields.io/pypi/v/google-maps-routeoptimization.svg
|
|
14
|
-
:target: https://pypi.org/project/google-maps-routeoptimization/
|
|
15
|
-
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-maps-routeoptimization.svg
|
|
16
|
-
:target: https://pypi.org/project/google-maps-routeoptimization/
|
|
17
|
-
.. _Route Optimization API: https://developers.google.com/maps/documentation/route-optimization
|
|
18
|
-
.. _Client Library Documentation: https://googleapis.dev/python/google-maps-routeoptimization/latest
|
|
19
|
-
.. _Product Documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
20
|
-
|
|
21
|
-
Quick Start
|
|
22
|
-
-----------
|
|
23
|
-
|
|
24
|
-
In order to use this library, you first need to go through the following steps:
|
|
25
|
-
|
|
26
|
-
1. `Select or create a Cloud Platform project.`_
|
|
27
|
-
2. `Enable billing for your project.`_
|
|
28
|
-
3. `Enable the Route Optimization API.`_
|
|
29
|
-
4. `Setup Authentication.`_
|
|
30
|
-
|
|
31
|
-
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
|
|
32
|
-
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
|
|
33
|
-
.. _Enable the Route Optimization API.: https://developers.google.com/maps/documentation/route-optimization
|
|
34
|
-
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
35
|
-
|
|
36
|
-
Installation
|
|
37
|
-
~~~~~~~~~~~~
|
|
38
|
-
|
|
39
|
-
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
|
|
40
|
-
creates isolated Python environments. These isolated environments can have separate
|
|
41
|
-
versions of Python packages, which allows you to isolate one project's dependencies
|
|
42
|
-
from the dependencies of other projects.
|
|
43
|
-
|
|
44
|
-
With `venv`_, it's possible to install this library without needing system
|
|
45
|
-
install permissions, and without clashing with the installed system
|
|
46
|
-
dependencies.
|
|
47
|
-
|
|
48
|
-
.. _`venv`: https://docs.python.org/3/library/venv.html
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Code samples and snippets
|
|
52
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
53
|
-
|
|
54
|
-
Code samples and snippets live in the `samples/`_ folder.
|
|
55
|
-
|
|
56
|
-
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-maps-routeoptimization/samples
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Supported Python Versions
|
|
60
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
61
|
-
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
|
|
62
|
-
Python.
|
|
63
|
-
|
|
64
|
-
Python >= 3.7
|
|
65
|
-
|
|
66
|
-
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
67
|
-
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
|
|
68
|
-
|
|
69
|
-
Unsupported Python Versions
|
|
70
|
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
71
|
-
Python <= 3.6
|
|
72
|
-
|
|
73
|
-
If you are using an `end-of-life`_
|
|
74
|
-
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
75
|
-
|
|
76
|
-
.. _end-of-life: https://devguide.python.org/devcycle/#end-of-life-branches
|
|
77
|
-
|
|
78
|
-
Mac/Linux
|
|
79
|
-
^^^^^^^^^
|
|
80
|
-
|
|
81
|
-
.. code-block:: console
|
|
82
|
-
|
|
83
|
-
python3 -m venv <your-env>
|
|
84
|
-
source <your-env>/bin/activate
|
|
85
|
-
pip install google-maps-routeoptimization
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Windows
|
|
89
|
-
^^^^^^^
|
|
90
|
-
|
|
91
|
-
.. code-block:: console
|
|
92
|
-
|
|
93
|
-
py -m venv <your-env>
|
|
94
|
-
.\<your-env>\Scripts\activate
|
|
95
|
-
pip install google-maps-routeoptimization
|
|
96
|
-
|
|
97
|
-
Next Steps
|
|
98
|
-
~~~~~~~~~~
|
|
99
|
-
|
|
100
|
-
- Read the `Client Library Documentation`_ for Route Optimization API
|
|
101
|
-
to see other available methods on the client.
|
|
102
|
-
- Read the `Route Optimization API Product documentation`_ to learn
|
|
103
|
-
more about the product and see How-to Guides.
|
|
104
|
-
- View this `README`_ to see the full list of Cloud
|
|
105
|
-
APIs that we cover.
|
|
106
|
-
|
|
107
|
-
.. _Route Optimization API Product documentation: https://developers.google.com/maps/documentation/route-optimization
|
|
108
|
-
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
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
|
|
2
|
-
google-auth!=2.24.0,!=2.25.0,<3.0.0dev,>=2.14.1
|
|
3
|
-
proto-plus<2.0.0dev,>=1.22.3
|
|
4
|
-
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
|
|
5
|
-
|
|
6
|
-
[:python_version >= "3.13"]
|
|
7
|
-
proto-plus<2.0.0dev,>=1.25.0
|
|
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.7 → google_maps_routeoptimization-0.1.9}/tests/__init__.py
RENAMED
|
File without changes
|
{google_maps_routeoptimization-0.1.7 → google_maps_routeoptimization-0.1.9}/tests/unit/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|