From 94695fe7a57e4d259ac73b505feb9ab17bad1157 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 14 May 2021 15:14:06 +0000 Subject: [PATCH] chore: upgrade gapic-generator-python to 0.46.3 (#20) 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 --- docs/apigateway_v1/api_gateway_service.rst | 1 - google/cloud/apigateway/__init__.py | 12 +- google/cloud/apigateway_v1/__init__.py | 7 +- .../cloud/apigateway_v1/gapic_metadata.json | 173 ++++ .../cloud/apigateway_v1/services/__init__.py | 1 - .../services/api_gateway_service/__init__.py | 2 - .../api_gateway_service/async_client.py | 90 +- .../services/api_gateway_service/client.py | 144 +-- .../services/api_gateway_service/pagers.py | 8 +- .../transports/__init__.py | 2 - .../api_gateway_service/transports/base.py | 186 ++-- .../api_gateway_service/transports/grpc.py | 60 +- .../transports/grpc_asyncio.py | 73 +- google/cloud/apigateway_v1/types/__init__.py | 2 - .../cloud/apigateway_v1/types/apigateway.py | 232 ++--- .../apigateway_v1/types/apigateway_service.py | 1 - scripts/fixup_apigateway_v1_keywords.py | 35 +- tests/__init__.py | 15 + tests/unit/__init__.py | 15 + tests/unit/gapic/__init__.py | 15 + tests/unit/gapic/apigateway_v1/__init__.py | 1 - .../apigateway_v1/test_api_gateway_service.py | 884 +++++++++--------- 22 files changed, 1043 insertions(+), 916 deletions(-) create mode 100644 google/cloud/apigateway_v1/gapic_metadata.json create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/gapic/__init__.py diff --git a/docs/apigateway_v1/api_gateway_service.rst b/docs/apigateway_v1/api_gateway_service.rst index 67d1d6b..2f75173 100644 --- a/docs/apigateway_v1/api_gateway_service.rst +++ b/docs/apigateway_v1/api_gateway_service.rst @@ -5,7 +5,6 @@ ApiGatewayService :members: :inherited-members: - .. automodule:: google.cloud.apigateway_v1.services.api_gateway_service.pagers :members: :inherited-members: diff --git a/google/cloud/apigateway/__init__.py b/google/cloud/apigateway/__init__.py index 86e9b79..07a20e4 100644 --- a/google/cloud/apigateway/__init__.py +++ b/google/cloud/apigateway/__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.apigateway_v1.services.api_gateway_service.async_client import ( - ApiGatewayServiceAsyncClient, -) from google.cloud.apigateway_v1.services.api_gateway_service.client import ( ApiGatewayServiceClient, ) +from google.cloud.apigateway_v1.services.api_gateway_service.async_client import ( + ApiGatewayServiceAsyncClient, +) + from google.cloud.apigateway_v1.types.apigateway import Api from google.cloud.apigateway_v1.types.apigateway import ApiConfig from google.cloud.apigateway_v1.types.apigateway import CreateApiConfigRequest @@ -45,10 +45,10 @@ from google.cloud.apigateway_v1.types.apigateway import UpdateGatewayRequest __all__ = ( + "ApiGatewayServiceClient", + "ApiGatewayServiceAsyncClient", "Api", "ApiConfig", - "ApiGatewayServiceAsyncClient", - "ApiGatewayServiceClient", "CreateApiConfigRequest", "CreateApiRequest", "CreateGatewayRequest", diff --git a/google/cloud/apigateway_v1/__init__.py b/google/cloud/apigateway_v1/__init__.py index aa6edb4..1e57740 100644 --- a/google/cloud/apigateway_v1/__init__.py +++ b/google/cloud/apigateway_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.api_gateway_service import ApiGatewayServiceClient +from .services.api_gateway_service import ApiGatewayServiceAsyncClient + from .types.apigateway import Api from .types.apigateway import ApiConfig from .types.apigateway import CreateApiConfigRequest @@ -39,10 +40,11 @@ from .types.apigateway import UpdateApiRequest from .types.apigateway import UpdateGatewayRequest - __all__ = ( + "ApiGatewayServiceAsyncClient", "Api", "ApiConfig", + "ApiGatewayServiceClient", "CreateApiConfigRequest", "CreateApiRequest", "CreateGatewayRequest", @@ -63,5 +65,4 @@ "UpdateApiConfigRequest", "UpdateApiRequest", "UpdateGatewayRequest", - "ApiGatewayServiceClient", ) diff --git a/google/cloud/apigateway_v1/gapic_metadata.json b/google/cloud/apigateway_v1/gapic_metadata.json new file mode 100644 index 0000000..2e07036 --- /dev/null +++ b/google/cloud/apigateway_v1/gapic_metadata.json @@ -0,0 +1,173 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.apigateway_v1", + "protoPackage": "google.cloud.apigateway.v1", + "schema": "1.0", + "services": { + "ApiGatewayService": { + "clients": { + "grpc": { + "libraryClient": "ApiGatewayServiceClient", + "rpcs": { + "CreateApi": { + "methods": [ + "create_api" + ] + }, + "CreateApiConfig": { + "methods": [ + "create_api_config" + ] + }, + "CreateGateway": { + "methods": [ + "create_gateway" + ] + }, + "DeleteApi": { + "methods": [ + "delete_api" + ] + }, + "DeleteApiConfig": { + "methods": [ + "delete_api_config" + ] + }, + "DeleteGateway": { + "methods": [ + "delete_gateway" + ] + }, + "GetApi": { + "methods": [ + "get_api" + ] + }, + "GetApiConfig": { + "methods": [ + "get_api_config" + ] + }, + "GetGateway": { + "methods": [ + "get_gateway" + ] + }, + "ListApiConfigs": { + "methods": [ + "list_api_configs" + ] + }, + "ListApis": { + "methods": [ + "list_apis" + ] + }, + "ListGateways": { + "methods": [ + "list_gateways" + ] + }, + "UpdateApi": { + "methods": [ + "update_api" + ] + }, + "UpdateApiConfig": { + "methods": [ + "update_api_config" + ] + }, + "UpdateGateway": { + "methods": [ + "update_gateway" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ApiGatewayServiceAsyncClient", + "rpcs": { + "CreateApi": { + "methods": [ + "create_api" + ] + }, + "CreateApiConfig": { + "methods": [ + "create_api_config" + ] + }, + "CreateGateway": { + "methods": [ + "create_gateway" + ] + }, + "DeleteApi": { + "methods": [ + "delete_api" + ] + }, + "DeleteApiConfig": { + "methods": [ + "delete_api_config" + ] + }, + "DeleteGateway": { + "methods": [ + "delete_gateway" + ] + }, + "GetApi": { + "methods": [ + "get_api" + ] + }, + "GetApiConfig": { + "methods": [ + "get_api_config" + ] + }, + "GetGateway": { + "methods": [ + "get_gateway" + ] + }, + "ListApiConfigs": { + "methods": [ + "list_api_configs" + ] + }, + "ListApis": { + "methods": [ + "list_apis" + ] + }, + "ListGateways": { + "methods": [ + "list_gateways" + ] + }, + "UpdateApi": { + "methods": [ + "update_api" + ] + }, + "UpdateApiConfig": { + "methods": [ + "update_api_config" + ] + }, + "UpdateGateway": { + "methods": [ + "update_gateway" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/apigateway_v1/services/__init__.py b/google/cloud/apigateway_v1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/apigateway_v1/services/__init__.py +++ b/google/cloud/apigateway_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/apigateway_v1/services/api_gateway_service/__init__.py b/google/cloud/apigateway_v1/services/api_gateway_service/__init__.py index f8a78c4..628178e 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/__init__.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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 ApiGatewayServiceClient from .async_client import ApiGatewayServiceAsyncClient diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py b/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py index ed7d274..6480acd 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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,20 +20,19 @@ 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.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.apigateway_v1.services.api_gateway_service import pagers from google.cloud.apigateway_v1.types import apigateway -from google.protobuf import empty_pb2 as empty # 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.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ApiGatewayServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ApiGatewayServiceGrpcAsyncIOTransport from .client import ApiGatewayServiceClient @@ -67,31 +64,26 @@ class ApiGatewayServiceAsyncClient: parse_service_account_path = staticmethod( ApiGatewayServiceClient.parse_service_account_path ) - common_billing_account_path = staticmethod( ApiGatewayServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ApiGatewayServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ApiGatewayServiceClient.common_folder_path) parse_common_folder_path = staticmethod( ApiGatewayServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( ApiGatewayServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( ApiGatewayServiceClient.parse_common_organization_path ) - common_project_path = staticmethod(ApiGatewayServiceClient.common_project_path) parse_common_project_path = staticmethod( ApiGatewayServiceClient.parse_common_project_path ) - common_location_path = staticmethod(ApiGatewayServiceClient.common_location_path) parse_common_location_path = staticmethod( ApiGatewayServiceClient.parse_common_location_path @@ -99,7 +91,8 @@ class ApiGatewayServiceAsyncClient: @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. @@ -114,7 +107,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 @@ -131,7 +124,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ApiGatewayServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: ApiGatewayServiceTransport: The transport used by the client instance. @@ -145,12 +138,12 @@ def transport(self) -> ApiGatewayServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ApiGatewayServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the api gateway service client. + """Instantiates the api gateway service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -182,7 +175,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ApiGatewayServiceClient( credentials=credentials, transport=transport, @@ -212,7 +204,6 @@ async def list_gateways( 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. @@ -242,7 +233,6 @@ async def list_gateways( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -294,7 +284,6 @@ async def get_gateway( 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. @@ -325,7 +314,6 @@ async def get_gateway( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -387,7 +375,6 @@ async def create_gateway( This corresponds to the ``gateway_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. @@ -418,7 +405,6 @@ async def create_gateway( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if gateway is not None: @@ -435,7 +421,7 @@ async def create_gateway( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -468,7 +454,7 @@ async def update_gateway( request: apigateway.UpdateGatewayRequest = None, *, gateway: apigateway.Gateway = 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]] = (), @@ -495,7 +481,6 @@ async def update_gateway( 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. @@ -526,7 +511,6 @@ async def update_gateway( # If we have keyword arguments corresponding to fields on the # request, apply these. - if gateway is not None: request.gateway = gateway if update_mask is not None: @@ -541,7 +525,7 @@ async def update_gateway( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -593,7 +577,6 @@ async def delete_gateway( 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. @@ -633,7 +616,6 @@ async def delete_gateway( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -646,7 +628,7 @@ async def delete_gateway( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -667,7 +649,7 @@ async def delete_gateway( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) @@ -696,7 +678,6 @@ async def list_apis( 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. @@ -726,7 +707,6 @@ async def list_apis( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -778,7 +758,6 @@ async def get_api( 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. @@ -805,7 +784,6 @@ async def get_api( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -866,7 +844,6 @@ async def create_api( This corresponds to the ``api_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. @@ -896,7 +873,6 @@ async def create_api( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if api is not None: @@ -913,7 +889,7 @@ async def create_api( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -946,7 +922,7 @@ async def update_api( request: apigateway.UpdateApiRequest = None, *, api: apigateway.Api = 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]] = (), @@ -973,7 +949,6 @@ async def update_api( 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. @@ -1003,7 +978,6 @@ async def update_api( # If we have keyword arguments corresponding to fields on the # request, apply these. - if api is not None: request.api = api if update_mask is not None: @@ -1018,7 +992,7 @@ async def update_api( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -1068,7 +1042,6 @@ async def delete_api( 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. @@ -1108,7 +1081,6 @@ async def delete_api( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1121,7 +1093,7 @@ async def delete_api( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -1142,7 +1114,7 @@ async def delete_api( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) @@ -1171,7 +1143,6 @@ async def list_api_configs( 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. @@ -1201,7 +1172,6 @@ async def list_api_configs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1253,7 +1223,6 @@ async def get_api_config( 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. @@ -1281,7 +1250,6 @@ async def get_api_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1343,7 +1311,6 @@ async def create_api_config( This corresponds to the ``api_config_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. @@ -1372,7 +1339,6 @@ async def create_api_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if api_config is not None: @@ -1389,7 +1355,7 @@ async def create_api_config( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -1422,7 +1388,7 @@ async def update_api_config( request: apigateway.UpdateApiConfigRequest = None, *, api_config: apigateway.ApiConfig = 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]] = (), @@ -1449,7 +1415,6 @@ async def update_api_config( 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. @@ -1478,7 +1443,6 @@ async def update_api_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if api_config is not None: request.api_config = api_config if update_mask is not None: @@ -1493,7 +1457,7 @@ async def update_api_config( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -1545,7 +1509,6 @@ async def delete_api_config( 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. @@ -1585,7 +1548,6 @@ async def delete_api_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1598,7 +1560,7 @@ async def delete_api_config( maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -1619,7 +1581,7 @@ async def delete_api_config( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/client.py b/google/cloud/apigateway_v1/services/api_gateway_service/client.py index c300026..ebb174f 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/client.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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 @@ -36,10 +34,9 @@ from google.api_core import operation_async # type: ignore from google.cloud.apigateway_v1.services.api_gateway_service import pagers from google.cloud.apigateway_v1.types import apigateway -from google.protobuf import empty_pb2 as empty # 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.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ApiGatewayServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ApiGatewayServiceGrpcTransport from .transports.grpc_asyncio import ApiGatewayServiceGrpcAsyncIOTransport @@ -62,7 +59,7 @@ class ApiGatewayServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[ApiGatewayServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -87,7 +84,8 @@ class ApiGatewayServiceClient(metaclass=ApiGatewayServiceClientMeta): @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: @@ -121,7 +119,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. @@ -138,7 +137,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 @@ -157,23 +156,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ApiGatewayServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - ApiGatewayServiceTransport: The transport used by the client instance. + ApiGatewayServiceTransport: The transport used by the client + instance. """ return self._transport @staticmethod def api_path(project: str, api: str,) -> str: - """Return a fully-qualified api string.""" + """Returns a fully-qualified api string.""" return "projects/{project}/locations/global/apis/{api}".format( project=project, api=api, ) @staticmethod def parse_api_path(path: str) -> Dict[str, str]: - """Parse a api path into its component segments.""" + """Parses a api path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/global/apis/(?P.+?)$", path ) @@ -181,14 +181,14 @@ def parse_api_path(path: str) -> Dict[str, str]: @staticmethod def api_config_path(project: str, api: str, api_config: str,) -> str: - """Return a fully-qualified api_config string.""" + """Returns a fully-qualified api_config string.""" return "projects/{project}/locations/global/apis/{api}/configs/{api_config}".format( project=project, api=api, api_config=api_config, ) @staticmethod def parse_api_config_path(path: str) -> Dict[str, str]: - """Parse a api_config path into its component segments.""" + """Parses a api_config path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/global/apis/(?P.+?)/configs/(?P.+?)$", path, @@ -197,14 +197,14 @@ def parse_api_config_path(path: str) -> Dict[str, str]: @staticmethod def gateway_path(project: str, location: str, gateway: str,) -> str: - """Return a fully-qualified gateway string.""" + """Returns a fully-qualified gateway string.""" return "projects/{project}/locations/{location}/gateways/{gateway}".format( project=project, location=location, gateway=gateway, ) @staticmethod def parse_gateway_path(path: str) -> Dict[str, str]: - """Parse a gateway path into its component segments.""" + """Parses a gateway path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/gateways/(?P.+?)$", path, @@ -213,38 +213,38 @@ def parse_gateway_path(path: str) -> Dict[str, str]: @staticmethod def managed_service_path(service: str,) -> str: - """Return a fully-qualified managed_service string.""" + """Returns a fully-qualified managed_service string.""" return "services/{service}".format(service=service,) @staticmethod def parse_managed_service_path(path: str) -> Dict[str, str]: - """Parse a managed_service path into its component segments.""" + """Parses a managed_service path into its component segments.""" m = re.match(r"^services/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def service_path(service: str, config: str,) -> str: - """Return a fully-qualified service string.""" + """Returns a fully-qualified service string.""" return "services/{service}/configs/{config}".format( service=service, config=config, ) @staticmethod def parse_service_path(path: str) -> Dict[str, str]: - """Parse a service path into its component segments.""" + """Parses a service path into its component segments.""" m = re.match(r"^services/(?P.+?)/configs/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def service_account_path(project: str, service_account: str,) -> str: - """Return a fully-qualified service_account string.""" + """Returns a fully-qualified service_account string.""" return "projects/{project}/serviceAccounts/{service_account}".format( project=project, service_account=service_account, ) @staticmethod def parse_service_account_path(path: str) -> Dict[str, str]: - """Parse a service_account path into its component segments.""" + """Parses a service_account path into its component segments.""" m = re.match( r"^projects/(?P.+?)/serviceAccounts/(?P.+?)$", path, @@ -253,7 +253,7 @@ def parse_service_account_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, ) @@ -266,7 +266,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 @@ -277,7 +277,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 @@ -288,7 +288,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 @@ -299,7 +299,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, ) @@ -313,12 +313,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, ApiGatewayServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the api gateway service client. + """Instantiates the api gateway service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -373,9 +373,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: @@ -387,12 +388,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. @@ -407,8 +410,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: @@ -445,7 +448,6 @@ def list_gateways( 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. @@ -477,10 +479,8 @@ def list_gateways( # there are no flattened fields. if not isinstance(request, apigateway.ListGatewaysRequest): request = apigateway.ListGatewaysRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -528,7 +528,6 @@ def get_gateway( 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. @@ -561,10 +560,8 @@ def get_gateway( # there are no flattened fields. if not isinstance(request, apigateway.GetGatewayRequest): request = apigateway.GetGatewayRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -622,7 +619,6 @@ def create_gateway( This corresponds to the ``gateway_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. @@ -655,10 +651,8 @@ def create_gateway( # there are no flattened fields. if not isinstance(request, apigateway.CreateGatewayRequest): request = apigateway.CreateGatewayRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if gateway is not None: @@ -695,7 +689,7 @@ def update_gateway( request: apigateway.UpdateGatewayRequest = None, *, gateway: apigateway.Gateway = 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]] = (), @@ -722,7 +716,6 @@ def update_gateway( 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. @@ -755,10 +748,8 @@ def update_gateway( # there are no flattened fields. if not isinstance(request, apigateway.UpdateGatewayRequest): request = apigateway.UpdateGatewayRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if gateway is not None: request.gateway = gateway if update_mask is not None: @@ -812,7 +803,6 @@ def delete_gateway( 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. @@ -854,10 +844,8 @@ def delete_gateway( # there are no flattened fields. if not isinstance(request, apigateway.DeleteGatewayRequest): request = apigateway.DeleteGatewayRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -878,7 +866,7 @@ def delete_gateway( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) @@ -907,7 +895,6 @@ def list_apis( 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. @@ -939,10 +926,8 @@ def list_apis( # there are no flattened fields. if not isinstance(request, apigateway.ListApisRequest): request = apigateway.ListApisRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -990,7 +975,6 @@ def get_api( 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. @@ -1019,10 +1003,8 @@ def get_api( # there are no flattened fields. if not isinstance(request, apigateway.GetApiRequest): request = apigateway.GetApiRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1079,7 +1061,6 @@ def create_api( This corresponds to the ``api_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. @@ -1111,10 +1092,8 @@ def create_api( # there are no flattened fields. if not isinstance(request, apigateway.CreateApiRequest): request = apigateway.CreateApiRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if api is not None: @@ -1151,7 +1130,7 @@ def update_api( request: apigateway.UpdateApiRequest = None, *, api: apigateway.Api = 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]] = (), @@ -1178,7 +1157,6 @@ def update_api( 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. @@ -1210,10 +1188,8 @@ def update_api( # there are no flattened fields. if not isinstance(request, apigateway.UpdateApiRequest): request = apigateway.UpdateApiRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if api is not None: request.api = api if update_mask is not None: @@ -1265,7 +1241,6 @@ def delete_api( 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. @@ -1307,10 +1282,8 @@ def delete_api( # there are no flattened fields. if not isinstance(request, apigateway.DeleteApiRequest): request = apigateway.DeleteApiRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1331,7 +1304,7 @@ def delete_api( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) @@ -1360,7 +1333,6 @@ def list_api_configs( 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. @@ -1392,10 +1364,8 @@ def list_api_configs( # there are no flattened fields. if not isinstance(request, apigateway.ListApiConfigsRequest): request = apigateway.ListApiConfigsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -1443,7 +1413,6 @@ def get_api_config( 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. @@ -1473,10 +1442,8 @@ def get_api_config( # there are no flattened fields. if not isinstance(request, apigateway.GetApiConfigRequest): request = apigateway.GetApiConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1534,7 +1501,6 @@ def create_api_config( This corresponds to the ``api_config_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. @@ -1565,10 +1531,8 @@ def create_api_config( # there are no flattened fields. if not isinstance(request, apigateway.CreateApiConfigRequest): request = apigateway.CreateApiConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if api_config is not None: @@ -1605,7 +1569,7 @@ def update_api_config( request: apigateway.UpdateApiConfigRequest = None, *, api_config: apigateway.ApiConfig = 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]] = (), @@ -1632,7 +1596,6 @@ def update_api_config( 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. @@ -1663,10 +1626,8 @@ def update_api_config( # there are no flattened fields. if not isinstance(request, apigateway.UpdateApiConfigRequest): request = apigateway.UpdateApiConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if api_config is not None: request.api_config = api_config if update_mask is not None: @@ -1720,7 +1681,6 @@ def delete_api_config( 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. @@ -1762,10 +1722,8 @@ def delete_api_config( # there are no flattened fields. if not isinstance(request, apigateway.DeleteApiConfigRequest): request = apigateway.DeleteApiConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1786,7 +1744,7 @@ def delete_api_config( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=apigateway.OperationMetadata, ) diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py b/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py index a1769ba..527e158 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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 diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/transports/__init__.py b/google/cloud/apigateway_v1/services/api_gateway_service/transports/__init__.py index 1917cdd..43133b0 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/transports/__init__.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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/apigateway_v1/services/api_gateway_service/transports/base.py b/google/cloud/apigateway_v1/services/api_gateway_service/transports/base.py index 316bf0b..bec6e35 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/transports/base.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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.api_core import operations_v1 # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.apigateway_v1.types import apigateway -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -39,27 +38,41 @@ 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 ApiGatewayServiceTransport(abc.ABC): """Abstract transport class for ApiGatewayService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "apigateway.googleapis.com" + def __init__( self, *, - host: str = "apigateway.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 @@ -68,7 +81,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): @@ -82,29 +95,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,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -135,7 +195,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -149,7 +209,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -169,7 +229,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -183,7 +243,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -197,7 +257,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -217,7 +277,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -231,7 +291,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -245,7 +305,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=2, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.Unknown, + core_exceptions.ServiceUnavailable, core_exceptions.Unknown, ), deadline=60.0, ), @@ -262,11 +322,10 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def list_gateways( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.ListGatewaysRequest], - typing.Union[ - apigateway.ListGatewaysResponse, - typing.Awaitable[apigateway.ListGatewaysResponse], + Union[ + apigateway.ListGatewaysResponse, Awaitable[apigateway.ListGatewaysResponse] ], ]: raise NotImplementedError() @@ -274,94 +333,91 @@ def list_gateways( @property def get_gateway( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.GetGatewayRequest], - typing.Union[apigateway.Gateway, typing.Awaitable[apigateway.Gateway]], + Union[apigateway.Gateway, Awaitable[apigateway.Gateway]], ]: raise NotImplementedError() @property def create_gateway( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.CreateGatewayRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_gateway( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.UpdateGatewayRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_gateway( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.DeleteGatewayRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_apis( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.ListApisRequest], - typing.Union[ - apigateway.ListApisResponse, typing.Awaitable[apigateway.ListApisResponse] - ], + Union[apigateway.ListApisResponse, Awaitable[apigateway.ListApisResponse]], ]: raise NotImplementedError() @property def get_api( self, - ) -> typing.Callable[ - [apigateway.GetApiRequest], - typing.Union[apigateway.Api, typing.Awaitable[apigateway.Api]], + ) -> Callable[ + [apigateway.GetApiRequest], Union[apigateway.Api, Awaitable[apigateway.Api]] ]: raise NotImplementedError() @property def create_api( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.CreateApiRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_api( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.UpdateApiRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_api( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.DeleteApiRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_api_configs( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.ListApiConfigsRequest], - typing.Union[ + Union[ apigateway.ListApiConfigsResponse, - typing.Awaitable[apigateway.ListApiConfigsResponse], + Awaitable[apigateway.ListApiConfigsResponse], ], ]: raise NotImplementedError() @@ -369,36 +425,36 @@ def list_api_configs( @property def get_api_config( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.GetApiConfigRequest], - typing.Union[apigateway.ApiConfig, typing.Awaitable[apigateway.ApiConfig]], + Union[apigateway.ApiConfig, Awaitable[apigateway.ApiConfig]], ]: raise NotImplementedError() @property def create_api_config( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.CreateApiConfigRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def update_api_config( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.UpdateApiConfigRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_api_config( self, - ) -> typing.Callable[ + ) -> Callable[ [apigateway.DeleteApiConfigRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py b/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py index c23280e..a6eb85d 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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 operations_v1 # 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.apigateway_v1.types import apigateway -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ApiGatewayServiceTransport, DEFAULT_CLIENT_INFO @@ -53,7 +50,7 @@ def __init__( self, *, host: str = "apigateway.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -67,7 +64,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 @@ -178,7 +176,7 @@ def __init__( def create_channel( cls, host: str = "apigateway.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, @@ -209,13 +207,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, ) @@ -294,7 +294,7 @@ def get_gateway( @property def create_gateway( self, - ) -> Callable[[apigateway.CreateGatewayRequest], operations.Operation]: + ) -> Callable[[apigateway.CreateGatewayRequest], operations_pb2.Operation]: r"""Return a callable for the create gateway method over gRPC. Creates a new Gateway in a given project and @@ -314,14 +314,14 @@ def create_gateway( self._stubs["create_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateGateway", request_serializer=apigateway.CreateGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_gateway"] @property def update_gateway( self, - ) -> Callable[[apigateway.UpdateGatewayRequest], operations.Operation]: + ) -> Callable[[apigateway.UpdateGatewayRequest], operations_pb2.Operation]: r"""Return a callable for the update gateway method over gRPC. Updates the parameters of a single Gateway. @@ -340,14 +340,14 @@ def update_gateway( self._stubs["update_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway", request_serializer=apigateway.UpdateGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_gateway"] @property def delete_gateway( self, - ) -> Callable[[apigateway.DeleteGatewayRequest], operations.Operation]: + ) -> Callable[[apigateway.DeleteGatewayRequest], operations_pb2.Operation]: r"""Return a callable for the delete gateway method over gRPC. Deletes a single Gateway. @@ -366,7 +366,7 @@ def delete_gateway( self._stubs["delete_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway", request_serializer=apigateway.DeleteGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_gateway"] @@ -423,7 +423,7 @@ def get_api(self) -> Callable[[apigateway.GetApiRequest], apigateway.Api]: @property def create_api( self, - ) -> Callable[[apigateway.CreateApiRequest], operations.Operation]: + ) -> Callable[[apigateway.CreateApiRequest], operations_pb2.Operation]: r"""Return a callable for the create api method over gRPC. Creates a new Api in a given project and location. @@ -442,14 +442,14 @@ def create_api( self._stubs["create_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApi", request_serializer=apigateway.CreateApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_api"] @property def update_api( self, - ) -> Callable[[apigateway.UpdateApiRequest], operations.Operation]: + ) -> Callable[[apigateway.UpdateApiRequest], operations_pb2.Operation]: r"""Return a callable for the update api method over gRPC. Updates the parameters of a single Api. @@ -468,14 +468,14 @@ def update_api( self._stubs["update_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApi", request_serializer=apigateway.UpdateApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_api"] @property def delete_api( self, - ) -> Callable[[apigateway.DeleteApiRequest], operations.Operation]: + ) -> Callable[[apigateway.DeleteApiRequest], operations_pb2.Operation]: r"""Return a callable for the delete api method over gRPC. Deletes a single Api. @@ -494,7 +494,7 @@ def delete_api( self._stubs["delete_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApi", request_serializer=apigateway.DeleteApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_api"] @@ -555,7 +555,7 @@ def get_api_config( @property def create_api_config( self, - ) -> Callable[[apigateway.CreateApiConfigRequest], operations.Operation]: + ) -> Callable[[apigateway.CreateApiConfigRequest], operations_pb2.Operation]: r"""Return a callable for the create api config method over gRPC. Creates a new ApiConfig in a given project and @@ -575,14 +575,14 @@ def create_api_config( self._stubs["create_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig", request_serializer=apigateway.CreateApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_api_config"] @property def update_api_config( self, - ) -> Callable[[apigateway.UpdateApiConfigRequest], operations.Operation]: + ) -> Callable[[apigateway.UpdateApiConfigRequest], operations_pb2.Operation]: r"""Return a callable for the update api config method over gRPC. Updates the parameters of a single ApiConfig. @@ -601,14 +601,14 @@ def update_api_config( self._stubs["update_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig", request_serializer=apigateway.UpdateApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_api_config"] @property def delete_api_config( self, - ) -> Callable[[apigateway.DeleteApiConfigRequest], operations.Operation]: + ) -> Callable[[apigateway.DeleteApiConfigRequest], operations_pb2.Operation]: r"""Return a callable for the delete api config method over gRPC. Deletes a single ApiConfig. @@ -627,7 +627,7 @@ def delete_api_config( self._stubs["delete_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig", request_serializer=apigateway.DeleteApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_api_config"] diff --git a/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py b/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py index de6d495..8a27509 100644 --- a/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py +++ b/google/cloud/apigateway_v1/services/api_gateway_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.api_core import operations_v1 # 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.apigateway_v1.types import apigateway -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ApiGatewayServiceTransport, DEFAULT_CLIENT_INFO from .grpc import ApiGatewayServiceGrpcTransport @@ -56,7 +53,7 @@ class ApiGatewayServiceGrpcAsyncIOTransport(ApiGatewayServiceTransport): def create_channel( cls, host: str = "apigateway.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, @@ -83,13 +80,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, ) @@ -97,7 +96,7 @@ def __init__( self, *, host: str = "apigateway.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, @@ -111,7 +110,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 @@ -170,7 +170,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 @@ -302,7 +301,9 @@ def get_gateway( @property def create_gateway( self, - ) -> Callable[[apigateway.CreateGatewayRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.CreateGatewayRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the create gateway method over gRPC. Creates a new Gateway in a given project and @@ -322,14 +323,16 @@ def create_gateway( self._stubs["create_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateGateway", request_serializer=apigateway.CreateGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_gateway"] @property def update_gateway( self, - ) -> Callable[[apigateway.UpdateGatewayRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.UpdateGatewayRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update gateway method over gRPC. Updates the parameters of a single Gateway. @@ -348,14 +351,16 @@ def update_gateway( self._stubs["update_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway", request_serializer=apigateway.UpdateGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_gateway"] @property def delete_gateway( self, - ) -> Callable[[apigateway.DeleteGatewayRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.DeleteGatewayRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete gateway method over gRPC. Deletes a single Gateway. @@ -374,7 +379,7 @@ def delete_gateway( self._stubs["delete_gateway"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway", request_serializer=apigateway.DeleteGatewayRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_gateway"] @@ -433,7 +438,7 @@ def get_api( @property def create_api( self, - ) -> Callable[[apigateway.CreateApiRequest], Awaitable[operations.Operation]]: + ) -> Callable[[apigateway.CreateApiRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create api method over gRPC. Creates a new Api in a given project and location. @@ -452,14 +457,14 @@ def create_api( self._stubs["create_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApi", request_serializer=apigateway.CreateApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_api"] @property def update_api( self, - ) -> Callable[[apigateway.UpdateApiRequest], Awaitable[operations.Operation]]: + ) -> Callable[[apigateway.UpdateApiRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the update api method over gRPC. Updates the parameters of a single Api. @@ -478,14 +483,14 @@ def update_api( self._stubs["update_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApi", request_serializer=apigateway.UpdateApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_api"] @property def delete_api( self, - ) -> Callable[[apigateway.DeleteApiRequest], Awaitable[operations.Operation]]: + ) -> Callable[[apigateway.DeleteApiRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the delete api method over gRPC. Deletes a single Api. @@ -504,7 +509,7 @@ def delete_api( self._stubs["delete_api"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApi", request_serializer=apigateway.DeleteApiRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_api"] @@ -565,7 +570,9 @@ def get_api_config( @property def create_api_config( self, - ) -> Callable[[apigateway.CreateApiConfigRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.CreateApiConfigRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the create api config method over gRPC. Creates a new ApiConfig in a given project and @@ -585,14 +592,16 @@ def create_api_config( self._stubs["create_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig", request_serializer=apigateway.CreateApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_api_config"] @property def update_api_config( self, - ) -> Callable[[apigateway.UpdateApiConfigRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.UpdateApiConfigRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update api config method over gRPC. Updates the parameters of a single ApiConfig. @@ -611,14 +620,16 @@ def update_api_config( self._stubs["update_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig", request_serializer=apigateway.UpdateApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_api_config"] @property def delete_api_config( self, - ) -> Callable[[apigateway.DeleteApiConfigRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [apigateway.DeleteApiConfigRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete api config method over gRPC. Deletes a single ApiConfig. @@ -637,7 +648,7 @@ def delete_api_config( self._stubs["delete_api_config"] = self.grpc_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig", request_serializer=apigateway.DeleteApiConfigRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_api_config"] diff --git a/google/cloud/apigateway_v1/types/__init__.py b/google/cloud/apigateway_v1/types/__init__.py index 19a585b..8e08d56 100644 --- a/google/cloud/apigateway_v1/types/__init__.py +++ b/google/cloud/apigateway_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 .apigateway import ( Api, ApiConfig, diff --git a/google/cloud/apigateway_v1/types/apigateway.py b/google/cloud/apigateway_v1/types/apigateway.py index ac8ebd8..786b4be 100644 --- a/google/cloud/apigateway_v1/types/apigateway.py +++ b/google/cloud/apigateway_v1/types/apigateway.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,12 +13,10 @@ # 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.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -53,7 +50,6 @@ class Api(proto.Message): r"""An API that can be served by one or more Gateways. - Attributes: name (str): Output only. Resource name of the API. @@ -91,18 +87,12 @@ class State(proto.Enum): DELETING = 4 UPDATING = 5 - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=4) - - display_name = proto.Field(proto.STRING, number=5) - - managed_service = proto.Field(proto.STRING, number=7) - + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=4,) + display_name = proto.Field(proto.STRING, number=5,) + managed_service = proto.Field(proto.STRING, number=7,) state = proto.Field(proto.ENUM, number=12, enum=State,) @@ -176,7 +166,6 @@ class State(proto.Enum): class File(proto.Message): r"""A lightweight description of a file. - Attributes: path (str): The file path (full or relative path). This @@ -186,13 +175,11 @@ class File(proto.Message): The bytes that constitute the file. """ - path = proto.Field(proto.STRING, number=1) - - contents = proto.Field(proto.BYTES, number=2) + path = proto.Field(proto.STRING, number=1,) + contents = proto.Field(proto.BYTES, number=2,) class OpenApiDocument(proto.Message): r"""An OpenAPI Specification Document describing an API. - Attributes: document (google.cloud.apigateway_v1.types.ApiConfig.File): The OpenAPI Specification document file. @@ -202,7 +189,6 @@ class OpenApiDocument(proto.Message): class GrpcServiceDefinition(proto.Message): r"""A gRPC service definition. - Attributes: file_descriptor_set (google.cloud.apigateway_v1.types.ApiConfig.File): Input only. File descriptor set, generated by protoc. @@ -223,33 +209,22 @@ class GrpcServiceDefinition(proto.Message): file_descriptor_set = proto.Field( proto.MESSAGE, number=1, message="ApiConfig.File", ) - source = proto.RepeatedField(proto.MESSAGE, number=2, message="ApiConfig.File",) - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=4) - - display_name = proto.Field(proto.STRING, number=5) - - gateway_service_account = proto.Field(proto.STRING, number=14) - - service_config_id = proto.Field(proto.STRING, number=12) - + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=4,) + display_name = proto.Field(proto.STRING, number=5,) + gateway_service_account = proto.Field(proto.STRING, number=14,) + service_config_id = proto.Field(proto.STRING, number=12,) state = proto.Field(proto.ENUM, number=8, enum=State,) - openapi_documents = proto.RepeatedField( proto.MESSAGE, number=9, message=OpenApiDocument, ) - grpc_services = proto.RepeatedField( proto.MESSAGE, number=10, message=GrpcServiceDefinition, ) - managed_service_configs = proto.RepeatedField( proto.MESSAGE, number=11, message=File, ) @@ -298,26 +273,18 @@ class State(proto.Enum): DELETING = 4 UPDATING = 5 - name = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=4) - - display_name = proto.Field(proto.STRING, number=5) - - api_config = proto.Field(proto.STRING, number=6) - + name = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + labels = proto.MapField(proto.STRING, proto.STRING, number=4,) + display_name = proto.Field(proto.STRING, number=5,) + api_config = proto.Field(proto.STRING, number=6,) state = proto.Field(proto.ENUM, number=7, enum=State,) - - default_hostname = proto.Field(proto.STRING, number=9) + default_hostname = proto.Field(proto.STRING, number=9,) class ListGatewaysRequest(proto.Message): r"""Request message for ApiGatewayService.ListGateways - Attributes: parent (str): Required. Parent resource of the Gateway, of the form: @@ -332,20 +299,15 @@ class ListGatewaysRequest(proto.Message): Order by parameters. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListGatewaysResponse(proto.Message): r"""Response message for ApiGatewayService.ListGateways - Attributes: gateways (Sequence[google.cloud.apigateway_v1.types.Gateway]): Gateways. @@ -360,27 +322,23 @@ def raw_page(self): return self gateways = proto.RepeatedField(proto.MESSAGE, number=1, message="Gateway",) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable_locations = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable_locations = proto.RepeatedField(proto.STRING, number=3,) class GetGatewayRequest(proto.Message): r"""Request message for ApiGatewayService.GetGateway - Attributes: name (str): Required. Resource name of the form: ``projects/*/locations/*/gateways/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateGatewayRequest(proto.Message): r"""Request message for ApiGatewayService.CreateGateway - Attributes: parent (str): Required. Parent resource of the Gateway, of the form: @@ -393,16 +351,13 @@ class CreateGatewayRequest(proto.Message): Required. Gateway resource. """ - parent = proto.Field(proto.STRING, number=1) - - gateway_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + gateway_id = proto.Field(proto.STRING, number=2,) gateway = proto.Field(proto.MESSAGE, number=3, message="Gateway",) class UpdateGatewayRequest(proto.Message): r"""Request message for ApiGatewayService.UpdateGateway - Attributes: update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten @@ -415,26 +370,25 @@ class UpdateGatewayRequest(proto.Message): Required. Gateway resource. """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) gateway = proto.Field(proto.MESSAGE, number=2, message="Gateway",) class DeleteGatewayRequest(proto.Message): r"""Request message for ApiGatewayService.DeleteGateway - Attributes: name (str): Required. Resource name of the form: ``projects/*/locations/*/gateways/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListApisRequest(proto.Message): r"""Request message for ApiGatewayService.ListApis - Attributes: parent (str): Required. Parent resource of the API, of the form: @@ -449,20 +403,15 @@ class ListApisRequest(proto.Message): Order by parameters. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListApisResponse(proto.Message): r"""Response message for ApiGatewayService.ListApis - Attributes: apis (Sequence[google.cloud.apigateway_v1.types.Api]): APIs. @@ -477,27 +426,23 @@ def raw_page(self): return self apis = proto.RepeatedField(proto.MESSAGE, number=1, message="Api",) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable_locations = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable_locations = proto.RepeatedField(proto.STRING, number=3,) class GetApiRequest(proto.Message): r"""Request message for ApiGatewayService.GetApi - Attributes: name (str): Required. Resource name of the form: ``projects/*/locations/global/apis/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class CreateApiRequest(proto.Message): r"""Request message for ApiGatewayService.CreateApi - Attributes: parent (str): Required. Parent resource of the API, of the form: @@ -510,16 +455,13 @@ class CreateApiRequest(proto.Message): Required. API resource. """ - parent = proto.Field(proto.STRING, number=1) - - api_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + api_id = proto.Field(proto.STRING, number=2,) api = proto.Field(proto.MESSAGE, number=3, message="Api",) class UpdateApiRequest(proto.Message): r"""Request message for ApiGatewayService.UpdateApi - Attributes: update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten @@ -532,26 +474,25 @@ class UpdateApiRequest(proto.Message): Required. API resource. """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) api = proto.Field(proto.MESSAGE, number=2, message="Api",) class DeleteApiRequest(proto.Message): r"""Request message for ApiGatewayService.DeleteApi - Attributes: name (str): Required. Resource name of the form: ``projects/*/locations/global/apis/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ListApiConfigsRequest(proto.Message): r"""Request message for ApiGatewayService.ListApiConfigs - Attributes: parent (str): Required. Parent resource of the API Config, of the form: @@ -566,20 +507,15 @@ class ListApiConfigsRequest(proto.Message): Order by parameters. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListApiConfigsResponse(proto.Message): r"""Response message for ApiGatewayService.ListApiConfigs - Attributes: api_configs (Sequence[google.cloud.apigateway_v1.types.ApiConfig]): API Configs. @@ -594,15 +530,12 @@ def raw_page(self): return self api_configs = proto.RepeatedField(proto.MESSAGE, number=1, message="ApiConfig",) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable_locations = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable_locations = proto.RepeatedField(proto.STRING, number=3,) class GetApiConfigRequest(proto.Message): r"""Request message for ApiGatewayService.GetApiConfig - Attributes: name (str): Required. Resource name of the form: @@ -620,14 +553,12 @@ class ConfigView(proto.Enum): BASIC = 1 FULL = 2 - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) view = proto.Field(proto.ENUM, number=3, enum=ConfigView,) class CreateApiConfigRequest(proto.Message): r"""Request message for ApiGatewayService.CreateApiConfig - Attributes: parent (str): Required. Parent resource of the API Config, of the form: @@ -640,16 +571,13 @@ class CreateApiConfigRequest(proto.Message): Required. API resource. """ - parent = proto.Field(proto.STRING, number=1) - - api_config_id = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + api_config_id = proto.Field(proto.STRING, number=2,) api_config = proto.Field(proto.MESSAGE, number=3, message="ApiConfig",) class UpdateApiConfigRequest(proto.Message): r"""Request message for ApiGatewayService.UpdateApiConfig - Attributes: update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields to be overwritten @@ -662,26 +590,25 @@ class UpdateApiConfigRequest(proto.Message): Required. API Config resource. """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) api_config = proto.Field(proto.MESSAGE, number=2, message="ApiConfig",) class DeleteApiConfigRequest(proto.Message): r"""Request message for ApiGatewayService.DeleteApiConfig - Attributes: name (str): Required. Resource name of the form: ``projects/*/locations/global/apis/*/configs/*`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class OperationMetadata(proto.Message): r"""Represents the metadata of the long-running operation. - Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the operation was @@ -714,7 +641,6 @@ class OperationMetadata(proto.Message): class Diagnostic(proto.Message): r"""Diagnostic information from configuration processing. - Attributes: location (str): Location of the diagnostic. @@ -722,24 +648,16 @@ class Diagnostic(proto.Message): The diagnostic message. """ - location = proto.Field(proto.STRING, number=1) - - message = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - target = proto.Field(proto.STRING, number=3) - - verb = proto.Field(proto.STRING, number=4) - - status_message = proto.Field(proto.STRING, number=5) - - requested_cancellation = proto.Field(proto.BOOL, number=6) - - api_version = proto.Field(proto.STRING, number=7) + location = proto.Field(proto.STRING, number=1,) + message = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + status_message = proto.Field(proto.STRING, number=5,) + requested_cancellation = proto.Field(proto.BOOL, number=6,) + api_version = proto.Field(proto.STRING, number=7,) diagnostics = proto.RepeatedField(proto.MESSAGE, number=8, message=Diagnostic,) diff --git a/google/cloud/apigateway_v1/types/apigateway_service.py b/google/cloud/apigateway_v1/types/apigateway_service.py index 3030b5c..430749c 100644 --- a/google/cloud/apigateway_v1/types/apigateway_service.py +++ b/google/cloud/apigateway_v1/types/apigateway_service.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/scripts/fixup_apigateway_v1_keywords.py b/scripts/fixup_apigateway_v1_keywords.py index 5cb5b7d..893aa60 100644 --- a/scripts/fixup_apigateway_v1_keywords.py +++ b/scripts/fixup_apigateway_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,22 +39,21 @@ def partition( class apigatewayCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_api': ('parent', 'api_id', 'api', ), - 'create_api_config': ('parent', 'api_config_id', 'api_config', ), - 'create_gateway': ('parent', 'gateway_id', 'gateway', ), - 'delete_api': ('name', ), - 'delete_api_config': ('name', ), - 'delete_gateway': ('name', ), - 'get_api': ('name', ), - 'get_api_config': ('name', 'view', ), - 'get_gateway': ('name', ), - 'list_api_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_apis': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'list_gateways': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'update_api': ('api', 'update_mask', ), - 'update_api_config': ('api_config', 'update_mask', ), - 'update_gateway': ('gateway', 'update_mask', ), - + 'create_api': ('parent', 'api_id', 'api', ), + 'create_api_config': ('parent', 'api_config_id', 'api_config', ), + 'create_gateway': ('parent', 'gateway_id', 'gateway', ), + 'delete_api': ('name', ), + 'delete_api_config': ('name', ), + 'delete_gateway': ('name', ), + 'get_api': ('name', ), + 'get_api_config': ('name', 'view', ), + 'get_gateway': ('name', ), + 'list_api_configs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_apis': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_gateways': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'update_api': ('api', 'update_mask', ), + 'update_api_config': ('api_config', 'update_mask', ), + 'update_gateway': ('gateway', 'update_mask', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -87,7 +84,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/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/__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/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..4de6597 --- /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 0000000..4de6597 --- /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/apigateway_v1/__init__.py b/tests/unit/gapic/apigateway_v1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/apigateway_v1/__init__.py +++ b/tests/unit/gapic/apigateway_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/apigateway_v1/test_api_gateway_service.py b/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py index 9d53fd1..5e28255 100644 --- a/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py +++ b/tests/unit/gapic/apigateway_v1/test_api_gateway_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,16 +23,16 @@ 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 future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.apigateway_v1.services.api_gateway_service import ( ApiGatewayServiceAsyncClient, @@ -43,11 +42,41 @@ ) from google.cloud.apigateway_v1.services.api_gateway_service import pagers from google.cloud.apigateway_v1.services.api_gateway_service import transports +from google.cloud.apigateway_v1.services.api_gateway_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.apigateway_v1.services.api_gateway_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.apigateway_v1.types import apigateway from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_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(): @@ -99,7 +128,7 @@ def test__get_default_mtls_endpoint(): "client_class", [ApiGatewayServiceClient, ApiGatewayServiceAsyncClient,] ) def test_api_gateway_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: @@ -116,7 +145,7 @@ def test_api_gateway_service_client_from_service_account_info(client_class): "client_class", [ApiGatewayServiceClient, ApiGatewayServiceAsyncClient,] ) def test_api_gateway_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: @@ -169,7 +198,7 @@ def test_api_gateway_service_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ApiGatewayServiceClient, "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() @@ -467,7 +496,7 @@ def test_list_gateways( transport: str = "grpc", request_type=apigateway.ListGatewaysRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -481,21 +510,16 @@ def test_list_gateways( next_page_token="next_page_token_value", unreachable_locations=["unreachable_locations_value"], ) - response = client.list_gateways(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListGatewaysRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListGatewaysPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -507,7 +531,7 @@ def test_list_gateways_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -515,7 +539,6 @@ def test_list_gateways_empty_call(): client.list_gateways() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListGatewaysRequest() @@ -524,7 +547,7 @@ async def test_list_gateways_async( transport: str = "grpc_asyncio", request_type=apigateway.ListGatewaysRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -540,20 +563,16 @@ async def test_list_gateways_async( unreachable_locations=["unreachable_locations_value"], ) ) - response = await client.list_gateways(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListGatewaysRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListGatewaysAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -563,17 +582,17 @@ async def test_list_gateways_async_from_dict(): def test_list_gateways_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.ListGatewaysRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_gateways), "__call__") as call: call.return_value = apigateway.ListGatewaysResponse() - client.list_gateways(request) # Establish that the underlying gRPC stub method was called. @@ -589,12 +608,13 @@ def test_list_gateways_field_headers(): @pytest.mark.asyncio async def test_list_gateways_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.ListGatewaysRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -602,7 +622,6 @@ async def test_list_gateways_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( apigateway.ListGatewaysResponse() ) - await client.list_gateways(request) # Establish that the underlying gRPC stub method was called. @@ -616,13 +635,12 @@ async def test_list_gateways_field_headers_async(): def test_list_gateways_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_gateways), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.ListGatewaysResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_gateways(parent="parent_value",) @@ -631,12 +649,11 @@ def test_list_gateways_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_gateways_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -649,7 +666,7 @@ def test_list_gateways_flattened_error(): @pytest.mark.asyncio async def test_list_gateways_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -668,14 +685,13 @@ async def test_list_gateways_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_gateways_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -687,7 +703,7 @@ async def test_list_gateways_flattened_error_async(): def test_list_gateways_pager(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_gateways), "__call__") as call: @@ -725,7 +741,7 @@ def test_list_gateways_pager(): def test_list_gateways_pages(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_gateways), "__call__") as call: @@ -755,7 +771,9 @@ def test_list_gateways_pages(): @pytest.mark.asyncio async def test_list_gateways_async_pager(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -792,7 +810,9 @@ async def test_list_gateways_async_pager(): @pytest.mark.asyncio async def test_list_gateways_async_pages(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -828,7 +848,7 @@ def test_get_gateway( transport: str = "grpc", request_type=apigateway.GetGatewayRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -845,27 +865,19 @@ def test_get_gateway( state=apigateway.Gateway.State.CREATING, default_hostname="default_hostname_value", ) - response = client.get_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetGatewayRequest() # Establish that the response is the type that we expect. - assert isinstance(response, apigateway.Gateway) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.api_config == "api_config_value" - assert response.state == apigateway.Gateway.State.CREATING - assert response.default_hostname == "default_hostname_value" @@ -877,7 +889,7 @@ def test_get_gateway_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -885,7 +897,6 @@ def test_get_gateway_empty_call(): client.get_gateway() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetGatewayRequest() @@ -894,7 +905,7 @@ async def test_get_gateway_async( transport: str = "grpc_asyncio", request_type=apigateway.GetGatewayRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -913,26 +924,19 @@ async def test_get_gateway_async( default_hostname="default_hostname_value", ) ) - response = await client.get_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetGatewayRequest() # Establish that the response is the type that we expect. assert isinstance(response, apigateway.Gateway) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.api_config == "api_config_value" - assert response.state == apigateway.Gateway.State.CREATING - assert response.default_hostname == "default_hostname_value" @@ -942,17 +946,17 @@ async def test_get_gateway_async_from_dict(): def test_get_gateway_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.GetGatewayRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_gateway), "__call__") as call: call.return_value = apigateway.Gateway() - client.get_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -968,18 +972,18 @@ def test_get_gateway_field_headers(): @pytest.mark.asyncio async def test_get_gateway_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.GetGatewayRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_gateway), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(apigateway.Gateway()) - await client.get_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -993,13 +997,12 @@ async def test_get_gateway_field_headers_async(): def test_get_gateway_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.Gateway() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_gateway(name="name_value",) @@ -1008,12 +1011,11 @@ def test_get_gateway_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_gateway_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1026,7 +1028,7 @@ def test_get_gateway_flattened_error(): @pytest.mark.asyncio async def test_get_gateway_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1043,14 +1045,13 @@ async def test_get_gateway_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_gateway_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1065,7 +1066,7 @@ def test_create_gateway( transport: str = "grpc", request_type=apigateway.CreateGatewayRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1076,13 +1077,11 @@ def test_create_gateway( with mock.patch.object(type(client.transport.create_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateGatewayRequest() # Establish that the response is the type that we expect. @@ -1097,7 +1096,7 @@ def test_create_gateway_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1105,7 +1104,6 @@ def test_create_gateway_empty_call(): client.create_gateway() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateGatewayRequest() @@ -1114,7 +1112,7 @@ async def test_create_gateway_async( transport: str = "grpc_asyncio", request_type=apigateway.CreateGatewayRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1127,13 +1125,11 @@ async def test_create_gateway_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateGatewayRequest() # Establish that the response is the type that we expect. @@ -1146,17 +1142,17 @@ async def test_create_gateway_async_from_dict(): def test_create_gateway_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.CreateGatewayRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_gateway), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1172,12 +1168,13 @@ def test_create_gateway_field_headers(): @pytest.mark.asyncio async def test_create_gateway_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.CreateGatewayRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1185,7 +1182,6 @@ async def test_create_gateway_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1199,13 +1195,12 @@ async def test_create_gateway_field_headers_async(): def test_create_gateway_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_gateway( @@ -1218,16 +1213,13 @@ def test_create_gateway_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway == apigateway.Gateway(name="name_value") - assert args[0].gateway_id == "gateway_id_value" def test_create_gateway_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1243,7 +1235,7 @@ def test_create_gateway_flattened_error(): @pytest.mark.asyncio async def test_create_gateway_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1266,18 +1258,15 @@ async def test_create_gateway_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway == apigateway.Gateway(name="name_value") - assert args[0].gateway_id == "gateway_id_value" @pytest.mark.asyncio async def test_create_gateway_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1295,7 +1284,7 @@ def test_update_gateway( transport: str = "grpc", request_type=apigateway.UpdateGatewayRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1306,13 +1295,11 @@ def test_update_gateway( with mock.patch.object(type(client.transport.update_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateGatewayRequest() # Establish that the response is the type that we expect. @@ -1327,7 +1314,7 @@ def test_update_gateway_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1335,7 +1322,6 @@ def test_update_gateway_empty_call(): client.update_gateway() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateGatewayRequest() @@ -1344,7 +1330,7 @@ async def test_update_gateway_async( transport: str = "grpc_asyncio", request_type=apigateway.UpdateGatewayRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1357,13 +1343,11 @@ async def test_update_gateway_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateGatewayRequest() # Establish that the response is the type that we expect. @@ -1376,17 +1360,17 @@ async def test_update_gateway_async_from_dict(): def test_update_gateway_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.UpdateGatewayRequest() + request.gateway.name = "gateway.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_gateway), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1404,12 +1388,13 @@ def test_update_gateway_field_headers(): @pytest.mark.asyncio async def test_update_gateway_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.UpdateGatewayRequest() + request.gateway.name = "gateway.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1417,7 +1402,6 @@ async def test_update_gateway_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1433,32 +1417,29 @@ async def test_update_gateway_field_headers_async(): def test_update_gateway_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_gateway( gateway=apigateway.Gateway(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].gateway == apigateway.Gateway(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_gateway_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1466,14 +1447,14 @@ def test_update_gateway_flattened_error(): client.update_gateway( apigateway.UpdateGatewayRequest(), gateway=apigateway.Gateway(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_gateway_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1488,23 +1469,21 @@ async def test_update_gateway_flattened_async(): # using the keyword arguments to the method. response = await client.update_gateway( gateway=apigateway.Gateway(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].gateway == apigateway.Gateway(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_gateway_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1513,7 +1492,7 @@ async def test_update_gateway_flattened_error_async(): await client.update_gateway( apigateway.UpdateGatewayRequest(), gateway=apigateway.Gateway(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1521,7 +1500,7 @@ def test_delete_gateway( transport: str = "grpc", request_type=apigateway.DeleteGatewayRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1532,13 +1511,11 @@ def test_delete_gateway( with mock.patch.object(type(client.transport.delete_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteGatewayRequest() # Establish that the response is the type that we expect. @@ -1553,7 +1530,7 @@ def test_delete_gateway_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1561,7 +1538,6 @@ def test_delete_gateway_empty_call(): client.delete_gateway() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteGatewayRequest() @@ -1570,7 +1546,7 @@ async def test_delete_gateway_async( transport: str = "grpc_asyncio", request_type=apigateway.DeleteGatewayRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1583,13 +1559,11 @@ async def test_delete_gateway_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_gateway(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteGatewayRequest() # Establish that the response is the type that we expect. @@ -1602,17 +1576,17 @@ async def test_delete_gateway_async_from_dict(): def test_delete_gateway_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.DeleteGatewayRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_gateway), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1628,12 +1602,13 @@ def test_delete_gateway_field_headers(): @pytest.mark.asyncio async def test_delete_gateway_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.DeleteGatewayRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1641,7 +1616,6 @@ async def test_delete_gateway_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_gateway(request) # Establish that the underlying gRPC stub method was called. @@ -1655,13 +1629,12 @@ async def test_delete_gateway_field_headers_async(): def test_delete_gateway_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_gateway), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_gateway(name="name_value",) @@ -1670,12 +1643,11 @@ def test_delete_gateway_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_gateway_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1688,7 +1660,7 @@ def test_delete_gateway_flattened_error(): @pytest.mark.asyncio async def test_delete_gateway_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1707,14 +1679,13 @@ async def test_delete_gateway_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_gateway_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1727,7 +1698,7 @@ async def test_delete_gateway_flattened_error_async(): def test_list_apis(transport: str = "grpc", request_type=apigateway.ListApisRequest): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1741,21 +1712,16 @@ def test_list_apis(transport: str = "grpc", request_type=apigateway.ListApisRequ next_page_token="next_page_token_value", unreachable_locations=["unreachable_locations_value"], ) - response = client.list_apis(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApisRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListApisPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -1767,7 +1733,7 @@ def test_list_apis_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1775,7 +1741,6 @@ def test_list_apis_empty_call(): client.list_apis() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApisRequest() @@ -1784,7 +1749,7 @@ async def test_list_apis_async( transport: str = "grpc_asyncio", request_type=apigateway.ListApisRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1800,20 +1765,16 @@ async def test_list_apis_async( unreachable_locations=["unreachable_locations_value"], ) ) - response = await client.list_apis(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApisRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListApisAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -1823,17 +1784,17 @@ async def test_list_apis_async_from_dict(): def test_list_apis_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.ListApisRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_apis), "__call__") as call: call.return_value = apigateway.ListApisResponse() - client.list_apis(request) # Establish that the underlying gRPC stub method was called. @@ -1849,12 +1810,13 @@ def test_list_apis_field_headers(): @pytest.mark.asyncio async def test_list_apis_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.ListApisRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1862,7 +1824,6 @@ async def test_list_apis_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( apigateway.ListApisResponse() ) - await client.list_apis(request) # Establish that the underlying gRPC stub method was called. @@ -1876,13 +1837,12 @@ async def test_list_apis_field_headers_async(): def test_list_apis_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_apis), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.ListApisResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_apis(parent="parent_value",) @@ -1891,12 +1851,11 @@ def test_list_apis_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_apis_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1909,7 +1868,7 @@ def test_list_apis_flattened_error(): @pytest.mark.asyncio async def test_list_apis_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1928,14 +1887,13 @@ async def test_list_apis_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_apis_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1947,7 +1905,7 @@ async def test_list_apis_flattened_error_async(): def test_list_apis_pager(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_apis), "__call__") as call: @@ -1979,7 +1937,7 @@ def test_list_apis_pager(): def test_list_apis_pages(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_apis), "__call__") as call: @@ -2003,7 +1961,9 @@ def test_list_apis_pages(): @pytest.mark.asyncio async def test_list_apis_async_pager(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2034,7 +1994,9 @@ async def test_list_apis_async_pager(): @pytest.mark.asyncio async def test_list_apis_async_pages(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2062,7 +2024,7 @@ async def test_list_apis_async_pages(): def test_get_api(transport: str = "grpc", request_type=apigateway.GetApiRequest): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2078,25 +2040,18 @@ def test_get_api(transport: str = "grpc", request_type=apigateway.GetApiRequest) managed_service="managed_service_value", state=apigateway.Api.State.CREATING, ) - response = client.get_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiRequest() # Establish that the response is the type that we expect. - assert isinstance(response, apigateway.Api) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.managed_service == "managed_service_value" - assert response.state == apigateway.Api.State.CREATING @@ -2108,7 +2063,7 @@ def test_get_api_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2116,7 +2071,6 @@ def test_get_api_empty_call(): client.get_api() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiRequest() @@ -2125,7 +2079,7 @@ async def test_get_api_async( transport: str = "grpc_asyncio", request_type=apigateway.GetApiRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2143,24 +2097,18 @@ async def test_get_api_async( state=apigateway.Api.State.CREATING, ) ) - response = await client.get_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiRequest() # Establish that the response is the type that we expect. assert isinstance(response, apigateway.Api) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.managed_service == "managed_service_value" - assert response.state == apigateway.Api.State.CREATING @@ -2170,17 +2118,17 @@ async def test_get_api_async_from_dict(): def test_get_api_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.GetApiRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_api), "__call__") as call: call.return_value = apigateway.Api() - client.get_api(request) # Establish that the underlying gRPC stub method was called. @@ -2196,18 +2144,18 @@ def test_get_api_field_headers(): @pytest.mark.asyncio async def test_get_api_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.GetApiRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_api), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(apigateway.Api()) - await client.get_api(request) # Establish that the underlying gRPC stub method was called. @@ -2221,13 +2169,12 @@ async def test_get_api_field_headers_async(): def test_get_api_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.Api() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_api(name="name_value",) @@ -2236,12 +2183,11 @@ def test_get_api_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_api_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2254,7 +2200,7 @@ def test_get_api_flattened_error(): @pytest.mark.asyncio async def test_get_api_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2271,14 +2217,13 @@ async def test_get_api_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_api_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2291,7 +2236,7 @@ async def test_get_api_flattened_error_async(): def test_create_api(transport: str = "grpc", request_type=apigateway.CreateApiRequest): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2302,13 +2247,11 @@ def test_create_api(transport: str = "grpc", request_type=apigateway.CreateApiRe with mock.patch.object(type(client.transport.create_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiRequest() # Establish that the response is the type that we expect. @@ -2323,7 +2266,7 @@ def test_create_api_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2331,7 +2274,6 @@ def test_create_api_empty_call(): client.create_api() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiRequest() @@ -2340,7 +2282,7 @@ async def test_create_api_async( transport: str = "grpc_asyncio", request_type=apigateway.CreateApiRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2353,13 +2295,11 @@ async def test_create_api_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiRequest() # Establish that the response is the type that we expect. @@ -2372,17 +2312,17 @@ async def test_create_api_async_from_dict(): def test_create_api_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.CreateApiRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_api), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_api(request) # Establish that the underlying gRPC stub method was called. @@ -2398,12 +2338,13 @@ def test_create_api_field_headers(): @pytest.mark.asyncio async def test_create_api_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.CreateApiRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2411,7 +2352,6 @@ async def test_create_api_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_api(request) # Establish that the underlying gRPC stub method was called. @@ -2425,13 +2365,12 @@ async def test_create_api_field_headers_async(): def test_create_api_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_api( @@ -2444,16 +2383,13 @@ def test_create_api_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].api == apigateway.Api(name="name_value") - assert args[0].api_id == "api_id_value" def test_create_api_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2469,7 +2405,7 @@ def test_create_api_flattened_error(): @pytest.mark.asyncio async def test_create_api_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2492,18 +2428,15 @@ async def test_create_api_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].api == apigateway.Api(name="name_value") - assert args[0].api_id == "api_id_value" @pytest.mark.asyncio async def test_create_api_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2519,7 +2452,7 @@ async def test_create_api_flattened_error_async(): def test_update_api(transport: str = "grpc", request_type=apigateway.UpdateApiRequest): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2530,13 +2463,11 @@ def test_update_api(transport: str = "grpc", request_type=apigateway.UpdateApiRe with mock.patch.object(type(client.transport.update_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiRequest() # Establish that the response is the type that we expect. @@ -2551,7 +2482,7 @@ def test_update_api_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2559,7 +2490,6 @@ def test_update_api_empty_call(): client.update_api() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiRequest() @@ -2568,7 +2498,7 @@ async def test_update_api_async( transport: str = "grpc_asyncio", request_type=apigateway.UpdateApiRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2581,13 +2511,11 @@ async def test_update_api_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiRequest() # Establish that the response is the type that we expect. @@ -2600,17 +2528,17 @@ async def test_update_api_async_from_dict(): def test_update_api_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.UpdateApiRequest() + request.api.name = "api.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_api), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_api(request) # Establish that the underlying gRPC stub method was called. @@ -2626,12 +2554,13 @@ def test_update_api_field_headers(): @pytest.mark.asyncio async def test_update_api_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.UpdateApiRequest() + request.api.name = "api.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2639,7 +2568,6 @@ async def test_update_api_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_api(request) # Establish that the underlying gRPC stub method was called. @@ -2653,32 +2581,29 @@ async def test_update_api_field_headers_async(): def test_update_api_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_api( api=apigateway.Api(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].api == apigateway.Api(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_api_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2686,14 +2611,14 @@ def test_update_api_flattened_error(): client.update_api( apigateway.UpdateApiRequest(), api=apigateway.Api(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_api_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2708,23 +2633,21 @@ async def test_update_api_flattened_async(): # using the keyword arguments to the method. response = await client.update_api( api=apigateway.Api(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].api == apigateway.Api(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_api_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2733,13 +2656,13 @@ async def test_update_api_flattened_error_async(): await client.update_api( apigateway.UpdateApiRequest(), api=apigateway.Api(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) def test_delete_api(transport: str = "grpc", request_type=apigateway.DeleteApiRequest): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2750,13 +2673,11 @@ def test_delete_api(transport: str = "grpc", request_type=apigateway.DeleteApiRe with mock.patch.object(type(client.transport.delete_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiRequest() # Establish that the response is the type that we expect. @@ -2771,7 +2692,7 @@ def test_delete_api_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2779,7 +2700,6 @@ def test_delete_api_empty_call(): client.delete_api() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiRequest() @@ -2788,7 +2708,7 @@ async def test_delete_api_async( transport: str = "grpc_asyncio", request_type=apigateway.DeleteApiRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2801,13 +2721,11 @@ async def test_delete_api_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_api(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiRequest() # Establish that the response is the type that we expect. @@ -2820,17 +2738,17 @@ async def test_delete_api_async_from_dict(): def test_delete_api_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.DeleteApiRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_api), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_api(request) # Establish that the underlying gRPC stub method was called. @@ -2846,12 +2764,13 @@ def test_delete_api_field_headers(): @pytest.mark.asyncio async def test_delete_api_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.DeleteApiRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2859,7 +2778,6 @@ async def test_delete_api_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_api(request) # Establish that the underlying gRPC stub method was called. @@ -2873,13 +2791,12 @@ async def test_delete_api_field_headers_async(): def test_delete_api_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_api), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_api(name="name_value",) @@ -2888,12 +2805,11 @@ def test_delete_api_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_api_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2906,7 +2822,7 @@ def test_delete_api_flattened_error(): @pytest.mark.asyncio async def test_delete_api_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2925,14 +2841,13 @@ async def test_delete_api_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_api_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2947,7 +2862,7 @@ def test_list_api_configs( transport: str = "grpc", request_type=apigateway.ListApiConfigsRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2961,21 +2876,16 @@ def test_list_api_configs( next_page_token="next_page_token_value", unreachable_locations=["unreachable_locations_value"], ) - response = client.list_api_configs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApiConfigsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListApiConfigsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -2987,7 +2897,7 @@ def test_list_api_configs_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2995,7 +2905,6 @@ def test_list_api_configs_empty_call(): client.list_api_configs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApiConfigsRequest() @@ -3004,7 +2913,7 @@ async def test_list_api_configs_async( transport: str = "grpc_asyncio", request_type=apigateway.ListApiConfigsRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3020,20 +2929,16 @@ async def test_list_api_configs_async( unreachable_locations=["unreachable_locations_value"], ) ) - response = await client.list_api_configs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.ListApiConfigsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListApiConfigsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable_locations == ["unreachable_locations_value"] @@ -3043,17 +2948,17 @@ async def test_list_api_configs_async_from_dict(): def test_list_api_configs_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.ListApiConfigsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_api_configs), "__call__") as call: call.return_value = apigateway.ListApiConfigsResponse() - client.list_api_configs(request) # Establish that the underlying gRPC stub method was called. @@ -3069,12 +2974,13 @@ def test_list_api_configs_field_headers(): @pytest.mark.asyncio async def test_list_api_configs_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.ListApiConfigsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3082,7 +2988,6 @@ async def test_list_api_configs_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( apigateway.ListApiConfigsResponse() ) - await client.list_api_configs(request) # Establish that the underlying gRPC stub method was called. @@ -3096,13 +3001,12 @@ async def test_list_api_configs_field_headers_async(): def test_list_api_configs_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_api_configs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.ListApiConfigsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_api_configs(parent="parent_value",) @@ -3111,12 +3015,11 @@ def test_list_api_configs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_api_configs_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3129,7 +3032,7 @@ def test_list_api_configs_flattened_error(): @pytest.mark.asyncio async def test_list_api_configs_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3148,14 +3051,13 @@ async def test_list_api_configs_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_api_configs_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3167,7 +3069,7 @@ async def test_list_api_configs_flattened_error_async(): def test_list_api_configs_pager(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_api_configs), "__call__") as call: @@ -3205,7 +3107,7 @@ def test_list_api_configs_pager(): def test_list_api_configs_pages(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_api_configs), "__call__") as call: @@ -3235,7 +3137,9 @@ def test_list_api_configs_pages(): @pytest.mark.asyncio async def test_list_api_configs_async_pager(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3272,7 +3176,9 @@ async def test_list_api_configs_async_pager(): @pytest.mark.asyncio async def test_list_api_configs_async_pages(): - client = ApiGatewayServiceAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ApiGatewayServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3308,7 +3214,7 @@ def test_get_api_config( transport: str = "grpc", request_type=apigateway.GetApiConfigRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3325,27 +3231,19 @@ def test_get_api_config( service_config_id="service_config_id_value", state=apigateway.ApiConfig.State.CREATING, ) - response = client.get_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, apigateway.ApiConfig) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.gateway_service_account == "gateway_service_account_value" - assert response.service_config_id == "service_config_id_value" - assert response.state == apigateway.ApiConfig.State.CREATING @@ -3357,7 +3255,7 @@ def test_get_api_config_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3365,7 +3263,6 @@ def test_get_api_config_empty_call(): client.get_api_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiConfigRequest() @@ -3374,7 +3271,7 @@ async def test_get_api_config_async( transport: str = "grpc_asyncio", request_type=apigateway.GetApiConfigRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3393,26 +3290,19 @@ async def test_get_api_config_async( state=apigateway.ApiConfig.State.CREATING, ) ) - response = await client.get_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.GetApiConfigRequest() # Establish that the response is the type that we expect. assert isinstance(response, apigateway.ApiConfig) - assert response.name == "name_value" - assert response.display_name == "display_name_value" - assert response.gateway_service_account == "gateway_service_account_value" - assert response.service_config_id == "service_config_id_value" - assert response.state == apigateway.ApiConfig.State.CREATING @@ -3422,17 +3312,17 @@ async def test_get_api_config_async_from_dict(): def test_get_api_config_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.GetApiConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_api_config), "__call__") as call: call.return_value = apigateway.ApiConfig() - client.get_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3448,12 +3338,13 @@ def test_get_api_config_field_headers(): @pytest.mark.asyncio async def test_get_api_config_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.GetApiConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3461,7 +3352,6 @@ async def test_get_api_config_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( apigateway.ApiConfig() ) - await client.get_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3475,13 +3365,12 @@ async def test_get_api_config_field_headers_async(): def test_get_api_config_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_api_config), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = apigateway.ApiConfig() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_api_config(name="name_value",) @@ -3490,12 +3379,11 @@ def test_get_api_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_api_config_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3508,7 +3396,7 @@ def test_get_api_config_flattened_error(): @pytest.mark.asyncio async def test_get_api_config_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3527,14 +3415,13 @@ async def test_get_api_config_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_api_config_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3549,7 +3436,7 @@ def test_create_api_config( transport: str = "grpc", request_type=apigateway.CreateApiConfigRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3562,13 +3449,11 @@ def test_create_api_config( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiConfigRequest() # Establish that the response is the type that we expect. @@ -3583,7 +3468,7 @@ def test_create_api_config_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3593,7 +3478,6 @@ def test_create_api_config_empty_call(): client.create_api_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiConfigRequest() @@ -3602,7 +3486,7 @@ async def test_create_api_config_async( transport: str = "grpc_asyncio", request_type=apigateway.CreateApiConfigRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3617,13 +3501,11 @@ async def test_create_api_config_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.CreateApiConfigRequest() # Establish that the response is the type that we expect. @@ -3636,11 +3518,12 @@ async def test_create_api_config_async_from_dict(): def test_create_api_config_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.CreateApiConfigRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3648,7 +3531,6 @@ def test_create_api_config_field_headers(): type(client.transport.create_api_config), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3664,12 +3546,13 @@ def test_create_api_config_field_headers(): @pytest.mark.asyncio async def test_create_api_config_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.CreateApiConfigRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3679,7 +3562,6 @@ async def test_create_api_config_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3693,7 +3575,7 @@ async def test_create_api_config_field_headers_async(): def test_create_api_config_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3701,7 +3583,6 @@ def test_create_api_config_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_api_config( @@ -3714,16 +3595,13 @@ def test_create_api_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].api_config == apigateway.ApiConfig(name="name_value") - assert args[0].api_config_id == "api_config_id_value" def test_create_api_config_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3739,7 +3617,7 @@ def test_create_api_config_flattened_error(): @pytest.mark.asyncio async def test_create_api_config_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3764,18 +3642,15 @@ async def test_create_api_config_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].api_config == apigateway.ApiConfig(name="name_value") - assert args[0].api_config_id == "api_config_id_value" @pytest.mark.asyncio async def test_create_api_config_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3793,7 +3668,7 @@ def test_update_api_config( transport: str = "grpc", request_type=apigateway.UpdateApiConfigRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3806,13 +3681,11 @@ def test_update_api_config( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiConfigRequest() # Establish that the response is the type that we expect. @@ -3827,7 +3700,7 @@ def test_update_api_config_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3837,7 +3710,6 @@ def test_update_api_config_empty_call(): client.update_api_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiConfigRequest() @@ -3846,7 +3718,7 @@ async def test_update_api_config_async( transport: str = "grpc_asyncio", request_type=apigateway.UpdateApiConfigRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3861,13 +3733,11 @@ async def test_update_api_config_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.UpdateApiConfigRequest() # Establish that the response is the type that we expect. @@ -3880,11 +3750,12 @@ async def test_update_api_config_async_from_dict(): def test_update_api_config_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.UpdateApiConfigRequest() + request.api_config.name = "api_config.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3892,7 +3763,6 @@ def test_update_api_config_field_headers(): type(client.transport.update_api_config), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3910,12 +3780,13 @@ def test_update_api_config_field_headers(): @pytest.mark.asyncio async def test_update_api_config_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.UpdateApiConfigRequest() + request.api_config.name = "api_config.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3925,7 +3796,6 @@ async def test_update_api_config_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -3941,7 +3811,7 @@ async def test_update_api_config_field_headers_async(): def test_update_api_config_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3949,26 +3819,23 @@ def test_update_api_config_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_api_config( api_config=apigateway.ApiConfig(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].api_config == apigateway.ApiConfig(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_api_config_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3976,14 +3843,14 @@ def test_update_api_config_flattened_error(): client.update_api_config( apigateway.UpdateApiConfigRequest(), api_config=apigateway.ApiConfig(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_api_config_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4000,23 +3867,21 @@ async def test_update_api_config_flattened_async(): # using the keyword arguments to the method. response = await client.update_api_config( api_config=apigateway.ApiConfig(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].api_config == apigateway.ApiConfig(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_api_config_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4025,7 +3890,7 @@ async def test_update_api_config_flattened_error_async(): await client.update_api_config( apigateway.UpdateApiConfigRequest(), api_config=apigateway.ApiConfig(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -4033,7 +3898,7 @@ def test_delete_api_config( transport: str = "grpc", request_type=apigateway.DeleteApiConfigRequest ): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4046,13 +3911,11 @@ def test_delete_api_config( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiConfigRequest() # Establish that the response is the type that we expect. @@ -4067,7 +3930,7 @@ def test_delete_api_config_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 = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4077,7 +3940,6 @@ def test_delete_api_config_empty_call(): client.delete_api_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiConfigRequest() @@ -4086,7 +3948,7 @@ async def test_delete_api_config_async( transport: str = "grpc_asyncio", request_type=apigateway.DeleteApiConfigRequest ): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4101,13 +3963,11 @@ async def test_delete_api_config_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_api_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == apigateway.DeleteApiConfigRequest() # Establish that the response is the type that we expect. @@ -4120,11 +3980,12 @@ async def test_delete_api_config_async_from_dict(): def test_delete_api_config_field_headers(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(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 = apigateway.DeleteApiConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4132,7 +3993,6 @@ def test_delete_api_config_field_headers(): type(client.transport.delete_api_config), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -4148,12 +4008,13 @@ def test_delete_api_config_field_headers(): @pytest.mark.asyncio async def test_delete_api_config_field_headers_async(): client = ApiGatewayServiceAsyncClient( - 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 = apigateway.DeleteApiConfigRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -4163,7 +4024,6 @@ async def test_delete_api_config_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_api_config(request) # Establish that the underlying gRPC stub method was called. @@ -4177,7 +4037,7 @@ async def test_delete_api_config_field_headers_async(): def test_delete_api_config_flattened(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4185,7 +4045,6 @@ def test_delete_api_config_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_api_config(name="name_value",) @@ -4194,12 +4053,11 @@ def test_delete_api_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_api_config_flattened_error(): - client = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4212,7 +4070,7 @@ def test_delete_api_config_flattened_error(): @pytest.mark.asyncio async def test_delete_api_config_flattened_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4233,14 +4091,13 @@ async def test_delete_api_config_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_api_config_flattened_error_async(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -4254,16 +4111,16 @@ async def test_delete_api_config_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ApiGatewayServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ApiGatewayServiceClient( - 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.ApiGatewayServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ApiGatewayServiceClient( @@ -4273,7 +4130,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ApiGatewayServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ApiGatewayServiceClient( @@ -4284,7 +4141,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ApiGatewayServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ApiGatewayServiceClient(transport=transport) assert client.transport is transport @@ -4293,13 +4150,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ApiGatewayServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ApiGatewayServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -4314,23 +4171,23 @@ 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 = ApiGatewayServiceClient(credentials=credentials.AnonymousCredentials(),) + client = ApiGatewayServiceClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.ApiGatewayServiceGrpcTransport,) def test_api_gateway_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.ApiGatewayServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -4342,7 +4199,7 @@ def test_api_gateway_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ApiGatewayServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -4374,15 +4231,37 @@ def test_api_gateway_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_api_gateway_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.apigateway_v1.services.api_gateway_service.transports.ApiGatewayServiceTransport._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.ApiGatewayServiceTransport( + 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/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_api_gateway_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.apigateway_v1.services.api_gateway_service.transports.ApiGatewayServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ApiGatewayServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -4395,19 +4274,33 @@ def test_api_gateway_service_base_transport_with_credentials_file(): def test_api_gateway_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.apigateway_v1.services.api_gateway_service.transports.ApiGatewayServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ApiGatewayServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_api_gateway_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) + ApiGatewayServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_api_gateway_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) ApiGatewayServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -4415,20 +4308,156 @@ def test_api_gateway_service_auth_adc(): ) -def test_api_gateway_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ApiGatewayServiceGrpcTransport, + transports.ApiGatewayServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_api_gateway_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.ApiGatewayServiceGrpcTransport( - 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/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ApiGatewayServiceGrpcTransport, + transports.ApiGatewayServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_api_gateway_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ApiGatewayServiceGrpcTransport, grpc_helpers), + (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_api_gateway_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( + "apigateway.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="apigateway.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.ApiGatewayServiceGrpcTransport, grpc_helpers), + (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_api_gateway_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( + "apigateway.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("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.ApiGatewayServiceGrpcTransport, grpc_helpers), + (transports.ApiGatewayServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_api_gateway_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( + "apigateway.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", [ @@ -4439,7 +4468,7 @@ def test_api_gateway_service_transport_auth_adc(): def test_api_gateway_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: @@ -4478,7 +4507,7 @@ def test_api_gateway_service_grpc_transport_client_cert_source_for_mtls( def test_api_gateway_service_host_no_port(): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="apigateway.googleapis.com" ), @@ -4488,7 +4517,7 @@ def test_api_gateway_service_host_no_port(): def test_api_gateway_service_host_with_port(): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="apigateway.googleapis.com:8000" ), @@ -4544,9 +4573,9 @@ def test_api_gateway_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", @@ -4622,7 +4651,7 @@ def test_api_gateway_service_transport_channel_mtls_with_adc(transport_class): def test_api_gateway_service_grpc_lro_client(): client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -4635,7 +4664,7 @@ def test_api_gateway_service_grpc_lro_client(): def test_api_gateway_service_grpc_lro_async_client(): client = ApiGatewayServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -4649,7 +4678,6 @@ def test_api_gateway_service_grpc_lro_async_client(): def test_api_path(): project = "squid" api = "clam" - expected = "projects/{project}/locations/global/apis/{api}".format( project=project, api=api, ) @@ -4673,7 +4701,6 @@ def test_api_config_path(): project = "oyster" api = "nudibranch" api_config = "cuttlefish" - expected = "projects/{project}/locations/global/apis/{api}/configs/{api_config}".format( project=project, api=api, api_config=api_config, ) @@ -4698,7 +4725,6 @@ def test_gateway_path(): project = "scallop" location = "abalone" gateway = "squid" - expected = "projects/{project}/locations/{location}/gateways/{gateway}".format( project=project, location=location, gateway=gateway, ) @@ -4721,7 +4747,6 @@ def test_parse_gateway_path(): def test_managed_service_path(): service = "oyster" - expected = "services/{service}".format(service=service,) actual = ApiGatewayServiceClient.managed_service_path(service) assert expected == actual @@ -4741,7 +4766,6 @@ def test_parse_managed_service_path(): def test_service_path(): service = "cuttlefish" config = "mussel" - expected = "services/{service}/configs/{config}".format( service=service, config=config, ) @@ -4764,7 +4788,6 @@ def test_parse_service_path(): def test_service_account_path(): project = "scallop" service_account = "abalone" - expected = "projects/{project}/serviceAccounts/{service_account}".format( project=project, service_account=service_account, ) @@ -4786,7 +4809,6 @@ def test_parse_service_account_path(): def test_common_billing_account_path(): billing_account = "whelk" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4807,7 +4829,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) actual = ApiGatewayServiceClient.common_folder_path(folder) assert expected == actual @@ -4826,7 +4847,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) actual = ApiGatewayServiceClient.common_organization_path(organization) assert expected == actual @@ -4845,7 +4865,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) actual = ApiGatewayServiceClient.common_project_path(project) assert expected == actual @@ -4865,7 +4884,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "scallop" location = "abalone" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -4892,7 +4910,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ApiGatewayServiceTransport, "_prep_wrapped_messages" ) as prep: client = ApiGatewayServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4901,6 +4919,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ApiGatewayServiceClient.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)