Skip to content

Commit

Permalink
feat: [Many APIs] Add support for opt-in debug logging (#13346)
Browse files Browse the repository at this point in the history
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:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXBvbGljeS10cm91Ymxlc2hvb3Rlci8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJ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ImNhMWUwYTFlNDcyZDZlNmY1ZGU4ODNhNWNiNTQ3MjRmMTEyY2UzNDgifQ==
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlc291cmNlLXNldHRpbmdzLy5Pd2xCb3QueWFtbCIsImgiOiJjYTFlMGExZTQ3MmQ2ZTZmNWRlODgzYTVjYjU0NzI0ZjExMmNlMzQ4In0=

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: ohmayr <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 856e0f0 commit 8e6b0cc
Show file tree
Hide file tree
Showing 313 changed files with 34,461 additions and 5,542 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.9.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.9.1" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from collections import OrderedDict
import logging as std_logging
import re
from typing import (
Callable,
Expand Down Expand Up @@ -52,6 +53,15 @@
from .transports.base import DEFAULT_CLIENT_INFO, FleetRoutingTransport
from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport

try:
from google.api_core import client_logging # type: ignore

CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
except ImportError: # pragma: NO COVER
CLIENT_LOGGING_SUPPORTED = False

_LOGGER = std_logging.getLogger(__name__)


class FleetRoutingAsyncClient:
"""A service for optimizing vehicle tours.
Expand Down Expand Up @@ -274,13 +284,35 @@ def __init__(
client_info=client_info,
)

if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.cloud.optimization_v1.FleetRoutingAsyncClient`.",
extra={
"serviceName": "google.cloud.optimization.v1.FleetRouting",
"universeDomain": getattr(
self._client._transport._credentials, "universe_domain", ""
),
"credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
"credentialsInfo": getattr(
self.transport._credentials, "get_cred_info", lambda: None
)(),
}
if hasattr(self._client._transport, "_credentials")
else {
"serviceName": "google.cloud.optimization.v1.FleetRouting",
"credentialsType": None,
},
)

async def optimize_tours(
self,
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> fleet_routing.OptimizeToursResponse:
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
and returns an ``OptimizeToursResponse`` containing
Expand Down Expand Up @@ -334,8 +366,10 @@ async def sample_optimize_tours():
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
google.cloud.optimization_v1.types.OptimizeToursResponse:
Expand Down Expand Up @@ -384,7 +418,7 @@ async def batch_optimize_tours(
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation_async.AsyncOperation:
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
messages as a batch.
Expand Down Expand Up @@ -445,8 +479,10 @@ async def sample_batch_optimize_tours():
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
google.api_core.operation_async.AsyncOperation:
Expand Down Expand Up @@ -502,7 +538,7 @@ async def get_operation(
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
Expand All @@ -513,8 +549,10 @@ async def get_operation(
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
~.operations_pb2.Operation:
An ``Operation`` object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
from collections import OrderedDict
import logging as std_logging
import os
import re
from typing import (
Expand Down Expand Up @@ -48,6 +49,15 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object, None] # type: ignore

try:
from google.api_core import client_logging # type: ignore

CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
except ImportError: # pragma: NO COVER
CLIENT_LOGGING_SUPPORTED = False

_LOGGER = std_logging.getLogger(__name__)

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.longrunning import operations_pb2 # type: ignore
Expand Down Expand Up @@ -580,6 +590,10 @@ def __init__(
# Initialize the universe domain validation.
self._is_universe_domain_valid = False

if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER
# Setup logging.
client_logging.initialize_logging()

api_key_value = getattr(self._client_options, "api_key", None)
if api_key_value and credentials:
raise ValueError(
Expand Down Expand Up @@ -642,13 +656,36 @@ def __init__(
api_audience=self._client_options.api_audience,
)

if "async" not in str(self._transport):
if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.cloud.optimization_v1.FleetRoutingClient`.",
extra={
"serviceName": "google.cloud.optimization.v1.FleetRouting",
"universeDomain": getattr(
self._transport._credentials, "universe_domain", ""
),
"credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}",
"credentialsInfo": getattr(
self.transport._credentials, "get_cred_info", lambda: None
)(),
}
if hasattr(self._transport, "_credentials")
else {
"serviceName": "google.cloud.optimization.v1.FleetRouting",
"credentialsType": None,
},
)

def optimize_tours(
self,
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> fleet_routing.OptimizeToursResponse:
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
and returns an ``OptimizeToursResponse`` containing
Expand Down Expand Up @@ -702,8 +739,10 @@ def sample_optimize_tours():
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
google.cloud.optimization_v1.types.OptimizeToursResponse:
Expand Down Expand Up @@ -750,7 +789,7 @@ def batch_optimize_tours(
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation.Operation:
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
messages as a batch.
Expand Down Expand Up @@ -811,8 +850,10 @@ def sample_batch_optimize_tours():
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
google.api_core.operation.Operation:
Expand Down Expand Up @@ -879,7 +920,7 @@ def get_operation(
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
Expand All @@ -890,8 +931,10 @@ def get_operation(
retry (google.api_core.retry.Retry): Designation of what errors,
if any, should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
~.operations_pb2.Operation:
An ``Operation`` object.
Expand Down
Loading

0 comments on commit 8e6b0cc

Please sign in to comment.