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 2f25d9e..5fbe3d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +### [1.3.2](https://github.com/googleapis/python-network-management/compare/v1.3.1...v1.3.2) (2022-05-05) + + +### Documentation + +* fix type in docstring for map fields ([3c71bcc](https://github.com/googleapis/python-network-management/commit/3c71bcc656d1d8a1a916caf4cf0854db48eb460f)) + ### [1.3.1](https://github.com/googleapis/python-network-management/compare/v1.3.0...v1.3.1) (2022-03-05) diff --git a/docs/conf.py b/docs/conf.py index db2ce24..37c3fad 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 @@ -361,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/network_management/__init__.py b/google/cloud/network_management/__init__.py index 3a3a322..8e7cdaa 100644 --- a/google/cloud/network_management/__init__.py +++ b/google/cloud/network_management/__init__.py @@ -14,58 +14,47 @@ # limitations under the License. # -from google.cloud.network_management_v1.services.reachability_service.client import ( - ReachabilityServiceClient, -) from google.cloud.network_management_v1.services.reachability_service.async_client import ( ReachabilityServiceAsyncClient, ) - -from google.cloud.network_management_v1.types.connectivity_test import ConnectivityTest -from google.cloud.network_management_v1.types.connectivity_test import Endpoint +from google.cloud.network_management_v1.services.reachability_service.client import ( + ReachabilityServiceClient, +) from google.cloud.network_management_v1.types.connectivity_test import ( + ConnectivityTest, + Endpoint, ReachabilityDetails, ) from google.cloud.network_management_v1.types.reachability import ( CreateConnectivityTestRequest, -) -from google.cloud.network_management_v1.types.reachability import ( DeleteConnectivityTestRequest, -) -from google.cloud.network_management_v1.types.reachability import ( GetConnectivityTestRequest, -) -from google.cloud.network_management_v1.types.reachability import ( ListConnectivityTestsRequest, -) -from google.cloud.network_management_v1.types.reachability import ( ListConnectivityTestsResponse, -) -from google.cloud.network_management_v1.types.reachability import OperationMetadata -from google.cloud.network_management_v1.types.reachability import ( + OperationMetadata, RerunConnectivityTestRequest, -) -from google.cloud.network_management_v1.types.reachability import ( UpdateConnectivityTestRequest, ) -from google.cloud.network_management_v1.types.trace import AbortInfo -from google.cloud.network_management_v1.types.trace import CloudSQLInstanceInfo -from google.cloud.network_management_v1.types.trace import DeliverInfo -from google.cloud.network_management_v1.types.trace import DropInfo -from google.cloud.network_management_v1.types.trace import EndpointInfo -from google.cloud.network_management_v1.types.trace import FirewallInfo -from google.cloud.network_management_v1.types.trace import ForwardInfo -from google.cloud.network_management_v1.types.trace import ForwardingRuleInfo -from google.cloud.network_management_v1.types.trace import GKEMasterInfo -from google.cloud.network_management_v1.types.trace import InstanceInfo -from google.cloud.network_management_v1.types.trace import LoadBalancerBackend -from google.cloud.network_management_v1.types.trace import LoadBalancerInfo -from google.cloud.network_management_v1.types.trace import NetworkInfo -from google.cloud.network_management_v1.types.trace import RouteInfo -from google.cloud.network_management_v1.types.trace import Step -from google.cloud.network_management_v1.types.trace import Trace -from google.cloud.network_management_v1.types.trace import VpnGatewayInfo -from google.cloud.network_management_v1.types.trace import VpnTunnelInfo +from google.cloud.network_management_v1.types.trace import ( + AbortInfo, + CloudSQLInstanceInfo, + DeliverInfo, + DropInfo, + EndpointInfo, + FirewallInfo, + ForwardInfo, + ForwardingRuleInfo, + GKEMasterInfo, + InstanceInfo, + LoadBalancerBackend, + LoadBalancerInfo, + NetworkInfo, + RouteInfo, + Step, + Trace, + VpnGatewayInfo, + VpnTunnelInfo, +) __all__ = ( "ReachabilityServiceClient", diff --git a/google/cloud/network_management_v1/__init__.py b/google/cloud/network_management_v1/__init__.py index 812333e..6762e83 100644 --- a/google/cloud/network_management_v1/__init__.py +++ b/google/cloud/network_management_v1/__init__.py @@ -14,38 +14,41 @@ # limitations under the License. # -from .services.reachability_service import ReachabilityServiceClient -from .services.reachability_service import ReachabilityServiceAsyncClient - -from .types.connectivity_test import ConnectivityTest -from .types.connectivity_test import Endpoint -from .types.connectivity_test import ReachabilityDetails -from .types.reachability import CreateConnectivityTestRequest -from .types.reachability import DeleteConnectivityTestRequest -from .types.reachability import GetConnectivityTestRequest -from .types.reachability import ListConnectivityTestsRequest -from .types.reachability import ListConnectivityTestsResponse -from .types.reachability import OperationMetadata -from .types.reachability import RerunConnectivityTestRequest -from .types.reachability import UpdateConnectivityTestRequest -from .types.trace import AbortInfo -from .types.trace import CloudSQLInstanceInfo -from .types.trace import DeliverInfo -from .types.trace import DropInfo -from .types.trace import EndpointInfo -from .types.trace import FirewallInfo -from .types.trace import ForwardInfo -from .types.trace import ForwardingRuleInfo -from .types.trace import GKEMasterInfo -from .types.trace import InstanceInfo -from .types.trace import LoadBalancerBackend -from .types.trace import LoadBalancerInfo -from .types.trace import NetworkInfo -from .types.trace import RouteInfo -from .types.trace import Step -from .types.trace import Trace -from .types.trace import VpnGatewayInfo -from .types.trace import VpnTunnelInfo +from .services.reachability_service import ( + ReachabilityServiceAsyncClient, + ReachabilityServiceClient, +) +from .types.connectivity_test import ConnectivityTest, Endpoint, ReachabilityDetails +from .types.reachability import ( + CreateConnectivityTestRequest, + DeleteConnectivityTestRequest, + GetConnectivityTestRequest, + ListConnectivityTestsRequest, + ListConnectivityTestsResponse, + OperationMetadata, + RerunConnectivityTestRequest, + UpdateConnectivityTestRequest, +) +from .types.trace import ( + AbortInfo, + CloudSQLInstanceInfo, + DeliverInfo, + DropInfo, + EndpointInfo, + FirewallInfo, + ForwardInfo, + ForwardingRuleInfo, + GKEMasterInfo, + InstanceInfo, + LoadBalancerBackend, + LoadBalancerInfo, + NetworkInfo, + RouteInfo, + Step, + Trace, + VpnGatewayInfo, + VpnTunnelInfo, +) __all__ = ( "ReachabilityServiceAsyncClient", diff --git a/google/cloud/network_management_v1/services/reachability_service/__init__.py b/google/cloud/network_management_v1/services/reachability_service/__init__.py index 8309358..8185c3e 100644 --- a/google/cloud/network_management_v1/services/reachability_service/__init__.py +++ b/google/cloud/network_management_v1/services/reachability_service/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import ReachabilityServiceClient from .async_client import ReachabilityServiceAsyncClient +from .client import ReachabilityServiceClient __all__ = ( "ReachabilityServiceClient", diff --git a/google/cloud/network_management_v1/services/reachability_service/async_client.py b/google/cloud/network_management_v1/services/reachability_service/async_client.py index 45ec883..6bd205c 100644 --- a/google/cloud/network_management_v1/services/reachability_service/async_client.py +++ b/google/cloud/network_management_v1/services/reachability_service/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,15 +33,16 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.network_management_v1.services.reachability_service import pagers -from google.cloud.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ReachabilityServiceTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import ReachabilityServiceGrpcAsyncIOTransport + +from google.cloud.network_management_v1.services.reachability_service import pagers +from google.cloud.network_management_v1.types import connectivity_test, reachability + from .client import ReachabilityServiceClient +from .transports.base import DEFAULT_CLIENT_INFO, ReachabilityServiceTransport +from .transports.grpc_asyncio import ReachabilityServiceGrpcAsyncIOTransport class ReachabilityServiceAsyncClient: @@ -238,9 +239,9 @@ async def list_connectivity_tests( from google.cloud import network_management_v1 - def sample_list_connectivity_tests(): + async def sample_list_connectivity_tests(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) request = network_management_v1.ListConnectivityTestsRequest( @@ -251,7 +252,7 @@ def sample_list_connectivity_tests(): page_result = client.list_connectivity_tests(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -311,12 +312,20 @@ def sample_list_connectivity_tests(): ) # 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.ListConnectivityTestsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -337,9 +346,9 @@ async def get_connectivity_test( from google.cloud import network_management_v1 - def sample_get_connectivity_test(): + async def sample_get_connectivity_test(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) request = network_management_v1.GetConnectivityTestRequest( @@ -347,7 +356,7 @@ def sample_get_connectivity_test(): ) # Make the request - response = client.get_connectivity_test(request=request) + response = await client.get_connectivity_test(request=request) # Handle the response print(response) @@ -408,7 +417,12 @@ def sample_get_connectivity_test(): ) # 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 @@ -439,14 +453,13 @@ async def create_connectivity_test( AMBIGUOUS. For more information, see the Connectivity Test documentation. - .. code-block:: python from google.cloud import network_management_v1 - def sample_create_connectivity_test(): + async def sample_create_connectivity_test(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) resource = network_management_v1.ConnectivityTest() @@ -463,7 +476,7 @@ def sample_create_connectivity_test(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -549,7 +562,12 @@ def sample_create_connectivity_test(): ) # 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( @@ -589,14 +607,13 @@ async def update_connectivity_test( ``AMBIGUOUS``. See the documentation in ``ConnectivityTest`` for for more details. - .. code-block:: python from google.cloud import network_management_v1 - def sample_update_connectivity_test(): + async def sample_update_connectivity_test(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) resource = network_management_v1.ConnectivityTest() @@ -611,7 +628,7 @@ def sample_update_connectivity_test(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -686,7 +703,12 @@ def sample_update_connectivity_test(): ) # 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( @@ -722,14 +744,13 @@ async def rerun_connectivity_test( configurations of listed projects), then the reachability result returns a value of ``UNKNOWN``. - .. code-block:: python from google.cloud import network_management_v1 - def sample_rerun_connectivity_test(): + async def sample_rerun_connectivity_test(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) request = network_management_v1.RerunConnectivityTestRequest( @@ -741,7 +762,7 @@ def sample_rerun_connectivity_test(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -783,7 +804,12 @@ def sample_rerun_connectivity_test(): ) # 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( @@ -811,9 +837,9 @@ async def delete_connectivity_test( from google.cloud import network_management_v1 - def sample_delete_connectivity_test(): + async def sample_delete_connectivity_test(): # Create a client - client = network_management_v1.ReachabilityServiceClient() + client = network_management_v1.ReachabilityServiceAsyncClient() # Initialize request argument(s) request = network_management_v1.DeleteConnectivityTestRequest( @@ -825,7 +851,7 @@ def sample_delete_connectivity_test(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -899,7 +925,12 @@ def sample_delete_connectivity_test(): ) # 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( diff --git a/google/cloud/network_management_v1/services/reachability_service/client.py b/google/cloud/network_management_v1/services/reachability_service/client.py index 2b69577..162fd03 100644 --- a/google/cloud/network_management_v1/services/reachability_service/client.py +++ b/google/cloud/network_management_v1/services/reachability_service/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,13 +36,14 @@ from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore -from google.cloud.network_management_v1.services.reachability_service import pagers -from google.cloud.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability from google.protobuf import empty_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import ReachabilityServiceTransport, DEFAULT_CLIENT_INFO + +from google.cloud.network_management_v1.services.reachability_service import pagers +from google.cloud.network_management_v1.types import connectivity_test, reachability + +from .transports.base import DEFAULT_CLIENT_INFO, ReachabilityServiceTransport from .transports.grpc import ReachabilityServiceGrpcTransport from .transports.grpc_asyncio import ReachabilityServiceGrpcAsyncIOTransport @@ -62,7 +63,8 @@ class ReachabilityServiceClientMeta(type): _transport_registry["grpc_asyncio"] = ReachabilityServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[ReachabilityServiceTransport]: """Returns an appropriate transport class. @@ -178,10 +180,14 @@ def transport(self) -> ReachabilityServiceTransport: return self._transport @staticmethod - def connectivity_test_path(project: str, test: str,) -> str: + def connectivity_test_path( + project: str, + test: str, + ) -> str: """Returns a fully-qualified connectivity_test string.""" return "projects/{project}/locations/global/connectivityTests/{test}".format( - project=project, test=test, + project=project, + test=test, ) @staticmethod @@ -194,7 +200,9 @@ def parse_connectivity_test_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, @@ -207,9 +215,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]: @@ -218,9 +230,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]: @@ -229,9 +245,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]: @@ -240,10 +260,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 @@ -505,12 +529,20 @@ def sample_list_connectivity_tests(): ) # 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.ListConnectivityTestsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -602,7 +634,12 @@ def sample_get_connectivity_test(): ) # 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 @@ -633,7 +670,6 @@ def create_connectivity_test( AMBIGUOUS. For more information, see the Connectivity Test documentation. - .. code-block:: python from google.cloud import network_management_v1 @@ -743,7 +779,12 @@ def sample_create_connectivity_test(): ) # 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( @@ -783,7 +824,6 @@ def update_connectivity_test( ``AMBIGUOUS``. See the documentation in ``ConnectivityTest`` for for more details. - .. code-block:: python from google.cloud import network_management_v1 @@ -880,7 +920,12 @@ def sample_update_connectivity_test(): ) # 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( @@ -916,7 +961,6 @@ def rerun_connectivity_test( configurations of listed projects), then the reachability result returns a value of ``UNKNOWN``. - .. code-block:: python from google.cloud import network_management_v1 @@ -978,7 +1022,12 @@ def sample_rerun_connectivity_test(): ) # 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( @@ -1094,7 +1143,12 @@ def sample_delete_connectivity_test(): ) # 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( diff --git a/google/cloud/network_management_v1/services/reachability_service/pagers.py b/google/cloud/network_management_v1/services/reachability_service/pagers.py index 6addb4d..25e07f5 100644 --- a/google/cloud/network_management_v1/services/reachability_service/pagers.py +++ b/google/cloud/network_management_v1/services/reachability_service/pagers.py @@ -18,14 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability +from google.cloud.network_management_v1.types import connectivity_test, reachability class ListConnectivityTestsPager: diff --git a/google/cloud/network_management_v1/services/reachability_service/transports/__init__.py b/google/cloud/network_management_v1/services/reachability_service/transports/__init__.py index 64d97d4..96e15b4 100644 --- a/google/cloud/network_management_v1/services/reachability_service/transports/__init__.py +++ b/google/cloud/network_management_v1/services/reachability_service/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import ReachabilityServiceGrpcTransport from .grpc_asyncio import ReachabilityServiceGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = ( OrderedDict() diff --git a/google/cloud/network_management_v1/services/reachability_service/transports/base.py b/google/cloud/network_management_v1/services/reachability_service/transports/base.py index 1aa4b97..e26fc1e 100644 --- a/google/cloud/network_management_v1/services/reachability_service/transports/base.py +++ b/google/cloud/network_management_v1/services/reachability_service/transports/base.py @@ -15,20 +15,18 @@ # 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.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability -from google.longrunning import operations_pb2 # type: ignore +from google.cloud.network_management_v1.types import connectivity_test, reachability try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -83,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" @@ -158,9 +157,9 @@ def _prep_wrapped_messages(self, 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() @@ -229,5 +228,9 @@ def delete_connectivity_test( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("ReachabilityServiceTransport",) diff --git a/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py b/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py index a9ae5a3..edeaceb 100644 --- a/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py +++ b/google/cloud/network_management_v1/services/reachability_service/transports/grpc.py @@ -13,22 +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.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability -from google.longrunning import operations_pb2 # type: ignore -from .base import ReachabilityServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.network_management_v1.types import connectivity_test, reachability + +from .base import DEFAULT_CLIENT_INFO, ReachabilityServiceTransport class ReachabilityServiceGrpcTransport(ReachabilityServiceTransport): @@ -237,8 +234,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 @@ -468,5 +464,9 @@ def delete_connectivity_test( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("ReachabilityServiceGrpcTransport",) diff --git a/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py b/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py index 26e1156..390a1d2 100644 --- a/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py +++ b/google/cloud/network_management_v1/services/reachability_service/transports/grpc_asyncio.py @@ -13,22 +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.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability -from google.longrunning import operations_pb2 # type: ignore -from .base import ReachabilityServiceTransport, DEFAULT_CLIENT_INFO +from google.cloud.network_management_v1.types import connectivity_test, reachability + +from .base import DEFAULT_CLIENT_INFO, ReachabilityServiceTransport from .grpc import ReachabilityServiceGrpcTransport diff --git a/google/cloud/network_management_v1/types/__init__.py b/google/cloud/network_management_v1/types/__init__.py index 0bf48e4..d19cc05 100644 --- a/google/cloud/network_management_v1/types/__init__.py +++ b/google/cloud/network_management_v1/types/__init__.py @@ -13,11 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .connectivity_test import ( - ConnectivityTest, - Endpoint, - ReachabilityDetails, -) +from .connectivity_test import ConnectivityTest, Endpoint, ReachabilityDetails from .reachability import ( CreateConnectivityTestRequest, DeleteConnectivityTestRequest, diff --git a/google/cloud/network_management_v1/types/connectivity_test.py b/google/cloud/network_management_v1/types/connectivity_test.py index 58ff836..d7ee610 100644 --- a/google/cloud/network_management_v1/types/connectivity_test.py +++ b/google/cloud/network_management_v1/types/connectivity_test.py @@ -13,16 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.network_management_v1.types import trace from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +import proto # type: ignore +from google.cloud.network_management_v1.types import trace __protobuf__ = proto.module( package="google.cloud.networkmanagement.v1", - manifest={"ConnectivityTest", "Endpoint", "ReachabilityDetails",}, + manifest={ + "ConnectivityTest", + "Endpoint", + "ReachabilityDetails", + }, ) @@ -98,7 +101,7 @@ class ConnectivityTest(proto.Message): display_name (str): Output only. The display name of a Connectivity Test. - labels (Sequence[google.cloud.network_management_v1.types.ConnectivityTest.LabelsEntry]): + labels (Mapping[str, str]): Resource labels to represent user-provided metadata. create_time (google.protobuf.timestamp_pb2.Timestamp): @@ -114,22 +117,55 @@ class ConnectivityTest(proto.Message): an existing test. """ - name = proto.Field(proto.STRING, number=1,) - description = proto.Field(proto.STRING, number=2,) - source = proto.Field(proto.MESSAGE, number=3, message="Endpoint",) - destination = proto.Field(proto.MESSAGE, number=4, message="Endpoint",) - protocol = proto.Field(proto.STRING, number=5,) - related_projects = proto.RepeatedField(proto.STRING, number=6,) - display_name = proto.Field(proto.STRING, number=7,) - labels = proto.MapField(proto.STRING, proto.STRING, number=8,) + name = proto.Field( + proto.STRING, + number=1, + ) + description = proto.Field( + proto.STRING, + number=2, + ) + source = proto.Field( + proto.MESSAGE, + number=3, + message="Endpoint", + ) + destination = proto.Field( + proto.MESSAGE, + number=4, + message="Endpoint", + ) + protocol = proto.Field( + proto.STRING, + number=5, + ) + related_projects = proto.RepeatedField( + proto.STRING, + number=6, + ) + display_name = proto.Field( + proto.STRING, + number=7, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=8, + ) create_time = proto.Field( - proto.MESSAGE, number=10, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=10, + message=timestamp_pb2.Timestamp, ) update_time = proto.Field( - proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, ) reachability_details = proto.Field( - proto.MESSAGE, number=12, message="ReachabilityDetails", + proto.MESSAGE, + number=12, + message="ReachabilityDetails", ) @@ -182,14 +218,39 @@ class NetworkType(proto.Enum): GCP_NETWORK = 1 NON_GCP_NETWORK = 2 - ip_address = proto.Field(proto.STRING, number=1,) - port = proto.Field(proto.INT32, number=2,) - instance = proto.Field(proto.STRING, number=3,) - gke_master_cluster = proto.Field(proto.STRING, number=7,) - cloud_sql_instance = proto.Field(proto.STRING, number=8,) - network = proto.Field(proto.STRING, number=4,) - network_type = proto.Field(proto.ENUM, number=5, enum=NetworkType,) - project_id = proto.Field(proto.STRING, number=6,) + ip_address = proto.Field( + proto.STRING, + number=1, + ) + port = proto.Field( + proto.INT32, + number=2, + ) + instance = proto.Field( + proto.STRING, + number=3, + ) + gke_master_cluster = proto.Field( + proto.STRING, + number=7, + ) + cloud_sql_instance = proto.Field( + proto.STRING, + number=8, + ) + network = proto.Field( + proto.STRING, + number=4, + ) + network_type = proto.Field( + proto.ENUM, + number=5, + enum=NetworkType, + ) + project_id = proto.Field( + proto.STRING, + number=6, + ) class ReachabilityDetails(proto.Message): @@ -220,10 +281,26 @@ class Result(proto.Enum): AMBIGUOUS = 4 UNDETERMINED = 5 - result = proto.Field(proto.ENUM, number=1, enum=Result,) - verify_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - error = proto.Field(proto.MESSAGE, number=3, message=status_pb2.Status,) - traces = proto.RepeatedField(proto.MESSAGE, number=5, message=trace.Trace,) + result = proto.Field( + proto.ENUM, + number=1, + enum=Result, + ) + verify_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + error = proto.Field( + proto.MESSAGE, + number=3, + message=status_pb2.Status, + ) + traces = proto.RepeatedField( + proto.MESSAGE, + number=5, + message=trace.Trace, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/network_management_v1/types/reachability.py b/google/cloud/network_management_v1/types/reachability.py index 16f02a6..718bc51 100644 --- a/google/cloud/network_management_v1/types/reachability.py +++ b/google/cloud/network_management_v1/types/reachability.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.network_management_v1.types import connectivity_test from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +import proto # type: ignore +from google.cloud.network_management_v1.types import connectivity_test __protobuf__ = proto.module( package="google.cloud.networkmanagement.v1", @@ -72,11 +71,26 @@ class ListConnectivityTestsRequest(proto.Message): Field to use to sort the list. """ - 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 ListConnectivityTestsResponse(proto.Message): @@ -98,10 +112,18 @@ def raw_page(self): return self resources = proto.RepeatedField( - proto.MESSAGE, number=1, message=connectivity_test.ConnectivityTest, + proto.MESSAGE, + number=1, + message=connectivity_test.ConnectivityTest, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) + unreachable = proto.RepeatedField( + proto.STRING, + number=3, ) - next_page_token = proto.Field(proto.STRING, number=2,) - unreachable = proto.RepeatedField(proto.STRING, number=3,) class GetConnectivityTestRequest(proto.Message): @@ -113,7 +135,10 @@ class GetConnectivityTestRequest(proto.Message): ``projects/{project_id}/locations/global/connectivityTests/{test_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class CreateConnectivityTestRequest(proto.Message): @@ -137,10 +162,18 @@ class CreateConnectivityTestRequest(proto.Message): Required. A ``ConnectivityTest`` resource """ - parent = proto.Field(proto.STRING, number=1,) - test_id = proto.Field(proto.STRING, number=2,) + parent = proto.Field( + proto.STRING, + number=1, + ) + test_id = proto.Field( + proto.STRING, + number=2, + ) resource = proto.Field( - proto.MESSAGE, number=3, message=connectivity_test.ConnectivityTest, + proto.MESSAGE, + number=3, + message=connectivity_test.ConnectivityTest, ) @@ -156,10 +189,14 @@ class UpdateConnectivityTestRequest(proto.Message): """ update_mask = proto.Field( - proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, ) resource = proto.Field( - proto.MESSAGE, number=2, message=connectivity_test.ConnectivityTest, + proto.MESSAGE, + number=2, + message=connectivity_test.ConnectivityTest, ) @@ -172,7 +209,10 @@ class DeleteConnectivityTestRequest(proto.Message): ``projects/{project_id}/locations/global/connectivityTests/{test_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class RerunConnectivityTestRequest(proto.Message): @@ -184,7 +224,10 @@ class RerunConnectivityTestRequest(proto.Message): ``projects/{project_id}/locations/global/connectivityTests/{test_id}`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class OperationMetadata(proto.Message): @@ -210,13 +253,36 @@ class OperationMetadata(proto.Message): API version. """ - 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_detail = proto.Field(proto.STRING, number=5,) - cancel_requested = 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_detail = proto.Field( + proto.STRING, + number=5, + ) + cancel_requested = proto.Field( + proto.BOOL, + number=6, + ) + api_version = proto.Field( + proto.STRING, + number=7, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/network_management_v1/types/trace.py b/google/cloud/network_management_v1/types/trace.py index 9344504..3a8259d 100644 --- a/google/cloud/network_management_v1/types/trace.py +++ b/google/cloud/network_management_v1/types/trace.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.networkmanagement.v1", manifest={ @@ -72,8 +71,16 @@ class Trace(proto.Message): and avoid reordering or sorting them. """ - endpoint_info = proto.Field(proto.MESSAGE, number=1, message="EndpointInfo",) - steps = proto.RepeatedField(proto.MESSAGE, number=2, message="Step",) + endpoint_info = proto.Field( + proto.MESSAGE, + number=1, + message="EndpointInfo", + ) + steps = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="Step", + ) class Step(proto.Message): @@ -207,52 +214,112 @@ class State(proto.Enum): ABORT = 19 VIEWER_PERMISSION_MISSING = 20 - description = proto.Field(proto.STRING, number=1,) - state = proto.Field(proto.ENUM, number=2, enum=State,) - causes_drop = proto.Field(proto.BOOL, number=3,) - project_id = proto.Field(proto.STRING, number=4,) + description = proto.Field( + proto.STRING, + number=1, + ) + state = proto.Field( + proto.ENUM, + number=2, + enum=State, + ) + causes_drop = proto.Field( + proto.BOOL, + number=3, + ) + project_id = proto.Field( + proto.STRING, + number=4, + ) instance = proto.Field( - proto.MESSAGE, number=5, oneof="step_info", message="InstanceInfo", + proto.MESSAGE, + number=5, + oneof="step_info", + message="InstanceInfo", ) firewall = proto.Field( - proto.MESSAGE, number=6, oneof="step_info", message="FirewallInfo", + proto.MESSAGE, + number=6, + oneof="step_info", + message="FirewallInfo", ) route = proto.Field( - proto.MESSAGE, number=7, oneof="step_info", message="RouteInfo", + proto.MESSAGE, + number=7, + oneof="step_info", + message="RouteInfo", ) endpoint = proto.Field( - proto.MESSAGE, number=8, oneof="step_info", message="EndpointInfo", + proto.MESSAGE, + number=8, + oneof="step_info", + message="EndpointInfo", ) forwarding_rule = proto.Field( - proto.MESSAGE, number=9, oneof="step_info", message="ForwardingRuleInfo", + proto.MESSAGE, + number=9, + oneof="step_info", + message="ForwardingRuleInfo", ) vpn_gateway = proto.Field( - proto.MESSAGE, number=10, oneof="step_info", message="VpnGatewayInfo", + proto.MESSAGE, + number=10, + oneof="step_info", + message="VpnGatewayInfo", ) vpn_tunnel = proto.Field( - proto.MESSAGE, number=11, oneof="step_info", message="VpnTunnelInfo", + proto.MESSAGE, + number=11, + oneof="step_info", + message="VpnTunnelInfo", ) deliver = proto.Field( - proto.MESSAGE, number=12, oneof="step_info", message="DeliverInfo", + proto.MESSAGE, + number=12, + oneof="step_info", + message="DeliverInfo", ) forward = proto.Field( - proto.MESSAGE, number=13, oneof="step_info", message="ForwardInfo", + proto.MESSAGE, + number=13, + oneof="step_info", + message="ForwardInfo", ) abort = proto.Field( - proto.MESSAGE, number=14, oneof="step_info", message="AbortInfo", + proto.MESSAGE, + number=14, + oneof="step_info", + message="AbortInfo", + ) + drop = proto.Field( + proto.MESSAGE, + number=15, + oneof="step_info", + message="DropInfo", ) - drop = proto.Field(proto.MESSAGE, number=15, oneof="step_info", message="DropInfo",) load_balancer = proto.Field( - proto.MESSAGE, number=16, oneof="step_info", message="LoadBalancerInfo", + proto.MESSAGE, + number=16, + oneof="step_info", + message="LoadBalancerInfo", ) network = proto.Field( - proto.MESSAGE, number=17, oneof="step_info", message="NetworkInfo", + proto.MESSAGE, + number=17, + oneof="step_info", + message="NetworkInfo", ) gke_master = proto.Field( - proto.MESSAGE, number=18, oneof="step_info", message="GKEMasterInfo", + proto.MESSAGE, + number=18, + oneof="step_info", + message="GKEMasterInfo", ) cloud_sql_instance = proto.Field( - proto.MESSAGE, number=19, oneof="step_info", message="CloudSQLInstanceInfo", + proto.MESSAGE, + number=19, + oneof="step_info", + message="CloudSQLInstanceInfo", ) @@ -280,14 +347,38 @@ class InstanceInfo(proto.Message): Service account authorized for the instance. """ - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - interface = proto.Field(proto.STRING, number=3,) - network_uri = proto.Field(proto.STRING, number=4,) - internal_ip = proto.Field(proto.STRING, number=5,) - external_ip = proto.Field(proto.STRING, number=6,) - network_tags = proto.RepeatedField(proto.STRING, number=7,) - service_account = proto.Field(proto.STRING, number=8,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + interface = proto.Field( + proto.STRING, + number=3, + ) + network_uri = proto.Field( + proto.STRING, + number=4, + ) + internal_ip = proto.Field( + proto.STRING, + number=5, + ) + external_ip = proto.Field( + proto.STRING, + number=6, + ) + network_tags = proto.RepeatedField( + proto.STRING, + number=7, + ) + service_account = proto.Field( + proto.STRING, + number=8, + ) class NetworkInfo(proto.Message): @@ -303,9 +394,18 @@ class NetworkInfo(proto.Message): The IP range that matches the test. """ - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - matched_ip_range = proto.Field(proto.STRING, number=4,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + matched_ip_range = proto.Field( + proto.STRING, + number=4, + ) class FirewallInfo(proto.Message): @@ -355,16 +455,47 @@ class FirewallRuleType(proto.Enum): VPC_FIREWALL_RULE = 2 IMPLIED_VPC_FIREWALL_RULE = 3 - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - direction = proto.Field(proto.STRING, number=3,) - action = proto.Field(proto.STRING, number=4,) - priority = proto.Field(proto.INT32, number=5,) - network_uri = proto.Field(proto.STRING, number=6,) - target_tags = proto.RepeatedField(proto.STRING, number=7,) - target_service_accounts = proto.RepeatedField(proto.STRING, number=8,) - policy = proto.Field(proto.STRING, number=9,) - firewall_rule_type = proto.Field(proto.ENUM, number=10, enum=FirewallRuleType,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + direction = proto.Field( + proto.STRING, + number=3, + ) + action = proto.Field( + proto.STRING, + number=4, + ) + priority = proto.Field( + proto.INT32, + number=5, + ) + network_uri = proto.Field( + proto.STRING, + number=6, + ) + target_tags = proto.RepeatedField( + proto.STRING, + number=7, + ) + target_service_accounts = proto.RepeatedField( + proto.STRING, + number=8, + ) + policy = proto.Field( + proto.STRING, + number=9, + ) + firewall_rule_type = proto.Field( + proto.ENUM, + number=10, + enum=FirewallRuleType, + ) class RouteInfo(proto.Message): @@ -419,15 +550,44 @@ class NextHopType(proto.Enum): NEXT_HOP_BLACKHOLE = 9 NEXT_HOP_ILB = 10 - route_type = proto.Field(proto.ENUM, number=8, enum=RouteType,) - next_hop_type = proto.Field(proto.ENUM, number=9, enum=NextHopType,) - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - dest_ip_range = proto.Field(proto.STRING, number=3,) - next_hop = proto.Field(proto.STRING, number=4,) - network_uri = proto.Field(proto.STRING, number=5,) - priority = proto.Field(proto.INT32, number=6,) - instance_tags = proto.RepeatedField(proto.STRING, number=7,) + route_type = proto.Field( + proto.ENUM, + number=8, + enum=RouteType, + ) + next_hop_type = proto.Field( + proto.ENUM, + number=9, + enum=NextHopType, + ) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + dest_ip_range = proto.Field( + proto.STRING, + number=3, + ) + next_hop = proto.Field( + proto.STRING, + number=4, + ) + network_uri = proto.Field( + proto.STRING, + number=5, + ) + priority = proto.Field( + proto.INT32, + number=6, + ) + instance_tags = proto.RepeatedField( + proto.STRING, + number=7, + ) class ForwardingRuleInfo(proto.Message): @@ -454,13 +614,34 @@ class ForwardingRuleInfo(proto.Message): Balancer. """ - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - matched_protocol = proto.Field(proto.STRING, number=3,) - matched_port_range = proto.Field(proto.STRING, number=6,) - vip = proto.Field(proto.STRING, number=4,) - target = proto.Field(proto.STRING, number=5,) - network_uri = proto.Field(proto.STRING, number=7,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + matched_protocol = proto.Field( + proto.STRING, + number=3, + ) + matched_port_range = proto.Field( + proto.STRING, + number=6, + ) + vip = proto.Field( + proto.STRING, + number=4, + ) + target = proto.Field( + proto.STRING, + number=5, + ) + network_uri = proto.Field( + proto.STRING, + number=7, + ) class LoadBalancerInfo(proto.Message): @@ -498,13 +679,29 @@ class BackendType(proto.Enum): BACKEND_SERVICE = 1 TARGET_POOL = 2 - load_balancer_type = proto.Field(proto.ENUM, number=1, enum=LoadBalancerType,) - health_check_uri = proto.Field(proto.STRING, number=2,) + load_balancer_type = proto.Field( + proto.ENUM, + number=1, + enum=LoadBalancerType, + ) + health_check_uri = proto.Field( + proto.STRING, + number=2, + ) backends = proto.RepeatedField( - proto.MESSAGE, number=3, message="LoadBalancerBackend", + proto.MESSAGE, + number=3, + message="LoadBalancerBackend", + ) + backend_type = proto.Field( + proto.ENUM, + number=4, + enum=BackendType, + ) + backend_uri = proto.Field( + proto.STRING, + number=5, ) - backend_type = proto.Field(proto.ENUM, number=4, enum=BackendType,) - backend_uri = proto.Field(proto.STRING, number=5,) class LoadBalancerBackend(proto.Message): @@ -535,13 +732,27 @@ class HealthCheckFirewallState(proto.Enum): CONFIGURED = 1 MISCONFIGURED = 2 - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) health_check_firewall_state = proto.Field( - proto.ENUM, number=3, enum=HealthCheckFirewallState, + proto.ENUM, + number=3, + enum=HealthCheckFirewallState, + ) + health_check_allowing_firewall_rules = proto.RepeatedField( + proto.STRING, + number=4, + ) + health_check_blocking_firewall_rules = proto.RepeatedField( + proto.STRING, + number=5, ) - health_check_allowing_firewall_rules = proto.RepeatedField(proto.STRING, number=4,) - health_check_blocking_firewall_rules = proto.RepeatedField(proto.STRING, number=5,) class VpnGatewayInfo(proto.Message): @@ -568,12 +779,30 @@ class VpnGatewayInfo(proto.Message): gateway is configured. """ - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - network_uri = proto.Field(proto.STRING, number=3,) - ip_address = proto.Field(proto.STRING, number=4,) - vpn_tunnel_uri = proto.Field(proto.STRING, number=5,) - region = proto.Field(proto.STRING, number=6,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + network_uri = proto.Field( + proto.STRING, + number=3, + ) + ip_address = proto.Field( + proto.STRING, + number=4, + ) + vpn_tunnel_uri = proto.Field( + proto.STRING, + number=5, + ) + region = proto.Field( + proto.STRING, + number=6, + ) class VpnTunnelInfo(proto.Message): @@ -615,15 +844,43 @@ class RoutingType(proto.Enum): POLICY_BASED = 2 DYNAMIC = 3 - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - source_gateway = proto.Field(proto.STRING, number=3,) - remote_gateway = proto.Field(proto.STRING, number=4,) - remote_gateway_ip = proto.Field(proto.STRING, number=5,) - source_gateway_ip = proto.Field(proto.STRING, number=6,) - network_uri = proto.Field(proto.STRING, number=7,) - region = proto.Field(proto.STRING, number=8,) - routing_type = proto.Field(proto.ENUM, number=9, enum=RoutingType,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + source_gateway = proto.Field( + proto.STRING, + number=3, + ) + remote_gateway = proto.Field( + proto.STRING, + number=4, + ) + remote_gateway_ip = proto.Field( + proto.STRING, + number=5, + ) + source_gateway_ip = proto.Field( + proto.STRING, + number=6, + ) + network_uri = proto.Field( + proto.STRING, + number=7, + ) + region = proto.Field( + proto.STRING, + number=8, + ) + routing_type = proto.Field( + proto.ENUM, + number=9, + enum=RoutingType, + ) class EndpointInfo(proto.Message): @@ -653,13 +910,34 @@ class EndpointInfo(proto.Message): to. """ - source_ip = proto.Field(proto.STRING, number=1,) - destination_ip = proto.Field(proto.STRING, number=2,) - protocol = proto.Field(proto.STRING, number=3,) - source_port = proto.Field(proto.INT32, number=4,) - destination_port = proto.Field(proto.INT32, number=5,) - source_network_uri = proto.Field(proto.STRING, number=6,) - destination_network_uri = proto.Field(proto.STRING, number=7,) + source_ip = proto.Field( + proto.STRING, + number=1, + ) + destination_ip = proto.Field( + proto.STRING, + number=2, + ) + protocol = proto.Field( + proto.STRING, + number=3, + ) + source_port = proto.Field( + proto.INT32, + number=4, + ) + destination_port = proto.Field( + proto.INT32, + number=5, + ) + source_network_uri = proto.Field( + proto.STRING, + number=6, + ) + destination_network_uri = proto.Field( + proto.STRING, + number=7, + ) class DeliverInfo(proto.Message): @@ -682,8 +960,15 @@ class Target(proto.Enum): GKE_MASTER = 4 CLOUD_SQL_INSTANCE = 5 - target = proto.Field(proto.ENUM, number=1, enum=Target,) - resource_uri = proto.Field(proto.STRING, number=2,) + target = proto.Field( + proto.ENUM, + number=1, + enum=Target, + ) + resource_uri = proto.Field( + proto.STRING, + number=2, + ) class ForwardInfo(proto.Message): @@ -708,8 +993,15 @@ class Target(proto.Enum): IMPORTED_CUSTOM_ROUTE_NEXT_HOP = 5 CLOUD_SQL_INSTANCE = 6 - target = proto.Field(proto.ENUM, number=1, enum=Target,) - resource_uri = proto.Field(proto.STRING, number=2,) + target = proto.Field( + proto.ENUM, + number=1, + enum=Target, + ) + resource_uri = proto.Field( + proto.STRING, + number=2, + ) class AbortInfo(proto.Message): @@ -740,8 +1032,15 @@ class Cause(proto.Enum): DESTINATION_ENDPOINT_NOT_FOUND = 13 MISMATCHED_DESTINATION_NETWORK = 14 - cause = proto.Field(proto.ENUM, number=1, enum=Cause,) - resource_uri = proto.Field(proto.STRING, number=2,) + cause = proto.Field( + proto.ENUM, + number=1, + enum=Cause, + ) + resource_uri = proto.Field( + proto.STRING, + number=2, + ) class DropInfo(proto.Message): @@ -779,8 +1078,15 @@ class Cause(proto.Enum): GOOGLE_MANAGED_SERVICE_NO_PEERING = 20 CLOUD_SQL_INSTANCE_NO_IP_ADDRESS = 21 - cause = proto.Field(proto.ENUM, number=1, enum=Cause,) - resource_uri = proto.Field(proto.STRING, number=2,) + cause = proto.Field( + proto.ENUM, + number=1, + enum=Cause, + ) + resource_uri = proto.Field( + proto.STRING, + number=2, + ) class GKEMasterInfo(proto.Message): @@ -798,10 +1104,22 @@ class GKEMasterInfo(proto.Message): External IP address of a GKE cluster master. """ - cluster_uri = proto.Field(proto.STRING, number=2,) - cluster_network_uri = proto.Field(proto.STRING, number=4,) - internal_ip = proto.Field(proto.STRING, number=5,) - external_ip = proto.Field(proto.STRING, number=6,) + cluster_uri = proto.Field( + proto.STRING, + number=2, + ) + cluster_network_uri = proto.Field( + proto.STRING, + number=4, + ) + internal_ip = proto.Field( + proto.STRING, + number=5, + ) + external_ip = proto.Field( + proto.STRING, + number=6, + ) class CloudSQLInstanceInfo(proto.Message): @@ -825,12 +1143,30 @@ class CloudSQLInstanceInfo(proto.Message): running. """ - display_name = proto.Field(proto.STRING, number=1,) - uri = proto.Field(proto.STRING, number=2,) - network_uri = proto.Field(proto.STRING, number=4,) - internal_ip = proto.Field(proto.STRING, number=5,) - external_ip = proto.Field(proto.STRING, number=6,) - region = proto.Field(proto.STRING, number=7,) + display_name = proto.Field( + proto.STRING, + number=1, + ) + uri = proto.Field( + proto.STRING, + number=2, + ) + network_uri = proto.Field( + proto.STRING, + number=4, + ) + internal_ip = proto.Field( + proto.STRING, + number=5, + ) + external_ip = proto.Field( + proto.STRING, + number=6, + ) + region = 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_network management_v1.json b/samples/generated_samples/snippet_metadata_network management_v1.json index 8eee9c4..96cf835 100644 --- a/samples/generated_samples/snippet_metadata_network management_v1.json +++ b/samples/generated_samples/snippet_metadata_network management_v1.json @@ -1,16 +1,69 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.networkmanagement.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-network-management" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.create_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.CreateConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "CreateConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.CreateConnectivityTestRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "test_id", + "type": "str" + }, + { + "name": "resource", + "type": "google.cloud.network_management_v1.types.ConnectivityTest" + }, + { + "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_connectivity_test" }, + "description": "Sample for CreateConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_create_connectivity_test_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_async", "segments": [ { @@ -43,18 +96,62 @@ "start": 51, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_create_connectivity_test_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.create_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.CreateConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "CreateConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.CreateConnectivityTestRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "test_id", + "type": "str" + }, + { + "name": "resource", + "type": "google.cloud.network_management_v1.types.ConnectivityTest" + }, + { + "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_connectivity_test" }, + "description": "Sample for CreateConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_create_connectivity_test_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_CreateConnectivityTest_sync", "segments": [ { @@ -87,19 +184,55 @@ "start": 51, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_create_connectivity_test_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.delete_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.DeleteConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "DeleteConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.DeleteConnectivityTestRequest" + }, + { + "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_connectivity_test" }, + "description": "Sample for DeleteConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_delete_connectivity_test_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_async", "segments": [ { @@ -132,18 +265,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_delete_connectivity_test_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.delete_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.DeleteConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "DeleteConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.DeleteConnectivityTestRequest" + }, + { + "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_connectivity_test" }, + "description": "Sample for DeleteConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_delete_connectivity_test_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_DeleteConnectivityTest_sync", "segments": [ { @@ -176,19 +345,55 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_delete_connectivity_test_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.get_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.GetConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "GetConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.GetConnectivityTestRequest" + }, + { + "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.network_management_v1.types.ConnectivityTest", + "shortName": "get_connectivity_test" }, + "description": "Sample for GetConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_get_connectivity_test_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_GetConnectivityTest_async", "segments": [ { @@ -221,18 +426,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_get_connectivity_test_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.get_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.GetConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "GetConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.GetConnectivityTestRequest" + }, + { + "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.network_management_v1.types.ConnectivityTest", + "shortName": "get_connectivity_test" }, + "description": "Sample for GetConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_get_connectivity_test_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_GetConnectivityTest_sync", "segments": [ { @@ -265,19 +506,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_get_connectivity_test_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.list_connectivity_tests", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.ListConnectivityTests", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "ListConnectivityTests" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.ListConnectivityTestsRequest" + }, + { + "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.network_management_v1.services.reachability_service.pagers.ListConnectivityTestsAsyncPager", + "shortName": "list_connectivity_tests" }, + "description": "Sample for ListConnectivityTests", "file": "networkmanagement_v1_generated_reachability_service_list_connectivity_tests_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_ListConnectivityTests_async", "segments": [ { @@ -310,18 +587,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_list_connectivity_tests_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.list_connectivity_tests", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.ListConnectivityTests", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "ListConnectivityTests" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.ListConnectivityTestsRequest" + }, + { + "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.network_management_v1.services.reachability_service.pagers.ListConnectivityTestsPager", + "shortName": "list_connectivity_tests" }, + "description": "Sample for ListConnectivityTests", "file": "networkmanagement_v1_generated_reachability_service_list_connectivity_tests_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_ListConnectivityTests_sync", "segments": [ { @@ -354,19 +667,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_list_connectivity_tests_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.rerun_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.RerunConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "RerunConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.RerunConnectivityTestRequest" + }, + { + "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": "rerun_connectivity_test" }, + "description": "Sample for RerunConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_rerun_connectivity_test_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_async", "segments": [ { @@ -399,18 +744,50 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_rerun_connectivity_test_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.rerun_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.RerunConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "RerunConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.RerunConnectivityTestRequest" + }, + { + "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": "rerun_connectivity_test" }, + "description": "Sample for RerunConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_rerun_connectivity_test_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_RerunConnectivityTest_sync", "segments": [ { @@ -443,19 +820,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_rerun_connectivity_test_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient", + "shortName": "ReachabilityServiceAsyncClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceAsyncClient.update_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.UpdateConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "UpdateConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.UpdateConnectivityTestRequest" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "resource", + "type": "google.cloud.network_management_v1.types.ConnectivityTest" + }, + { + "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": "update_connectivity_test" }, + "description": "Sample for UpdateConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_update_connectivity_test_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_async", "segments": [ { @@ -488,18 +905,58 @@ "start": 49, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_update_connectivity_test_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient", + "shortName": "ReachabilityServiceClient" + }, + "fullName": "google.cloud.network_management_v1.ReachabilityServiceClient.update_connectivity_test", "method": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService.UpdateConnectivityTest", "service": { + "fullName": "google.cloud.networkmanagement.v1.ReachabilityService", "shortName": "ReachabilityService" }, "shortName": "UpdateConnectivityTest" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.network_management_v1.types.UpdateConnectivityTestRequest" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "resource", + "type": "google.cloud.network_management_v1.types.ConnectivityTest" + }, + { + "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": "update_connectivity_test" }, + "description": "Sample for UpdateConnectivityTest", "file": "networkmanagement_v1_generated_reachability_service_update_connectivity_test_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "networkmanagement_v1_generated_ReachabilityService_UpdateConnectivityTest_sync", "segments": [ { @@ -532,7 +989,8 @@ "start": 49, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "networkmanagement_v1_generated_reachability_service_update_connectivity_test_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 513416f..5f37e8b 100644 --- a/setup.py +++ b/setup.py @@ -19,10 +19,9 @@ import setuptools - name = "google-cloud-network-management" description = "Network Management API client library" -version = "1.3.1" +version = "1.3.2" release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-network-management" dependencies = [ diff --git a/tests/unit/gapic/network_management_v1/test_reachability_service.py b/tests/unit/gapic/network_management_v1/test_reachability_service.py index 0558f5b..fa6ac5a 100644 --- a/tests/unit/gapic/network_management_v1/test_reachability_service.py +++ b/tests/unit/gapic/network_management_v1/test_reachability_service.py @@ -13,46 +13,47 @@ # See the License for the specific language governing permissions and # 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 - +import os +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.network_management_v1.services.reachability_service import ( - ReachabilityServiceAsyncClient, -) -from google.cloud.network_management_v1.services.reachability_service import ( - ReachabilityServiceClient, -) -from google.cloud.network_management_v1.services.reachability_service import pagers -from google.cloud.network_management_v1.services.reachability_service import transports -from google.cloud.network_management_v1.types import connectivity_test -from google.cloud.network_management_v1.types import reachability -from google.cloud.network_management_v1.types import trace from google.longrunning import operations_pb2 from google.oauth2 import service_account from google.protobuf import any_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.network_management_v1.services.reachability_service import ( + ReachabilityServiceAsyncClient, + ReachabilityServiceClient, + pagers, + transports, +) +from google.cloud.network_management_v1.types import ( + connectivity_test, + reachability, + trace, +) def client_cert_source_callback(): @@ -101,20 +102,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [ReachabilityServiceClient, ReachabilityServiceAsyncClient,] + "client_class,transport_name", + [ + (ReachabilityServiceClient, "grpc"), + (ReachabilityServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_reachability_service_client_from_service_account_info(client_class): +def test_reachability_service_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 == "networkmanagement.googleapis.com:443" + assert client.transport._host == ("networkmanagement.googleapis.com:443") @pytest.mark.parametrize( @@ -143,23 +150,33 @@ def test_reachability_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [ReachabilityServiceClient, ReachabilityServiceAsyncClient,] + "client_class,transport_name", + [ + (ReachabilityServiceClient, "grpc"), + (ReachabilityServiceAsyncClient, "grpc_asyncio"), + ], ) -def test_reachability_service_client_from_service_account_file(client_class): +def test_reachability_service_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 == "networkmanagement.googleapis.com:443" + assert client.transport._host == ("networkmanagement.googleapis.com:443") def test_reachability_service_client_get_transport_class(): @@ -525,7 +542,9 @@ def test_reachability_service_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) @@ -666,11 +685,16 @@ def test_reachability_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [reachability.ListConnectivityTestsRequest, dict,] + "request_type", + [ + reachability.ListConnectivityTestsRequest, + dict, + ], ) def test_list_connectivity_tests(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -683,7 +707,8 @@ def test_list_connectivity_tests(request_type, transport: str = "grpc"): ) as call: # Designate an appropriate return value for the call. call.return_value = reachability.ListConnectivityTestsResponse( - next_page_token="next_page_token_value", unreachable=["unreachable_value"], + next_page_token="next_page_token_value", + unreachable=["unreachable_value"], ) response = client.list_connectivity_tests(request) @@ -702,7 +727,8 @@ def test_list_connectivity_tests_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -721,7 +747,8 @@ async def test_list_connectivity_tests_async( request_type=reachability.ListConnectivityTestsRequest, ): client = ReachabilityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -766,7 +793,7 @@ def test_list_connectivity_tests_field_headers(): # a field header. Set these to a non-empty value. request = reachability.ListConnectivityTestsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -782,7 +809,10 @@ def test_list_connectivity_tests_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 @@ -795,7 +825,7 @@ async def test_list_connectivity_tests_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.ListConnectivityTestsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -813,7 +843,10 @@ async def test_list_connectivity_tests_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_connectivity_tests_flattened(): @@ -829,7 +862,9 @@ def test_list_connectivity_tests_flattened(): call.return_value = reachability.ListConnectivityTestsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_connectivity_tests(parent="parent_value",) + client.list_connectivity_tests( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -849,7 +884,8 @@ def test_list_connectivity_tests_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.list_connectivity_tests( - reachability.ListConnectivityTestsRequest(), parent="parent_value", + reachability.ListConnectivityTestsRequest(), + parent="parent_value", ) @@ -871,7 +907,9 @@ async def test_list_connectivity_tests_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_connectivity_tests(parent="parent_value",) + response = await client.list_connectivity_tests( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -892,13 +930,15 @@ async def test_list_connectivity_tests_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_connectivity_tests( - reachability.ListConnectivityTestsRequest(), parent="parent_value", + reachability.ListConnectivityTestsRequest(), + parent="parent_value", ) def test_list_connectivity_tests_pager(transport_name: str = "grpc"): client = ReachabilityServiceClient( - 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. @@ -916,10 +956,13 @@ def test_list_connectivity_tests_pager(transport_name: str = "grpc"): next_page_token="abc", ), reachability.ListConnectivityTestsResponse( - resources=[], next_page_token="def", + resources=[], + next_page_token="def", ), reachability.ListConnectivityTestsResponse( - resources=[connectivity_test.ConnectivityTest(),], + resources=[ + connectivity_test.ConnectivityTest(), + ], next_page_token="ghi", ), reachability.ListConnectivityTestsResponse( @@ -939,14 +982,15 @@ def test_list_connectivity_tests_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, connectivity_test.ConnectivityTest) for i in results) def test_list_connectivity_tests_pages(transport_name: str = "grpc"): client = ReachabilityServiceClient( - 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. @@ -964,10 +1008,13 @@ def test_list_connectivity_tests_pages(transport_name: str = "grpc"): next_page_token="abc", ), reachability.ListConnectivityTestsResponse( - resources=[], next_page_token="def", + resources=[], + next_page_token="def", ), reachability.ListConnectivityTestsResponse( - resources=[connectivity_test.ConnectivityTest(),], + resources=[ + connectivity_test.ConnectivityTest(), + ], next_page_token="ghi", ), reachability.ListConnectivityTestsResponse( @@ -1006,10 +1053,13 @@ async def test_list_connectivity_tests_async_pager(): next_page_token="abc", ), reachability.ListConnectivityTestsResponse( - resources=[], next_page_token="def", + resources=[], + next_page_token="def", ), reachability.ListConnectivityTestsResponse( - resources=[connectivity_test.ConnectivityTest(),], + resources=[ + connectivity_test.ConnectivityTest(), + ], next_page_token="ghi", ), reachability.ListConnectivityTestsResponse( @@ -1020,10 +1070,12 @@ async def test_list_connectivity_tests_async_pager(): ), RuntimeError, ) - async_pager = await client.list_connectivity_tests(request={},) + async_pager = await client.list_connectivity_tests( + 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 @@ -1053,10 +1105,13 @@ async def test_list_connectivity_tests_async_pages(): next_page_token="abc", ), reachability.ListConnectivityTestsResponse( - resources=[], next_page_token="def", + resources=[], + next_page_token="def", ), reachability.ListConnectivityTestsResponse( - resources=[connectivity_test.ConnectivityTest(),], + resources=[ + connectivity_test.ConnectivityTest(), + ], next_page_token="ghi", ), reachability.ListConnectivityTestsResponse( @@ -1068,18 +1123,25 @@ async def test_list_connectivity_tests_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_connectivity_tests(request={})).pages: + async for page_ in ( + await client.list_connectivity_tests(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", [reachability.GetConnectivityTestRequest, dict,] + "request_type", + [ + reachability.GetConnectivityTestRequest, + dict, + ], ) def test_get_connectivity_test(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1118,7 +1180,8 @@ def test_get_connectivity_test_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1137,7 +1200,8 @@ async def test_get_connectivity_test_async( request_type=reachability.GetConnectivityTestRequest, ): client = ReachabilityServiceAsyncClient( - 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,7 +1252,7 @@ def test_get_connectivity_test_field_headers(): # a field header. Set these to a non-empty value. request = reachability.GetConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1204,7 +1268,10 @@ def test_get_connectivity_test_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 @@ -1217,7 +1284,7 @@ async def test_get_connectivity_test_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.GetConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1235,7 +1302,10 @@ async def test_get_connectivity_test_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_connectivity_test_flattened(): @@ -1251,7 +1321,9 @@ def test_get_connectivity_test_flattened(): call.return_value = connectivity_test.ConnectivityTest() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_connectivity_test(name="name_value",) + client.get_connectivity_test( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1271,7 +1343,8 @@ def test_get_connectivity_test_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.get_connectivity_test( - reachability.GetConnectivityTestRequest(), name="name_value", + reachability.GetConnectivityTestRequest(), + name="name_value", ) @@ -1293,7 +1366,9 @@ async def test_get_connectivity_test_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_connectivity_test(name="name_value",) + response = await client.get_connectivity_test( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1314,16 +1389,22 @@ async def test_get_connectivity_test_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_connectivity_test( - reachability.GetConnectivityTestRequest(), name="name_value", + reachability.GetConnectivityTestRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [reachability.CreateConnectivityTestRequest, dict,] + "request_type", + [ + reachability.CreateConnectivityTestRequest, + dict, + ], ) def test_create_connectivity_test(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1351,7 +1432,8 @@ def test_create_connectivity_test_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1370,7 +1452,8 @@ async def test_create_connectivity_test_async( request_type=reachability.CreateConnectivityTestRequest, ): client = ReachabilityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1410,7 +1493,7 @@ def test_create_connectivity_test_field_headers(): # a field header. Set these to a non-empty value. request = reachability.CreateConnectivityTestRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1426,7 +1509,10 @@ def test_create_connectivity_test_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 @@ -1439,7 +1525,7 @@ async def test_create_connectivity_test_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.CreateConnectivityTestRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1457,7 +1543,10 @@ async def test_create_connectivity_test_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_connectivity_test_flattened(): @@ -1567,11 +1656,16 @@ async def test_create_connectivity_test_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [reachability.UpdateConnectivityTestRequest, dict,] + "request_type", + [ + reachability.UpdateConnectivityTestRequest, + dict, + ], ) def test_update_connectivity_test(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1599,7 +1693,8 @@ def test_update_connectivity_test_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1618,7 +1713,8 @@ async def test_update_connectivity_test_async( request_type=reachability.UpdateConnectivityTestRequest, ): client = ReachabilityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1658,7 +1754,7 @@ def test_update_connectivity_test_field_headers(): # a field header. Set these to a non-empty value. request = reachability.UpdateConnectivityTestRequest() - request.resource.name = "resource.name/value" + request.resource.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1674,9 +1770,10 @@ def test_update_connectivity_test_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource.name=resource.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "resource.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1689,7 +1786,7 @@ async def test_update_connectivity_test_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.UpdateConnectivityTestRequest() - request.resource.name = "resource.name/value" + request.resource.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1707,9 +1804,10 @@ async def test_update_connectivity_test_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource.name=resource.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "resource.name=name_value", + ) in kw["metadata"] def test_update_connectivity_test_flattened(): @@ -1809,11 +1907,16 @@ async def test_update_connectivity_test_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [reachability.RerunConnectivityTestRequest, dict,] + "request_type", + [ + reachability.RerunConnectivityTestRequest, + dict, + ], ) def test_rerun_connectivity_test(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1841,7 +1944,8 @@ def test_rerun_connectivity_test_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1860,7 +1964,8 @@ async def test_rerun_connectivity_test_async( request_type=reachability.RerunConnectivityTestRequest, ): client = ReachabilityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1900,7 +2005,7 @@ def test_rerun_connectivity_test_field_headers(): # a field header. Set these to a non-empty value. request = reachability.RerunConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1916,7 +2021,10 @@ def test_rerun_connectivity_test_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 @@ -1929,7 +2037,7 @@ async def test_rerun_connectivity_test_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.RerunConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1947,15 +2055,23 @@ async def test_rerun_connectivity_test_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"] @pytest.mark.parametrize( - "request_type", [reachability.DeleteConnectivityTestRequest, dict,] + "request_type", + [ + reachability.DeleteConnectivityTestRequest, + dict, + ], ) def test_delete_connectivity_test(request_type, transport: str = "grpc"): client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1983,7 +2099,8 @@ def test_delete_connectivity_test_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 = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2002,7 +2119,8 @@ async def test_delete_connectivity_test_async( request_type=reachability.DeleteConnectivityTestRequest, ): client = ReachabilityServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2042,7 +2160,7 @@ def test_delete_connectivity_test_field_headers(): # a field header. Set these to a non-empty value. request = reachability.DeleteConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2058,7 +2176,10 @@ def test_delete_connectivity_test_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 @@ -2071,7 +2192,7 @@ async def test_delete_connectivity_test_field_headers_async(): # a field header. Set these to a non-empty value. request = reachability.DeleteConnectivityTestRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2089,7 +2210,10 @@ async def test_delete_connectivity_test_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_connectivity_test_flattened(): @@ -2105,7 +2229,9 @@ def test_delete_connectivity_test_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_connectivity_test(name="name_value",) + client.delete_connectivity_test( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2125,7 +2251,8 @@ def test_delete_connectivity_test_flattened_error(): # fields is an error. with pytest.raises(ValueError): client.delete_connectivity_test( - reachability.DeleteConnectivityTestRequest(), name="name_value", + reachability.DeleteConnectivityTestRequest(), + name="name_value", ) @@ -2147,7 +2274,9 @@ async def test_delete_connectivity_test_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_connectivity_test(name="name_value",) + response = await client.delete_connectivity_test( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2168,7 +2297,8 @@ async def test_delete_connectivity_test_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_connectivity_test( - reachability.DeleteConnectivityTestRequest(), name="name_value", + reachability.DeleteConnectivityTestRequest(), + name="name_value", ) @@ -2179,7 +2309,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ReachabilityServiceClient( - 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. @@ -2199,7 +2330,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = ReachabilityServiceClient(client_options=options, transport=transport,) + client = ReachabilityServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -2215,7 +2349,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = ReachabilityServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2258,12 +2393,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = ReachabilityServiceClient.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 = ReachabilityServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) - assert isinstance(client.transport, transports.ReachabilityServiceGrpcTransport,) + assert isinstance( + client.transport, + transports.ReachabilityServiceGrpcTransport, + ) def test_reachability_service_base_transport_error(): @@ -2307,6 +2458,14 @@ def test_reachability_service_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_reachability_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2318,7 +2477,8 @@ def test_reachability_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ReachabilityServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2453,24 +2613,40 @@ def test_reachability_service_grpc_transport_client_cert_source_for_mtls( ) -def test_reachability_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_reachability_service_host_no_port(transport_name): client = ReachabilityServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="networkmanagement.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "networkmanagement.googleapis.com:443" + assert client.transport._host == ("networkmanagement.googleapis.com:443") -def test_reachability_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_reachability_service_host_with_port(transport_name): client = ReachabilityServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="networkmanagement.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "networkmanagement.googleapis.com:8000" + assert client.transport._host == ("networkmanagement.googleapis.com:8000") def test_reachability_service_grpc_transport_channel(): @@ -2478,7 +2654,8 @@ def test_reachability_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.ReachabilityServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2490,7 +2667,8 @@ def test_reachability_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.ReachabilityServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2599,12 +2777,16 @@ def test_reachability_service_transport_channel_mtls_with_adc(transport_class): def test_reachability_service_grpc_lro_client(): client = ReachabilityServiceClient( - 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 @@ -2612,12 +2794,16 @@ def test_reachability_service_grpc_lro_client(): def test_reachability_service_grpc_lro_async_client(): client = ReachabilityServiceAsyncClient( - 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 @@ -2627,7 +2813,8 @@ def test_connectivity_test_path(): project = "squid" test = "clam" expected = "projects/{project}/locations/global/connectivityTests/{test}".format( - project=project, test=test, + project=project, + test=test, ) actual = ReachabilityServiceClient.connectivity_test_path(project, test) assert expected == actual @@ -2667,7 +2854,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = ReachabilityServiceClient.common_folder_path(folder) assert expected == actual @@ -2685,7 +2874,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = ReachabilityServiceClient.common_organization_path(organization) assert expected == actual @@ -2703,7 +2894,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = ReachabilityServiceClient.common_project_path(project) assert expected == actual @@ -2723,7 +2916,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = ReachabilityServiceClient.common_location_path(project, location) assert expected == actual @@ -2748,7 +2942,8 @@ def test_client_with_default_client_info(): transports.ReachabilityServiceTransport, "_prep_wrapped_messages" ) as prep: client = ReachabilityServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2757,7 +2952,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = ReachabilityServiceClient.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) @@ -2765,7 +2961,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = ReachabilityServiceAsyncClient( - 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"