Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [Many APIs] Add support for opt-in debug logging #13349

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__ = "0.4.4" # {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__ = "0.4.4" # {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 @@ -56,6 +57,15 @@
from .transports.base import DEFAULT_CLIENT_INFO, MapsPlatformDatasetsTransport
from .transports.grpc_asyncio import MapsPlatformDatasetsGrpcAsyncIOTransport

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 MapsPlatformDatasetsAsyncClient:
"""Service definition for the Maps Platform Datasets API."""
Expand Down Expand Up @@ -265,6 +275,28 @@ def __init__(
client_info=client_info,
)

if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.maps.mapsplatformdatasets_v1.MapsPlatformDatasetsAsyncClient`.",
extra={
"serviceName": "google.maps.mapsplatformdatasets.v1.MapsPlatformDatasets",
"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.maps.mapsplatformdatasets.v1.MapsPlatformDatasets",
"credentialsType": None,
},
)

async def create_dataset(
self,
request: Optional[
Expand All @@ -275,7 +307,7 @@ async def create_dataset(
dataset: Optional[gmm_dataset.Dataset] = 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]]] = (),
) -> gmm_dataset.Dataset:
r"""Creates a new dataset for the specified project.

Expand Down Expand Up @@ -326,8 +358,10 @@ async def sample_create_dataset():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -393,7 +427,7 @@ async def update_dataset_metadata(
update_mask: Optional[field_mask_pb2.FieldMask] = 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]]] = (),
) -> gmm_dataset.Dataset:
r"""Updates the metadata for the dataset.

Expand Down Expand Up @@ -444,8 +478,10 @@ async def sample_update_dataset_metadata():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -510,7 +546,7 @@ async def get_dataset(
name: Optional[str] = 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]]] = (),
) -> dataset.Dataset:
r"""Gets the dataset.

Expand Down Expand Up @@ -561,8 +597,10 @@ async def sample_get_dataset():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -625,7 +663,7 @@ async def fetch_dataset_errors(
dataset: Optional[str] = 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]]] = (),
) -> pagers.FetchDatasetErrorsAsyncPager:
r"""Gets all the errors of a dataset.

Expand Down Expand Up @@ -670,8 +708,10 @@ async def sample_fetch_dataset_errors():
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.maps.mapsplatformdatasets_v1.services.maps_platform_datasets.pagers.FetchDatasetErrorsAsyncPager:
Expand Down Expand Up @@ -748,7 +788,7 @@ async def list_datasets(
parent: Optional[str] = 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]]] = (),
) -> pagers.ListDatasetsAsyncPager:
r"""Lists all the datasets for the specified project.

Expand Down Expand Up @@ -794,8 +834,10 @@ async def sample_list_datasets():
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.maps.mapsplatformdatasets_v1.services.maps_platform_datasets.pagers.ListDatasetsAsyncPager:
Expand Down Expand Up @@ -872,7 +914,7 @@ async def delete_dataset(
name: Optional[str] = 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]]] = (),
) -> None:
r"""Deletes the specified dataset.

Expand Down Expand Up @@ -912,8 +954,10 @@ async def sample_delete_dataset():
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`.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
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.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.rpc import status_pb2 # type: ignore
Expand Down Expand Up @@ -584,6 +594,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 @@ -650,6 +664,29 @@ 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.maps.mapsplatformdatasets_v1.MapsPlatformDatasetsClient`.",
extra={
"serviceName": "google.maps.mapsplatformdatasets.v1.MapsPlatformDatasets",
"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.maps.mapsplatformdatasets.v1.MapsPlatformDatasets",
"credentialsType": None,
},
)

def create_dataset(
self,
request: Optional[
Expand All @@ -660,7 +697,7 @@ def create_dataset(
dataset: Optional[gmm_dataset.Dataset] = 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]]] = (),
) -> gmm_dataset.Dataset:
r"""Creates a new dataset for the specified project.

Expand Down Expand Up @@ -711,8 +748,10 @@ def sample_create_dataset():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -775,7 +814,7 @@ def update_dataset_metadata(
update_mask: Optional[field_mask_pb2.FieldMask] = 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]]] = (),
) -> gmm_dataset.Dataset:
r"""Updates the metadata for the dataset.

Expand Down Expand Up @@ -826,8 +865,10 @@ def sample_update_dataset_metadata():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -889,7 +930,7 @@ def get_dataset(
name: Optional[str] = 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]]] = (),
) -> dataset.Dataset:
r"""Gets the dataset.

Expand Down Expand Up @@ -940,8 +981,10 @@ def sample_get_dataset():
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.maps.mapsplatformdatasets_v1.types.Dataset:
Expand Down Expand Up @@ -1001,7 +1044,7 @@ def fetch_dataset_errors(
dataset: Optional[str] = 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]]] = (),
) -> pagers.FetchDatasetErrorsPager:
r"""Gets all the errors of a dataset.

Expand Down Expand Up @@ -1046,8 +1089,10 @@ def sample_fetch_dataset_errors():
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.maps.mapsplatformdatasets_v1.services.maps_platform_datasets.pagers.FetchDatasetErrorsPager:
Expand Down Expand Up @@ -1121,7 +1166,7 @@ def list_datasets(
parent: Optional[str] = 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]]] = (),
) -> pagers.ListDatasetsPager:
r"""Lists all the datasets for the specified project.

Expand Down Expand Up @@ -1167,8 +1212,10 @@ def sample_list_datasets():
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.maps.mapsplatformdatasets_v1.services.maps_platform_datasets.pagers.ListDatasetsPager:
Expand Down Expand Up @@ -1242,7 +1289,7 @@ def delete_dataset(
name: Optional[str] = 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]]] = (),
) -> None:
r"""Deletes the specified dataset.

Expand Down Expand Up @@ -1282,8 +1329,10 @@ def sample_delete_dataset():
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`.
"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
Expand Down
Loading
Loading