diff --git a/.flake8 b/.flake8 index 29227d4..2e43874 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..757c9dc 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000..311ebbb --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000..41bff0b --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 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. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e..6def37a 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb..238b87b 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a7..46d2371 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 87fec32..9a80534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog -### [1.1.1](https://github.com/googleapis/python-ids/compare/v1.1.0...v1.1.1) (2022-03-05) +## [1.1.2](https://github.com/googleapis/python-ids/compare/v1.1.1...v1.1.2) (2022-06-03) + + +### Bug Fixes + +* **deps:** require protobuf <4.0.0dev ([#52](https://github.com/googleapis/python-ids/issues/52)) ([cde8a52](https://github.com/googleapis/python-ids/commit/cde8a52a5152df0d7f2858ab4733769a024eb9aa)) + + +### Documentation + +* fix changelog header to consistent size ([#51](https://github.com/googleapis/python-ids/issues/51)) ([24267af](https://github.com/googleapis/python-ids/commit/24267afe4003f33c2f7505ac69c23f352136c55a)) + +## [1.1.1](https://github.com/googleapis/python-ids/compare/v1.1.0...v1.1.1) (2022-03-05) ### Bug Fixes diff --git a/docs/conf.py b/docs/conf.py index 69b6e85..c18ce65 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-ids", "google-cloud-ids Documentation", [author], 1,) + ( + root_doc, + "google-cloud-ids", + "google-cloud-ids Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/ids/__init__.py b/google/cloud/ids/__init__.py index 29f06cd..92bb4b8 100644 --- a/google/cloud/ids/__init__.py +++ b/google/cloud/ids/__init__.py @@ -14,16 +14,17 @@ # limitations under the License. # -from google.cloud.ids_v1.services.ids.client import IDSClient from google.cloud.ids_v1.services.ids.async_client import IDSAsyncClient - -from google.cloud.ids_v1.types.ids import CreateEndpointRequest -from google.cloud.ids_v1.types.ids import DeleteEndpointRequest -from google.cloud.ids_v1.types.ids import Endpoint -from google.cloud.ids_v1.types.ids import GetEndpointRequest -from google.cloud.ids_v1.types.ids import ListEndpointsRequest -from google.cloud.ids_v1.types.ids import ListEndpointsResponse -from google.cloud.ids_v1.types.ids import OperationMetadata +from google.cloud.ids_v1.services.ids.client import IDSClient +from google.cloud.ids_v1.types.ids import ( + CreateEndpointRequest, + DeleteEndpointRequest, + Endpoint, + GetEndpointRequest, + ListEndpointsRequest, + ListEndpointsResponse, + OperationMetadata, +) __all__ = ( "IDSClient", diff --git a/google/cloud/ids_v1/__init__.py b/google/cloud/ids_v1/__init__.py index 2319491..3be1628 100644 --- a/google/cloud/ids_v1/__init__.py +++ b/google/cloud/ids_v1/__init__.py @@ -14,16 +14,16 @@ # limitations under the License. # -from .services.ids import IDSClient -from .services.ids import IDSAsyncClient - -from .types.ids import CreateEndpointRequest -from .types.ids import DeleteEndpointRequest -from .types.ids import Endpoint -from .types.ids import GetEndpointRequest -from .types.ids import ListEndpointsRequest -from .types.ids import ListEndpointsResponse -from .types.ids import OperationMetadata +from .services.ids import IDSAsyncClient, IDSClient +from .types.ids import ( + CreateEndpointRequest, + DeleteEndpointRequest, + Endpoint, + GetEndpointRequest, + ListEndpointsRequest, + ListEndpointsResponse, + OperationMetadata, +) __all__ = ( "IDSAsyncClient", diff --git a/google/cloud/ids_v1/services/ids/__init__.py b/google/cloud/ids_v1/services/ids/__init__.py index 9ea6261..a1ea5e1 100644 --- a/google/cloud/ids_v1/services/ids/__init__.py +++ b/google/cloud/ids_v1/services/ids/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import IDSClient from .async_client import IDSAsyncClient +from .client import IDSClient __all__ = ( "IDSClient", diff --git a/google/cloud/ids_v1/services/ids/async_client.py b/google/cloud/ids_v1/services/ids/async_client.py index 7032bc8..0a19a8a 100644 --- a/google/cloud/ids_v1/services/ids/async_client.py +++ b/google/cloud/ids_v1/services/ids/async_client.py @@ -16,15 +16,15 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -33,13 +33,15 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.ids_v1.services.ids import pagers -from google.cloud.ids_v1.types import ids from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import IDSTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import IDSGrpcAsyncIOTransport + +from google.cloud.ids_v1.services.ids import pagers +from google.cloud.ids_v1.types import ids + from .client import IDSClient +from .transports.base import DEFAULT_CLIENT_INFO, IDSTransport +from .transports.grpc_asyncio import IDSGrpcAsyncIOTransport class IDSAsyncClient: @@ -211,9 +213,9 @@ async def list_endpoints( from google.cloud import ids_v1 - def sample_list_endpoints(): + async def sample_list_endpoints(): # Create a client - client = ids_v1.IDSClient() + client = ids_v1.IDSAsyncClient() # Initialize request argument(s) request = ids_v1.ListEndpointsRequest( @@ -224,7 +226,7 @@ def sample_list_endpoints(): page_result = client.list_endpoints(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -291,12 +293,20 @@ def sample_list_endpoints(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListEndpointsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -317,9 +327,9 @@ async def get_endpoint( from google.cloud import ids_v1 - def sample_get_endpoint(): + async def sample_get_endpoint(): # Create a client - client = ids_v1.IDSClient() + client = ids_v1.IDSAsyncClient() # Initialize request argument(s) request = ids_v1.GetEndpointRequest( @@ -327,7 +337,7 @@ def sample_get_endpoint(): ) # Make the request - response = client.get_endpoint(request=request) + response = await client.get_endpoint(request=request) # Handle the response print(response) @@ -397,7 +407,12 @@ def sample_get_endpoint(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -416,14 +431,13 @@ async def create_endpoint( r"""Creates a new Endpoint in a given project and location. - .. code-block:: python from google.cloud import ids_v1 - def sample_create_endpoint(): + async def sample_create_endpoint(): # Create a client - client = ids_v1.IDSClient() + client = ids_v1.IDSAsyncClient() # Initialize request argument(s) endpoint = ids_v1.Endpoint() @@ -441,7 +455,7 @@ def sample_create_endpoint(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -520,7 +534,12 @@ def sample_create_endpoint(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -548,9 +567,9 @@ async def delete_endpoint( from google.cloud import ids_v1 - def sample_delete_endpoint(): + async def sample_delete_endpoint(): # Create a client - client = ids_v1.IDSClient() + client = ids_v1.IDSAsyncClient() # Initialize request argument(s) request = ids_v1.DeleteEndpointRequest( @@ -562,7 +581,7 @@ def sample_delete_endpoint(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -634,7 +653,12 @@ def sample_delete_endpoint(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -656,7 +680,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-ids",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-ids", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/ids_v1/services/ids/client.py b/google/cloud/ids_v1/services/ids/client.py index 565a7f0..2e138b1 100644 --- a/google/cloud/ids_v1/services/ids/client.py +++ b/google/cloud/ids_v1/services/ids/client.py @@ -16,18 +16,18 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # 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 from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] @@ -36,11 +36,13 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.ids_v1.services.ids import pagers -from google.cloud.ids_v1.types import ids from google.protobuf import empty_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import IDSTransport, DEFAULT_CLIENT_INFO + +from google.cloud.ids_v1.services.ids import pagers +from google.cloud.ids_v1.types import ids + +from .transports.base import DEFAULT_CLIENT_INFO, IDSTransport from .transports.grpc import IDSGrpcTransport from .transports.grpc_asyncio import IDSGrpcAsyncIOTransport @@ -57,7 +59,10 @@ class IDSClientMeta(type): _transport_registry["grpc"] = IDSGrpcTransport _transport_registry["grpc_asyncio"] = IDSGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[IDSTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[IDSTransport]: """Returns an appropriate transport class. Args: @@ -162,10 +167,16 @@ def transport(self) -> IDSTransport: return self._transport @staticmethod - def endpoint_path(project: str, location: str, endpoint: str,) -> str: + def endpoint_path( + project: str, + location: str, + endpoint: str, + ) -> str: """Returns a fully-qualified endpoint string.""" return "projects/{project}/locations/{location}/endpoints/{endpoint}".format( - project=project, location=location, endpoint=endpoint, + project=project, + location=location, + endpoint=endpoint, ) @staticmethod @@ -178,7 +189,9 @@ def parse_endpoint_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -191,9 +204,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -202,9 +219,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -213,9 +234,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -224,10 +249,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -487,12 +516,20 @@ def sample_list_endpoints(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListEndpointsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -584,7 +621,12 @@ def sample_get_endpoint(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -603,7 +645,6 @@ def create_endpoint( r"""Creates a new Endpoint in a given project and location. - .. code-block:: python from google.cloud import ids_v1 @@ -707,7 +748,12 @@ def sample_create_endpoint(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -821,7 +867,12 @@ def sample_delete_endpoint(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -850,7 +901,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-ids",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-ids", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/ids_v1/services/ids/pagers.py b/google/cloud/ids_v1/services/ids/pagers.py index fdaa82c..5b79e97 100644 --- a/google/cloud/ids_v1/services/ids/pagers.py +++ b/google/cloud/ids_v1/services/ids/pagers.py @@ -18,10 +18,10 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) from google.cloud.ids_v1.types import ids diff --git a/google/cloud/ids_v1/services/ids/transports/__init__.py b/google/cloud/ids_v1/services/ids/transports/__init__.py index 2a1ade5..a6aa114 100644 --- a/google/cloud/ids_v1/services/ids/transports/__init__.py +++ b/google/cloud/ids_v1/services/ids/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import IDSGrpcTransport from .grpc_asyncio import IDSGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[IDSTransport]] _transport_registry["grpc"] = IDSGrpcTransport diff --git a/google/cloud/ids_v1/services/ids/transports/base.py b/google/cloud/ids_v1/services/ids/transports/base.py index 4d89d42..c09fef1 100644 --- a/google/cloud/ids_v1/services/ids/transports/base.py +++ b/google/cloud/ids_v1/services/ids/transports/base.py @@ -15,23 +15,24 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, operations_v1 from google.api_core import retry as retries -from google.api_core import operations_v1 +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.longrunning import operations_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources from google.cloud.ids_v1.types import ids -from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-ids",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-ids", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -80,6 +81,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -149,19 +151,23 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_endpoint: gapic_v1.method.wrap_method( - self.create_endpoint, default_timeout=3600.0, client_info=client_info, + self.create_endpoint, + default_timeout=3600.0, + client_info=client_info, ), self.delete_endpoint: gapic_v1.method.wrap_method( - self.delete_endpoint, default_timeout=3600.0, client_info=client_info, + self.delete_endpoint, + default_timeout=3600.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -205,5 +211,9 @@ def delete_endpoint( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("IDSTransport",) diff --git a/google/cloud/ids_v1/services/ids/transports/grpc.py b/google/cloud/ids_v1/services/ids/transports/grpc.py index 50b64b2..8be6bb8 100644 --- a/google/cloud/ids_v1/services/ids/transports/grpc.py +++ b/google/cloud/ids_v1/services/ids/transports/grpc.py @@ -13,21 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import operations_v1 -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers, operations_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from google.cloud.ids_v1.types import ids -from google.longrunning import operations_pb2 # type: ignore -from .base import IDSTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IDSTransport class IDSGrpcTransport(IDSTransport): @@ -227,8 +225,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -351,5 +348,9 @@ def delete_endpoint( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("IDSGrpcTransport",) diff --git a/google/cloud/ids_v1/services/ids/transports/grpc_asyncio.py b/google/cloud/ids_v1/services/ids/transports/grpc_asyncio.py index 9982b83..4f7d55f 100644 --- a/google/cloud/ids_v1/services/ids/transports/grpc_asyncio.py +++ b/google/cloud/ids_v1/services/ids/transports/grpc_asyncio.py @@ -13,21 +13,19 @@ # 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, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.api_core import operations_v1 +from google.api_core import gapic_v1, grpc_helpers_async, operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.longrunning import operations_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.ids_v1.types import ids -from google.longrunning import operations_pb2 # type: ignore -from .base import IDSTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, IDSTransport from .grpc import IDSGrpcTransport diff --git a/google/cloud/ids_v1/types/ids.py b/google/cloud/ids_v1/types/ids.py index 88b9a85..459e6bf 100644 --- a/google/cloud/ids_v1/types/ids.py +++ b/google/cloud/ids_v1/types/ids.py @@ -13,10 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - from google.protobuf import timestamp_pb2 # type: ignore - +import proto # type: ignore __protobuf__ = proto.module( package="google.cloud.ids.v1", @@ -43,7 +41,7 @@ class Endpoint(proto.Message): Output only. The create time timestamp. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time timestamp. - labels (Sequence[google.cloud.ids_v1.types.Endpoint.LabelsEntry]): + labels (Mapping[str, str]): The labels of the endpoint. network (str): Required. The fully qualified URL of the @@ -82,17 +80,55 @@ class State(proto.Enum): READY = 2 DELETING = 3 - 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,) - network = proto.Field(proto.STRING, number=5,) - endpoint_forwarding_rule = proto.Field(proto.STRING, number=6,) - endpoint_ip = proto.Field(proto.STRING, number=7,) - description = proto.Field(proto.STRING, number=8,) - severity = proto.Field(proto.ENUM, number=9, enum=Severity,) - state = proto.Field(proto.ENUM, number=12, enum=State,) - traffic_logs = proto.Field(proto.BOOL, number=13,) + 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, + ) + network = proto.Field( + proto.STRING, + number=5, + ) + endpoint_forwarding_rule = proto.Field( + proto.STRING, + number=6, + ) + endpoint_ip = proto.Field( + proto.STRING, + number=7, + ) + description = proto.Field( + proto.STRING, + number=8, + ) + severity = proto.Field( + proto.ENUM, + number=9, + enum=Severity, + ) + state = proto.Field( + proto.ENUM, + number=12, + enum=State, + ) + traffic_logs = proto.Field( + proto.BOOL, + number=13, + ) class ListEndpointsRequest(proto.Message): @@ -124,11 +160,26 @@ class ListEndpointsRequest(proto.Message): https://google.aip.dev/132#ordering. """ - 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 ListEndpointsResponse(proto.Message): @@ -149,9 +200,19 @@ class ListEndpointsResponse(proto.Message): def raw_page(self): return self - endpoints = proto.RepeatedField(proto.MESSAGE, number=1, message="Endpoint",) - next_page_token = proto.Field(proto.STRING, number=2,) - unreachable = proto.RepeatedField(proto.STRING, number=3,) + endpoints = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Endpoint", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, + ) class GetEndpointRequest(proto.Message): @@ -163,7 +224,10 @@ class GetEndpointRequest(proto.Message): ``projects/{project}/locations/{location}/endpoints/{endpoint}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class CreateEndpointRequest(proto.Message): @@ -201,10 +265,23 @@ class CreateEndpointRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - parent = proto.Field(proto.STRING, number=1,) - endpoint_id = proto.Field(proto.STRING, number=2,) - endpoint = proto.Field(proto.MESSAGE, number=3, message="Endpoint",) - request_id = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + endpoint_id = proto.Field( + proto.STRING, + number=2, + ) + endpoint = proto.Field( + proto.MESSAGE, + number=3, + message="Endpoint", + ) + request_id = proto.Field( + proto.STRING, + number=4, + ) class DeleteEndpointRequest(proto.Message): @@ -233,8 +310,14 @@ class DeleteEndpointRequest(proto.Message): (00000000-0000-0000-0000-000000000000). """ - name = proto.Field(proto.STRING, number=1,) - request_id = proto.Field(proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=1, + ) + request_id = proto.Field( + proto.STRING, + number=2, + ) class OperationMetadata(proto.Message): @@ -267,13 +350,36 @@ class OperationMetadata(proto.Message): operation. """ - 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,) + 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, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..7c1742d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,19 +17,45 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +83,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +95,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +127,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +185,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +236,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/samples/generated_samples/snippet_metadata_ids_v1.json b/samples/generated_samples/snippet_metadata_ids_v1.json index 593eb88..1d4dc9e 100644 --- a/samples/generated_samples/snippet_metadata_ids_v1.json +++ b/samples/generated_samples/snippet_metadata_ids_v1.json @@ -1,16 +1,69 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.ids.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-ids" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.ids_v1.IDSAsyncClient", + "shortName": "IDSAsyncClient" + }, + "fullName": "google.cloud.ids_v1.IDSAsyncClient.create_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.CreateEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "CreateEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.CreateEndpointRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "endpoint", + "type": "google.cloud.ids_v1.types.Endpoint" + }, + { + "name": "endpoint_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_endpoint" }, + "description": "Sample for CreateEndpoint", "file": "ids_v1_generated_ids_create_endpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_CreateEndpoint_async", "segments": [ { @@ -43,18 +96,62 @@ "start": 52, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_create_endpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.ids_v1.IDSClient", + "shortName": "IDSClient" + }, + "fullName": "google.cloud.ids_v1.IDSClient.create_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.CreateEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "CreateEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.CreateEndpointRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "endpoint", + "type": "google.cloud.ids_v1.types.Endpoint" + }, + { + "name": "endpoint_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_endpoint" }, + "description": "Sample for CreateEndpoint", "file": "ids_v1_generated_ids_create_endpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_CreateEndpoint_sync", "segments": [ { @@ -87,19 +184,55 @@ "start": 52, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_create_endpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.ids_v1.IDSAsyncClient", + "shortName": "IDSAsyncClient" + }, + "fullName": "google.cloud.ids_v1.IDSAsyncClient.delete_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.DeleteEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "DeleteEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.DeleteEndpointRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_endpoint" }, + "description": "Sample for DeleteEndpoint", "file": "ids_v1_generated_ids_delete_endpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_DeleteEndpoint_async", "segments": [ { @@ -132,18 +265,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_delete_endpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.ids_v1.IDSClient", + "shortName": "IDSClient" + }, + "fullName": "google.cloud.ids_v1.IDSClient.delete_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.DeleteEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "DeleteEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.DeleteEndpointRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_endpoint" }, + "description": "Sample for DeleteEndpoint", "file": "ids_v1_generated_ids_delete_endpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_DeleteEndpoint_sync", "segments": [ { @@ -176,19 +345,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_delete_endpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.ids_v1.IDSAsyncClient", + "shortName": "IDSAsyncClient" + }, + "fullName": "google.cloud.ids_v1.IDSAsyncClient.get_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.GetEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "GetEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.GetEndpointRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.ids_v1.types.Endpoint", + "shortName": "get_endpoint" }, + "description": "Sample for GetEndpoint", "file": "ids_v1_generated_ids_get_endpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_GetEndpoint_async", "segments": [ { @@ -221,18 +426,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_get_endpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.ids_v1.IDSClient", + "shortName": "IDSClient" + }, + "fullName": "google.cloud.ids_v1.IDSClient.get_endpoint", "method": { + "fullName": "google.cloud.ids.v1.IDS.GetEndpoint", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "GetEndpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.GetEndpointRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.ids_v1.types.Endpoint", + "shortName": "get_endpoint" }, + "description": "Sample for GetEndpoint", "file": "ids_v1_generated_ids_get_endpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_GetEndpoint_sync", "segments": [ { @@ -265,19 +506,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_get_endpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.ids_v1.IDSAsyncClient", + "shortName": "IDSAsyncClient" + }, + "fullName": "google.cloud.ids_v1.IDSAsyncClient.list_endpoints", "method": { + "fullName": "google.cloud.ids.v1.IDS.ListEndpoints", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "ListEndpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.ListEndpointsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.ids_v1.services.ids.pagers.ListEndpointsAsyncPager", + "shortName": "list_endpoints" }, + "description": "Sample for ListEndpoints", "file": "ids_v1_generated_ids_list_endpoints_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_ListEndpoints_async", "segments": [ { @@ -310,18 +587,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_list_endpoints_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.ids_v1.IDSClient", + "shortName": "IDSClient" + }, + "fullName": "google.cloud.ids_v1.IDSClient.list_endpoints", "method": { + "fullName": "google.cloud.ids.v1.IDS.ListEndpoints", "service": { + "fullName": "google.cloud.ids.v1.IDS", "shortName": "IDS" }, "shortName": "ListEndpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.ids_v1.types.ListEndpointsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.ids_v1.services.ids.pagers.ListEndpointsPager", + "shortName": "list_endpoints" }, + "description": "Sample for ListEndpoints", "file": "ids_v1_generated_ids_list_endpoints_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "ids_v1_generated_IDS_ListEndpoints_sync", "segments": [ { @@ -354,7 +667,8 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "ids_v1_generated_ids_list_endpoints_sync.py" } ] } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e..91b5967 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index e4049fd..ad77d5e 100644 --- a/setup.py +++ b/setup.py @@ -19,10 +19,9 @@ import setuptools - name = "google-cloud-ids" description = "Cloud IDS API client library" -version = "1.1.1" +version = "1.1.2" url = "https://github.com/googleapis/python-ids" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ @@ -30,7 +29,8 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "proto-plus >= 1.15.0", + "proto-plus >= 1.15.0, <2.0.0dev", + "protobuf >= 3.19.0, <4.0.0dev", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index be5a64f..786e637 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,3 +6,4 @@ # Then this file should have google-cloud-foo==1.14.0 google-api-core==1.31.5 proto-plus==1.15.0 +protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index e69de29..786e637 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -0,0 +1,9 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.31.5 +proto-plus==1.15.0 +protobuf==3.19.0 diff --git a/tests/unit/gapic/ids_v1/test_ids.py b/tests/unit/gapic/ids_v1/test_ids.py index 00a0ea5..53ca6ce 100644 --- a/tests/unit/gapic/ids_v1/test_ids.py +++ b/tests/unit/gapic/ids_v1/test_ids.py @@ -14,36 +14,46 @@ # limitations under the License. # import os -import mock -import grpc -from grpc.experimental import aio -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock +import math +from google.api_core import ( + future, + gapic_v1, + grpc_helpers, + grpc_helpers_async, + operation, + operations_v1, + path_template, +) from google.api_core import client_options 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 from google.api_core import operation_async # type: ignore -from google.api_core import operations_v1 -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.ids_v1.services.ids import IDSAsyncClient -from google.cloud.ids_v1.services.ids import IDSClient -from google.cloud.ids_v1.services.ids import pagers -from google.cloud.ids_v1.services.ids import transports -from google.cloud.ids_v1.types import ids from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import timestamp_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.ids_v1.services.ids import ( + IDSAsyncClient, + IDSClient, + pagers, + transports, +) +from google.cloud.ids_v1.types import ids def client_cert_source_callback(): @@ -81,19 +91,25 @@ def test__get_default_mtls_endpoint(): assert IDSClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [IDSClient, IDSAsyncClient,]) -def test_ids_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (IDSClient, "grpc"), + (IDSAsyncClient, "grpc_asyncio"), + ], +) +def test_ids_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "ids.googleapis.com:443" + assert client.transport._host == ("ids.googleapis.com:443") @pytest.mark.parametrize( @@ -119,22 +135,32 @@ def test_ids_client_service_account_always_use_jwt(transport_class, transport_na use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [IDSClient, IDSAsyncClient,]) -def test_ids_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (IDSClient, "grpc"), + (IDSAsyncClient, "grpc_asyncio"), + ], +) +def test_ids_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "ids.googleapis.com:443" + assert client.transport._host == ("ids.googleapis.com:443") def test_ids_client_get_transport_class(): @@ -442,7 +468,9 @@ def test_ids_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -570,10 +598,17 @@ def test_ids_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [ids.ListEndpointsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + ids.ListEndpointsRequest, + dict, + ], +) def test_list_endpoints(request_type, transport: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -584,7 +619,8 @@ def test_list_endpoints(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = ids.ListEndpointsResponse( - next_page_token="next_page_token_value", unreachable=["unreachable_value"], + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) response = client.list_endpoints(request) @@ -603,7 +639,8 @@ def test_list_endpoints_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 = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -619,7 +656,8 @@ async def test_list_endpoints_async( transport: str = "grpc_asyncio", request_type=ids.ListEndpointsRequest ): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -654,13 +692,15 @@ async def test_list_endpoints_async_from_dict(): def test_list_endpoints_field_headers(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + 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 = ids.ListEndpointsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -674,18 +714,23 @@ def test_list_endpoints_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_endpoints_field_headers_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + 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 = ids.ListEndpointsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -701,11 +746,16 @@ async def test_list_endpoints_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_endpoints_flattened(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -713,7 +763,9 @@ def test_list_endpoints_flattened(): call.return_value = ids.ListEndpointsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_endpoints(parent="parent_value",) + client.list_endpoints( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -725,19 +777,24 @@ def test_list_endpoints_flattened(): def test_list_endpoints_flattened_error(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_endpoints( - ids.ListEndpointsRequest(), parent="parent_value", + ids.ListEndpointsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_endpoints_flattened_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_endpoints), "__call__") as call: @@ -749,7 +806,9 @@ async def test_list_endpoints_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_endpoints(parent="parent_value",) + response = await client.list_endpoints( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -762,19 +821,23 @@ async def test_list_endpoints_flattened_async(): @pytest.mark.asyncio async def test_list_endpoints_flattened_error_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_endpoints( - ids.ListEndpointsRequest(), parent="parent_value", + ids.ListEndpointsRequest(), + parent="parent_value", ) def test_list_endpoints_pager(transport_name: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -782,14 +845,29 @@ def test_list_endpoints_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(), ids.Endpoint(), ids.Endpoint(),], + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ids.Endpoint(), + ], next_page_token="abc", ), - ids.ListEndpointsResponse(endpoints=[], next_page_token="def",), ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(),], next_page_token="ghi", + endpoints=[], + next_page_token="def", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ], + next_page_token="ghi", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ], ), - ids.ListEndpointsResponse(endpoints=[ids.Endpoint(), ids.Endpoint(),],), RuntimeError, ) @@ -801,14 +879,15 @@ def test_list_endpoints_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, ids.Endpoint) for i in results) def test_list_endpoints_pages(transport_name: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -816,14 +895,29 @@ def test_list_endpoints_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(), ids.Endpoint(), ids.Endpoint(),], + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ids.Endpoint(), + ], next_page_token="abc", ), - ids.ListEndpointsResponse(endpoints=[], next_page_token="def",), ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(),], next_page_token="ghi", + endpoints=[], + next_page_token="def", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ], + next_page_token="ghi", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ], ), - ids.ListEndpointsResponse(endpoints=[ids.Endpoint(), ids.Endpoint(),],), RuntimeError, ) pages = list(client.list_endpoints(request={}).pages) @@ -833,7 +927,9 @@ def test_list_endpoints_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_endpoints_async_pager(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -842,20 +938,37 @@ async def test_list_endpoints_async_pager(): # Set the response to a series of pages. call.side_effect = ( ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(), ids.Endpoint(), ids.Endpoint(),], + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ids.Endpoint(), + ], next_page_token="abc", ), - ids.ListEndpointsResponse(endpoints=[], next_page_token="def",), ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(),], next_page_token="ghi", + endpoints=[], + next_page_token="def", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ], + next_page_token="ghi", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ], ), - ids.ListEndpointsResponse(endpoints=[ids.Endpoint(), ids.Endpoint(),],), RuntimeError, ) - async_pager = await client.list_endpoints(request={},) + async_pager = await client.list_endpoints( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -864,7 +977,9 @@ async def test_list_endpoints_async_pager(): @pytest.mark.asyncio async def test_list_endpoints_async_pages(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -873,27 +988,51 @@ async def test_list_endpoints_async_pages(): # Set the response to a series of pages. call.side_effect = ( ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(), ids.Endpoint(), ids.Endpoint(),], + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ids.Endpoint(), + ], next_page_token="abc", ), - ids.ListEndpointsResponse(endpoints=[], next_page_token="def",), ids.ListEndpointsResponse( - endpoints=[ids.Endpoint(),], next_page_token="ghi", + endpoints=[], + next_page_token="def", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ], + next_page_token="ghi", + ), + ids.ListEndpointsResponse( + endpoints=[ + ids.Endpoint(), + ids.Endpoint(), + ], ), - ids.ListEndpointsResponse(endpoints=[ids.Endpoint(), ids.Endpoint(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_endpoints(request={})).pages: + async for page_ in ( + await client.list_endpoints(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [ids.GetEndpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + ids.GetEndpointRequest, + dict, + ], +) def test_get_endpoint(request_type, transport: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -936,7 +1075,8 @@ def test_get_endpoint_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 = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -952,7 +1092,8 @@ async def test_get_endpoint_async( transport: str = "grpc_asyncio", request_type=ids.GetEndpointRequest ): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -999,13 +1140,15 @@ async def test_get_endpoint_async_from_dict(): def test_get_endpoint_field_headers(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + 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 = ids.GetEndpointRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -1019,18 +1162,23 @@ def test_get_endpoint_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_endpoint_field_headers_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + 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 = ids.GetEndpointRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -1044,11 +1192,16 @@ async def test_get_endpoint_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_endpoint_flattened(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -1056,7 +1209,9 @@ def test_get_endpoint_flattened(): call.return_value = ids.Endpoint() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_endpoint(name="name_value",) + client.get_endpoint( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1068,19 +1223,24 @@ def test_get_endpoint_flattened(): def test_get_endpoint_flattened_error(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_endpoint( - ids.GetEndpointRequest(), name="name_value", + ids.GetEndpointRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_endpoint_flattened_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_endpoint), "__call__") as call: @@ -1090,7 +1250,9 @@ async def test_get_endpoint_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(ids.Endpoint()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_endpoint(name="name_value",) + response = await client.get_endpoint( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1103,20 +1265,30 @@ async def test_get_endpoint_flattened_async(): @pytest.mark.asyncio async def test_get_endpoint_flattened_error_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_endpoint( - ids.GetEndpointRequest(), name="name_value", + ids.GetEndpointRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [ids.CreateEndpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + ids.CreateEndpointRequest, + dict, + ], +) def test_create_endpoint(request_type, transport: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1142,7 +1314,8 @@ def test_create_endpoint_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 = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1158,7 +1331,8 @@ async def test_create_endpoint_async( transport: str = "grpc_asyncio", request_type=ids.CreateEndpointRequest ): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1188,13 +1362,15 @@ async def test_create_endpoint_async_from_dict(): def test_create_endpoint_field_headers(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + 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 = ids.CreateEndpointRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -1208,18 +1384,23 @@ def test_create_endpoint_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_endpoint_field_headers_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + 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 = ids.CreateEndpointRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -1235,11 +1416,16 @@ async def test_create_endpoint_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_endpoint_flattened(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -1269,7 +1455,9 @@ def test_create_endpoint_flattened(): def test_create_endpoint_flattened_error(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1284,7 +1472,9 @@ def test_create_endpoint_flattened_error(): @pytest.mark.asyncio async def test_create_endpoint_flattened_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_endpoint), "__call__") as call: @@ -1319,7 +1509,9 @@ async def test_create_endpoint_flattened_async(): @pytest.mark.asyncio async def test_create_endpoint_flattened_error_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1332,10 +1524,17 @@ async def test_create_endpoint_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [ids.DeleteEndpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + ids.DeleteEndpointRequest, + dict, + ], +) def test_delete_endpoint(request_type, transport: str = "grpc"): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1361,7 +1560,8 @@ def test_delete_endpoint_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 = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1377,7 +1577,8 @@ async def test_delete_endpoint_async( transport: str = "grpc_asyncio", request_type=ids.DeleteEndpointRequest ): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1407,13 +1608,15 @@ async def test_delete_endpoint_async_from_dict(): def test_delete_endpoint_field_headers(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + 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 = ids.DeleteEndpointRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1427,18 +1630,23 @@ def test_delete_endpoint_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_endpoint_field_headers_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + 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 = ids.DeleteEndpointRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1454,11 +1662,16 @@ async def test_delete_endpoint_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_endpoint_flattened(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1466,7 +1679,9 @@ def test_delete_endpoint_flattened(): 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_endpoint(name="name_value",) + client.delete_endpoint( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1478,19 +1693,24 @@ def test_delete_endpoint_flattened(): def test_delete_endpoint_flattened_error(): - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_endpoint( - ids.DeleteEndpointRequest(), name="name_value", + ids.DeleteEndpointRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_endpoint_flattened_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_endpoint), "__call__") as call: @@ -1502,7 +1722,9 @@ async def test_delete_endpoint_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_endpoint(name="name_value",) + response = await client.delete_endpoint( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1515,13 +1737,16 @@ async def test_delete_endpoint_flattened_async(): @pytest.mark.asyncio async def test_delete_endpoint_flattened_error_async(): - client = IDSAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = IDSAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_endpoint( - ids.DeleteEndpointRequest(), name="name_value", + ids.DeleteEndpointRequest(), + name="name_value", ) @@ -1532,7 +1757,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1552,7 +1778,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = IDSClient(client_options=options, transport=transport,) + client = IDSClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1567,7 +1796,10 @@ def test_credentials_transport_error(): credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): - client = IDSClient(client_options={"scopes": ["1", "2"]}, transport=transport,) + client = IDSClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) def test_transport_instance(): @@ -1596,7 +1828,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.IDSGrpcTransport, transports.IDSGrpcAsyncIOTransport,], + [ + transports.IDSGrpcTransport, + transports.IDSGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -1606,10 +1841,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = IDSClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = IDSClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.IDSGrpcTransport,) + client = IDSClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.IDSGrpcTransport, + ) def test_ids_base_transport_error(): @@ -1651,6 +1904,14 @@ def test_ids_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_ids_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1662,7 +1923,8 @@ def test_ids_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.IDSTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1697,7 +1959,10 @@ def test_ids_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.IDSGrpcTransport, transports.IDSGrpcAsyncIOTransport,], + [ + transports.IDSGrpcTransport, + transports.IDSGrpcAsyncIOTransport, + ], ) def test_ids_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -1788,29 +2053,48 @@ def test_ids_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_ids_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_ids_host_no_port(transport_name): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="ids.googleapis.com"), + transport=transport_name, ) - assert client.transport._host == "ids.googleapis.com:443" + assert client.transport._host == ("ids.googleapis.com:443") -def test_ids_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_ids_host_with_port(transport_name): client = IDSClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="ids.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "ids.googleapis.com:8000" + assert client.transport._host == ("ids.googleapis.com:8000") def test_ids_grpc_transport_channel(): channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. - transport = transports.IDSGrpcTransport(host="squid.clam.whelk", channel=channel,) + transport = transports.IDSGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" assert transport._ssl_channel_credentials == None @@ -1821,7 +2105,8 @@ def test_ids_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.IDSGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1920,12 +2205,16 @@ def test_ids_transport_channel_mtls_with_adc(transport_class): def test_ids_grpc_lro_client(): client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1933,12 +2222,16 @@ def test_ids_grpc_lro_client(): def test_ids_grpc_lro_async_client(): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -1949,7 +2242,9 @@ def test_endpoint_path(): location = "clam" endpoint = "whelk" expected = "projects/{project}/locations/{location}/endpoints/{endpoint}".format( - project=project, location=location, endpoint=endpoint, + project=project, + location=location, + endpoint=endpoint, ) actual = IDSClient.endpoint_path(project, location, endpoint) assert expected == actual @@ -1990,7 +2285,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = IDSClient.common_folder_path(folder) assert expected == actual @@ -2008,7 +2305,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = IDSClient.common_organization_path(organization) assert expected == actual @@ -2026,7 +2325,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = IDSClient.common_project_path(project) assert expected == actual @@ -2046,7 +2347,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = IDSClient.common_location_path(project, location) assert expected == actual @@ -2069,14 +2371,16 @@ def test_client_with_default_client_info(): with mock.patch.object(transports.IDSTransport, "_prep_wrapped_messages") as prep: client = IDSClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) with mock.patch.object(transports.IDSTransport, "_prep_wrapped_messages") as prep: transport_class = IDSClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2084,7 +2388,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = IDSAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"