Skip to content

Commit 8e6b0cc

Browse files
feat: [Many APIs] Add support for opt-in debug logging (#13346)
BEGIN_COMMIT_OVERRIDE feat: Add support for opt-in debug logging fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. fix: Fix typing issue with gRPC metadata when key ends in -bin chore: Update gapic-generator-python to v1.21.0 PiperOrigin-RevId: 705285820 Source-Link: googleapis/googleapis@f9b8b91 Source-Link: googleapis/googleapis-gen@ca1e0a1 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9wdGltaXphdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zLWNvbmZpZy8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW9zLWxvZ2luLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBoaXNoaW5nLXByb3RlY3Rpb24vLk93bEJvdC55YW1sIiwiaCI6ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeS10cm91Ymxlc2hvb3Rlci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9 Copy-Tag: eyJwI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mMTEyY2UzNDgifQ== Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlLXNldHRpbmdzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <[email protected]>
1 parent 856e0f0 commit 8e6b0cc

File tree

313 files changed

+34461
-5542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+34461
-5542
lines changed

packages/google-cloud-optimization/google/cloud/optimization/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.9.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-optimization/google/cloud/optimization_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "1.9.1" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/async_client.py

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
import logging as std_logging
1718
import re
1819
from typing import (
1920
Callable,
@@ -52,6 +53,15 @@
5253
from .transports.base import DEFAULT_CLIENT_INFO, FleetRoutingTransport
5354
from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport
5455

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+
5565

5666
class FleetRoutingAsyncClient:
5767
"""A service for optimizing vehicle tours.
@@ -274,13 +284,35 @@ def __init__(
274284
client_info=client_info,
275285
)
276286

287+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
288+
std_logging.DEBUG
289+
): # pragma: NO COVER
290+
_LOGGER.debug(
291+
"Created client `google.cloud.optimization_v1.FleetRoutingAsyncClient`.",
292+
extra={
293+
"serviceName": "google.cloud.optimization.v1.FleetRouting",
294+
"universeDomain": getattr(
295+
self._client._transport._credentials, "universe_domain", ""
296+
),
297+
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
298+
"credentialsInfo": getattr(
299+
self.transport._credentials, "get_cred_info", lambda: None
300+
)(),
301+
}
302+
if hasattr(self._client._transport, "_credentials")
303+
else {
304+
"serviceName": "google.cloud.optimization.v1.FleetRouting",
305+
"credentialsType": None,
306+
},
307+
)
308+
277309
async def optimize_tours(
278310
self,
279311
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
280312
*,
281313
retry: OptionalRetry = gapic_v1.method.DEFAULT,
282314
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
283-
metadata: Sequence[Tuple[str, str]] = (),
315+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
284316
) -> fleet_routing.OptimizeToursResponse:
285317
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
286318
and returns an ``OptimizeToursResponse`` containing
@@ -334,8 +366,10 @@ async def sample_optimize_tours():
334366
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
335367
should be retried.
336368
timeout (float): The timeout for this request.
337-
metadata (Sequence[Tuple[str, str]]): Strings which should be
338-
sent along with the request as metadata.
369+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
370+
sent along with the request as metadata. Normally, each value must be of type `str`,
371+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
372+
be of type `bytes`.
339373
340374
Returns:
341375
google.cloud.optimization_v1.types.OptimizeToursResponse:
@@ -384,7 +418,7 @@ async def batch_optimize_tours(
384418
*,
385419
retry: OptionalRetry = gapic_v1.method.DEFAULT,
386420
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
387-
metadata: Sequence[Tuple[str, str]] = (),
421+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
388422
) -> operation_async.AsyncOperation:
389423
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
390424
messages as a batch.
@@ -445,8 +479,10 @@ async def sample_batch_optimize_tours():
445479
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
446480
should be retried.
447481
timeout (float): The timeout for this request.
448-
metadata (Sequence[Tuple[str, str]]): Strings which should be
449-
sent along with the request as metadata.
482+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
483+
sent along with the request as metadata. Normally, each value must be of type `str`,
484+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
485+
be of type `bytes`.
450486
451487
Returns:
452488
google.api_core.operation_async.AsyncOperation:
@@ -502,7 +538,7 @@ async def get_operation(
502538
*,
503539
retry: OptionalRetry = gapic_v1.method.DEFAULT,
504540
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
505-
metadata: Sequence[Tuple[str, str]] = (),
541+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
506542
) -> operations_pb2.Operation:
507543
r"""Gets the latest state of a long-running operation.
508544
@@ -513,8 +549,10 @@ async def get_operation(
513549
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
514550
if any, should be retried.
515551
timeout (float): The timeout for this request.
516-
metadata (Sequence[Tuple[str, str]]): Strings which should be
517-
sent along with the request as metadata.
552+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
553+
sent along with the request as metadata. Normally, each value must be of type `str`,
554+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
555+
be of type `bytes`.
518556
Returns:
519557
~.operations_pb2.Operation:
520558
An ``Operation`` object.

packages/google-cloud-optimization/google/cloud/optimization_v1/services/fleet_routing/client.py

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
#
1616
from collections import OrderedDict
17+
import logging as std_logging
1718
import os
1819
import re
1920
from typing import (
@@ -48,6 +49,15 @@
4849
except AttributeError: # pragma: NO COVER
4950
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
5051

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+
5161
from google.api_core import operation # type: ignore
5262
from google.api_core import operation_async # type: ignore
5363
from google.longrunning import operations_pb2 # type: ignore
@@ -580,6 +590,10 @@ def __init__(
580590
# Initialize the universe domain validation.
581591
self._is_universe_domain_valid = False
582592

593+
if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
594+
# Setup logging.
595+
client_logging.initialize_logging()
596+
583597
api_key_value = getattr(self._client_options, "api_key", None)
584598
if api_key_value and credentials:
585599
raise ValueError(
@@ -642,13 +656,36 @@ def __init__(
642656
api_audience=self._client_options.api_audience,
643657
)
644658

659+
if "async" not in str(self._transport):
660+
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
661+
std_logging.DEBUG
662+
): # pragma: NO COVER
663+
_LOGGER.debug(
664+
"Created client `google.cloud.optimization_v1.FleetRoutingClient`.",
665+
extra={
666+
"serviceName": "google.cloud.optimization.v1.FleetRouting",
667+
"universeDomain": getattr(
668+
self._transport._credentials, "universe_domain", ""
669+
),
670+
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
671+
"credentialsInfo": getattr(
672+
self.transport._credentials, "get_cred_info", lambda: None
673+
)(),
674+
}
675+
if hasattr(self._transport, "_credentials")
676+
else {
677+
"serviceName": "google.cloud.optimization.v1.FleetRouting",
678+
"credentialsType": None,
679+
},
680+
)
681+
645682
def optimize_tours(
646683
self,
647684
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
648685
*,
649686
retry: OptionalRetry = gapic_v1.method.DEFAULT,
650687
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
651-
metadata: Sequence[Tuple[str, str]] = (),
688+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
652689
) -> fleet_routing.OptimizeToursResponse:
653690
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
654691
and returns an ``OptimizeToursResponse`` containing
@@ -702,8 +739,10 @@ def sample_optimize_tours():
702739
retry (google.api_core.retry.Retry): Designation of what errors, if any,
703740
should be retried.
704741
timeout (float): The timeout for this request.
705-
metadata (Sequence[Tuple[str, str]]): Strings which should be
706-
sent along with the request as metadata.
742+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
743+
sent along with the request as metadata. Normally, each value must be of type `str`,
744+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
745+
be of type `bytes`.
707746
708747
Returns:
709748
google.cloud.optimization_v1.types.OptimizeToursResponse:
@@ -750,7 +789,7 @@ def batch_optimize_tours(
750789
*,
751790
retry: OptionalRetry = gapic_v1.method.DEFAULT,
752791
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
753-
metadata: Sequence[Tuple[str, str]] = (),
792+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
754793
) -> operation.Operation:
755794
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
756795
messages as a batch.
@@ -811,8 +850,10 @@ def sample_batch_optimize_tours():
811850
retry (google.api_core.retry.Retry): Designation of what errors, if any,
812851
should be retried.
813852
timeout (float): The timeout for this request.
814-
metadata (Sequence[Tuple[str, str]]): Strings which should be
815-
sent along with the request as metadata.
853+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
854+
sent along with the request as metadata. Normally, each value must be of type `str`,
855+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
856+
be of type `bytes`.
816857
817858
Returns:
818859
google.api_core.operation.Operation:
@@ -879,7 +920,7 @@ def get_operation(
879920
*,
880921
retry: OptionalRetry = gapic_v1.method.DEFAULT,
881922
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
882-
metadata: Sequence[Tuple[str, str]] = (),
923+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
883924
) -> operations_pb2.Operation:
884925
r"""Gets the latest state of a long-running operation.
885926
@@ -890,8 +931,10 @@ def get_operation(
890931
retry (google.api_core.retry.Retry): Designation of what errors,
891932
if any, should be retried.
892933
timeout (float): The timeout for this request.
893-
metadata (Sequence[Tuple[str, str]]): Strings which should be
894-
sent along with the request as metadata.
934+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
935+
sent along with the request as metadata. Normally, each value must be of type `str`,
936+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
937+
be of type `bytes`.
895938
Returns:
896939
~.operations_pb2.Operation:
897940
An ``Operation`` object.

0 commit comments

Comments
 (0)