From 4d52ed91ae9eaa7ec6091138c134e682c9434853 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 21 May 2021 01:54:08 +0000 Subject: [PATCH] chore: upgrade gapic-generator-python to 0.46.3 (#110) PiperOrigin-RevId: 373649163 Source-Link: https://github.com/googleapis/googleapis/commit/7e1b14e6c7a9ab96d2db7e4a131981f162446d34 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0a3c7d272d697796db75857bac73905c68e498c3 fix: add async client to %name_%version/init.py chore: add autogenerated snippets chore: remove auth, policy, and options from the reserved names list feat: support self-signed JWT flow for service accounts chore: enable GAPIC metadata generation chore: sort subpackages in %namespace/%name/init.py --- .../reservation_service.rst | 1 - google/cloud/bigquery_reservation/__init__.py | 12 +- .../cloud/bigquery_reservation_v1/__init__.py | 7 +- .../gapic_metadata.json | 213 +++ .../services/__init__.py | 1 - .../services/reservation_service/__init__.py | 2 - .../reservation_service/async_client.py | 105 +- .../services/reservation_service/client.py | 142 +- .../services/reservation_service/pagers.py | 10 +- .../transports/__init__.py | 2 - .../reservation_service/transports/base.py | 238 ++-- .../reservation_service/transports/grpc.py | 36 +- .../transports/grpc_asyncio.py | 37 +- .../bigquery_reservation_v1/types/__init__.py | 2 - .../types/reservation.py | 154 +-- noxfile.py | 2 +- owlbot.py | 2 +- .../fixup_bigquery_reservation_v1_keywords.py | 43 +- setup.py | 1 + testing/constraints-3.6.txt | 2 + ...st_bigquery_reservation.py => __init__.py} | 8 - tests/unit/__init__.py | 15 + tests/unit/gapic/__init__.py | 15 + .../gapic/bigquery_reservation_v1/__init__.py | 1 - .../test_reservation_service.py | 1193 +++++++++-------- 25 files changed, 1219 insertions(+), 1025 deletions(-) create mode 100644 google/cloud/bigquery_reservation_v1/gapic_metadata.json rename tests/{unit/test_bigquery_reservation.py => __init__.py} (75%) create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/gapic/__init__.py diff --git a/docs/bigquery_reservation_v1/reservation_service.rst b/docs/bigquery_reservation_v1/reservation_service.rst index bfa849bf..35e6b3cf 100644 --- a/docs/bigquery_reservation_v1/reservation_service.rst +++ b/docs/bigquery_reservation_v1/reservation_service.rst @@ -5,7 +5,6 @@ ReservationService :members: :inherited-members: - .. automodule:: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers :members: :inherited-members: diff --git a/google/cloud/bigquery_reservation/__init__.py b/google/cloud/bigquery_reservation/__init__.py index 8ef414c5..60f322a8 100644 --- a/google/cloud/bigquery_reservation/__init__.py +++ b/google/cloud/bigquery_reservation/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,13 @@ # limitations under the License. # -from google.cloud.bigquery_reservation_v1.services.reservation_service.async_client import ( - ReservationServiceAsyncClient, -) from google.cloud.bigquery_reservation_v1.services.reservation_service.client import ( ReservationServiceClient, ) +from google.cloud.bigquery_reservation_v1.services.reservation_service.async_client import ( + ReservationServiceAsyncClient, +) + from google.cloud.bigquery_reservation_v1.types.reservation import Assignment from google.cloud.bigquery_reservation_v1.types.reservation import BiReservation from google.cloud.bigquery_reservation_v1.types.reservation import CapacityCommitment @@ -95,6 +95,8 @@ ) __all__ = ( + "ReservationServiceClient", + "ReservationServiceAsyncClient", "Assignment", "BiReservation", "CapacityCommitment", @@ -116,8 +118,6 @@ "MergeCapacityCommitmentsRequest", "MoveAssignmentRequest", "Reservation", - "ReservationServiceAsyncClient", - "ReservationServiceClient", "SearchAssignmentsRequest", "SearchAssignmentsResponse", "SplitCapacityCommitmentRequest", diff --git a/google/cloud/bigquery_reservation_v1/__init__.py b/google/cloud/bigquery_reservation_v1/__init__.py index 804db281..5902a13e 100644 --- a/google/cloud/bigquery_reservation_v1/__init__.py +++ b/google/cloud/bigquery_reservation_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,8 @@ # from .services.reservation_service import ReservationServiceClient +from .services.reservation_service import ReservationServiceAsyncClient + from .types.reservation import Assignment from .types.reservation import BiReservation from .types.reservation import CapacityCommitment @@ -45,8 +46,8 @@ from .types.reservation import UpdateCapacityCommitmentRequest from .types.reservation import UpdateReservationRequest - __all__ = ( + "ReservationServiceAsyncClient", "Assignment", "BiReservation", "CapacityCommitment", @@ -68,6 +69,7 @@ "MergeCapacityCommitmentsRequest", "MoveAssignmentRequest", "Reservation", + "ReservationServiceClient", "SearchAssignmentsRequest", "SearchAssignmentsResponse", "SplitCapacityCommitmentRequest", @@ -75,5 +77,4 @@ "UpdateBiReservationRequest", "UpdateCapacityCommitmentRequest", "UpdateReservationRequest", - "ReservationServiceClient", ) diff --git a/google/cloud/bigquery_reservation_v1/gapic_metadata.json b/google/cloud/bigquery_reservation_v1/gapic_metadata.json new file mode 100644 index 00000000..801191bf --- /dev/null +++ b/google/cloud/bigquery_reservation_v1/gapic_metadata.json @@ -0,0 +1,213 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.bigquery_reservation_v1", + "protoPackage": "google.cloud.bigquery.reservation.v1", + "schema": "1.0", + "services": { + "ReservationService": { + "clients": { + "grpc": { + "libraryClient": "ReservationServiceClient", + "rpcs": { + "CreateAssignment": { + "methods": [ + "create_assignment" + ] + }, + "CreateCapacityCommitment": { + "methods": [ + "create_capacity_commitment" + ] + }, + "CreateReservation": { + "methods": [ + "create_reservation" + ] + }, + "DeleteAssignment": { + "methods": [ + "delete_assignment" + ] + }, + "DeleteCapacityCommitment": { + "methods": [ + "delete_capacity_commitment" + ] + }, + "DeleteReservation": { + "methods": [ + "delete_reservation" + ] + }, + "GetBiReservation": { + "methods": [ + "get_bi_reservation" + ] + }, + "GetCapacityCommitment": { + "methods": [ + "get_capacity_commitment" + ] + }, + "GetReservation": { + "methods": [ + "get_reservation" + ] + }, + "ListAssignments": { + "methods": [ + "list_assignments" + ] + }, + "ListCapacityCommitments": { + "methods": [ + "list_capacity_commitments" + ] + }, + "ListReservations": { + "methods": [ + "list_reservations" + ] + }, + "MergeCapacityCommitments": { + "methods": [ + "merge_capacity_commitments" + ] + }, + "MoveAssignment": { + "methods": [ + "move_assignment" + ] + }, + "SearchAssignments": { + "methods": [ + "search_assignments" + ] + }, + "SplitCapacityCommitment": { + "methods": [ + "split_capacity_commitment" + ] + }, + "UpdateBiReservation": { + "methods": [ + "update_bi_reservation" + ] + }, + "UpdateCapacityCommitment": { + "methods": [ + "update_capacity_commitment" + ] + }, + "UpdateReservation": { + "methods": [ + "update_reservation" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ReservationServiceAsyncClient", + "rpcs": { + "CreateAssignment": { + "methods": [ + "create_assignment" + ] + }, + "CreateCapacityCommitment": { + "methods": [ + "create_capacity_commitment" + ] + }, + "CreateReservation": { + "methods": [ + "create_reservation" + ] + }, + "DeleteAssignment": { + "methods": [ + "delete_assignment" + ] + }, + "DeleteCapacityCommitment": { + "methods": [ + "delete_capacity_commitment" + ] + }, + "DeleteReservation": { + "methods": [ + "delete_reservation" + ] + }, + "GetBiReservation": { + "methods": [ + "get_bi_reservation" + ] + }, + "GetCapacityCommitment": { + "methods": [ + "get_capacity_commitment" + ] + }, + "GetReservation": { + "methods": [ + "get_reservation" + ] + }, + "ListAssignments": { + "methods": [ + "list_assignments" + ] + }, + "ListCapacityCommitments": { + "methods": [ + "list_capacity_commitments" + ] + }, + "ListReservations": { + "methods": [ + "list_reservations" + ] + }, + "MergeCapacityCommitments": { + "methods": [ + "merge_capacity_commitments" + ] + }, + "MoveAssignment": { + "methods": [ + "move_assignment" + ] + }, + "SearchAssignments": { + "methods": [ + "search_assignments" + ] + }, + "SplitCapacityCommitment": { + "methods": [ + "split_capacity_commitment" + ] + }, + "UpdateBiReservation": { + "methods": [ + "update_bi_reservation" + ] + }, + "UpdateCapacityCommitment": { + "methods": [ + "update_capacity_commitment" + ] + }, + "UpdateReservation": { + "methods": [ + "update_reservation" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/bigquery_reservation_v1/services/__init__.py b/google/cloud/bigquery_reservation_v1/services/__init__.py index 42ffdf2b..4de65971 100644 --- a/google/cloud/bigquery_reservation_v1/services/__init__.py +++ b/google/cloud/bigquery_reservation_v1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/__init__.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/__init__.py index 81e7a031..0c8e5c2b 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/__init__.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import ReservationServiceClient from .async_client import ReservationServiceAsyncClient diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py index e7bd79e7..148a7601 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,19 +20,18 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # 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 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore 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 -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import ReservationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ReservationServiceGrpcAsyncIOTransport from .client import ReservationServiceClient @@ -81,31 +78,26 @@ class ReservationServiceAsyncClient: parse_reservation_path = staticmethod( ReservationServiceClient.parse_reservation_path ) - common_billing_account_path = staticmethod( ReservationServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ReservationServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ReservationServiceClient.common_folder_path) parse_common_folder_path = staticmethod( ReservationServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( ReservationServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( ReservationServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(ReservationServiceClient.common_project_path) parse_common_project_path = staticmethod( ReservationServiceClient.parse_common_project_path ) - common_location_path = staticmethod(ReservationServiceClient.common_location_path) parse_common_location_path = staticmethod( ReservationServiceClient.parse_common_location_path @@ -113,7 +105,8 @@ class ReservationServiceAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -128,7 +121,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -145,7 +138,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ReservationServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: ReservationServiceTransport: The transport used by the client instance. @@ -160,12 +153,12 @@ def transport(self) -> ReservationServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ReservationServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the reservation service client. + """Instantiates the reservation service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -197,7 +190,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ReservationServiceClient( credentials=credentials, transport=transport, @@ -245,7 +237,6 @@ async def create_reservation( This corresponds to the ``reservation_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -272,7 +263,6 @@ async def create_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if reservation is not None: @@ -323,7 +313,6 @@ async def list_reservations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -353,7 +342,6 @@ async def list_reservations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -366,7 +354,8 @@ async def list_reservations( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -415,7 +404,6 @@ async def get_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -442,7 +430,6 @@ async def get_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -455,7 +442,8 @@ async def get_reservation( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -500,7 +488,6 @@ async def delete_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -521,7 +508,6 @@ async def delete_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -534,7 +520,8 @@ async def delete_reservation( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -558,7 +545,7 @@ async def update_reservation( request: gcbr_reservation.UpdateReservationRequest = None, *, reservation: gcbr_reservation.Reservation = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -581,7 +568,6 @@ async def update_reservation( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -608,7 +594,6 @@ async def update_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if reservation is not None: request.reservation = reservation if update_mask is not None: @@ -666,7 +651,6 @@ async def create_capacity_commitment( This corresponds to the ``capacity_commitment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -705,7 +689,6 @@ async def create_capacity_commitment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if capacity_commitment is not None: @@ -754,7 +737,6 @@ async def list_capacity_commitments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -784,7 +766,6 @@ async def list_capacity_commitments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -797,7 +778,8 @@ async def list_capacity_commitments( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -846,7 +828,6 @@ async def get_capacity_commitment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -885,7 +866,6 @@ async def get_capacity_commitment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -898,7 +878,8 @@ async def get_capacity_commitment( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -943,7 +924,6 @@ async def delete_capacity_commitment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -964,7 +944,6 @@ async def delete_capacity_commitment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -977,7 +956,8 @@ async def delete_capacity_commitment( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -1001,7 +981,7 @@ async def update_capacity_commitment( request: reservation.UpdateCapacityCommitmentRequest = None, *, capacity_commitment: reservation.CapacityCommitment = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1033,7 +1013,6 @@ async def update_capacity_commitment( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1072,7 +1051,6 @@ async def update_capacity_commitment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if capacity_commitment is not None: request.capacity_commitment = capacity_commitment if update_mask is not None: @@ -1138,7 +1116,6 @@ async def split_capacity_commitment( This corresponds to the ``slot_count`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1165,7 +1142,6 @@ async def split_capacity_commitment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if slot_count is not None: @@ -1235,7 +1211,6 @@ async def merge_capacity_commitments( This corresponds to the ``capacity_commitment_ids`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1274,10 +1249,8 @@ async def merge_capacity_commitments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent - if capacity_commitment_ids: request.capacity_commitment_ids.extend(capacity_commitment_ids) @@ -1363,7 +1336,6 @@ async def create_assignment( This corresponds to the ``assignment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1391,7 +1363,6 @@ async def create_assignment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if assignment is not None: @@ -1465,7 +1436,6 @@ async def list_assignments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1495,7 +1465,6 @@ async def list_assignments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1508,7 +1477,8 @@ async def list_assignments( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -1573,7 +1543,6 @@ async def delete_assignment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1594,7 +1563,6 @@ async def delete_assignment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1607,7 +1575,8 @@ async def delete_assignment( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -1689,7 +1658,6 @@ async def search_assignments( This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1719,7 +1687,6 @@ async def search_assignments( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if query is not None: @@ -1734,7 +1701,8 @@ async def search_assignments( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -1800,7 +1768,6 @@ async def move_assignment( This corresponds to the ``destination_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1828,7 +1795,6 @@ async def move_assignment( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if destination_id is not None: @@ -1877,7 +1843,6 @@ async def get_bi_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1902,7 +1867,6 @@ async def get_bi_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1915,7 +1879,8 @@ async def get_bi_reservation( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -1940,7 +1905,7 @@ async def update_bi_reservation( request: reservation.UpdateBiReservationRequest = None, *, bi_reservation: reservation.BiReservation = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1970,7 +1935,6 @@ async def update_bi_reservation( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1995,7 +1959,6 @@ async def update_bi_reservation( # If we have keyword arguments corresponding to fields on the # request, apply these. - if bi_reservation is not None: request.bi_reservation = bi_reservation if update_mask is not None: diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py index 800e5a99..6b966ad1 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # 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 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -35,10 +33,9 @@ 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 -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore - +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore from .transports.base import ReservationServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ReservationServiceGrpcTransport from .transports.grpc_asyncio import ReservationServiceGrpcAsyncIOTransport @@ -61,7 +58,7 @@ class ReservationServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[ReservationServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -101,7 +98,8 @@ class ReservationServiceClient(metaclass=ReservationServiceClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -135,7 +133,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -152,7 +151,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -171,10 +170,11 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ReservationServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - ReservationServiceTransport: The transport used by the client instance. + ReservationServiceTransport: The transport used by the client + instance. """ return self._transport @@ -182,7 +182,7 @@ def transport(self) -> ReservationServiceTransport: def assignment_path( project: str, location: str, reservation: str, assignment: str, ) -> str: - """Return a fully-qualified assignment string.""" + """Returns a fully-qualified assignment string.""" return "projects/{project}/locations/{location}/reservations/{reservation}/assignments/{assignment}".format( project=project, location=location, @@ -192,7 +192,7 @@ def assignment_path( @staticmethod def parse_assignment_path(path: str) -> Dict[str, str]: - """Parse a assignment path into its component segments.""" + """Parses a assignment path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/reservations/(?P.+?)/assignments/(?P.+?)$", path, @@ -201,14 +201,14 @@ def parse_assignment_path(path: str) -> Dict[str, str]: @staticmethod def bi_reservation_path(project: str, location: str,) -> str: - """Return a fully-qualified bi_reservation string.""" + """Returns a fully-qualified bi_reservation string.""" return "projects/{project}/locations/{location}/bireservation".format( project=project, location=location, ) @staticmethod def parse_bi_reservation_path(path: str) -> Dict[str, str]: - """Parse a bi_reservation path into its component segments.""" + """Parses a bi_reservation path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/bireservation$", path, @@ -219,14 +219,14 @@ def parse_bi_reservation_path(path: str) -> Dict[str, str]: def capacity_commitment_path( project: str, location: str, capacity_commitment: str, ) -> str: - """Return a fully-qualified capacity_commitment string.""" + """Returns a fully-qualified capacity_commitment string.""" return "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( project=project, location=location, capacity_commitment=capacity_commitment, ) @staticmethod def parse_capacity_commitment_path(path: str) -> Dict[str, str]: - """Parse a capacity_commitment path into its component segments.""" + """Parses a capacity_commitment path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/capacityCommitments/(?P.+?)$", path, @@ -235,14 +235,14 @@ def parse_capacity_commitment_path(path: str) -> Dict[str, str]: @staticmethod def reservation_path(project: str, location: str, reservation: str,) -> str: - """Return a fully-qualified reservation string.""" + """Returns a fully-qualified reservation string.""" return "projects/{project}/locations/{location}/reservations/{reservation}".format( project=project, location=location, reservation=reservation, ) @staticmethod def parse_reservation_path(path: str) -> Dict[str, str]: - """Parse a reservation path into its component segments.""" + """Parses a reservation path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/reservations/(?P.+?)$", path, @@ -251,7 +251,7 @@ def parse_reservation_path(path: str) -> Dict[str, str]: @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -264,7 +264,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -275,7 +275,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -286,7 +286,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -297,7 +297,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -311,12 +311,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, ReservationServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the reservation service client. + """Instantiates the reservation service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -371,9 +371,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + if is_mtls: + client_cert_source_func = mtls.default_client_cert_source() + else: + client_cert_source_func = None # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -385,12 +386,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + if is_mtls: + api_endpoint = self.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = self.DEFAULT_ENDPOINT else: raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -405,8 +408,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -461,7 +464,6 @@ def create_reservation( This corresponds to the ``reservation_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -490,10 +492,8 @@ def create_reservation( # there are no flattened fields. if not isinstance(request, gcbr_reservation.CreateReservationRequest): request = gcbr_reservation.CreateReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if reservation is not None: @@ -540,7 +540,6 @@ def list_reservations( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -572,10 +571,8 @@ def list_reservations( # there are no flattened fields. if not isinstance(request, reservation.ListReservationsRequest): request = reservation.ListReservationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -624,7 +621,6 @@ def get_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -653,10 +649,8 @@ def get_reservation( # there are no flattened fields. if not isinstance(request, reservation.GetReservationRequest): request = reservation.GetReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -701,7 +695,6 @@ def delete_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -724,10 +717,8 @@ def delete_reservation( # there are no flattened fields. if not isinstance(request, reservation.DeleteReservationRequest): request = reservation.DeleteReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -751,7 +742,7 @@ def update_reservation( request: gcbr_reservation.UpdateReservationRequest = None, *, reservation: gcbr_reservation.Reservation = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -774,7 +765,6 @@ def update_reservation( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -803,10 +793,8 @@ def update_reservation( # there are no flattened fields. if not isinstance(request, gcbr_reservation.UpdateReservationRequest): request = gcbr_reservation.UpdateReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if reservation is not None: request.reservation = reservation if update_mask is not None: @@ -860,7 +848,6 @@ def create_capacity_commitment( This corresponds to the ``capacity_commitment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -901,10 +888,8 @@ def create_capacity_commitment( # there are no flattened fields. if not isinstance(request, reservation.CreateCapacityCommitmentRequest): request = reservation.CreateCapacityCommitmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if capacity_commitment is not None: @@ -951,7 +936,6 @@ def list_capacity_commitments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -983,10 +967,8 @@ def list_capacity_commitments( # there are no flattened fields. if not isinstance(request, reservation.ListCapacityCommitmentsRequest): request = reservation.ListCapacityCommitmentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1037,7 +1019,6 @@ def get_capacity_commitment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1078,10 +1059,8 @@ def get_capacity_commitment( # there are no flattened fields. if not isinstance(request, reservation.GetCapacityCommitmentRequest): request = reservation.GetCapacityCommitmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1126,7 +1105,6 @@ def delete_capacity_commitment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1149,10 +1127,8 @@ def delete_capacity_commitment( # there are no flattened fields. if not isinstance(request, reservation.DeleteCapacityCommitmentRequest): request = reservation.DeleteCapacityCommitmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1178,7 +1154,7 @@ def update_capacity_commitment( request: reservation.UpdateCapacityCommitmentRequest = None, *, capacity_commitment: reservation.CapacityCommitment = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1210,7 +1186,6 @@ def update_capacity_commitment( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1251,10 +1226,8 @@ def update_capacity_commitment( # there are no flattened fields. if not isinstance(request, reservation.UpdateCapacityCommitmentRequest): request = reservation.UpdateCapacityCommitmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if capacity_commitment is not None: request.capacity_commitment = capacity_commitment if update_mask is not None: @@ -1318,7 +1291,6 @@ def split_capacity_commitment( This corresponds to the ``slot_count`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1347,10 +1319,8 @@ def split_capacity_commitment( # there are no flattened fields. if not isinstance(request, reservation.SplitCapacityCommitmentRequest): request = reservation.SplitCapacityCommitmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if slot_count is not None: @@ -1418,7 +1388,6 @@ def merge_capacity_commitments( This corresponds to the ``capacity_commitment_ids`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1459,10 +1428,8 @@ def merge_capacity_commitments( # there are no flattened fields. if not isinstance(request, reservation.MergeCapacityCommitmentsRequest): request = reservation.MergeCapacityCommitmentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if capacity_commitment_ids is not None: @@ -1548,7 +1515,6 @@ def create_assignment( This corresponds to the ``assignment`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1578,10 +1544,8 @@ def create_assignment( # there are no flattened fields. if not isinstance(request, reservation.CreateAssignmentRequest): request = reservation.CreateAssignmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if assignment is not None: @@ -1651,7 +1615,6 @@ def list_assignments( This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1683,10 +1646,8 @@ def list_assignments( # there are no flattened fields. if not isinstance(request, reservation.ListAssignmentsRequest): request = reservation.ListAssignmentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1751,7 +1712,6 @@ def delete_assignment( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1774,10 +1734,8 @@ def delete_assignment( # there are no flattened fields. if not isinstance(request, reservation.DeleteAssignmentRequest): request = reservation.DeleteAssignmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1859,7 +1817,6 @@ def search_assignments( This corresponds to the ``query`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1891,10 +1848,8 @@ def search_assignments( # there are no flattened fields. if not isinstance(request, reservation.SearchAssignmentsRequest): request = reservation.SearchAssignmentsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if query is not None: @@ -1962,7 +1917,6 @@ def move_assignment( This corresponds to the ``destination_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1992,10 +1946,8 @@ def move_assignment( # there are no flattened fields. if not isinstance(request, reservation.MoveAssignmentRequest): request = reservation.MoveAssignmentRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if destination_id is not None: @@ -2040,7 +1992,6 @@ def get_bi_reservation( This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2067,10 +2018,8 @@ def get_bi_reservation( # there are no flattened fields. if not isinstance(request, reservation.GetBiReservationRequest): request = reservation.GetBiReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -2095,7 +2044,7 @@ def update_bi_reservation( request: reservation.UpdateBiReservationRequest = None, *, bi_reservation: reservation.BiReservation = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -2125,7 +2074,6 @@ def update_bi_reservation( This corresponds to the ``update_mask`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -2152,10 +2100,8 @@ def update_bi_reservation( # there are no flattened fields. if not isinstance(request, reservation.UpdateBiReservationRequest): request = reservation.UpdateBiReservationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if bi_reservation is not None: request.bi_reservation = bi_reservation if update_mask is not None: diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py index 17a074ce..cda6ca16 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -117,7 +115,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -245,7 +243,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -373,7 +371,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -501,7 +499,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/__init__.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/__init__.py index b0422036..e4b9552d 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/__init__.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py index 6d800e63..e6d4f319 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # 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 # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -39,6 +38,17 @@ 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 + +_API_CORE_VERSION = google.api_core.__version__ + class ReservationServiceTransport(abc.ABC): """Abstract transport class for ReservationService.""" @@ -48,21 +58,24 @@ class ReservationServiceTransport(abc.ABC): "https://www.googleapis.com/auth/cloud-platform", ) + DEFAULT_HOST: str = "bigqueryreservation.googleapis.com" + def __init__( self, *, - host: str = "bigqueryreservation.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -71,7 +84,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -85,29 +98,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are 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 + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -121,7 +181,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -135,7 +196,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -149,7 +211,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -171,7 +234,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -185,7 +249,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -199,7 +264,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -231,7 +297,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -245,7 +312,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -259,7 +327,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -276,7 +345,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=60.0, ), @@ -293,22 +363,20 @@ def _prep_wrapped_messages(self, client_info): @property def create_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [gcbr_reservation.CreateReservationRequest], - typing.Union[ - gcbr_reservation.Reservation, typing.Awaitable[gcbr_reservation.Reservation] - ], + Union[gcbr_reservation.Reservation, Awaitable[gcbr_reservation.Reservation]], ]: raise NotImplementedError() @property def list_reservations( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.ListReservationsRequest], - typing.Union[ + Union[ reservation.ListReservationsResponse, - typing.Awaitable[reservation.ListReservationsResponse], + Awaitable[reservation.ListReservationsResponse], ], ]: raise NotImplementedError() @@ -316,42 +384,37 @@ def list_reservations( @property def get_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.GetReservationRequest], - typing.Union[ - reservation.Reservation, typing.Awaitable[reservation.Reservation] - ], + Union[reservation.Reservation, Awaitable[reservation.Reservation]], ]: raise NotImplementedError() @property def delete_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.DeleteReservationRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [gcbr_reservation.UpdateReservationRequest], - typing.Union[ - gcbr_reservation.Reservation, typing.Awaitable[gcbr_reservation.Reservation] - ], + Union[gcbr_reservation.Reservation, Awaitable[gcbr_reservation.Reservation]], ]: raise NotImplementedError() @property def create_capacity_commitment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.CreateCapacityCommitmentRequest], - typing.Union[ - reservation.CapacityCommitment, - typing.Awaitable[reservation.CapacityCommitment], + Union[ + reservation.CapacityCommitment, Awaitable[reservation.CapacityCommitment] ], ]: raise NotImplementedError() @@ -359,11 +422,11 @@ def create_capacity_commitment( @property def list_capacity_commitments( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.ListCapacityCommitmentsRequest], - typing.Union[ + Union[ reservation.ListCapacityCommitmentsResponse, - typing.Awaitable[reservation.ListCapacityCommitmentsResponse], + Awaitable[reservation.ListCapacityCommitmentsResponse], ], ]: raise NotImplementedError() @@ -371,11 +434,10 @@ def list_capacity_commitments( @property def get_capacity_commitment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.GetCapacityCommitmentRequest], - typing.Union[ - reservation.CapacityCommitment, - typing.Awaitable[reservation.CapacityCommitment], + Union[ + reservation.CapacityCommitment, Awaitable[reservation.CapacityCommitment] ], ]: raise NotImplementedError() @@ -383,20 +445,19 @@ def get_capacity_commitment( @property def delete_capacity_commitment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.DeleteCapacityCommitmentRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_capacity_commitment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.UpdateCapacityCommitmentRequest], - typing.Union[ - reservation.CapacityCommitment, - typing.Awaitable[reservation.CapacityCommitment], + Union[ + reservation.CapacityCommitment, Awaitable[reservation.CapacityCommitment] ], ]: raise NotImplementedError() @@ -404,11 +465,11 @@ def update_capacity_commitment( @property def split_capacity_commitment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.SplitCapacityCommitmentRequest], - typing.Union[ + Union[ reservation.SplitCapacityCommitmentResponse, - typing.Awaitable[reservation.SplitCapacityCommitmentResponse], + Awaitable[reservation.SplitCapacityCommitmentResponse], ], ]: raise NotImplementedError() @@ -416,11 +477,10 @@ def split_capacity_commitment( @property def merge_capacity_commitments( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.MergeCapacityCommitmentsRequest], - typing.Union[ - reservation.CapacityCommitment, - typing.Awaitable[reservation.CapacityCommitment], + Union[ + reservation.CapacityCommitment, Awaitable[reservation.CapacityCommitment] ], ]: raise NotImplementedError() @@ -428,20 +488,20 @@ def merge_capacity_commitments( @property def create_assignment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.CreateAssignmentRequest], - typing.Union[reservation.Assignment, typing.Awaitable[reservation.Assignment]], + Union[reservation.Assignment, Awaitable[reservation.Assignment]], ]: raise NotImplementedError() @property def list_assignments( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.ListAssignmentsRequest], - typing.Union[ + Union[ reservation.ListAssignmentsResponse, - typing.Awaitable[reservation.ListAssignmentsResponse], + Awaitable[reservation.ListAssignmentsResponse], ], ]: raise NotImplementedError() @@ -449,20 +509,20 @@ def list_assignments( @property def delete_assignment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.DeleteAssignmentRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def search_assignments( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.SearchAssignmentsRequest], - typing.Union[ + Union[ reservation.SearchAssignmentsResponse, - typing.Awaitable[reservation.SearchAssignmentsResponse], + Awaitable[reservation.SearchAssignmentsResponse], ], ]: raise NotImplementedError() @@ -470,31 +530,27 @@ def search_assignments( @property def move_assignment( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.MoveAssignmentRequest], - typing.Union[reservation.Assignment, typing.Awaitable[reservation.Assignment]], + Union[reservation.Assignment, Awaitable[reservation.Assignment]], ]: raise NotImplementedError() @property def get_bi_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.GetBiReservationRequest], - typing.Union[ - reservation.BiReservation, typing.Awaitable[reservation.BiReservation] - ], + Union[reservation.BiReservation, Awaitable[reservation.BiReservation]], ]: raise NotImplementedError() @property def update_bi_reservation( self, - ) -> typing.Callable[ + ) -> Callable[ [reservation.UpdateBiReservationRequest], - typing.Union[ - reservation.BiReservation, typing.Awaitable[reservation.BiReservation] - ], + Union[reservation.BiReservation, Awaitable[reservation.BiReservation]], ]: raise NotImplementedError() diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py index 21a8d737..78aa9766 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +from typing import Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import grpc_helpers # type: ignore from google.api_core import gapic_v1 # type: ignore -from google import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import ReservationServiceTransport, DEFAULT_CLIENT_INFO @@ -68,7 +65,7 @@ def __init__( self, *, host: str = "bigqueryreservation.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -82,7 +79,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -192,7 +190,7 @@ def __init__( def create_channel( cls, host: str = "bigqueryreservation.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -223,13 +221,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -325,7 +325,7 @@ def get_reservation( @property def delete_reservation( self, - ) -> Callable[[reservation.DeleteReservationRequest], empty.Empty]: + ) -> Callable[[reservation.DeleteReservationRequest], empty_pb2.Empty]: r"""Return a callable for the delete reservation method over gRPC. Deletes a reservation. Returns @@ -346,7 +346,7 @@ def delete_reservation( self._stubs["delete_reservation"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation", request_serializer=reservation.DeleteReservationRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_reservation"] @@ -467,7 +467,7 @@ def get_capacity_commitment( @property def delete_capacity_commitment( self, - ) -> Callable[[reservation.DeleteCapacityCommitmentRequest], empty.Empty]: + ) -> Callable[[reservation.DeleteCapacityCommitmentRequest], empty_pb2.Empty]: r"""Return a callable for the delete capacity commitment method over gRPC. Deletes a capacity commitment. Attempting to delete capacity @@ -488,7 +488,7 @@ def delete_capacity_commitment( self._stubs["delete_capacity_commitment"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment", request_serializer=reservation.DeleteCapacityCommitmentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_capacity_commitment"] @@ -710,7 +710,7 @@ def list_assignments( @property def delete_assignment( self, - ) -> Callable[[reservation.DeleteAssignmentRequest], empty.Empty]: + ) -> Callable[[reservation.DeleteAssignmentRequest], empty_pb2.Empty]: r"""Return a callable for the delete assignment method over gRPC. Deletes a assignment. No expansion will happen. @@ -744,7 +744,7 @@ def delete_assignment( self._stubs["delete_assignment"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteAssignment", request_serializer=reservation.DeleteAssignmentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_assignment"] diff --git a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py index b678d626..7aa87f11 100644 --- a/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union from google.api_core import gapic_v1 # type: ignore from google.api_core import grpc_helpers_async # type: ignore -from google import auth # type: ignore -from google.auth import credentials # 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 from google.cloud.bigquery_reservation_v1.types import reservation from google.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.protobuf import empty_pb2 # type: ignore from .base import ReservationServiceTransport, DEFAULT_CLIENT_INFO from .grpc import ReservationServiceGrpcTransport @@ -71,7 +68,7 @@ class ReservationServiceGrpcAsyncIOTransport(ReservationServiceTransport): def create_channel( cls, host: str = "bigqueryreservation.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -98,13 +95,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -112,7 +111,7 @@ def __init__( self, *, host: str = "bigqueryreservation.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -126,7 +125,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -184,7 +184,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -333,7 +332,7 @@ def get_reservation( @property def delete_reservation( self, - ) -> Callable[[reservation.DeleteReservationRequest], Awaitable[empty.Empty]]: + ) -> Callable[[reservation.DeleteReservationRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete reservation method over gRPC. Deletes a reservation. Returns @@ -354,7 +353,7 @@ def delete_reservation( self._stubs["delete_reservation"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation", request_serializer=reservation.DeleteReservationRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_reservation"] @@ -479,7 +478,7 @@ def get_capacity_commitment( def delete_capacity_commitment( self, ) -> Callable[ - [reservation.DeleteCapacityCommitmentRequest], Awaitable[empty.Empty] + [reservation.DeleteCapacityCommitmentRequest], Awaitable[empty_pb2.Empty] ]: r"""Return a callable for the delete capacity commitment method over gRPC. @@ -501,7 +500,7 @@ def delete_capacity_commitment( self._stubs["delete_capacity_commitment"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment", request_serializer=reservation.DeleteCapacityCommitmentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_capacity_commitment"] @@ -728,7 +727,7 @@ def list_assignments( @property def delete_assignment( self, - ) -> Callable[[reservation.DeleteAssignmentRequest], Awaitable[empty.Empty]]: + ) -> Callable[[reservation.DeleteAssignmentRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete assignment method over gRPC. Deletes a assignment. No expansion will happen. @@ -762,7 +761,7 @@ def delete_assignment( self._stubs["delete_assignment"] = self.grpc_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteAssignment", request_serializer=reservation.DeleteAssignmentRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_assignment"] diff --git a/google/cloud/bigquery_reservation_v1/types/__init__.py b/google/cloud/bigquery_reservation_v1/types/__init__.py index aaab3471..2e2d2b78 100644 --- a/google/cloud/bigquery_reservation_v1/types/__init__.py +++ b/google/cloud/bigquery_reservation_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .reservation import ( Assignment, BiReservation, diff --git a/google/cloud/bigquery_reservation_v1/types/reservation.py b/google/cloud/bigquery_reservation_v1/types/reservation.py index 43f13d98..ab6c8e69 100644 --- a/google/cloud/bigquery_reservation_v1/types/reservation.py +++ b/google/cloud/bigquery_reservation_v1/types/reservation.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore __protobuf__ = proto.module( @@ -87,11 +84,9 @@ class Reservation(proto.Message): slot capacity specified above at most. """ - name = proto.Field(proto.STRING, number=1) - - slot_capacity = proto.Field(proto.INT64, number=2) - - ignore_idle_slots = proto.Field(proto.BOOL, number=4) + name = proto.Field(proto.STRING, number=1,) + slot_capacity = proto.Field(proto.INT64, number=2,) + ignore_idle_slots = proto.Field(proto.BOOL, number=4,) class CapacityCommitment(proto.Message): @@ -151,20 +146,14 @@ class State(proto.Enum): ACTIVE = 2 FAILED = 3 - name = proto.Field(proto.STRING, number=1) - - slot_count = proto.Field(proto.INT64, number=2) - + name = proto.Field(proto.STRING, number=1,) + slot_count = proto.Field(proto.INT64, number=2,) plan = proto.Field(proto.ENUM, number=3, enum=CommitmentPlan,) - state = proto.Field(proto.ENUM, number=4, enum=State,) - commitment_end_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp.Timestamp, + proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, ) - - failure_status = proto.Field(proto.MESSAGE, number=7, message=status.Status,) - + failure_status = proto.Field(proto.MESSAGE, number=7, message=status_pb2.Status,) renewal_plan = proto.Field(proto.ENUM, number=8, enum=CommitmentPlan,) @@ -184,10 +173,8 @@ class CreateReservationRequest(proto.Message): Definition of the new reservation to create. """ - parent = proto.Field(proto.STRING, number=1) - - reservation_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + reservation_id = proto.Field(proto.STRING, number=2,) reservation = proto.Field(proto.MESSAGE, number=3, message="Reservation",) @@ -207,11 +194,9 @@ class ListReservationsRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListReservationsResponse(proto.Message): @@ -232,8 +217,7 @@ def raw_page(self): return self reservations = proto.RepeatedField(proto.MESSAGE, number=1, message="Reservation",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetReservationRequest(proto.Message): @@ -247,7 +231,7 @@ class GetReservationRequest(proto.Message): ``projects/myproject/locations/US/reservations/team1-prod`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteReservationRequest(proto.Message): @@ -261,7 +245,7 @@ class DeleteReservationRequest(proto.Message): ``projects/myproject/locations/US/reservations/team1-prod`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateReservationRequest(proto.Message): @@ -277,8 +261,9 @@ class UpdateReservationRequest(proto.Message): """ reservation = proto.Field(proto.MESSAGE, number=1, message="Reservation",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class CreateCapacityCommitmentRequest(proto.Message): @@ -296,13 +281,11 @@ class CreateCapacityCommitmentRequest(proto.Message): in the organization has a capacity commitment. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) capacity_commitment = proto.Field( proto.MESSAGE, number=2, message="CapacityCommitment", ) - - enforce_single_admin_project_per_org = proto.Field(proto.BOOL, number=4) + enforce_single_admin_project_per_org = proto.Field(proto.BOOL, number=4,) class ListCapacityCommitmentsRequest(proto.Message): @@ -320,11 +303,9 @@ class ListCapacityCommitmentsRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListCapacityCommitmentsResponse(proto.Message): @@ -348,8 +329,7 @@ def raw_page(self): capacity_commitments = proto.RepeatedField( proto.MESSAGE, number=1, message="CapacityCommitment", ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetCapacityCommitmentRequest(proto.Message): @@ -363,7 +343,7 @@ class GetCapacityCommitmentRequest(proto.Message): ``projects/myproject/locations/US/capacityCommitments/123`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteCapacityCommitmentRequest(proto.Message): @@ -377,7 +357,7 @@ class DeleteCapacityCommitmentRequest(proto.Message): ``projects/myproject/locations/US/capacityCommitments/123`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateCapacityCommitmentRequest(proto.Message): @@ -395,8 +375,9 @@ class UpdateCapacityCommitmentRequest(proto.Message): capacity_commitment = proto.Field( proto.MESSAGE, number=1, message="CapacityCommitment", ) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class SplitCapacityCommitmentRequest(proto.Message): @@ -412,9 +393,8 @@ class SplitCapacityCommitmentRequest(proto.Message): after the split. """ - name = proto.Field(proto.STRING, number=1) - - slot_count = proto.Field(proto.INT64, number=2) + name = proto.Field(proto.STRING, number=1,) + slot_count = proto.Field(proto.INT64, number=2,) class SplitCapacityCommitmentResponse(proto.Message): @@ -430,7 +410,6 @@ class SplitCapacityCommitmentResponse(proto.Message): """ first = proto.Field(proto.MESSAGE, number=1, message="CapacityCommitment",) - second = proto.Field(proto.MESSAGE, number=2, message="CapacityCommitment",) @@ -452,9 +431,8 @@ class MergeCapacityCommitmentsRequest(proto.Message): projects/myproject/locations/US/capacityCommitments/abc """ - parent = proto.Field(proto.STRING, number=1) - - capacity_commitment_ids = proto.RepeatedField(proto.STRING, number=2) + parent = proto.Field(proto.STRING, number=1,) + capacity_commitment_ids = proto.RepeatedField(proto.STRING, number=2,) class Assignment(proto.Message): @@ -492,12 +470,9 @@ class State(proto.Enum): PENDING = 1 ACTIVE = 2 - name = proto.Field(proto.STRING, number=1) - - assignee = proto.Field(proto.STRING, number=4) - + name = proto.Field(proto.STRING, number=1,) + assignee = proto.Field(proto.STRING, number=4,) job_type = proto.Field(proto.ENUM, number=3, enum=JobType,) - state = proto.Field(proto.ENUM, number=6, enum=State,) @@ -515,8 +490,7 @@ class CreateAssignmentRequest(proto.Message): Assignment resource to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) assignment = proto.Field(proto.MESSAGE, number=2, message="Assignment",) @@ -541,11 +515,9 @@ class ListAssignmentsRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListAssignmentsResponse(proto.Message): @@ -566,8 +538,7 @@ def raw_page(self): return self assignments = proto.RepeatedField(proto.MESSAGE, number=1, message="Assignment",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteAssignmentRequest(proto.Message): @@ -582,7 +553,7 @@ class DeleteAssignmentRequest(proto.Message): ``projects/myproject/locations/US/reservations/team1-prod/assignments/123`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class SearchAssignmentsRequest(proto.Message): @@ -612,13 +583,10 @@ class SearchAssignmentsRequest(proto.Message): request, if any. """ - parent = proto.Field(proto.STRING, number=1) - - query = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - page_token = proto.Field(proto.STRING, number=4) + parent = proto.Field(proto.STRING, number=1,) + query = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + page_token = proto.Field(proto.STRING, number=4,) class SearchAssignmentsResponse(proto.Message): @@ -639,8 +607,7 @@ def raw_page(self): return self assignments = proto.RepeatedField(proto.MESSAGE, number=1, message="Assignment",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class MoveAssignmentRequest(proto.Message): @@ -663,14 +630,12 @@ class MoveAssignmentRequest(proto.Message): ``projects/myotherproject/locations/US/reservations/team2-prod`` """ - name = proto.Field(proto.STRING, number=1) - - destination_id = proto.Field(proto.STRING, number=3) + name = proto.Field(proto.STRING, number=1,) + destination_id = proto.Field(proto.STRING, number=3,) class BiReservation(proto.Message): r"""Represents a BI Reservation. - Attributes: name (str): The resource name of the singleton BI reservation. @@ -683,28 +648,24 @@ class BiReservation(proto.Message): Size of a reservation, in bytes. """ - name = proto.Field(proto.STRING, number=1) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - size = proto.Field(proto.INT64, number=4) + name = proto.Field(proto.STRING, number=1,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + size = proto.Field(proto.INT64, number=4,) class GetBiReservationRequest(proto.Message): r"""A request to get a singleton BI reservation. - Attributes: name (str): Required. Name of the requested reservation, for example: ``projects/{project_id}/locations/{location_id}/bireservation`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateBiReservationRequest(proto.Message): r"""A request to update a BI reservation. - Attributes: bi_reservation (google.cloud.bigquery_reservation_v1.types.BiReservation): A reservation to update. @@ -714,8 +675,9 @@ class UpdateBiReservationRequest(proto.Message): """ bi_reservation = proto.Field(proto.MESSAGE, number=1, message="BiReservation",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 04c230d2..4a3ebdf8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -169,7 +169,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") + session.run("coverage", "report", "--show-missing", "--fail-under=97") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py index bfa4ef31..b60325b9 100644 --- a/owlbot.py +++ b/owlbot.py @@ -42,7 +42,7 @@ # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library(cov_level=100, microgenerator=True, samples=True,) +templated_files = common.py_library(cov_level=97, microgenerator=True, samples=True,) s.move( templated_files, excludes=[".coveragerc"], # the microgenerator has a good coveragerc file diff --git a/scripts/fixup_bigquery_reservation_v1_keywords.py b/scripts/fixup_bigquery_reservation_v1_keywords.py index 7056b9ed..381112b8 100644 --- a/scripts/fixup_bigquery_reservation_v1_keywords.py +++ b/scripts/fixup_bigquery_reservation_v1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,26 +39,25 @@ def partition( class bigquery_reservationCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_assignment': ('parent', 'assignment', ), - 'create_capacity_commitment': ('parent', 'capacity_commitment', 'enforce_single_admin_project_per_org', ), - 'create_reservation': ('parent', 'reservation_id', 'reservation', ), - 'delete_assignment': ('name', ), - 'delete_capacity_commitment': ('name', ), - 'delete_reservation': ('name', ), - 'get_bi_reservation': ('name', ), - 'get_capacity_commitment': ('name', ), - 'get_reservation': ('name', ), - 'list_assignments': ('parent', 'page_size', 'page_token', ), - 'list_capacity_commitments': ('parent', 'page_size', 'page_token', ), - 'list_reservations': ('parent', 'page_size', 'page_token', ), - 'merge_capacity_commitments': ('parent', 'capacity_commitment_ids', ), - 'move_assignment': ('name', 'destination_id', ), - 'search_assignments': ('parent', 'query', 'page_size', 'page_token', ), - 'split_capacity_commitment': ('name', 'slot_count', ), - 'update_bi_reservation': ('bi_reservation', 'update_mask', ), - 'update_capacity_commitment': ('capacity_commitment', 'update_mask', ), - 'update_reservation': ('reservation', 'update_mask', ), - + 'create_assignment': ('parent', 'assignment', ), + 'create_capacity_commitment': ('parent', 'capacity_commitment', 'enforce_single_admin_project_per_org', ), + 'create_reservation': ('parent', 'reservation_id', 'reservation', ), + 'delete_assignment': ('name', ), + 'delete_capacity_commitment': ('name', ), + 'delete_reservation': ('name', ), + 'get_bi_reservation': ('name', ), + 'get_capacity_commitment': ('name', ), + 'get_reservation': ('name', ), + 'list_assignments': ('parent', 'page_size', 'page_token', ), + 'list_capacity_commitments': ('parent', 'page_size', 'page_token', ), + 'list_reservations': ('parent', 'page_size', 'page_token', ), + 'merge_capacity_commitments': ('parent', 'capacity_commitment_ids', ), + 'move_assignment': ('name', 'destination_id', ), + 'search_assignments': ('parent', 'query', 'page_size', 'page_token', ), + 'split_capacity_commitment': ('name', 'slot_count', ), + 'update_bi_reservation': ('bi_reservation', 'update_mask', ), + 'update_capacity_commitment': ('capacity_commitment', 'update_mask', ), + 'update_reservation': ('reservation', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -91,7 +88,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/setup.py b/setup.py index 7b57aa42..7d6823d3 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ install_requires=( "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", "proto-plus >= 1.4.0", + "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index a37a34af..1bcef21b 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -7,3 +7,5 @@ # Then this file should have foo==1.14.0 google-api-core==1.22.2 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/tests/unit/test_bigquery_reservation.py b/tests/__init__.py similarity index 75% rename from tests/unit/test_bigquery_reservation.py rename to tests/__init__.py index 6c27c06d..4de65971 100644 --- a/tests/unit/test_bigquery_reservation.py +++ b/tests/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,10 +13,3 @@ # See the License for the specific language governing permissions and # limitations under the License. # - - -def test_versionless_import(): - from google.cloud import bigquery_reservation - - assert bigquery_reservation is not None - assert bigquery_reservation.ReservationServiceClient is not None diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..4de65971 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 00000000..4de65971 --- /dev/null +++ b/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/bigquery_reservation_v1/__init__.py b/tests/unit/gapic/bigquery_reservation_v1/__init__.py index 42ffdf2b..4de65971 100644 --- a/tests/unit/gapic/bigquery_reservation_v1/__init__.py +++ b/tests/unit/gapic/bigquery_reservation_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py b/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py index d7a742ad..98002200 100644 --- a/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py +++ b/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,13 +23,13 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.bigquery_reservation_v1.services.reservation_service import ( ReservationServiceAsyncClient, @@ -40,13 +39,43 @@ ) 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 ( + _API_CORE_VERSION, +) +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 -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.rpc import status_pb2 as status # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and 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", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -98,7 +127,7 @@ def test__get_default_mtls_endpoint(): "client_class", [ReservationServiceClient, ReservationServiceAsyncClient,] ) def test_reservation_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -115,7 +144,7 @@ def test_reservation_service_client_from_service_account_info(client_class): "client_class", [ReservationServiceClient, ReservationServiceAsyncClient,] ) def test_reservation_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -168,7 +197,7 @@ def test_reservation_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ReservationServiceClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -466,7 +495,7 @@ def test_create_reservation( transport: str = "grpc", request_type=gcbr_reservation.CreateReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -481,23 +510,17 @@ def test_create_reservation( call.return_value = gcbr_reservation.Reservation( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) - response = client.create_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.CreateReservationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gcbr_reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -509,7 +532,7 @@ def test_create_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -519,7 +542,6 @@ def test_create_reservation_empty_call(): client.create_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.CreateReservationRequest() @@ -529,7 +551,7 @@ async def test_create_reservation_async( request_type=gcbr_reservation.CreateReservationRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -546,22 +568,17 @@ async def test_create_reservation_async( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) ) - response = await client.create_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.CreateReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gcbr_reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -571,11 +588,14 @@ async def test_create_reservation_async_from_dict(): def test_create_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = gcbr_reservation.CreateReservationRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -583,7 +603,6 @@ def test_create_reservation_field_headers(): type(client.transport.create_reservation), "__call__" ) as call: call.return_value = gcbr_reservation.Reservation() - client.create_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -599,12 +618,13 @@ def test_create_reservation_field_headers(): @pytest.mark.asyncio async def test_create_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = gcbr_reservation.CreateReservationRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -614,7 +634,6 @@ async def test_create_reservation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gcbr_reservation.Reservation() ) - await client.create_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -628,7 +647,9 @@ async def test_create_reservation_field_headers_async(): def test_create_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -636,7 +657,6 @@ def test_create_reservation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_reservation( @@ -649,16 +669,15 @@ def test_create_reservation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].reservation == gcbr_reservation.Reservation(name="name_value") - assert args[0].reservation_id == "reservation_id_value" def test_create_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -674,7 +693,7 @@ def test_create_reservation_flattened_error(): @pytest.mark.asyncio async def test_create_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -699,18 +718,15 @@ async def test_create_reservation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].reservation == gcbr_reservation.Reservation(name="name_value") - assert args[0].reservation_id == "reservation_id_value" @pytest.mark.asyncio async def test_create_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -728,7 +744,7 @@ def test_list_reservations( transport: str = "grpc", request_type=reservation.ListReservationsRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -743,19 +759,15 @@ def test_list_reservations( call.return_value = reservation.ListReservationsResponse( next_page_token="next_page_token_value", ) - response = client.list_reservations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListReservationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListReservationsPager) - assert response.next_page_token == "next_page_token_value" @@ -767,7 +779,7 @@ def test_list_reservations_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -777,7 +789,6 @@ def test_list_reservations_empty_call(): client.list_reservations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListReservationsRequest() @@ -786,7 +797,7 @@ async def test_list_reservations_async( transport: str = "grpc_asyncio", request_type=reservation.ListReservationsRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -803,18 +814,15 @@ async def test_list_reservations_async( next_page_token="next_page_token_value", ) ) - response = await client.list_reservations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListReservationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListReservationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -824,11 +832,14 @@ async def test_list_reservations_async_from_dict(): def test_list_reservations_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListReservationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -836,7 +847,6 @@ def test_list_reservations_field_headers(): type(client.transport.list_reservations), "__call__" ) as call: call.return_value = reservation.ListReservationsResponse() - client.list_reservations(request) # Establish that the underlying gRPC stub method was called. @@ -852,12 +862,13 @@ def test_list_reservations_field_headers(): @pytest.mark.asyncio async def test_list_reservations_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListReservationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -867,7 +878,6 @@ async def test_list_reservations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListReservationsResponse() ) - await client.list_reservations(request) # Establish that the underlying gRPC stub method was called. @@ -881,7 +891,9 @@ async def test_list_reservations_field_headers_async(): def test_list_reservations_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -889,7 +901,6 @@ def test_list_reservations_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListReservationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_reservations(parent="parent_value",) @@ -898,12 +909,13 @@ def test_list_reservations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_reservations_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -916,7 +928,7 @@ def test_list_reservations_flattened_error(): @pytest.mark.asyncio async def test_list_reservations_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -937,14 +949,13 @@ async def test_list_reservations_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_reservations_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -956,7 +967,7 @@ async def test_list_reservations_flattened_error_async(): def test_list_reservations_pager(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -998,7 +1009,7 @@ def test_list_reservations_pager(): def test_list_reservations_pages(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1033,7 +1044,7 @@ def test_list_reservations_pages(): @pytest.mark.asyncio async def test_list_reservations_async_pager(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1076,7 +1087,7 @@ async def test_list_reservations_async_pager(): @pytest.mark.asyncio async def test_list_reservations_async_pages(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1117,7 +1128,7 @@ def test_get_reservation( transport: str = "grpc", request_type=reservation.GetReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1130,23 +1141,17 @@ def test_get_reservation( call.return_value = reservation.Reservation( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) - response = client.get_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetReservationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -1158,7 +1163,7 @@ def test_get_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1166,7 +1171,6 @@ def test_get_reservation_empty_call(): client.get_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetReservationRequest() @@ -1175,7 +1179,7 @@ async def test_get_reservation_async( transport: str = "grpc_asyncio", request_type=reservation.GetReservationRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1190,22 +1194,17 @@ async def test_get_reservation_async( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) ) - response = await client.get_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -1215,17 +1214,19 @@ async def test_get_reservation_async_from_dict(): def test_get_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: call.return_value = reservation.Reservation() - client.get_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1241,12 +1242,13 @@ def test_get_reservation_field_headers(): @pytest.mark.asyncio async def test_get_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1254,7 +1256,6 @@ async def test_get_reservation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Reservation() ) - await client.get_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1268,13 +1269,14 @@ async def test_get_reservation_field_headers_async(): def test_get_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Reservation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_reservation(name="name_value",) @@ -1283,12 +1285,13 @@ def test_get_reservation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1301,7 +1304,7 @@ def test_get_reservation_flattened_error(): @pytest.mark.asyncio async def test_get_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,14 +1323,13 @@ async def test_get_reservation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1342,7 +1344,7 @@ def test_delete_reservation( transport: str = "grpc", request_type=reservation.DeleteReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1355,13 +1357,11 @@ def test_delete_reservation( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteReservationRequest() # Establish that the response is the type that we expect. @@ -1376,7 +1376,7 @@ def test_delete_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1386,7 +1386,6 @@ def test_delete_reservation_empty_call(): client.delete_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteReservationRequest() @@ -1395,7 +1394,7 @@ async def test_delete_reservation_async( transport: str = "grpc_asyncio", request_type=reservation.DeleteReservationRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1408,13 +1407,11 @@ async def test_delete_reservation_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteReservationRequest() # Establish that the response is the type that we expect. @@ -1427,11 +1424,14 @@ async def test_delete_reservation_async_from_dict(): def test_delete_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1439,7 +1439,6 @@ def test_delete_reservation_field_headers(): type(client.transport.delete_reservation), "__call__" ) as call: call.return_value = None - client.delete_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1455,12 +1454,13 @@ def test_delete_reservation_field_headers(): @pytest.mark.asyncio async def test_delete_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1468,7 +1468,6 @@ async def test_delete_reservation_field_headers_async(): type(client.transport.delete_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1482,7 +1481,9 @@ async def test_delete_reservation_field_headers_async(): def test_delete_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1490,7 +1491,6 @@ def test_delete_reservation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_reservation(name="name_value",) @@ -1499,12 +1499,13 @@ def test_delete_reservation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1517,7 +1518,7 @@ def test_delete_reservation_flattened_error(): @pytest.mark.asyncio async def test_delete_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1536,14 +1537,13 @@ async def test_delete_reservation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1558,7 +1558,7 @@ def test_update_reservation( transport: str = "grpc", request_type=gcbr_reservation.UpdateReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1573,23 +1573,17 @@ def test_update_reservation( call.return_value = gcbr_reservation.Reservation( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) - response = client.update_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.UpdateReservationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, gcbr_reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -1601,7 +1595,7 @@ def test_update_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1611,7 +1605,6 @@ def test_update_reservation_empty_call(): client.update_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.UpdateReservationRequest() @@ -1621,7 +1614,7 @@ async def test_update_reservation_async( request_type=gcbr_reservation.UpdateReservationRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1638,22 +1631,17 @@ async def test_update_reservation_async( name="name_value", slot_capacity=1391, ignore_idle_slots=True, ) ) - response = await client.update_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == gcbr_reservation.UpdateReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gcbr_reservation.Reservation) - assert response.name == "name_value" - assert response.slot_capacity == 1391 - assert response.ignore_idle_slots is True @@ -1663,11 +1651,14 @@ async def test_update_reservation_async_from_dict(): def test_update_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = gcbr_reservation.UpdateReservationRequest() + request.reservation.name = "reservation.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1675,7 +1666,6 @@ def test_update_reservation_field_headers(): type(client.transport.update_reservation), "__call__" ) as call: call.return_value = gcbr_reservation.Reservation() - client.update_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1693,12 +1683,13 @@ def test_update_reservation_field_headers(): @pytest.mark.asyncio async def test_update_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = gcbr_reservation.UpdateReservationRequest() + request.reservation.name = "reservation.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1708,7 +1699,6 @@ async def test_update_reservation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gcbr_reservation.Reservation() ) - await client.update_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -1724,7 +1714,9 @@ async def test_update_reservation_field_headers_async(): def test_update_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1732,26 +1724,25 @@ def test_update_reservation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_reservation( reservation=gcbr_reservation.Reservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].reservation == gcbr_reservation.Reservation(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1759,14 +1750,14 @@ def test_update_reservation_flattened_error(): client.update_reservation( gcbr_reservation.UpdateReservationRequest(), reservation=gcbr_reservation.Reservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1783,23 +1774,21 @@ async def test_update_reservation_flattened_async(): # using the keyword arguments to the method. response = await client.update_reservation( reservation=gcbr_reservation.Reservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].reservation == gcbr_reservation.Reservation(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1808,7 +1797,7 @@ async def test_update_reservation_flattened_error_async(): await client.update_reservation( gcbr_reservation.UpdateReservationRequest(), reservation=gcbr_reservation.Reservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1816,7 +1805,7 @@ def test_create_capacity_commitment( transport: str = "grpc", request_type=reservation.CreateCapacityCommitmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1835,27 +1824,19 @@ def test_create_capacity_commitment( state=reservation.CapacityCommitment.State.PENDING, renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) - response = client.create_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateCapacityCommitmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -1867,7 +1848,7 @@ def test_create_capacity_commitment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1877,7 +1858,6 @@ def test_create_capacity_commitment_empty_call(): client.create_capacity_commitment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateCapacityCommitmentRequest() @@ -1887,7 +1867,7 @@ async def test_create_capacity_commitment_async( request_type=reservation.CreateCapacityCommitmentRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1908,26 +1888,19 @@ async def test_create_capacity_commitment_async( renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) ) - response = await client.create_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -1937,11 +1910,14 @@ async def test_create_capacity_commitment_async_from_dict(): def test_create_capacity_commitment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.CreateCapacityCommitmentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1949,7 +1925,6 @@ def test_create_capacity_commitment_field_headers(): type(client.transport.create_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() - client.create_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -1965,12 +1940,13 @@ def test_create_capacity_commitment_field_headers(): @pytest.mark.asyncio async def test_create_capacity_commitment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.CreateCapacityCommitmentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1980,7 +1956,6 @@ async def test_create_capacity_commitment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() ) - await client.create_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -1994,7 +1969,9 @@ async def test_create_capacity_commitment_field_headers_async(): def test_create_capacity_commitment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2002,7 +1979,6 @@ def test_create_capacity_commitment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_capacity_commitment( @@ -2014,16 +1990,16 @@ def test_create_capacity_commitment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].capacity_commitment == reservation.CapacityCommitment( name="name_value" ) def test_create_capacity_commitment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2038,7 +2014,7 @@ def test_create_capacity_commitment_flattened_error(): @pytest.mark.asyncio async def test_create_capacity_commitment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2062,9 +2038,7 @@ async def test_create_capacity_commitment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].capacity_commitment == reservation.CapacityCommitment( name="name_value" ) @@ -2073,7 +2047,7 @@ async def test_create_capacity_commitment_flattened_async(): @pytest.mark.asyncio async def test_create_capacity_commitment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2090,7 +2064,7 @@ def test_list_capacity_commitments( transport: str = "grpc", request_type=reservation.ListCapacityCommitmentsRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2105,19 +2079,15 @@ def test_list_capacity_commitments( call.return_value = reservation.ListCapacityCommitmentsResponse( next_page_token="next_page_token_value", ) - response = client.list_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListCapacityCommitmentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListCapacityCommitmentsPager) - assert response.next_page_token == "next_page_token_value" @@ -2129,7 +2099,7 @@ def test_list_capacity_commitments_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2139,7 +2109,6 @@ def test_list_capacity_commitments_empty_call(): client.list_capacity_commitments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListCapacityCommitmentsRequest() @@ -2149,7 +2118,7 @@ async def test_list_capacity_commitments_async( request_type=reservation.ListCapacityCommitmentsRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2166,18 +2135,15 @@ async def test_list_capacity_commitments_async( next_page_token="next_page_token_value", ) ) - response = await client.list_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListCapacityCommitmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCapacityCommitmentsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2187,11 +2153,14 @@ async def test_list_capacity_commitments_async_from_dict(): def test_list_capacity_commitments_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListCapacityCommitmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2199,7 +2168,6 @@ def test_list_capacity_commitments_field_headers(): type(client.transport.list_capacity_commitments), "__call__" ) as call: call.return_value = reservation.ListCapacityCommitmentsResponse() - client.list_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. @@ -2215,12 +2183,13 @@ def test_list_capacity_commitments_field_headers(): @pytest.mark.asyncio async def test_list_capacity_commitments_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListCapacityCommitmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2230,7 +2199,6 @@ async def test_list_capacity_commitments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListCapacityCommitmentsResponse() ) - await client.list_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. @@ -2244,7 +2212,9 @@ async def test_list_capacity_commitments_field_headers_async(): def test_list_capacity_commitments_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2252,7 +2222,6 @@ def test_list_capacity_commitments_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListCapacityCommitmentsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_capacity_commitments(parent="parent_value",) @@ -2261,12 +2230,13 @@ def test_list_capacity_commitments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_capacity_commitments_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2279,7 +2249,7 @@ def test_list_capacity_commitments_flattened_error(): @pytest.mark.asyncio async def test_list_capacity_commitments_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2300,14 +2270,13 @@ async def test_list_capacity_commitments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_capacity_commitments_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2319,7 +2288,7 @@ async def test_list_capacity_commitments_flattened_error_async(): def test_list_capacity_commitments_pager(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2365,7 +2334,7 @@ def test_list_capacity_commitments_pager(): def test_list_capacity_commitments_pages(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2404,7 +2373,7 @@ def test_list_capacity_commitments_pages(): @pytest.mark.asyncio async def test_list_capacity_commitments_async_pager(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2451,7 +2420,7 @@ async def test_list_capacity_commitments_async_pager(): @pytest.mark.asyncio async def test_list_capacity_commitments_async_pages(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2496,7 +2465,7 @@ def test_get_capacity_commitment( transport: str = "grpc", request_type=reservation.GetCapacityCommitmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2515,27 +2484,19 @@ def test_get_capacity_commitment( state=reservation.CapacityCommitment.State.PENDING, renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) - response = client.get_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetCapacityCommitmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -2547,7 +2508,7 @@ def test_get_capacity_commitment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2557,7 +2518,6 @@ def test_get_capacity_commitment_empty_call(): client.get_capacity_commitment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetCapacityCommitmentRequest() @@ -2567,7 +2527,7 @@ async def test_get_capacity_commitment_async( request_type=reservation.GetCapacityCommitmentRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2588,26 +2548,19 @@ async def test_get_capacity_commitment_async( renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) ) - response = await client.get_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -2617,11 +2570,14 @@ async def test_get_capacity_commitment_async_from_dict(): def test_get_capacity_commitment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2629,7 +2585,6 @@ def test_get_capacity_commitment_field_headers(): type(client.transport.get_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() - client.get_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -2645,12 +2600,13 @@ def test_get_capacity_commitment_field_headers(): @pytest.mark.asyncio async def test_get_capacity_commitment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2660,7 +2616,6 @@ async def test_get_capacity_commitment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() ) - await client.get_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -2674,7 +2629,9 @@ async def test_get_capacity_commitment_field_headers_async(): def test_get_capacity_commitment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2682,7 +2639,6 @@ def test_get_capacity_commitment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_capacity_commitment(name="name_value",) @@ -2691,12 +2647,13 @@ def test_get_capacity_commitment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_capacity_commitment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2709,7 +2666,7 @@ def test_get_capacity_commitment_flattened_error(): @pytest.mark.asyncio async def test_get_capacity_commitment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2730,14 +2687,13 @@ async def test_get_capacity_commitment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_capacity_commitment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2752,7 +2708,7 @@ def test_delete_capacity_commitment( transport: str = "grpc", request_type=reservation.DeleteCapacityCommitmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2765,13 +2721,11 @@ def test_delete_capacity_commitment( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteCapacityCommitmentRequest() # Establish that the response is the type that we expect. @@ -2786,7 +2740,7 @@ def test_delete_capacity_commitment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2796,7 +2750,6 @@ def test_delete_capacity_commitment_empty_call(): client.delete_capacity_commitment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteCapacityCommitmentRequest() @@ -2806,7 +2759,7 @@ async def test_delete_capacity_commitment_async( request_type=reservation.DeleteCapacityCommitmentRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2819,13 +2772,11 @@ async def test_delete_capacity_commitment_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteCapacityCommitmentRequest() # Establish that the response is the type that we expect. @@ -2838,11 +2789,14 @@ async def test_delete_capacity_commitment_async_from_dict(): def test_delete_capacity_commitment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2850,7 +2804,6 @@ def test_delete_capacity_commitment_field_headers(): type(client.transport.delete_capacity_commitment), "__call__" ) as call: call.return_value = None - client.delete_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -2866,12 +2819,13 @@ def test_delete_capacity_commitment_field_headers(): @pytest.mark.asyncio async def test_delete_capacity_commitment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2879,7 +2833,6 @@ async def test_delete_capacity_commitment_field_headers_async(): type(client.transport.delete_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -2893,7 +2846,9 @@ async def test_delete_capacity_commitment_field_headers_async(): def test_delete_capacity_commitment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2901,7 +2856,6 @@ def test_delete_capacity_commitment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_capacity_commitment(name="name_value",) @@ -2910,12 +2864,13 @@ def test_delete_capacity_commitment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_capacity_commitment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2928,7 +2883,7 @@ def test_delete_capacity_commitment_flattened_error(): @pytest.mark.asyncio async def test_delete_capacity_commitment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2947,14 +2902,13 @@ async def test_delete_capacity_commitment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_capacity_commitment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2969,7 +2923,7 @@ def test_update_capacity_commitment( transport: str = "grpc", request_type=reservation.UpdateCapacityCommitmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2988,27 +2942,19 @@ def test_update_capacity_commitment( state=reservation.CapacityCommitment.State.PENDING, renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) - response = client.update_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateCapacityCommitmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -3020,7 +2966,7 @@ def test_update_capacity_commitment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3030,7 +2976,6 @@ def test_update_capacity_commitment_empty_call(): client.update_capacity_commitment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateCapacityCommitmentRequest() @@ -3040,7 +2985,7 @@ async def test_update_capacity_commitment_async( request_type=reservation.UpdateCapacityCommitmentRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3061,26 +3006,19 @@ async def test_update_capacity_commitment_async( renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) ) - response = await client.update_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -3090,11 +3028,14 @@ async def test_update_capacity_commitment_async_from_dict(): def test_update_capacity_commitment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.UpdateCapacityCommitmentRequest() + request.capacity_commitment.name = "capacity_commitment.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3102,7 +3043,6 @@ def test_update_capacity_commitment_field_headers(): type(client.transport.update_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() - client.update_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -3121,12 +3061,13 @@ def test_update_capacity_commitment_field_headers(): @pytest.mark.asyncio async def test_update_capacity_commitment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.UpdateCapacityCommitmentRequest() + request.capacity_commitment.name = "capacity_commitment.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3136,7 +3077,6 @@ async def test_update_capacity_commitment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() ) - await client.update_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -3153,7 +3093,9 @@ async def test_update_capacity_commitment_field_headers_async(): def test_update_capacity_commitment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3161,28 +3103,27 @@ def test_update_capacity_commitment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_capacity_commitment( capacity_commitment=reservation.CapacityCommitment(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].capacity_commitment == reservation.CapacityCommitment( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_capacity_commitment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3190,14 +3131,14 @@ def test_update_capacity_commitment_flattened_error(): client.update_capacity_commitment( reservation.UpdateCapacityCommitmentRequest(), capacity_commitment=reservation.CapacityCommitment(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_capacity_commitment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3214,25 +3155,23 @@ async def test_update_capacity_commitment_flattened_async(): # using the keyword arguments to the method. response = await client.update_capacity_commitment( capacity_commitment=reservation.CapacityCommitment(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].capacity_commitment == reservation.CapacityCommitment( name="name_value" ) - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_capacity_commitment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3241,7 +3180,7 @@ async def test_update_capacity_commitment_flattened_error_async(): await client.update_capacity_commitment( reservation.UpdateCapacityCommitmentRequest(), capacity_commitment=reservation.CapacityCommitment(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -3249,7 +3188,7 @@ def test_split_capacity_commitment( transport: str = "grpc", request_type=reservation.SplitCapacityCommitmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3262,17 +3201,14 @@ def test_split_capacity_commitment( ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SplitCapacityCommitmentResponse() - response = client.split_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SplitCapacityCommitmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.SplitCapacityCommitmentResponse) @@ -3284,7 +3220,7 @@ def test_split_capacity_commitment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3294,7 +3230,6 @@ def test_split_capacity_commitment_empty_call(): client.split_capacity_commitment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SplitCapacityCommitmentRequest() @@ -3304,7 +3239,7 @@ async def test_split_capacity_commitment_async( request_type=reservation.SplitCapacityCommitmentRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3319,13 +3254,11 @@ async def test_split_capacity_commitment_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.SplitCapacityCommitmentResponse() ) - response = await client.split_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SplitCapacityCommitmentRequest() # Establish that the response is the type that we expect. @@ -3338,11 +3271,14 @@ async def test_split_capacity_commitment_async_from_dict(): def test_split_capacity_commitment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.SplitCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3350,7 +3286,6 @@ def test_split_capacity_commitment_field_headers(): type(client.transport.split_capacity_commitment), "__call__" ) as call: call.return_value = reservation.SplitCapacityCommitmentResponse() - client.split_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -3366,12 +3301,13 @@ def test_split_capacity_commitment_field_headers(): @pytest.mark.asyncio async def test_split_capacity_commitment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.SplitCapacityCommitmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3381,7 +3317,6 @@ async def test_split_capacity_commitment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.SplitCapacityCommitmentResponse() ) - await client.split_capacity_commitment(request) # Establish that the underlying gRPC stub method was called. @@ -3395,7 +3330,9 @@ async def test_split_capacity_commitment_field_headers_async(): def test_split_capacity_commitment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3403,7 +3340,6 @@ def test_split_capacity_commitment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SplitCapacityCommitmentResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.split_capacity_commitment( @@ -3414,14 +3350,14 @@ def test_split_capacity_commitment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].slot_count == 1098 def test_split_capacity_commitment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3436,7 +3372,7 @@ def test_split_capacity_commitment_flattened_error(): @pytest.mark.asyncio async def test_split_capacity_commitment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3459,16 +3395,14 @@ async def test_split_capacity_commitment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].slot_count == 1098 @pytest.mark.asyncio async def test_split_capacity_commitment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3485,7 +3419,7 @@ def test_merge_capacity_commitments( transport: str = "grpc", request_type=reservation.MergeCapacityCommitmentsRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3504,27 +3438,19 @@ def test_merge_capacity_commitments( state=reservation.CapacityCommitment.State.PENDING, renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) - response = client.merge_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MergeCapacityCommitmentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -3536,7 +3462,7 @@ def test_merge_capacity_commitments_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3546,7 +3472,6 @@ def test_merge_capacity_commitments_empty_call(): client.merge_capacity_commitments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MergeCapacityCommitmentsRequest() @@ -3556,7 +3481,7 @@ async def test_merge_capacity_commitments_async( request_type=reservation.MergeCapacityCommitmentsRequest, ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3577,26 +3502,19 @@ async def test_merge_capacity_commitments_async( renewal_plan=reservation.CapacityCommitment.CommitmentPlan.FLEX, ) ) - response = await client.merge_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MergeCapacityCommitmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) - assert response.name == "name_value" - assert response.slot_count == 1098 - assert response.plan == reservation.CapacityCommitment.CommitmentPlan.FLEX - assert response.state == reservation.CapacityCommitment.State.PENDING - assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX @@ -3606,11 +3524,14 @@ async def test_merge_capacity_commitments_async_from_dict(): def test_merge_capacity_commitments_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.MergeCapacityCommitmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3618,7 +3539,6 @@ def test_merge_capacity_commitments_field_headers(): type(client.transport.merge_capacity_commitments), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() - client.merge_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. @@ -3634,12 +3554,13 @@ def test_merge_capacity_commitments_field_headers(): @pytest.mark.asyncio async def test_merge_capacity_commitments_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.MergeCapacityCommitmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3649,7 +3570,6 @@ async def test_merge_capacity_commitments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() ) - await client.merge_capacity_commitments(request) # Establish that the underlying gRPC stub method was called. @@ -3663,7 +3583,9 @@ async def test_merge_capacity_commitments_field_headers_async(): def test_merge_capacity_commitments_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3671,7 +3593,6 @@ def test_merge_capacity_commitments_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.merge_capacity_commitments( @@ -3683,14 +3604,14 @@ def test_merge_capacity_commitments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].capacity_commitment_ids == ["capacity_commitment_ids_value"] def test_merge_capacity_commitments_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3705,7 +3626,7 @@ def test_merge_capacity_commitments_flattened_error(): @pytest.mark.asyncio async def test_merge_capacity_commitments_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3729,16 +3650,14 @@ async def test_merge_capacity_commitments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].capacity_commitment_ids == ["capacity_commitment_ids_value"] @pytest.mark.asyncio async def test_merge_capacity_commitments_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3755,7 +3674,7 @@ def test_create_assignment( transport: str = "grpc", request_type=reservation.CreateAssignmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3773,25 +3692,18 @@ def test_create_assignment( job_type=reservation.Assignment.JobType.PIPELINE, state=reservation.Assignment.State.PENDING, ) - response = client.create_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateAssignmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.Assignment) - assert response.name == "name_value" - assert response.assignee == "assignee_value" - assert response.job_type == reservation.Assignment.JobType.PIPELINE - assert response.state == reservation.Assignment.State.PENDING @@ -3803,7 +3715,7 @@ def test_create_assignment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3813,7 +3725,6 @@ def test_create_assignment_empty_call(): client.create_assignment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateAssignmentRequest() @@ -3822,7 +3733,7 @@ async def test_create_assignment_async( transport: str = "grpc_asyncio", request_type=reservation.CreateAssignmentRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3842,24 +3753,18 @@ async def test_create_assignment_async( state=reservation.Assignment.State.PENDING, ) ) - response = await client.create_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.CreateAssignmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Assignment) - assert response.name == "name_value" - assert response.assignee == "assignee_value" - assert response.job_type == reservation.Assignment.JobType.PIPELINE - assert response.state == reservation.Assignment.State.PENDING @@ -3869,11 +3774,14 @@ async def test_create_assignment_async_from_dict(): def test_create_assignment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.CreateAssignmentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3881,7 +3789,6 @@ def test_create_assignment_field_headers(): type(client.transport.create_assignment), "__call__" ) as call: call.return_value = reservation.Assignment() - client.create_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -3897,12 +3804,13 @@ def test_create_assignment_field_headers(): @pytest.mark.asyncio async def test_create_assignment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.CreateAssignmentRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3912,7 +3820,6 @@ async def test_create_assignment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Assignment() ) - await client.create_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -3926,7 +3833,9 @@ async def test_create_assignment_field_headers_async(): def test_create_assignment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3934,7 +3843,6 @@ def test_create_assignment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_assignment( @@ -3945,14 +3853,14 @@ def test_create_assignment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].assignment == reservation.Assignment(name="name_value") def test_create_assignment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3967,7 +3875,7 @@ def test_create_assignment_flattened_error(): @pytest.mark.asyncio async def test_create_assignment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3990,16 +3898,14 @@ async def test_create_assignment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].assignment == reservation.Assignment(name="name_value") @pytest.mark.asyncio async def test_create_assignment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4016,7 +3922,7 @@ def test_list_assignments( transport: str = "grpc", request_type=reservation.ListAssignmentsRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4029,19 +3935,15 @@ def test_list_assignments( call.return_value = reservation.ListAssignmentsResponse( next_page_token="next_page_token_value", ) - response = client.list_assignments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListAssignmentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListAssignmentsPager) - assert response.next_page_token == "next_page_token_value" @@ -4053,7 +3955,7 @@ def test_list_assignments_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4061,7 +3963,6 @@ def test_list_assignments_empty_call(): client.list_assignments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListAssignmentsRequest() @@ -4070,7 +3971,7 @@ async def test_list_assignments_async( transport: str = "grpc_asyncio", request_type=reservation.ListAssignmentsRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4085,18 +3986,15 @@ async def test_list_assignments_async( next_page_token="next_page_token_value", ) ) - response = await client.list_assignments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.ListAssignmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAssignmentsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -4106,17 +4004,19 @@ async def test_list_assignments_async_from_dict(): def test_list_assignments_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListAssignmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: call.return_value = reservation.ListAssignmentsResponse() - client.list_assignments(request) # Establish that the underlying gRPC stub method was called. @@ -4132,12 +4032,13 @@ def test_list_assignments_field_headers(): @pytest.mark.asyncio async def test_list_assignments_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.ListAssignmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4145,7 +4046,6 @@ async def test_list_assignments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListAssignmentsResponse() ) - await client.list_assignments(request) # Establish that the underlying gRPC stub method was called. @@ -4159,13 +4059,14 @@ async def test_list_assignments_field_headers_async(): def test_list_assignments_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListAssignmentsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_assignments(parent="parent_value",) @@ -4174,12 +4075,13 @@ def test_list_assignments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_assignments_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4192,7 +4094,7 @@ def test_list_assignments_flattened_error(): @pytest.mark.asyncio async def test_list_assignments_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4211,14 +4113,13 @@ async def test_list_assignments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_assignments_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4230,7 +4131,7 @@ async def test_list_assignments_flattened_error_async(): def test_list_assignments_pager(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: @@ -4268,7 +4169,7 @@ def test_list_assignments_pager(): def test_list_assignments_pages(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: @@ -4299,7 +4200,7 @@ def test_list_assignments_pages(): @pytest.mark.asyncio async def test_list_assignments_async_pager(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4338,7 +4239,7 @@ async def test_list_assignments_async_pager(): @pytest.mark.asyncio async def test_list_assignments_async_pages(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4375,7 +4276,7 @@ def test_delete_assignment( transport: str = "grpc", request_type=reservation.DeleteAssignmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4388,13 +4289,11 @@ def test_delete_assignment( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteAssignmentRequest() # Establish that the response is the type that we expect. @@ -4409,7 +4308,7 @@ def test_delete_assignment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4419,7 +4318,6 @@ def test_delete_assignment_empty_call(): client.delete_assignment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteAssignmentRequest() @@ -4428,7 +4326,7 @@ async def test_delete_assignment_async( transport: str = "grpc_asyncio", request_type=reservation.DeleteAssignmentRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4441,13 +4339,11 @@ async def test_delete_assignment_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.DeleteAssignmentRequest() # Establish that the response is the type that we expect. @@ -4460,11 +4356,14 @@ async def test_delete_assignment_async_from_dict(): def test_delete_assignment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteAssignmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4472,7 +4371,6 @@ def test_delete_assignment_field_headers(): type(client.transport.delete_assignment), "__call__" ) as call: call.return_value = None - client.delete_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -4488,12 +4386,13 @@ def test_delete_assignment_field_headers(): @pytest.mark.asyncio async def test_delete_assignment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.DeleteAssignmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4501,7 +4400,6 @@ async def test_delete_assignment_field_headers_async(): type(client.transport.delete_assignment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -4515,7 +4413,9 @@ async def test_delete_assignment_field_headers_async(): def test_delete_assignment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4523,7 +4423,6 @@ def test_delete_assignment_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_assignment(name="name_value",) @@ -4532,12 +4431,13 @@ def test_delete_assignment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_assignment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4550,7 +4450,7 @@ def test_delete_assignment_flattened_error(): @pytest.mark.asyncio async def test_delete_assignment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4569,14 +4469,13 @@ async def test_delete_assignment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_assignment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4591,7 +4490,7 @@ def test_search_assignments( transport: str = "grpc", request_type=reservation.SearchAssignmentsRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4606,19 +4505,15 @@ def test_search_assignments( call.return_value = reservation.SearchAssignmentsResponse( next_page_token="next_page_token_value", ) - response = client.search_assignments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SearchAssignmentsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.SearchAssignmentsPager) - assert response.next_page_token == "next_page_token_value" @@ -4630,7 +4525,7 @@ def test_search_assignments_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4640,7 +4535,6 @@ def test_search_assignments_empty_call(): client.search_assignments() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SearchAssignmentsRequest() @@ -4649,7 +4543,7 @@ async def test_search_assignments_async( transport: str = "grpc_asyncio", request_type=reservation.SearchAssignmentsRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4666,18 +4560,15 @@ async def test_search_assignments_async( next_page_token="next_page_token_value", ) ) - response = await client.search_assignments(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.SearchAssignmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchAssignmentsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -4687,11 +4578,14 @@ async def test_search_assignments_async_from_dict(): def test_search_assignments_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.SearchAssignmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4699,7 +4593,6 @@ def test_search_assignments_field_headers(): type(client.transport.search_assignments), "__call__" ) as call: call.return_value = reservation.SearchAssignmentsResponse() - client.search_assignments(request) # Establish that the underlying gRPC stub method was called. @@ -4715,12 +4608,13 @@ def test_search_assignments_field_headers(): @pytest.mark.asyncio async def test_search_assignments_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.SearchAssignmentsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4730,7 +4624,6 @@ async def test_search_assignments_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.SearchAssignmentsResponse() ) - await client.search_assignments(request) # Establish that the underlying gRPC stub method was called. @@ -4744,7 +4637,9 @@ async def test_search_assignments_field_headers_async(): def test_search_assignments_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4752,7 +4647,6 @@ def test_search_assignments_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SearchAssignmentsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_assignments( @@ -4763,14 +4657,14 @@ def test_search_assignments_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].query == "query_value" def test_search_assignments_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4785,7 +4679,7 @@ def test_search_assignments_flattened_error(): @pytest.mark.asyncio async def test_search_assignments_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4808,16 +4702,14 @@ async def test_search_assignments_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].query == "query_value" @pytest.mark.asyncio async def test_search_assignments_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4831,7 +4723,7 @@ async def test_search_assignments_flattened_error_async(): def test_search_assignments_pager(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4873,7 +4765,7 @@ def test_search_assignments_pager(): def test_search_assignments_pages(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) + client = ReservationServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4908,7 +4800,7 @@ def test_search_assignments_pages(): @pytest.mark.asyncio async def test_search_assignments_async_pager(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4951,7 +4843,7 @@ async def test_search_assignments_async_pager(): @pytest.mark.asyncio async def test_search_assignments_async_pages(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4992,7 +4884,7 @@ def test_move_assignment( transport: str = "grpc", request_type=reservation.MoveAssignmentRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5008,25 +4900,18 @@ def test_move_assignment( job_type=reservation.Assignment.JobType.PIPELINE, state=reservation.Assignment.State.PENDING, ) - response = client.move_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MoveAssignmentRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.Assignment) - assert response.name == "name_value" - assert response.assignee == "assignee_value" - assert response.job_type == reservation.Assignment.JobType.PIPELINE - assert response.state == reservation.Assignment.State.PENDING @@ -5038,7 +4923,7 @@ def test_move_assignment_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5046,7 +4931,6 @@ def test_move_assignment_empty_call(): client.move_assignment() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MoveAssignmentRequest() @@ -5055,7 +4939,7 @@ async def test_move_assignment_async( transport: str = "grpc_asyncio", request_type=reservation.MoveAssignmentRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5073,24 +4957,18 @@ async def test_move_assignment_async( state=reservation.Assignment.State.PENDING, ) ) - response = await client.move_assignment(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.MoveAssignmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Assignment) - assert response.name == "name_value" - assert response.assignee == "assignee_value" - assert response.job_type == reservation.Assignment.JobType.PIPELINE - assert response.state == reservation.Assignment.State.PENDING @@ -5100,17 +4978,19 @@ async def test_move_assignment_async_from_dict(): def test_move_assignment_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.MoveAssignmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: call.return_value = reservation.Assignment() - client.move_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -5126,12 +5006,13 @@ def test_move_assignment_field_headers(): @pytest.mark.asyncio async def test_move_assignment_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.MoveAssignmentRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5139,7 +5020,6 @@ async def test_move_assignment_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Assignment() ) - await client.move_assignment(request) # Establish that the underlying gRPC stub method was called. @@ -5153,13 +5033,14 @@ async def test_move_assignment_field_headers_async(): def test_move_assignment_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.move_assignment( @@ -5170,14 +5051,14 @@ def test_move_assignment_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].destination_id == "destination_id_value" def test_move_assignment_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5192,7 +5073,7 @@ def test_move_assignment_flattened_error(): @pytest.mark.asyncio async def test_move_assignment_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5213,16 +5094,14 @@ async def test_move_assignment_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].destination_id == "destination_id_value" @pytest.mark.asyncio async def test_move_assignment_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5239,7 +5118,7 @@ def test_get_bi_reservation( transport: str = "grpc", request_type=reservation.GetBiReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5252,21 +5131,16 @@ def test_get_bi_reservation( ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation(name="name_value", size=443,) - response = client.get_bi_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetBiReservationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.BiReservation) - assert response.name == "name_value" - assert response.size == 443 @@ -5278,7 +5152,7 @@ def test_get_bi_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5288,7 +5162,6 @@ def test_get_bi_reservation_empty_call(): client.get_bi_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetBiReservationRequest() @@ -5297,7 +5170,7 @@ async def test_get_bi_reservation_async( transport: str = "grpc_asyncio", request_type=reservation.GetBiReservationRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5312,20 +5185,16 @@ async def test_get_bi_reservation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation(name="name_value", size=443,) ) - response = await client.get_bi_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.GetBiReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.BiReservation) - assert response.name == "name_value" - assert response.size == 443 @@ -5335,11 +5204,14 @@ async def test_get_bi_reservation_async_from_dict(): def test_get_bi_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetBiReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5347,7 +5219,6 @@ def test_get_bi_reservation_field_headers(): type(client.transport.get_bi_reservation), "__call__" ) as call: call.return_value = reservation.BiReservation() - client.get_bi_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -5363,12 +5234,13 @@ def test_get_bi_reservation_field_headers(): @pytest.mark.asyncio async def test_get_bi_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.GetBiReservationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5378,7 +5250,6 @@ async def test_get_bi_reservation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation() ) - await client.get_bi_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -5392,7 +5263,9 @@ async def test_get_bi_reservation_field_headers_async(): def test_get_bi_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5400,7 +5273,6 @@ def test_get_bi_reservation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_bi_reservation(name="name_value",) @@ -5409,12 +5281,13 @@ def test_get_bi_reservation_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_bi_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5427,7 +5300,7 @@ def test_get_bi_reservation_flattened_error(): @pytest.mark.asyncio async def test_get_bi_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5448,14 +5321,13 @@ async def test_get_bi_reservation_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_bi_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5470,7 +5342,7 @@ def test_update_bi_reservation( transport: str = "grpc", request_type=reservation.UpdateBiReservationRequest ): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5483,21 +5355,16 @@ def test_update_bi_reservation( ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation(name="name_value", size=443,) - response = client.update_bi_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateBiReservationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, reservation.BiReservation) - assert response.name == "name_value" - assert response.size == 443 @@ -5509,7 +5376,7 @@ def test_update_bi_reservation_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5519,7 +5386,6 @@ def test_update_bi_reservation_empty_call(): client.update_bi_reservation() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateBiReservationRequest() @@ -5528,7 +5394,7 @@ async def test_update_bi_reservation_async( transport: str = "grpc_asyncio", request_type=reservation.UpdateBiReservationRequest ): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -5543,20 +5409,16 @@ async def test_update_bi_reservation_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation(name="name_value", size=443,) ) - response = await client.update_bi_reservation(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == reservation.UpdateBiReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.BiReservation) - assert response.name == "name_value" - assert response.size == 443 @@ -5566,11 +5428,14 @@ async def test_update_bi_reservation_async_from_dict(): def test_update_bi_reservation_field_headers(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.UpdateBiReservationRequest() + request.bi_reservation.name = "bi_reservation.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5578,7 +5443,6 @@ def test_update_bi_reservation_field_headers(): type(client.transport.update_bi_reservation), "__call__" ) as call: call.return_value = reservation.BiReservation() - client.update_bi_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -5597,12 +5461,13 @@ def test_update_bi_reservation_field_headers(): @pytest.mark.asyncio async def test_update_bi_reservation_field_headers_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = reservation.UpdateBiReservationRequest() + request.bi_reservation.name = "bi_reservation.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -5612,7 +5477,6 @@ async def test_update_bi_reservation_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation() ) - await client.update_bi_reservation(request) # Establish that the underlying gRPC stub method was called. @@ -5629,7 +5493,9 @@ async def test_update_bi_reservation_field_headers_async(): def test_update_bi_reservation_flattened(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -5637,26 +5503,25 @@ def test_update_bi_reservation_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_bi_reservation( bi_reservation=reservation.BiReservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].bi_reservation == reservation.BiReservation(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_bi_reservation_flattened_error(): - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -5664,14 +5529,14 @@ def test_update_bi_reservation_flattened_error(): client.update_bi_reservation( reservation.UpdateBiReservationRequest(), bi_reservation=reservation.BiReservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_bi_reservation_flattened_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -5688,23 +5553,21 @@ async def test_update_bi_reservation_flattened_async(): # using the keyword arguments to the method. response = await client.update_bi_reservation( bi_reservation=reservation.BiReservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].bi_reservation == reservation.BiReservation(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_bi_reservation_flattened_error_async(): client = ReservationServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -5713,23 +5576,23 @@ async def test_update_bi_reservation_flattened_error_async(): await client.update_bi_reservation( reservation.UpdateBiReservationRequest(), bi_reservation=reservation.BiReservation(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ReservationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.ReservationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ReservationServiceClient( @@ -5739,7 +5602,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ReservationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ReservationServiceClient( @@ -5750,7 +5613,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ReservationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ReservationServiceClient(transport=transport) assert client.transport is transport @@ -5759,13 +5622,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ReservationServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ReservationServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -5780,23 +5643,25 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ReservationServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) assert isinstance(client.transport, transports.ReservationServiceGrpcTransport,) def test_reservation_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.ReservationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -5808,7 +5673,7 @@ def test_reservation_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ReservationServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -5839,15 +5704,40 @@ def test_reservation_service_base_transport(): getattr(transport, method)(request=object()) +@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( - auth, "load_credentials_from_file" + 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=None, + default_scopes=( + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ), + quota_project_id="octopus", + ) + + +@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 = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ReservationServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -5863,19 +5753,36 @@ def test_reservation_service_base_transport_with_credentials_file(): 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(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.bigquery_reservation_v1.services.reservation_service.transports.ReservationServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ReservationServiceTransport() 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(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + 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=None, + default_scopes=( + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ), + quota_project_id=None, + ) + + +@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=( @@ -5886,14 +5793,44 @@ def test_reservation_service_auth_adc(): ) -def test_reservation_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ReservationServiceGrpcTransport, + 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. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.ReservationServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ), + quota_project_id="octopus", ) + + +@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", @@ -5903,6 +5840,121 @@ def test_reservation_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ReservationServiceGrpcTransport, grpc_helpers), + (transports.ReservationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_reservation_service_transport_create_channel(transport_class, grpc_helpers): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "bigqueryreservation.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ), + scopes=["1", "2"], + default_host="bigqueryreservation.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ReservationServiceGrpcTransport, grpc_helpers), + (transports.ReservationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_reservation_service_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "bigqueryreservation.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=( + "https://www.googleapis.com/auth/bigquery", + "https://www.googleapis.com/auth/cloud-platform", + ), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ReservationServiceGrpcTransport, grpc_helpers), + (transports.ReservationServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_reservation_service_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # 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, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "bigqueryreservation.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -5913,7 +5965,7 @@ def test_reservation_service_transport_auth_adc(): def test_reservation_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -5955,7 +6007,7 @@ def test_reservation_service_grpc_transport_client_cert_source_for_mtls( def test_reservation_service_host_no_port(): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="bigqueryreservation.googleapis.com" ), @@ -5965,7 +6017,7 @@ def test_reservation_service_host_no_port(): def test_reservation_service_host_with_port(): client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="bigqueryreservation.googleapis.com:8000" ), @@ -6021,9 +6073,9 @@ def test_reservation_service_transport_channel_mtls_with_client_cert_source( mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -6108,7 +6160,6 @@ def test_assignment_path(): location = "clam" reservation = "whelk" assignment = "octopus" - expected = "projects/{project}/locations/{location}/reservations/{reservation}/assignments/{assignment}".format( project=project, location=location, @@ -6138,7 +6189,6 @@ def test_parse_assignment_path(): def test_bi_reservation_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}/bireservation".format( project=project, location=location, ) @@ -6162,7 +6212,6 @@ def test_capacity_commitment_path(): project = "squid" location = "clam" capacity_commitment = "whelk" - expected = "projects/{project}/locations/{location}/capacityCommitments/{capacity_commitment}".format( project=project, location=location, capacity_commitment=capacity_commitment, ) @@ -6189,7 +6238,6 @@ def test_reservation_path(): project = "cuttlefish" location = "mussel" reservation = "winkle" - expected = "projects/{project}/locations/{location}/reservations/{reservation}".format( project=project, location=location, reservation=reservation, ) @@ -6212,7 +6260,6 @@ def test_parse_reservation_path(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -6233,7 +6280,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = ReservationServiceClient.common_folder_path(folder) assert expected == actual @@ -6252,7 +6298,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = ReservationServiceClient.common_organization_path(organization) assert expected == actual @@ -6271,7 +6316,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = ReservationServiceClient.common_project_path(project) assert expected == actual @@ -6291,7 +6335,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "winkle" location = "nautilus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -6318,7 +6361,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ReservationServiceTransport, "_prep_wrapped_messages" ) as prep: client = ReservationServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -6327,6 +6370,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ReservationServiceClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)