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

chore: remove body selector from http rule #521

Merged
merged 6 commits into from
Nov 11, 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 @@ -2456,11 +2456,7 @@ async def list_operations(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.list_operations,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self.transport._wrapped_methods[self._client._transport.list_operations]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -2513,11 +2509,7 @@ async def get_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self.transport._wrapped_methods[self._client._transport.get_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -2574,11 +2566,7 @@ async def delete_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self.transport._wrapped_methods[self._client._transport.delete_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -2631,11 +2619,7 @@ async def cancel_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.cancel_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self.transport._wrapped_methods[self._client._transport.cancel_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down
64 changes: 7 additions & 57 deletions google/cloud/pubsublite_v1/services/admin_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,36 +510,6 @@ 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.

Returns:
bool: True iff client_universe matches the universe in credentials.

Raises:
ValueError: when client_universe does not match the universe in credentials.
"""

default_universe = AdminServiceClient._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."
)
return True

def _validate_universe_domain(self):
"""Validates client's and credentials' universe domains are consistent.

Expand All @@ -549,13 +519,9 @@ def _validate_universe_domain(self):
Raises:
ValueError: If the configured universe domain is not valid.
"""
self._is_universe_domain_valid = (
self._is_universe_domain_valid
or AdminServiceClient._compare_universes(
self.universe_domain, self.transport._credentials
)
)
return self._is_universe_domain_valid

# NOTE (b/349488459): universe validation is disabled until further notice.
return True

@property
def api_endpoint(self):
Expand Down Expand Up @@ -2874,11 +2840,7 @@ def list_operations(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._transport.list_operations,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self._transport._wrapped_methods[self._transport.list_operations]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -2931,11 +2893,7 @@ def get_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._transport.get_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self._transport._wrapped_methods[self._transport.get_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -2992,11 +2950,7 @@ def delete_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._transport.delete_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self._transport._wrapped_methods[self._transport.delete_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down Expand Up @@ -3049,11 +3003,7 @@ def cancel_operation(

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._transport.cancel_operation,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)
rpc = self._transport._wrapped_methods[self._transport.cancel_operation]

# Certain fields should be provided within the metadata header;
# add these here.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

transport inheritance structure
_______________________________

`AdminServiceTransport` is the ABC for all transports.
- public child `AdminServiceGrpcTransport` for sync gRPC transport (defined in `grpc.py`).
- public child `AdminServiceGrpcAsyncIOTransport` for async gRPC transport (defined in `grpc_asyncio.py`).
- private child `_BaseAdminServiceRestTransport` for base REST transport with inner classes `_BaseMETHOD` (defined in `rest_base.py`).
- public child `AdminServiceRestTransport` for sync REST transport with inner classes `METHOD` derived from the parent's corresponding `_BaseMETHOD` classes (defined in `rest.py`).
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.cancel_operation: gapic_v1.method.wrap_method(
self.cancel_operation,
default_timeout=None,
client_info=client_info,
),
self.delete_operation: gapic_v1.method.wrap_method(
self.delete_operation,
default_timeout=None,
client_info=client_info,
),
self.get_operation: gapic_v1.method.wrap_method(
self.get_operation,
default_timeout=None,
client_info=client_info,
),
self.list_operations: gapic_v1.method.wrap_method(
self.list_operations,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down
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 inspect
import warnings
from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union

Expand Down Expand Up @@ -234,6 +235,9 @@ def __init__(
)

# Wrap messages. This must be done after self._grpc_channel exists
self._wrap_with_kind = (
"kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters
)
self._prep_wrapped_messages(client_info)

@property
Expand Down Expand Up @@ -798,106 +802,135 @@ def list_reservation_topics(
def _prep_wrapped_messages(self, client_info):
"""Precompute the wrapped methods, overriding the base class method to use async wrappers."""
self._wrapped_methods = {
self.create_topic: gapic_v1.method_async.wrap_method(
self.create_topic: self._wrap_method(
self.create_topic,
default_timeout=None,
client_info=client_info,
),
self.get_topic: gapic_v1.method_async.wrap_method(
self.get_topic: self._wrap_method(
self.get_topic,
default_timeout=None,
client_info=client_info,
),
self.get_topic_partitions: gapic_v1.method_async.wrap_method(
self.get_topic_partitions: self._wrap_method(
self.get_topic_partitions,
default_timeout=None,
client_info=client_info,
),
self.list_topics: gapic_v1.method_async.wrap_method(
self.list_topics: self._wrap_method(
self.list_topics,
default_timeout=None,
client_info=client_info,
),
self.update_topic: gapic_v1.method_async.wrap_method(
self.update_topic: self._wrap_method(
self.update_topic,
default_timeout=None,
client_info=client_info,
),
self.delete_topic: gapic_v1.method_async.wrap_method(
self.delete_topic: self._wrap_method(
self.delete_topic,
default_timeout=None,
client_info=client_info,
),
self.list_topic_subscriptions: gapic_v1.method_async.wrap_method(
self.list_topic_subscriptions: self._wrap_method(
self.list_topic_subscriptions,
default_timeout=None,
client_info=client_info,
),
self.create_subscription: gapic_v1.method_async.wrap_method(
self.create_subscription: self._wrap_method(
self.create_subscription,
default_timeout=None,
client_info=client_info,
),
self.get_subscription: gapic_v1.method_async.wrap_method(
self.get_subscription: self._wrap_method(
self.get_subscription,
default_timeout=None,
client_info=client_info,
),
self.list_subscriptions: gapic_v1.method_async.wrap_method(
self.list_subscriptions: self._wrap_method(
self.list_subscriptions,
default_timeout=None,
client_info=client_info,
),
self.update_subscription: gapic_v1.method_async.wrap_method(
self.update_subscription: self._wrap_method(
self.update_subscription,
default_timeout=None,
client_info=client_info,
),
self.delete_subscription: gapic_v1.method_async.wrap_method(
self.delete_subscription: self._wrap_method(
self.delete_subscription,
default_timeout=None,
client_info=client_info,
),
self.seek_subscription: gapic_v1.method_async.wrap_method(
self.seek_subscription: self._wrap_method(
self.seek_subscription,
default_timeout=None,
client_info=client_info,
),
self.create_reservation: gapic_v1.method_async.wrap_method(
self.create_reservation: self._wrap_method(
self.create_reservation,
default_timeout=None,
client_info=client_info,
),
self.get_reservation: gapic_v1.method_async.wrap_method(
self.get_reservation: self._wrap_method(
self.get_reservation,
default_timeout=None,
client_info=client_info,
),
self.list_reservations: gapic_v1.method_async.wrap_method(
self.list_reservations: self._wrap_method(
self.list_reservations,
default_timeout=None,
client_info=client_info,
),
self.update_reservation: gapic_v1.method_async.wrap_method(
self.update_reservation: self._wrap_method(
self.update_reservation,
default_timeout=None,
client_info=client_info,
),
self.delete_reservation: gapic_v1.method_async.wrap_method(
self.delete_reservation: self._wrap_method(
self.delete_reservation,
default_timeout=None,
client_info=client_info,
),
self.list_reservation_topics: gapic_v1.method_async.wrap_method(
self.list_reservation_topics: self._wrap_method(
self.list_reservation_topics,
default_timeout=None,
client_info=client_info,
),
self.cancel_operation: self._wrap_method(
self.cancel_operation,
default_timeout=None,
client_info=client_info,
),
self.delete_operation: self._wrap_method(
self.delete_operation,
default_timeout=None,
client_info=client_info,
),
self.get_operation: self._wrap_method(
self.get_operation,
default_timeout=None,
client_info=client_info,
),
self.list_operations: self._wrap_method(
self.list_operations,
default_timeout=None,
client_info=client_info,
),
}

def _wrap_method(self, func, *args, **kwargs):
if self._wrap_with_kind: # pragma: NO COVER
kwargs["kind"] = self.kind
return gapic_v1.method_async.wrap_method(func, *args, **kwargs)

def close(self):
return self.grpc_channel.close()

@property
def kind(self) -> str:
return "grpc_asyncio"

@property
def delete_operation(
self,
Expand Down
Loading