From ce2e5ef952708776fccc6652fb2c485c35b48e2f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:26:11 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#268) - [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): drop packaging dependency committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: https://github.com/googleapis/googleapis/commit/83d81b0c8fc22291a13398d6d77f02dc97a5b6f4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9 --- .../services/admin_service/async_client.py | 118 +++++++++--------- .../services/admin_service/client.py | 40 +++--- .../services/admin_service/transports/base.py | 37 +----- .../services/admin_service/transports/grpc.py | 2 +- .../admin_service/transports/grpc_asyncio.py | 3 +- .../services/cursor_service/async_client.py | 18 +-- .../services/cursor_service/client.py | 8 +- .../cursor_service/transports/base.py | 35 +----- .../cursor_service/transports/grpc_asyncio.py | 1 - .../async_client.py | 6 +- .../partition_assignment_service/client.py | 4 +- .../transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - .../publisher_service/async_client.py | 6 +- .../services/publisher_service/client.py | 4 +- .../publisher_service/transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - .../subscriber_service/async_client.py | 6 +- .../services/subscriber_service/client.py | 4 +- .../subscriber_service/transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - .../topic_stats_service/async_client.py | 22 ++-- .../services/topic_stats_service/client.py | 8 +- .../topic_stats_service/transports/base.py | 35 +----- .../transports/grpc_asyncio.py | 1 - google/cloud/pubsublite_v1/types/admin.py | 9 ++ google/cloud/pubsublite_v1/types/common.py | 18 +++ google/cloud/pubsublite_v1/types/cursor.py | 18 +++ google/cloud/pubsublite_v1/types/publisher.py | 18 +++ .../cloud/pubsublite_v1/types/subscriber.py | 38 ++++++ setup.py | 1 - .../gapic/pubsublite_v1/test_admin_service.py | 91 ++------------ .../pubsublite_v1/test_cursor_service.py | 91 ++------------ .../test_partition_assignment_service.py | 93 ++------------ .../pubsublite_v1/test_publisher_service.py | 91 ++------------ .../pubsublite_v1/test_subscriber_service.py | 91 ++------------ .../pubsublite_v1/test_topic_stats_service.py | 91 ++------------ 37 files changed, 298 insertions(+), 818 deletions(-) diff --git a/google/cloud/pubsublite_v1/services/admin_service/async_client.py b/google/cloud/pubsublite_v1/services/admin_service/async_client.py index 80285489..8a63d994 100644 --- a/google/cloud/pubsublite_v1/services/admin_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/admin_service/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.pubsublite_v1.services.admin_service import pagers @@ -170,19 +172,19 @@ def __init__( async def create_topic( self, - request: admin.CreateTopicRequest = None, + request: Union[admin.CreateTopicRequest, dict] = None, *, parent: str = None, topic: common.Topic = None, topic_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: r"""Creates a new topic. Args: - request (:class:`google.cloud.pubsublite_v1.types.CreateTopicRequest`): + request (Union[google.cloud.pubsublite_v1.types.CreateTopicRequest, dict]): The request object. Request for CreateTopic. parent (:class:`str`): Required. The parent location in which to create the @@ -261,17 +263,17 @@ async def create_topic( async def get_topic( self, - request: admin.GetTopicRequest = None, + request: Union[admin.GetTopicRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: r"""Returns the topic configuration. Args: - request (:class:`google.cloud.pubsublite_v1.types.GetTopicRequest`): + request (Union[google.cloud.pubsublite_v1.types.GetTopicRequest, dict]): The request object. Request for GetTopic. name (:class:`str`): Required. The name of the topic whose @@ -329,10 +331,10 @@ async def get_topic( async def get_topic_partitions( self, - request: admin.GetTopicPartitionsRequest = None, + request: Union[admin.GetTopicPartitionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> admin.TopicPartitions: @@ -340,7 +342,7 @@ async def get_topic_partitions( topic. Args: - request (:class:`google.cloud.pubsublite_v1.types.GetTopicPartitionsRequest`): + request (Union[google.cloud.pubsublite_v1.types.GetTopicPartitionsRequest, dict]): The request object. Request for GetTopicPartitions. name (:class:`str`): Required. The topic whose partition @@ -398,17 +400,17 @@ async def get_topic_partitions( async def list_topics( self, - request: admin.ListTopicsRequest = None, + request: Union[admin.ListTopicsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTopicsAsyncPager: r"""Returns the list of topics for the given project. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListTopicsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListTopicsRequest, dict]): The request object. Request for ListTopics. parent (:class:`str`): Required. The parent whose topics are to be listed. @@ -477,18 +479,18 @@ async def list_topics( async def update_topic( self, - request: admin.UpdateTopicRequest = None, + request: Union[admin.UpdateTopicRequest, dict] = None, *, topic: common.Topic = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: r"""Updates properties of the specified topic. Args: - request (:class:`google.cloud.pubsublite_v1.types.UpdateTopicRequest`): + request (Union[google.cloud.pubsublite_v1.types.UpdateTopicRequest, dict]): The request object. Request for UpdateTopic. topic (:class:`google.cloud.pubsublite_v1.types.Topic`): Required. The topic to update. Its ``name`` field must @@ -557,17 +559,17 @@ async def update_topic( async def delete_topic( self, - request: admin.DeleteTopicRequest = None, + request: Union[admin.DeleteTopicRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified topic. Args: - request (:class:`google.cloud.pubsublite_v1.types.DeleteTopicRequest`): + request (Union[google.cloud.pubsublite_v1.types.DeleteTopicRequest, dict]): The request object. Request for DeleteTopic. name (:class:`str`): Required. The name of the topic to @@ -620,10 +622,10 @@ async def delete_topic( async def list_topic_subscriptions( self, - request: admin.ListTopicSubscriptionsRequest = None, + request: Union[admin.ListTopicSubscriptionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTopicSubscriptionsAsyncPager: @@ -631,7 +633,7 @@ async def list_topic_subscriptions( topic. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListTopicSubscriptionsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListTopicSubscriptionsRequest, dict]): The request object. Request for ListTopicSubscriptions. name (:class:`str`): Required. The name of the topic whose @@ -699,19 +701,19 @@ async def list_topic_subscriptions( async def create_subscription( self, - request: admin.CreateSubscriptionRequest = None, + request: Union[admin.CreateSubscriptionRequest, dict] = None, *, parent: str = None, subscription: common.Subscription = None, subscription_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: r"""Creates a new subscription. Args: - request (:class:`google.cloud.pubsublite_v1.types.CreateSubscriptionRequest`): + request (Union[google.cloud.pubsublite_v1.types.CreateSubscriptionRequest, dict]): The request object. Request for CreateSubscription. parent (:class:`str`): Required. The parent location in which to create the @@ -792,17 +794,17 @@ async def create_subscription( async def get_subscription( self, - request: admin.GetSubscriptionRequest = None, + request: Union[admin.GetSubscriptionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: r"""Returns the subscription configuration. Args: - request (:class:`google.cloud.pubsublite_v1.types.GetSubscriptionRequest`): + request (Union[google.cloud.pubsublite_v1.types.GetSubscriptionRequest, dict]): The request object. Request for GetSubscription. name (:class:`str`): Required. The name of the @@ -863,10 +865,10 @@ async def get_subscription( async def list_subscriptions( self, - request: admin.ListSubscriptionsRequest = None, + request: Union[admin.ListSubscriptionsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSubscriptionsAsyncPager: @@ -874,7 +876,7 @@ async def list_subscriptions( project. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListSubscriptionsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListSubscriptionsRequest, dict]): The request object. Request for ListSubscriptions. parent (:class:`str`): Required. The parent whose subscriptions are to be @@ -943,18 +945,18 @@ async def list_subscriptions( async def update_subscription( self, - request: admin.UpdateSubscriptionRequest = None, + request: Union[admin.UpdateSubscriptionRequest, dict] = None, *, subscription: common.Subscription = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: r"""Updates properties of the specified subscription. Args: - request (:class:`google.cloud.pubsublite_v1.types.UpdateSubscriptionRequest`): + request (Union[google.cloud.pubsublite_v1.types.UpdateSubscriptionRequest, dict]): The request object. Request for UpdateSubscription. subscription (:class:`google.cloud.pubsublite_v1.types.Subscription`): Required. The subscription to update. Its ``name`` field @@ -1025,17 +1027,17 @@ async def update_subscription( async def delete_subscription( self, - request: admin.DeleteSubscriptionRequest = None, + request: Union[admin.DeleteSubscriptionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified subscription. Args: - request (:class:`google.cloud.pubsublite_v1.types.DeleteSubscriptionRequest`): + request (Union[google.cloud.pubsublite_v1.types.DeleteSubscriptionRequest, dict]): The request object. Request for DeleteSubscription. name (:class:`str`): Required. The name of the @@ -1088,9 +1090,9 @@ async def delete_subscription( async def seek_subscription( self, - request: admin.SeekSubscriptionRequest = None, + request: Union[admin.SeekSubscriptionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1123,7 +1125,7 @@ async def seek_subscription( supersede it. Args: - request (:class:`google.cloud.pubsublite_v1.types.SeekSubscriptionRequest`): + request (Union[google.cloud.pubsublite_v1.types.SeekSubscriptionRequest, dict]): The request object. Request for SeekSubscription. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -1173,19 +1175,19 @@ async def seek_subscription( async def create_reservation( self, - request: admin.CreateReservationRequest = None, + request: Union[admin.CreateReservationRequest, dict] = None, *, parent: str = None, reservation: common.Reservation = None, reservation_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: r"""Creates a new reservation. Args: - request (:class:`google.cloud.pubsublite_v1.types.CreateReservationRequest`): + request (Union[google.cloud.pubsublite_v1.types.CreateReservationRequest, dict]): The request object. Request for CreateReservation. parent (:class:`str`): Required. The parent location in which to create the @@ -1266,17 +1268,17 @@ async def create_reservation( async def get_reservation( self, - request: admin.GetReservationRequest = None, + request: Union[admin.GetReservationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: r"""Returns the reservation configuration. Args: - request (:class:`google.cloud.pubsublite_v1.types.GetReservationRequest`): + request (Union[google.cloud.pubsublite_v1.types.GetReservationRequest, dict]): The request object. Request for GetReservation. name (:class:`str`): Required. The name of the reservation whose @@ -1337,10 +1339,10 @@ async def get_reservation( async def list_reservations( self, - request: admin.ListReservationsRequest = None, + request: Union[admin.ListReservationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListReservationsAsyncPager: @@ -1348,7 +1350,7 @@ async def list_reservations( project. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListReservationsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListReservationsRequest, dict]): The request object. Request for ListReservations. parent (:class:`str`): Required. The parent whose reservations are to be @@ -1417,18 +1419,18 @@ async def list_reservations( async def update_reservation( self, - request: admin.UpdateReservationRequest = None, + request: Union[admin.UpdateReservationRequest, dict] = None, *, reservation: common.Reservation = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: r"""Updates properties of the specified reservation. Args: - request (:class:`google.cloud.pubsublite_v1.types.UpdateReservationRequest`): + request (Union[google.cloud.pubsublite_v1.types.UpdateReservationRequest, dict]): The request object. Request for UpdateReservation. reservation (:class:`google.cloud.pubsublite_v1.types.Reservation`): Required. The reservation to update. Its ``name`` field @@ -1499,17 +1501,17 @@ async def update_reservation( async def delete_reservation( self, - request: admin.DeleteReservationRequest = None, + request: Union[admin.DeleteReservationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes the specified reservation. Args: - request (:class:`google.cloud.pubsublite_v1.types.DeleteReservationRequest`): + request (Union[google.cloud.pubsublite_v1.types.DeleteReservationRequest, dict]): The request object. Request for DeleteReservation. name (:class:`str`): Required. The name of the reservation to delete. @@ -1563,10 +1565,10 @@ async def delete_reservation( async def list_reservation_topics( self, - request: admin.ListReservationTopicsRequest = None, + request: Union[admin.ListReservationTopicsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListReservationTopicsAsyncPager: @@ -1574,7 +1576,7 @@ async def list_reservation_topics( reservation. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListReservationTopicsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListReservationTopicsRequest, dict]): The request object. Request for ListReservationTopics. name (:class:`str`): Required. The name of the reservation whose topics to diff --git a/google/cloud/pubsublite_v1/services/admin_service/client.py b/google/cloud/pubsublite_v1/services/admin_service/client.py index 3caf53b0..bca69438 100644 --- a/google/cloud/pubsublite_v1/services/admin_service/client.py +++ b/google/cloud/pubsublite_v1/services/admin_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.pubsublite_v1.services.admin_service import pagers @@ -391,7 +393,7 @@ def create_topic( parent: str = None, topic: common.Topic = None, topic_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: @@ -480,7 +482,7 @@ def get_topic( request: Union[admin.GetTopicRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: @@ -548,7 +550,7 @@ def get_topic_partitions( request: Union[admin.GetTopicPartitionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> admin.TopicPartitions: @@ -617,7 +619,7 @@ def list_topics( request: Union[admin.ListTopicsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTopicsPager: @@ -697,7 +699,7 @@ def update_topic( *, topic: common.Topic = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Topic: @@ -776,7 +778,7 @@ def delete_topic( request: Union[admin.DeleteTopicRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -839,7 +841,7 @@ def list_topic_subscriptions( request: Union[admin.ListTopicSubscriptionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListTopicSubscriptionsPager: @@ -920,7 +922,7 @@ def create_subscription( parent: str = None, subscription: common.Subscription = None, subscription_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: @@ -1011,7 +1013,7 @@ def get_subscription( request: Union[admin.GetSubscriptionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: @@ -1082,7 +1084,7 @@ def list_subscriptions( request: Union[admin.ListSubscriptionsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListSubscriptionsPager: @@ -1163,7 +1165,7 @@ def update_subscription( *, subscription: common.Subscription = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Subscription: @@ -1244,7 +1246,7 @@ def delete_subscription( request: Union[admin.DeleteSubscriptionRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1306,7 +1308,7 @@ def seek_subscription( self, request: Union[admin.SeekSubscriptionRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1395,7 +1397,7 @@ def create_reservation( parent: str = None, reservation: common.Reservation = None, reservation_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: @@ -1486,7 +1488,7 @@ def get_reservation( request: Union[admin.GetReservationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: @@ -1557,7 +1559,7 @@ def list_reservations( request: Union[admin.ListReservationsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListReservationsPager: @@ -1638,7 +1640,7 @@ def update_reservation( *, reservation: common.Reservation = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> common.Reservation: @@ -1719,7 +1721,7 @@ def delete_reservation( request: Union[admin.DeleteReservationRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1783,7 +1785,7 @@ def list_reservation_topics( request: Union[admin.ListReservationTopicsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListReservationTopicsPager: diff --git a/google/cloud/pubsublite_v1/services/admin_service/transports/base.py b/google/cloud/pubsublite_v1/services/admin_service/transports/base.py index f6757685..a5a59288 100644 --- a/google/cloud/pubsublite_v1/services/admin_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/admin_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -41,15 +40,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class AdminServiceTransport(abc.ABC): """Abstract transport class for AdminService.""" @@ -99,7 +89,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -132,29 +122,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -233,7 +200,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/pubsublite_v1/services/admin_service/transports/grpc.py b/google/cloud/pubsublite_v1/services/admin_service/transports/grpc.py index d526776a..33f7e00a 100644 --- a/google/cloud/pubsublite_v1/services/admin_service/transports/grpc.py +++ b/google/cloud/pubsublite_v1/services/admin_service/transports/grpc.py @@ -116,7 +116,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/pubsublite_v1/services/admin_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/admin_service/transports/grpc_asyncio.py index 3866b9eb..bbb8c51e 100644 --- a/google/cloud/pubsublite_v1/services/admin_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/admin_service/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -163,7 +162,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/pubsublite_v1/services/cursor_service/async_client.py b/google/cloud/pubsublite_v1/services/cursor_service/async_client.py index 88a02149..b95ba1e2 100644 --- a/google/cloud/pubsublite_v1/services/cursor_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/cursor_service/async_client.py @@ -28,13 +28,15 @@ ) import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.services.cursor_service import pagers from google.cloud.pubsublite_v1.types import cursor from .transports.base import CursorServiceTransport, DEFAULT_CLIENT_INFO @@ -178,7 +180,7 @@ def streaming_commit_cursor( self, requests: AsyncIterator[cursor.StreamingCommitCursorRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Awaitable[AsyncIterable[cursor.StreamingCommitCursorResponse]]: @@ -218,16 +220,16 @@ def streaming_commit_cursor( async def commit_cursor( self, - request: cursor.CommitCursorRequest = None, + request: Union[cursor.CommitCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cursor.CommitCursorResponse: r"""Updates the committed cursor. Args: - request (:class:`google.cloud.pubsublite_v1.types.CommitCursorRequest`): + request (Union[google.cloud.pubsublite_v1.types.CommitCursorRequest, dict]): The request object. Request for CommitCursor. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -279,10 +281,10 @@ async def commit_cursor( async def list_partition_cursors( self, - request: cursor.ListPartitionCursorsRequest = None, + request: Union[cursor.ListPartitionCursorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListPartitionCursorsAsyncPager: @@ -290,7 +292,7 @@ async def list_partition_cursors( subscription. Args: - request (:class:`google.cloud.pubsublite_v1.types.ListPartitionCursorsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ListPartitionCursorsRequest, dict]): The request object. Request for ListPartitionCursors. parent (:class:`str`): Required. The subscription for which to retrieve diff --git a/google/cloud/pubsublite_v1/services/cursor_service/client.py b/google/cloud/pubsublite_v1/services/cursor_service/client.py index 8adfb4d5..92896be2 100644 --- a/google/cloud/pubsublite_v1/services/cursor_service/client.py +++ b/google/cloud/pubsublite_v1/services/cursor_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.services.cursor_service import pagers from google.cloud.pubsublite_v1.types import cursor from .transports.base import CursorServiceTransport, DEFAULT_CLIENT_INFO @@ -353,7 +355,7 @@ def streaming_commit_cursor( self, requests: Iterator[cursor.StreamingCommitCursorRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Iterable[cursor.StreamingCommitCursorResponse]: @@ -391,7 +393,7 @@ def commit_cursor( self, request: Union[cursor.CommitCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> cursor.CommitCursorResponse: @@ -441,7 +443,7 @@ def list_partition_cursors( request: Union[cursor.ListPartitionCursorsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListPartitionCursorsPager: diff --git a/google/cloud/pubsublite_v1/services/cursor_service/transports/base.py b/google/cloud/pubsublite_v1/services/cursor_service/transports/base.py index a17304ec..c8f88c5b 100644 --- a/google/cloud/pubsublite_v1/services/cursor_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/cursor_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class CursorServiceTransport(abc.ABC): """Abstract transport class for CursorService.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/pubsublite_v1/services/cursor_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/cursor_service/transports/grpc_asyncio.py index 7940a71c..31f77480 100644 --- a/google/cloud/pubsublite_v1/services/cursor_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/cursor_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/pubsublite_v1/services/partition_assignment_service/async_client.py b/google/cloud/pubsublite_v1/services/partition_assignment_service/async_client.py index 0109bd78..27272804 100644 --- a/google/cloud/pubsublite_v1/services/partition_assignment_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/partition_assignment_service/async_client.py @@ -28,13 +28,15 @@ ) import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import subscriber from .transports.base import PartitionAssignmentServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PartitionAssignmentServiceGrpcAsyncIOTransport @@ -180,7 +182,7 @@ def assign_partitions( self, requests: AsyncIterator[subscriber.PartitionAssignmentRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Awaitable[AsyncIterable[subscriber.PartitionAssignment]]: diff --git a/google/cloud/pubsublite_v1/services/partition_assignment_service/client.py b/google/cloud/pubsublite_v1/services/partition_assignment_service/client.py index 804db7c2..5d4bbc3e 100644 --- a/google/cloud/pubsublite_v1/services/partition_assignment_service/client.py +++ b/google/cloud/pubsublite_v1/services/partition_assignment_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import subscriber from .transports.base import PartitionAssignmentServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PartitionAssignmentServiceGrpcTransport @@ -338,7 +340,7 @@ def assign_partitions( self, requests: Iterator[subscriber.PartitionAssignmentRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Iterable[subscriber.PartitionAssignment]: diff --git a/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/base.py b/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/base.py index ff39d6d6..7a4e61de 100644 --- a/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class PartitionAssignmentServiceTransport(abc.ABC): """Abstract transport class for PartitionAssignmentService.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/grpc_asyncio.py index 6211f0b3..cd279056 100644 --- a/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/partition_assignment_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/pubsublite_v1/services/publisher_service/async_client.py b/google/cloud/pubsublite_v1/services/publisher_service/async_client.py index 6fe5116a..87a0ad33 100644 --- a/google/cloud/pubsublite_v1/services/publisher_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/publisher_service/async_client.py @@ -28,13 +28,15 @@ ) import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import publisher from .transports.base import PublisherServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import PublisherServiceGrpcAsyncIOTransport @@ -176,7 +178,7 @@ def publish( self, requests: AsyncIterator[publisher.PublishRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Awaitable[AsyncIterable[publisher.PublishResponse]]: diff --git a/google/cloud/pubsublite_v1/services/publisher_service/client.py b/google/cloud/pubsublite_v1/services/publisher_service/client.py index 0c6f6fa4..6739f478 100644 --- a/google/cloud/pubsublite_v1/services/publisher_service/client.py +++ b/google/cloud/pubsublite_v1/services/publisher_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import publisher from .transports.base import PublisherServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import PublisherServiceGrpcTransport @@ -339,7 +341,7 @@ def publish( self, requests: Iterator[publisher.PublishRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Iterable[publisher.PublishResponse]: diff --git a/google/cloud/pubsublite_v1/services/publisher_service/transports/base.py b/google/cloud/pubsublite_v1/services/publisher_service/transports/base.py index 604580b2..159a8026 100644 --- a/google/cloud/pubsublite_v1/services/publisher_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/publisher_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class PublisherServiceTransport(abc.ABC): """Abstract transport class for PublisherService.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/pubsublite_v1/services/publisher_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/publisher_service/transports/grpc_asyncio.py index f036207e..2ae4a737 100644 --- a/google/cloud/pubsublite_v1/services/publisher_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/publisher_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/pubsublite_v1/services/subscriber_service/async_client.py b/google/cloud/pubsublite_v1/services/subscriber_service/async_client.py index ff170718..749d421c 100644 --- a/google/cloud/pubsublite_v1/services/subscriber_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/subscriber_service/async_client.py @@ -28,13 +28,15 @@ ) import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import subscriber from .transports.base import SubscriberServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import SubscriberServiceGrpcAsyncIOTransport @@ -173,7 +175,7 @@ def subscribe( self, requests: AsyncIterator[subscriber.SubscribeRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Awaitable[AsyncIterable[subscriber.SubscribeResponse]]: diff --git a/google/cloud/pubsublite_v1/services/subscriber_service/client.py b/google/cloud/pubsublite_v1/services/subscriber_service/client.py index 152d82d4..9c583375 100644 --- a/google/cloud/pubsublite_v1/services/subscriber_service/client.py +++ b/google/cloud/pubsublite_v1/services/subscriber_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import subscriber from .transports.base import SubscriberServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import SubscriberServiceGrpcTransport @@ -338,7 +340,7 @@ def subscribe( self, requests: Iterator[subscriber.SubscribeRequest] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> Iterable[subscriber.SubscribeResponse]: diff --git a/google/cloud/pubsublite_v1/services/subscriber_service/transports/base.py b/google/cloud/pubsublite_v1/services/subscriber_service/transports/base.py index 37b5f8e9..e0d752cd 100644 --- a/google/cloud/pubsublite_v1/services/subscriber_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/subscriber_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class SubscriberServiceTransport(abc.ABC): """Abstract transport class for SubscriberService.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/pubsublite_v1/services/subscriber_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/subscriber_service/transports/grpc_asyncio.py index 7bb8bfb0..f91fe28c 100644 --- a/google/cloud/pubsublite_v1/services/subscriber_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/subscriber_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/pubsublite_v1/services/topic_stats_service/async_client.py b/google/cloud/pubsublite_v1/services/topic_stats_service/async_client.py index 7525688c..3423f6ce 100644 --- a/google/cloud/pubsublite_v1/services/topic_stats_service/async_client.py +++ b/google/cloud/pubsublite_v1/services/topic_stats_service/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import topic_stats from google.protobuf import timestamp_pb2 # type: ignore @@ -166,9 +168,9 @@ def __init__( async def compute_message_stats( self, - request: topic_stats.ComputeMessageStatsRequest = None, + request: Union[topic_stats.ComputeMessageStatsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeMessageStatsResponse: @@ -176,7 +178,7 @@ async def compute_message_stats( given topic and partition. Args: - request (:class:`google.cloud.pubsublite_v1.types.ComputeMessageStatsRequest`): + request (Union[google.cloud.pubsublite_v1.types.ComputeMessageStatsRequest, dict]): The request object. Compute statistics about a range of messages in a given topic and partition. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -217,9 +219,9 @@ async def compute_message_stats( async def compute_head_cursor( self, - request: topic_stats.ComputeHeadCursorRequest = None, + request: Union[topic_stats.ComputeHeadCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeHeadCursorResponse: @@ -232,7 +234,7 @@ async def compute_head_cursor( messages in the partition. Args: - request (:class:`google.cloud.pubsublite_v1.types.ComputeHeadCursorRequest`): + request (Union[google.cloud.pubsublite_v1.types.ComputeHeadCursorRequest, dict]): The request object. Compute the current head cursor for a partition. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -272,9 +274,9 @@ async def compute_head_cursor( async def compute_time_cursor( self, - request: topic_stats.ComputeTimeCursorRequest = None, + request: Union[topic_stats.ComputeTimeCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeTimeCursorResponse: @@ -282,7 +284,7 @@ async def compute_time_cursor( event time in a topic partition. Args: - request (:class:`google.cloud.pubsublite_v1.types.ComputeTimeCursorRequest`): + request (Union[google.cloud.pubsublite_v1.types.ComputeTimeCursorRequest, dict]): The request object. Compute the corresponding cursor for a publish or event time in a topic partition. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/pubsublite_v1/services/topic_stats_service/client.py b/google/cloud/pubsublite_v1/services/topic_stats_service/client.py index acb531bc..6cef60e7 100644 --- a/google/cloud/pubsublite_v1/services/topic_stats_service/client.py +++ b/google/cloud/pubsublite_v1/services/topic_stats_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import topic_stats from google.protobuf import timestamp_pb2 # type: ignore @@ -356,7 +358,7 @@ def compute_message_stats( self, request: Union[topic_stats.ComputeMessageStatsRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeMessageStatsResponse: @@ -408,7 +410,7 @@ def compute_head_cursor( self, request: Union[topic_stats.ComputeHeadCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeHeadCursorResponse: @@ -464,7 +466,7 @@ def compute_time_cursor( self, request: Union[topic_stats.ComputeTimeCursorRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> topic_stats.ComputeTimeCursorResponse: diff --git a/google/cloud/pubsublite_v1/services/topic_stats_service/transports/base.py b/google/cloud/pubsublite_v1/services/topic_stats_service/transports/base.py index 57bb2035..0522cbed 100644 --- a/google/cloud/pubsublite_v1/services/topic_stats_service/transports/base.py +++ b/google/cloud/pubsublite_v1/services/topic_stats_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -37,15 +36,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class TopicStatsServiceTransport(abc.ABC): """Abstract transport class for TopicStatsService.""" @@ -95,7 +85,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -128,29 +118,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/pubsublite_v1/services/topic_stats_service/transports/grpc_asyncio.py b/google/cloud/pubsublite_v1/services/topic_stats_service/transports/grpc_asyncio.py index b17e8220..0c4c72a6 100644 --- a/google/cloud/pubsublite_v1/services/topic_stats_service/transports/grpc_asyncio.py +++ b/google/cloud/pubsublite_v1/services/topic_stats_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/pubsublite_v1/types/admin.py b/google/cloud/pubsublite_v1/types/admin.py index e4d05f83..1deae5b3 100644 --- a/google/cloud/pubsublite_v1/types/admin.py +++ b/google/cloud/pubsublite_v1/types/admin.py @@ -364,6 +364,13 @@ class DeleteSubscriptionRequest(proto.Message): class SeekSubscriptionRequest(proto.Message): r"""Request for SeekSubscription. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): Required. The name of the subscription to @@ -371,12 +378,14 @@ class SeekSubscriptionRequest(proto.Message): named_target (google.cloud.pubsublite_v1.types.SeekSubscriptionRequest.NamedTarget): Seek to a named position with respect to the message backlog. + This field is a member of `oneof`_ ``target``. time_target (google.cloud.pubsublite_v1.types.TimeTarget): Seek to the first message whose publish or event time is greater than or equal to the specified query time. If no such message can be located, will seek to the end of the message backlog. + This field is a member of `oneof`_ ``target``. """ class NamedTarget(proto.Enum): diff --git a/google/cloud/pubsublite_v1/types/common.py b/google/cloud/pubsublite_v1/types/common.py index 6c52cd5a..764dbf05 100644 --- a/google/cloud/pubsublite_v1/types/common.py +++ b/google/cloud/pubsublite_v1/types/common.py @@ -154,6 +154,13 @@ class Topic(proto.Message): class PartitionConfig(proto.Message): r"""The settings for a topic's partitions. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: count (int): The number of partitions in the topic. Must be at least 1. @@ -172,8 +179,10 @@ class PartitionConfig(proto.Message): this topic; a topic with ``scale`` of 2 and count of 10 is charged for 20 partitions. This value must be in the range [1,4]. + This field is a member of `oneof`_ ``dimension``. capacity (google.cloud.pubsublite_v1.types.Topic.PartitionConfig.Capacity): The capacity configuration. + This field is a member of `oneof`_ ``dimension``. """ class Capacity(proto.Message): @@ -288,12 +297,20 @@ class TimeTarget(proto.Message): r"""A target publish or event time. Can be used for seeking to or retrieving the corresponding cursor. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: publish_time (google.protobuf.timestamp_pb2.Timestamp): Request the cursor of the first message with publish time greater than or equal to ``publish_time``. All messages thereafter are guaranteed to have publish times >= ``publish_time``. + This field is a member of `oneof`_ ``time``. event_time (google.protobuf.timestamp_pb2.Timestamp): Request the cursor of the first message with event time greater than or equal to ``event_time``. If messages are @@ -301,6 +318,7 @@ class TimeTarget(proto.Message): fallback. As event times are user supplied, subsequent messages may have event times less than ``event_time`` and should be filtered by the client, if necessary. + This field is a member of `oneof`_ ``time``. """ publish_time = proto.Field( diff --git a/google/cloud/pubsublite_v1/types/cursor.py b/google/cloud/pubsublite_v1/types/cursor.py index 72a47ad6..765ece00 100644 --- a/google/cloud/pubsublite_v1/types/cursor.py +++ b/google/cloud/pubsublite_v1/types/cursor.py @@ -90,11 +90,20 @@ class SequencedCommitCursorResponse(proto.Message): class StreamingCommitCursorRequest(proto.Message): r"""A request sent from the client to the server on a stream. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial (google.cloud.pubsublite_v1.types.InitialCommitCursorRequest): Initial request on the stream. + This field is a member of `oneof`_ ``request``. commit (google.cloud.pubsublite_v1.types.SequencedCommitCursorRequest): Request to commit a new cursor value. + This field is a member of `oneof`_ ``request``. """ initial = proto.Field( @@ -111,11 +120,20 @@ class StreamingCommitCursorRequest(proto.Message): class StreamingCommitCursorResponse(proto.Message): r"""Response to a StreamingCommitCursorRequest. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial (google.cloud.pubsublite_v1.types.InitialCommitCursorResponse): Initial response on the stream. + This field is a member of `oneof`_ ``request``. commit (google.cloud.pubsublite_v1.types.SequencedCommitCursorResponse): Response to committing a new cursor value. + This field is a member of `oneof`_ ``request``. """ initial = proto.Field( diff --git a/google/cloud/pubsublite_v1/types/publisher.py b/google/cloud/pubsublite_v1/types/publisher.py index b48a7074..adf41a44 100644 --- a/google/cloud/pubsublite_v1/types/publisher.py +++ b/google/cloud/pubsublite_v1/types/publisher.py @@ -82,11 +82,20 @@ class MessagePublishResponse(proto.Message): class PublishRequest(proto.Message): r"""Request sent from the client to the server on a stream. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial_request (google.cloud.pubsublite_v1.types.InitialPublishRequest): Initial request on the stream. + This field is a member of `oneof`_ ``request_type``. message_publish_request (google.cloud.pubsublite_v1.types.MessagePublishRequest): Request to publish messages. + This field is a member of `oneof`_ ``request_type``. """ initial_request = proto.Field( @@ -100,11 +109,20 @@ class PublishRequest(proto.Message): class PublishResponse(proto.Message): r"""Response to a PublishRequest. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial_response (google.cloud.pubsublite_v1.types.InitialPublishResponse): Initial response on the stream. + This field is a member of `oneof`_ ``response_type``. message_response (google.cloud.pubsublite_v1.types.MessagePublishResponse): Response to publishing messages. + This field is a member of `oneof`_ ``response_type``. """ initial_response = proto.Field( diff --git a/google/cloud/pubsublite_v1/types/subscriber.py b/google/cloud/pubsublite_v1/types/subscriber.py index 645842ae..3197a410 100644 --- a/google/cloud/pubsublite_v1/types/subscriber.py +++ b/google/cloud/pubsublite_v1/types/subscriber.py @@ -84,12 +84,21 @@ class SeekRequest(proto.Message): outstanding (i.e., has not received a SeekResponse) on the same stream. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: named_target (google.cloud.pubsublite_v1.types.SeekRequest.NamedTarget): A named target. + This field is a member of `oneof`_ ``target``. cursor (google.cloud.pubsublite_v1.types.Cursor): A target corresponding to the cursor, pointing to anywhere in the topic partition. + This field is a member of `oneof`_ ``target``. """ class NamedTarget(proto.Enum): @@ -138,14 +147,24 @@ class FlowControlRequest(proto.Message): class SubscribeRequest(proto.Message): r"""A request sent from the client to the server on a stream. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial (google.cloud.pubsublite_v1.types.InitialSubscribeRequest): Initial request on the stream. + This field is a member of `oneof`_ ``request``. seek (google.cloud.pubsublite_v1.types.SeekRequest): Request to update the stream's delivery cursor. + This field is a member of `oneof`_ ``request``. flow_control (google.cloud.pubsublite_v1.types.FlowControlRequest): Request to grant tokens to the server, + This field is a member of `oneof`_ ``request``. """ initial = proto.Field( @@ -179,14 +198,24 @@ class MessageResponse(proto.Message): class SubscribeResponse(proto.Message): r"""Response to SubscribeRequest. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial (google.cloud.pubsublite_v1.types.InitialSubscribeResponse): Initial response on the stream. + This field is a member of `oneof`_ ``response``. seek (google.cloud.pubsublite_v1.types.SeekResponse): Response to a Seek operation. + This field is a member of `oneof`_ ``response``. messages (google.cloud.pubsublite_v1.types.MessageResponse): Response containing messages from the topic partition. + This field is a member of `oneof`_ ``response``. """ initial = proto.Field( @@ -255,11 +284,20 @@ class PartitionAssignmentAck(proto.Message): class PartitionAssignmentRequest(proto.Message): r"""A request on the PartitionAssignment stream. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: initial (google.cloud.pubsublite_v1.types.InitialPartitionAssignmentRequest): Initial request on the stream. + This field is a member of `oneof`_ ``request``. ack (google.cloud.pubsublite_v1.types.PartitionAssignmentAck): Acknowledgement of a partition assignment. + This field is a member of `oneof`_ ``request``. """ initial = proto.Field( diff --git a/setup.py b/setup.py index 4590584f..ad933fe8 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,6 @@ "grpcio >= 1.18.0", "grpcio-status >= 1.18.0", "overrides>=6.0.1, <7.0.0", - "packaging >= 14.3", ] setuptools.setup( diff --git a/tests/unit/gapic/pubsublite_v1/test_admin_service.py b/tests/unit/gapic/pubsublite_v1/test_admin_service.py index 5f8bb8d0..459eb44f 100644 --- a/tests/unit/gapic/pubsublite_v1/test_admin_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_admin_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ from google.cloud.pubsublite_v1.services.admin_service import AdminServiceClient from google.cloud.pubsublite_v1.services.admin_service import pagers from google.cloud.pubsublite_v1.services.admin_service import transports -from google.cloud.pubsublite_v1.services.admin_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import admin from google.cloud.pubsublite_v1.types import common from google.longrunning import operations_pb2 @@ -52,20 +48,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -213,7 +195,7 @@ def test_admin_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -230,7 +212,7 @@ def test_admin_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -247,7 +229,7 @@ def test_admin_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -276,7 +258,7 @@ def test_admin_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -333,7 +315,7 @@ def test_admin_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -375,7 +357,7 @@ def test_admin_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -397,7 +379,7 @@ def test_admin_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -428,7 +410,7 @@ def test_admin_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -459,7 +441,7 @@ def test_admin_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -5152,7 +5134,6 @@ def test_admin_service_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_admin_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -5173,26 +5154,6 @@ def test_admin_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_admin_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.admin_service.transports.AdminServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.AdminServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_admin_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -5204,7 +5165,6 @@ def test_admin_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_admin_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -5217,18 +5177,6 @@ def test_admin_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_admin_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - AdminServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -5236,7 +5184,6 @@ def test_admin_service_auth_adc_old_google_auth(): transports.AdminServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_admin_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -5250,26 +5197,6 @@ def test_admin_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.AdminServiceGrpcTransport, - transports.AdminServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_admin_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/pubsublite_v1/test_cursor_service.py b/tests/unit/gapic/pubsublite_v1/test_cursor_service.py index f6b343ac..5b369dfe 100644 --- a/tests/unit/gapic/pubsublite_v1/test_cursor_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_cursor_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,29 +35,12 @@ from google.cloud.pubsublite_v1.services.cursor_service import CursorServiceClient from google.cloud.pubsublite_v1.services.cursor_service import pagers from google.cloud.pubsublite_v1.services.cursor_service import transports -from google.cloud.pubsublite_v1.services.cursor_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import cursor from google.oauth2 import service_account import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -215,7 +197,7 @@ def test_cursor_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -232,7 +214,7 @@ def test_cursor_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -249,7 +231,7 @@ def test_cursor_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -278,7 +260,7 @@ def test_cursor_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -337,7 +319,7 @@ def test_cursor_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -379,7 +361,7 @@ def test_cursor_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -401,7 +383,7 @@ def test_cursor_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -432,7 +414,7 @@ def test_cursor_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -463,7 +445,7 @@ def test_cursor_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -1188,7 +1170,6 @@ def test_cursor_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_cursor_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1209,26 +1190,6 @@ def test_cursor_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_cursor_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.cursor_service.transports.CursorServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.CursorServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_cursor_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -1240,7 +1201,6 @@ def test_cursor_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_cursor_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1253,18 +1213,6 @@ def test_cursor_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_cursor_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - CursorServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1272,7 +1220,6 @@ def test_cursor_service_auth_adc_old_google_auth(): transports.CursorServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_cursor_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1286,26 +1233,6 @@ def test_cursor_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.CursorServiceGrpcTransport, - transports.CursorServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_cursor_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/pubsublite_v1/test_partition_assignment_service.py b/tests/unit/gapic/pubsublite_v1/test_partition_assignment_service.py index 9c8a4905..3eab7bbb 100644 --- a/tests/unit/gapic/pubsublite_v1/test_partition_assignment_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_partition_assignment_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,28 +38,11 @@ PartitionAssignmentServiceClient, ) from google.cloud.pubsublite_v1.services.partition_assignment_service import transports -from google.cloud.pubsublite_v1.services.partition_assignment_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import subscriber from google.oauth2 import service_account import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -230,7 +212,7 @@ def test_partition_assignment_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -247,7 +229,7 @@ def test_partition_assignment_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -264,7 +246,7 @@ def test_partition_assignment_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -293,7 +275,7 @@ def test_partition_assignment_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -362,7 +344,7 @@ def test_partition_assignment_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -404,7 +386,7 @@ def test_partition_assignment_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -426,7 +408,7 @@ def test_partition_assignment_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -461,7 +443,7 @@ def test_partition_assignment_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -496,7 +478,7 @@ def test_partition_assignment_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -711,7 +693,6 @@ def test_partition_assignment_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_partition_assignment_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -732,26 +713,6 @@ def test_partition_assignment_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_partition_assignment_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.partition_assignment_service.transports.PartitionAssignmentServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.PartitionAssignmentServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_partition_assignment_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -763,7 +724,6 @@ def test_partition_assignment_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_partition_assignment_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -776,18 +736,6 @@ def test_partition_assignment_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_partition_assignment_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - PartitionAssignmentServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -795,7 +743,6 @@ def test_partition_assignment_service_auth_adc_old_google_auth(): transports.PartitionAssignmentServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_partition_assignment_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -809,28 +756,6 @@ def test_partition_assignment_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.PartitionAssignmentServiceGrpcTransport, - transports.PartitionAssignmentServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_partition_assignment_service_transport_auth_adc_old_google_auth( - transport_class, -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/pubsublite_v1/test_publisher_service.py b/tests/unit/gapic/pubsublite_v1/test_publisher_service.py index 057eabe3..59aaaccd 100644 --- a/tests/unit/gapic/pubsublite_v1/test_publisher_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_publisher_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -37,9 +36,6 @@ ) from google.cloud.pubsublite_v1.services.publisher_service import PublisherServiceClient from google.cloud.pubsublite_v1.services.publisher_service import transports -from google.cloud.pubsublite_v1.services.publisher_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import publisher from google.oauth2 import service_account @@ -47,20 +43,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -218,7 +200,7 @@ def test_publisher_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -235,7 +217,7 @@ def test_publisher_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -252,7 +234,7 @@ def test_publisher_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -281,7 +263,7 @@ def test_publisher_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -350,7 +332,7 @@ def test_publisher_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -392,7 +374,7 @@ def test_publisher_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -414,7 +396,7 @@ def test_publisher_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -445,7 +427,7 @@ def test_publisher_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -476,7 +458,7 @@ def test_publisher_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -681,7 +663,6 @@ def test_publisher_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_publisher_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -702,26 +683,6 @@ def test_publisher_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_publisher_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.publisher_service.transports.PublisherServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.PublisherServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_publisher_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -733,7 +694,6 @@ def test_publisher_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_publisher_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -746,18 +706,6 @@ def test_publisher_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_publisher_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - PublisherServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -765,7 +713,6 @@ def test_publisher_service_auth_adc_old_google_auth(): transports.PublisherServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_publisher_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -779,26 +726,6 @@ def test_publisher_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.PublisherServiceGrpcTransport, - transports.PublisherServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_publisher_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/pubsublite_v1/test_subscriber_service.py b/tests/unit/gapic/pubsublite_v1/test_subscriber_service.py index 2806922e..85745f9a 100644 --- a/tests/unit/gapic/pubsublite_v1/test_subscriber_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_subscriber_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,29 +38,12 @@ SubscriberServiceClient, ) from google.cloud.pubsublite_v1.services.subscriber_service import transports -from google.cloud.pubsublite_v1.services.subscriber_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import subscriber from google.oauth2 import service_account import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -219,7 +201,7 @@ def test_subscriber_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -236,7 +218,7 @@ def test_subscriber_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -253,7 +235,7 @@ def test_subscriber_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -282,7 +264,7 @@ def test_subscriber_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -351,7 +333,7 @@ def test_subscriber_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -393,7 +375,7 @@ def test_subscriber_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -415,7 +397,7 @@ def test_subscriber_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -446,7 +428,7 @@ def test_subscriber_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -477,7 +459,7 @@ def test_subscriber_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -682,7 +664,6 @@ def test_subscriber_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_subscriber_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -703,26 +684,6 @@ def test_subscriber_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_subscriber_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.subscriber_service.transports.SubscriberServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.SubscriberServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_subscriber_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -734,7 +695,6 @@ def test_subscriber_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_subscriber_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -747,18 +707,6 @@ def test_subscriber_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_subscriber_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - SubscriberServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -766,7 +714,6 @@ def test_subscriber_service_auth_adc_old_google_auth(): transports.SubscriberServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_subscriber_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -780,26 +727,6 @@ def test_subscriber_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.SubscriberServiceGrpcTransport, - transports.SubscriberServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_subscriber_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/pubsublite_v1/test_topic_stats_service.py b/tests/unit/gapic/pubsublite_v1/test_topic_stats_service.py index 834c6e03..20ed49f3 100644 --- a/tests/unit/gapic/pubsublite_v1/test_topic_stats_service.py +++ b/tests/unit/gapic/pubsublite_v1/test_topic_stats_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -39,9 +38,6 @@ TopicStatsServiceClient, ) from google.cloud.pubsublite_v1.services.topic_stats_service import transports -from google.cloud.pubsublite_v1.services.topic_stats_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.pubsublite_v1.types import common from google.cloud.pubsublite_v1.types import topic_stats from google.oauth2 import service_account @@ -49,20 +45,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -220,7 +202,7 @@ def test_topic_stats_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -237,7 +219,7 @@ def test_topic_stats_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -254,7 +236,7 @@ def test_topic_stats_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -283,7 +265,7 @@ def test_topic_stats_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -352,7 +334,7 @@ def test_topic_stats_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -394,7 +376,7 @@ def test_topic_stats_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -416,7 +398,7 @@ def test_topic_stats_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -447,7 +429,7 @@ def test_topic_stats_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -478,7 +460,7 @@ def test_topic_stats_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -1054,7 +1036,6 @@ def test_topic_stats_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_topic_stats_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1075,26 +1056,6 @@ def test_topic_stats_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_topic_stats_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.pubsublite_v1.services.topic_stats_service.transports.TopicStatsServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TopicStatsServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_topic_stats_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -1106,7 +1067,6 @@ def test_topic_stats_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_topic_stats_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1119,18 +1079,6 @@ def test_topic_stats_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_topic_stats_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - TopicStatsServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1138,7 +1086,6 @@ def test_topic_stats_service_auth_adc_old_google_auth(): transports.TopicStatsServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_topic_stats_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1152,26 +1099,6 @@ def test_topic_stats_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.TopicStatsServiceGrpcTransport, - transports.TopicStatsServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_topic_stats_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [