Skip to content

Commit

Permalink
chore: Update gapic-generator-python to v1.23.2 (#529)
Browse files Browse the repository at this point in the history
* chore: remove body selector from http rule

PiperOrigin-RevId: 693215877

Source-Link: googleapis/googleapis@bb6b53e

Source-Link: googleapis/googleapis-gen@db8b5a9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGI4YjVhOTM0ODRhZDQ0MDU1YjJiYWNjNGM3Y2Y4N2U5NzBmZTBlZCJ9

chore: Configure Ruby clients for google-ads-ad_manager

PiperOrigin-RevId: 689139590

Source-Link: googleapis/googleapis@296f2ac

Source-Link: googleapis/googleapis-gen@2692736
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjY5MjczNjJlMGFhMTI5MzI1OGZjMjNmZTNjZTgzYzVjMjFkNWZiYiJ9

chore: Update gapic-generator-python to v1.19.1

PiperOrigin-RevId: 684571179

Source-Link: googleapis/googleapis@fbdc238

Source-Link: googleapis/googleapis-gen@3a2cdcf
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2EyY2RjZmI4MGMyZDBmNWVjMGNjNjYzYzJiYWIwYTk0ODYyMjlkMCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 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

PiperOrigin-RevId: 705285820

Source-Link: googleapis/googleapis@f9b8b91

Source-Link: googleapis/googleapis-gen@ca1e0a1
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2ExZTBhMWU0NzJkNmU2ZjVkZTg4M2E1Y2I1NDcyNGYxMTJjZTM0OCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Add REST Interceptors which support reading metadata
feat: Add support for reading selective GAPIC generation methods from service YAML
chore: Update gapic-generator-python to v1.22.0

PiperOrigin-RevId: 724026024

Source-Link: googleapis/googleapis@ad99638

Source-Link: googleapis/googleapis-gen@e291c4d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTI5MWM0ZGQxZDY3MGVkYTE5OTk4ZGU3NmY5NjdlMTYwM2E0ODk5MyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: Update gapic-generator-python to v1.23.2

PiperOrigin-RevId: 732281673

Source-Link: googleapis/googleapis@2f37e0a

Source-Link: googleapis/googleapis-gen@016b753
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDE2Yjc1MzhiYTVhNzk4ZjJhZTQyM2Q0Y2NkN2Y4MmIwNmNkZjZkMiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
3 people authored Mar 3, 2025
1 parent ffd913f commit 1d120c7
Show file tree
Hide file tree
Showing 27 changed files with 4,482 additions and 2,276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging as std_logging
from collections import OrderedDict
import re
from typing import (
Expand Down Expand Up @@ -49,6 +50,15 @@
from .transports.grpc_asyncio import ErrorGroupServiceGrpcAsyncIOTransport
from .client import ErrorGroupServiceClient

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 ErrorGroupServiceAsyncClient:
"""Service for retrieving and updating individual error groups."""
Expand Down Expand Up @@ -260,14 +270,36 @@ def __init__(
client_info=client_info,
)

if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
std_logging.DEBUG
): # pragma: NO COVER
_LOGGER.debug(
"Created client `google.devtools.clouderrorreporting_v1beta1.ErrorGroupServiceAsyncClient`.",
extra={
"serviceName": "google.devtools.clouderrorreporting.v1beta1.ErrorGroupService",
"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.devtools.clouderrorreporting.v1beta1.ErrorGroupService",
"credentialsType": None,
},
)

async def get_group(
self,
request: Optional[Union[error_group_service.GetGroupRequest, dict]] = None,
*,
group_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]]] = (),
) -> common.ErrorGroup:
r"""Get the specified group.
Expand Down Expand Up @@ -329,8 +361,10 @@ async def sample_get_group():
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.errorreporting_v1beta1.types.ErrorGroup:
Expand All @@ -341,7 +375,10 @@ async def sample_get_group():
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([group_name])
flattened_params = [group_name]
has_flattened_params = (
len([param for param in flattened_params if param is not None]) > 0
)
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
Expand Down Expand Up @@ -393,7 +430,7 @@ async def update_group(
group: Optional[common.ErrorGroup] = 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]]] = (),
) -> common.ErrorGroup:
r"""Replace the data for the specified group.
Fails if the group does not exist.
Expand Down Expand Up @@ -437,8 +474,10 @@ async def sample_update_group():
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.errorreporting_v1beta1.types.ErrorGroup:
Expand All @@ -449,7 +488,10 @@ async def sample_update_group():
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([group])
flattened_params = [group]
has_flattened_params = (
len([param for param in flattened_params if param is not None]) > 0
)
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# limitations under the License.
#
from collections import OrderedDict
from http import HTTPStatus
import json
import logging as std_logging
import os
import re
from typing import (
Expand Down Expand Up @@ -48,6 +51,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.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
from .transports.base import ErrorGroupServiceTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -455,52 +467,45 @@ def _get_universe_domain(
raise ValueError("Universe Domain cannot be an empty string.")
return universe_domain

@staticmethod
def _compare_universes(
client_universe: str, credentials: ga_credentials.Credentials
) -> bool:
"""Returns True iff the universe domains used by the client and credentials match.
Args:
client_universe (str): The universe domain configured via the client options.
credentials (ga_credentials.Credentials): The credentials being used in the client.
def _validate_universe_domain(self):
"""Validates client's and credentials' universe domains are consistent.
Returns:
bool: True iff client_universe matches the universe in credentials.
bool: True iff the configured universe domain is valid.
Raises:
ValueError: when client_universe does not match the universe in credentials.
ValueError: If the configured universe domain is not valid.
"""

default_universe = ErrorGroupServiceClient._DEFAULT_UNIVERSE
credentials_universe = getattr(credentials, "universe_domain", default_universe)

if client_universe != credentials_universe:
raise ValueError(
"The configured universe domain "
f"({client_universe}) does not match the universe domain "
f"found in the credentials ({credentials_universe}). "
"If you haven't configured the universe domain explicitly, "
f"`{default_universe}` is the default."
)
# NOTE (b/349488459): universe validation is disabled until further notice.
return True

def _validate_universe_domain(self):
"""Validates client's and credentials' universe domains are consistent.
Returns:
bool: True iff the configured universe domain is valid.
def _add_cred_info_for_auth_errors(
self, error: core_exceptions.GoogleAPICallError
) -> None:
"""Adds credential info string to error details for 401/403/404 errors.
Raises:
ValueError: If the configured universe domain is not valid.
Args:
error (google.api_core.exceptions.GoogleAPICallError): The error to add the cred info.
"""
self._is_universe_domain_valid = (
self._is_universe_domain_valid
or ErrorGroupServiceClient._compare_universes(
self.universe_domain, self.transport._credentials
)
)
return self._is_universe_domain_valid
if error.code not in [
HTTPStatus.UNAUTHORIZED,
HTTPStatus.FORBIDDEN,
HTTPStatus.NOT_FOUND,
]:
return

cred = self._transport._credentials

# get_cred_info is only available in google-auth>=2.35.0
if not hasattr(cred, "get_cred_info"):
return

# ignore the type check since pypy test fails when get_cred_info
# is not available
cred_info = cred.get_cred_info() # type: ignore
if cred_info and hasattr(error._details, "append"):
error._details.append(json.dumps(cred_info))

@property
def api_endpoint(self):
Expand Down Expand Up @@ -610,6 +615,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 @@ -676,14 +685,37 @@ 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.devtools.clouderrorreporting_v1beta1.ErrorGroupServiceClient`.",
extra={
"serviceName": "google.devtools.clouderrorreporting.v1beta1.ErrorGroupService",
"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.devtools.clouderrorreporting.v1beta1.ErrorGroupService",
"credentialsType": None,
},
)

def get_group(
self,
request: Optional[Union[error_group_service.GetGroupRequest, dict]] = None,
*,
group_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]]] = (),
) -> common.ErrorGroup:
r"""Get the specified group.
Expand Down Expand Up @@ -745,8 +777,10 @@ def sample_get_group():
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.errorreporting_v1beta1.types.ErrorGroup:
Expand All @@ -757,7 +791,10 @@ def sample_get_group():
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([group_name])
flattened_params = [group_name]
has_flattened_params = (
len([param for param in flattened_params if param is not None]) > 0
)
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
Expand Down Expand Up @@ -806,7 +843,7 @@ def update_group(
group: Optional[common.ErrorGroup] = 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]]] = (),
) -> common.ErrorGroup:
r"""Replace the data for the specified group.
Fails if the group does not exist.
Expand Down Expand Up @@ -850,8 +887,10 @@ def sample_update_group():
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.errorreporting_v1beta1.types.ErrorGroup:
Expand All @@ -862,7 +901,10 @@ def sample_update_group():
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([group])
flattened_params = [group]
has_flattened_params = (
len([param for param in flattened_params if param is not None]) > 0
)
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

transport inheritance structure
_______________________________

`ErrorGroupServiceTransport` is the ABC for all transports.
- public child `ErrorGroupServiceGrpcTransport` for sync gRPC transport (defined in `grpc.py`).
- public child `ErrorGroupServiceGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`).
- private child `_BaseErrorGroupServiceRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`).
- public child `ErrorGroupServiceRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`).
Loading

0 comments on commit 1d120c7

Please sign in to comment.