From e7019082acc55ef005f27f17b09d17aec6c5136c 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 15:02:16 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#182) - [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): require google-api-core >= 1.28.0 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 --- .../reservation_service/async_client.py | 124 +++++++++--------- .../services/reservation_service/client.py | 42 +++--- .../reservation_service/transports/base.py | 35 +---- .../transports/grpc_asyncio.py | 1 - .../setup.py | 3 +- .../testing/constraints-3.6.txt | 4 +- .../test_reservation_service.py | 100 ++------------ 7 files changed, 97 insertions(+), 212 deletions(-) diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py index 05ae6d34d6c8..a3d9a74fe8f9 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py @@ -20,13 +20,15 @@ import pkg_resources import warnings -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.bigquery_reservation_v1.services.reservation_service import pagers from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation @@ -200,19 +202,19 @@ def __init__( async def create_reservation( self, - request: gcbr_reservation.CreateReservationRequest = None, + request: Union[gcbr_reservation.CreateReservationRequest, dict] = None, *, parent: str = None, reservation: gcbr_reservation.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]] = (), ) -> gcbr_reservation.Reservation: r"""Creates a new reservation resource. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.CreateReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.CreateReservationRequest, dict]): The request object. The request for [ReservationService.CreateReservation][google.cloud.bigquery.reservation.v1.ReservationService.CreateReservation]. parent (:class:`str`): @@ -293,10 +295,10 @@ async def create_reservation( async def list_reservations( self, - request: reservation.ListReservationsRequest = None, + request: Union[reservation.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: @@ -304,7 +306,7 @@ async def list_reservations( specified location. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.ListReservationsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.ListReservationsRequest, dict]): The request object. The request for [ReservationService.ListReservations][google.cloud.bigquery.reservation.v1.ReservationService.ListReservations]. parent (:class:`str`): @@ -384,17 +386,17 @@ async def list_reservations( async def get_reservation( self, - request: reservation.GetReservationRequest = None, + request: Union[reservation.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]] = (), ) -> reservation.Reservation: r"""Returns information about the reservation. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.GetReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.GetReservationRequest, dict]): The request object. The request for [ReservationService.GetReservation][google.cloud.bigquery.reservation.v1.ReservationService.GetReservation]. name (:class:`str`): @@ -466,10 +468,10 @@ async def get_reservation( async def delete_reservation( self, - request: reservation.DeleteReservationRequest = None, + request: Union[reservation.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: @@ -478,7 +480,7 @@ async def delete_reservation( assignments. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.DeleteReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.DeleteReservationRequest, dict]): The request object. The request for [ReservationService.DeleteReservation][google.cloud.bigquery.reservation.v1.ReservationService.DeleteReservation]. name (:class:`str`): @@ -543,18 +545,18 @@ async def delete_reservation( async def update_reservation( self, - request: gcbr_reservation.UpdateReservationRequest = None, + request: Union[gcbr_reservation.UpdateReservationRequest, dict] = None, *, reservation: gcbr_reservation.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]] = (), ) -> gcbr_reservation.Reservation: r"""Updates an existing reservation resource. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.UpdateReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.UpdateReservationRequest, dict]): The request object. The request for [ReservationService.UpdateReservation][google.cloud.bigquery.reservation.v1.ReservationService.UpdateReservation]. reservation (:class:`google.cloud.bigquery_reservation_v1.types.Reservation`): @@ -624,18 +626,18 @@ async def update_reservation( async def create_capacity_commitment( self, - request: reservation.CreateCapacityCommitmentRequest = None, + request: Union[reservation.CreateCapacityCommitmentRequest, dict] = None, *, parent: str = None, capacity_commitment: reservation.CapacityCommitment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.CapacityCommitment: r"""Creates a new capacity commitment resource. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.CreateCapacityCommitmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.CreateCapacityCommitmentRequest, dict]): The request object. The request for [ReservationService.CreateCapacityCommitment][google.cloud.bigquery.reservation.v1.ReservationService.CreateCapacityCommitment]. parent (:class:`str`): @@ -717,10 +719,10 @@ async def create_capacity_commitment( async def list_capacity_commitments( self, - request: reservation.ListCapacityCommitmentsRequest = None, + request: Union[reservation.ListCapacityCommitmentsRequest, 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.ListCapacityCommitmentsAsyncPager: @@ -728,7 +730,7 @@ async def list_capacity_commitments( project. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.ListCapacityCommitmentsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.ListCapacityCommitmentsRequest, dict]): The request object. The request for [ReservationService.ListCapacityCommitments][google.cloud.bigquery.reservation.v1.ReservationService.ListCapacityCommitments]. parent (:class:`str`): @@ -808,17 +810,17 @@ async def list_capacity_commitments( async def get_capacity_commitment( self, - request: reservation.GetCapacityCommitmentRequest = None, + request: Union[reservation.GetCapacityCommitmentRequest, 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]] = (), ) -> reservation.CapacityCommitment: r"""Returns information about the capacity commitment. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.GetCapacityCommitmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.GetCapacityCommitmentRequest, dict]): The request object. The request for [ReservationService.GetCapacityCommitment][google.cloud.bigquery.reservation.v1.ReservationService.GetCapacityCommitment]. name (:class:`str`): @@ -902,10 +904,10 @@ async def get_capacity_commitment( async def delete_capacity_commitment( self, - request: reservation.DeleteCapacityCommitmentRequest = None, + request: Union[reservation.DeleteCapacityCommitmentRequest, 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: @@ -914,7 +916,7 @@ async def delete_capacity_commitment( error code ``google.rpc.Code.FAILED_PRECONDITION``. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.DeleteCapacityCommitmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.DeleteCapacityCommitmentRequest, dict]): The request object. The request for [ReservationService.DeleteCapacityCommitment][google.cloud.bigquery.reservation.v1.ReservationService.DeleteCapacityCommitment]. name (:class:`str`): @@ -979,11 +981,11 @@ async def delete_capacity_commitment( async def update_capacity_commitment( self, - request: reservation.UpdateCapacityCommitmentRequest = None, + request: Union[reservation.UpdateCapacityCommitmentRequest, dict] = None, *, capacity_commitment: reservation.CapacityCommitment = 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]] = (), ) -> reservation.CapacityCommitment: @@ -997,7 +999,7 @@ async def update_capacity_commitment( ``google.rpc.Code.FAILED_PRECONDITION``. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.UpdateCapacityCommitmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.UpdateCapacityCommitmentRequest, dict]): The request object. The request for [ReservationService.UpdateCapacityCommitment][google.cloud.bigquery.reservation.v1.ReservationService.UpdateCapacityCommitment]. capacity_commitment (:class:`google.cloud.bigquery_reservation_v1.types.CapacityCommitment`): @@ -1081,11 +1083,11 @@ async def update_capacity_commitment( async def split_capacity_commitment( self, - request: reservation.SplitCapacityCommitmentRequest = None, + request: Union[reservation.SplitCapacityCommitmentRequest, dict] = None, *, name: str = None, slot_count: int = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.SplitCapacityCommitmentResponse: @@ -1100,7 +1102,7 @@ async def split_capacity_commitment( ``FLEX`` and then delete it. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentRequest, dict]): The request object. The request for [ReservationService.SplitCapacityCommitment][google.cloud.bigquery.reservation.v1.ReservationService.SplitCapacityCommitment]. name (:class:`str`): @@ -1170,11 +1172,11 @@ async def split_capacity_commitment( async def merge_capacity_commitments( self, - request: reservation.MergeCapacityCommitmentsRequest = None, + request: Union[reservation.MergeCapacityCommitmentsRequest, dict] = None, *, parent: str = None, capacity_commitment_ids: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.CapacityCommitment: @@ -1190,7 +1192,7 @@ async def merge_capacity_commitments( ``google.rpc.Code.FAILED_PRECONDITION``. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.MergeCapacityCommitmentsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.MergeCapacityCommitmentsRequest, dict]): The request object. The request for [ReservationService.MergeCapacityCommitments][google.cloud.bigquery.reservation.v1.ReservationService.MergeCapacityCommitments]. parent (:class:`str`): @@ -1277,11 +1279,11 @@ async def merge_capacity_commitments( async def create_assignment( self, - request: reservation.CreateAssignmentRequest = None, + request: Union[reservation.CreateAssignmentRequest, dict] = None, *, parent: str = None, assignment: reservation.Assignment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.Assignment: @@ -1325,7 +1327,7 @@ async def create_assignment( the assignment does not match location of the reservation. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.CreateAssignmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.CreateAssignmentRequest, dict]): The request object. The request for [ReservationService.CreateAssignment][google.cloud.bigquery.reservation.v1.ReservationService.CreateAssignment]. Note: "bigquery.reservationAssignments.create" @@ -1397,10 +1399,10 @@ async def create_assignment( async def list_assignments( self, - request: reservation.ListAssignmentsRequest = None, + request: Union[reservation.ListAssignmentsRequest, 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.ListAssignmentsAsyncPager: @@ -1428,7 +1430,7 @@ async def list_assignments( **Note** "-" cannot be used for projects nor locations. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.ListAssignmentsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.ListAssignmentsRequest, dict]): The request object. The request for [ReservationService.ListAssignments][google.cloud.bigquery.reservation.v1.ReservationService.ListAssignments]. parent (:class:`str`): @@ -1513,10 +1515,10 @@ async def list_assignments( async def delete_assignment( self, - request: reservation.DeleteAssignmentRequest = None, + request: Union[reservation.DeleteAssignmentRequest, 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: @@ -1538,7 +1540,7 @@ async def delete_assignment( ``project2`` will switch to use on-demand mode. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.DeleteAssignmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.DeleteAssignmentRequest, dict]): The request object. The request for [ReservationService.DeleteAssignment][google.cloud.bigquery.reservation.v1.ReservationService.DeleteAssignment]. Note: "bigquery.reservationAssignments.delete" @@ -1604,11 +1606,11 @@ async def delete_assignment( async def search_assignments( self, - request: reservation.SearchAssignmentsRequest = None, + request: Union[reservation.SearchAssignmentsRequest, dict] = None, *, parent: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAssignmentsAsyncPager: @@ -1639,7 +1641,7 @@ async def search_assignments( **Note** "-" cannot be used for projects nor locations. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.SearchAssignmentsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.SearchAssignmentsRequest, dict]): The request object. The request for [ReservationService.SearchAssignments][google.cloud.bigquery.reservation.v1.ReservationService.SearchAssignments]. Note: "bigquery.reservationAssignments.search" @@ -1742,11 +1744,11 @@ async def search_assignments( async def search_all_assignments( self, - request: reservation.SearchAllAssignmentsRequest = None, + request: Union[reservation.SearchAllAssignmentsRequest, dict] = None, *, parent: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAllAssignmentsAsyncPager: @@ -1775,7 +1777,7 @@ async def search_all_assignments( ``projects/*/locations/*reservations/*``. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.SearchAllAssignmentsRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.SearchAllAssignmentsRequest, dict]): The request object. The request for [ReservationService.SearchAllAssignments][google.cloud.bigquery.reservation.v1.ReservationService.SearchAllAssignments]. Note: "bigquery.reservationAssignments.search" @@ -1863,11 +1865,11 @@ async def search_all_assignments( async def move_assignment( self, - request: reservation.MoveAssignmentRequest = None, + request: Union[reservation.MoveAssignmentRequest, dict] = None, *, name: str = None, destination_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.Assignment: @@ -1878,7 +1880,7 @@ async def move_assignment( reservation. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.MoveAssignmentRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.MoveAssignmentRequest, dict]): The request object. The request for [ReservationService.MoveAssignment][google.cloud.bigquery.reservation.v1.ReservationService.MoveAssignment]. **Note**: "bigquery.reservationAssignments.create" @@ -1955,17 +1957,17 @@ async def move_assignment( async def get_bi_reservation( self, - request: reservation.GetBiReservationRequest = None, + request: Union[reservation.GetBiReservationRequest, 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]] = (), ) -> reservation.BiReservation: r"""Retrieves a BI reservation. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.GetBiReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.GetBiReservationRequest, dict]): The request object. A request to get a singleton BI reservation. name (:class:`str`): @@ -2035,11 +2037,11 @@ async def get_bi_reservation( async def update_bi_reservation( self, - request: reservation.UpdateBiReservationRequest = None, + request: Union[reservation.UpdateBiReservationRequest, dict] = None, *, bi_reservation: reservation.BiReservation = 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]] = (), ) -> reservation.BiReservation: @@ -2053,7 +2055,7 @@ async def update_bi_reservation( must be set to 0. Args: - request (:class:`google.cloud.bigquery_reservation_v1.types.UpdateBiReservationRequest`): + request (Union[google.cloud.bigquery_reservation_v1.types.UpdateBiReservationRequest, dict]): The request object. A request to update a BI reservation. bi_reservation (:class:`google.cloud.bigquery_reservation_v1.types.BiReservation`): diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py index 0387956b3d30..fede8039c478 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py @@ -31,6 +31,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.bigquery_reservation_v1.services.reservation_service import pagers from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation @@ -433,7 +435,7 @@ def create_reservation( parent: str = None, reservation: gcbr_reservation.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]] = (), ) -> gcbr_reservation.Reservation: @@ -524,7 +526,7 @@ def list_reservations( request: Union[reservation.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: @@ -605,7 +607,7 @@ def get_reservation( request: Union[reservation.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]] = (), ) -> reservation.Reservation: @@ -677,7 +679,7 @@ def delete_reservation( request: Union[reservation.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: @@ -745,7 +747,7 @@ def update_reservation( *, reservation: gcbr_reservation.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]] = (), ) -> gcbr_reservation.Reservation: @@ -826,7 +828,7 @@ def create_capacity_commitment( *, parent: str = None, capacity_commitment: reservation.CapacityCommitment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.CapacityCommitment: @@ -920,7 +922,7 @@ def list_capacity_commitments( request: Union[reservation.ListCapacityCommitmentsRequest, 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.ListCapacityCommitmentsPager: @@ -1003,7 +1005,7 @@ def get_capacity_commitment( request: Union[reservation.GetCapacityCommitmentRequest, 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]] = (), ) -> reservation.CapacityCommitment: @@ -1087,7 +1089,7 @@ def delete_capacity_commitment( request: Union[reservation.DeleteCapacityCommitmentRequest, 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: @@ -1157,7 +1159,7 @@ def update_capacity_commitment( *, capacity_commitment: reservation.CapacityCommitment = 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]] = (), ) -> reservation.CapacityCommitment: @@ -1261,7 +1263,7 @@ def split_capacity_commitment( *, name: str = None, slot_count: int = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.SplitCapacityCommitmentResponse: @@ -1352,7 +1354,7 @@ def merge_capacity_commitments( *, parent: str = None, capacity_commitment_ids: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.CapacityCommitment: @@ -1461,7 +1463,7 @@ def create_assignment( *, parent: str = None, assignment: reservation.Assignment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.Assignment: @@ -1580,7 +1582,7 @@ def list_assignments( request: Union[reservation.ListAssignmentsRequest, 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.ListAssignmentsPager: @@ -1686,7 +1688,7 @@ def delete_assignment( request: Union[reservation.DeleteAssignmentRequest, 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: @@ -1768,7 +1770,7 @@ def search_assignments( *, parent: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAssignmentsPager: @@ -1896,7 +1898,7 @@ def search_all_assignments( *, parent: str = None, query: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.SearchAllAssignmentsPager: @@ -2017,7 +2019,7 @@ def move_assignment( *, name: str = None, destination_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> reservation.Assignment: @@ -2108,7 +2110,7 @@ def get_bi_reservation( request: Union[reservation.GetBiReservationRequest, 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]] = (), ) -> reservation.BiReservation: @@ -2179,7 +2181,7 @@ def update_bi_reservation( *, bi_reservation: reservation.BiReservation = 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]] = (), ) -> reservation.BiReservation: diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py index ed076e2c92ad..d1aef8fdd3e3 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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 @@ -39,15 +38,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 ReservationServiceTransport(abc.ABC): """Abstract transport class for ReservationService.""" @@ -100,7 +90,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 @@ -133,29 +123,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/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py index b9b8ac36e938..f9ac7cd20fc9 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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/packages/google-cloud-bigquery-reservation/setup.py b/packages/google-cloud-bigquery-reservation/setup.py index 6ab3e24dfa34..22faead2234b 100644 --- a/packages/google-cloud-bigquery-reservation/setup.py +++ b/packages/google-cloud-bigquery-reservation/setup.py @@ -49,9 +49,8 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.4.0", - "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/packages/google-cloud-bigquery-reservation/testing/constraints-3.6.txt b/packages/google-cloud-bigquery-reservation/testing/constraints-3.6.txt index 31166429cc2b..6b451bc37e2f 100644 --- a/packages/google-cloud-bigquery-reservation/testing/constraints-3.6.txt +++ b/packages/google-cloud-bigquery-reservation/testing/constraints-3.6.txt @@ -5,7 +5,5 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.4.0 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is transitively required through google-api-core diff --git a/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py b/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py index 0646fd1071a7..a744987b4004 100644 --- a/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py +++ b/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,9 +39,6 @@ ) from google.cloud.bigquery_reservation_v1.services.reservation_service import pagers from google.cloud.bigquery_reservation_v1.services.reservation_service import transports -from google.cloud.bigquery_reservation_v1.services.reservation_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation from google.oauth2 import service_account @@ -53,20 +49,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" @@ -224,7 +206,7 @@ def test_reservation_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, @@ -241,7 +223,7 @@ def test_reservation_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, @@ -258,7 +240,7 @@ def test_reservation_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, @@ -287,7 +269,7 @@ def test_reservation_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, @@ -356,7 +338,7 @@ def test_reservation_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 @@ -398,7 +380,7 @@ def test_reservation_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, @@ -420,7 +402,7 @@ def test_reservation_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, @@ -451,7 +433,7 @@ def test_reservation_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, @@ -482,7 +464,7 @@ def test_reservation_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", @@ -6127,7 +6109,6 @@ def test_reservation_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_reservation_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -6151,29 +6132,6 @@ def test_reservation_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_reservation_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.bigquery_reservation_v1.services.reservation_service.transports.ReservationServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ReservationServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/bigquery", - "https://www.googleapis.com/auth/cloud-platform", - ), - quota_project_id="octopus", - ) - - def test_reservation_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( @@ -6185,7 +6143,6 @@ def test_reservation_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_reservation_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -6201,21 +6158,6 @@ def test_reservation_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_reservation_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) - ReservationServiceClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/bigquery", - "https://www.googleapis.com/auth/cloud-platform", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -6223,7 +6165,6 @@ def test_reservation_service_auth_adc_old_google_auth(): transports.ReservationServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_reservation_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -6240,29 +6181,6 @@ def test_reservation_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.ReservationServiceGrpcTransport, - transports.ReservationServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_reservation_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/bigquery", - "https://www.googleapis.com/auth/cloud-platform", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [