From 518f32b90db80cd8a5b2774aba8c9a4b13ea1f57 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 10:48:11 +0000 Subject: [PATCH] chore: use gapic-generator-python 0.53.4 (#47) - [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): require google-api-core >= 1.28.0 fix(deps): drop packaging dependency committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: https://github.com/googleapis/googleapis/commit/83d81b0c8fc22291a13398d6d77f02dc97a5b6f4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9 --- .../services/network_security/async_client.py | 102 ++++++++++-------- .../services/network_security/client.py | 32 +++--- .../network_security/transports/base.py | 37 +------ .../network_security/transports/grpc.py | 2 +- .../transports/grpc_asyncio.py | 3 +- .../types/authorization_policy.py | 3 + .../network_security_v1beta1/types/tls.py | 18 ++++ setup.py | 3 +- testing/constraints-3.6.txt | 4 +- .../test_network_security.py | 91 ++-------------- 10 files changed, 109 insertions(+), 186 deletions(-) diff --git a/google/cloud/network_security_v1beta1/services/network_security/async_client.py b/google/cloud/network_security_v1beta1/services/network_security/async_client.py index ab1700e..e949a61 100644 --- a/google/cloud/network_security_v1beta1/services/network_security/async_client.py +++ b/google/cloud/network_security_v1beta1/services/network_security/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.network_security_v1beta1.services.network_security import pagers @@ -193,10 +195,12 @@ def __init__( async def list_authorization_policies( self, - request: authorization_policy.ListAuthorizationPoliciesRequest = None, + request: Union[ + authorization_policy.ListAuthorizationPoliciesRequest, dict + ] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizationPoliciesAsyncPager: @@ -204,7 +208,7 @@ async def list_authorization_policies( location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.ListAuthorizationPoliciesRequest`): + request (Union[google.cloud.network_security_v1beta1.types.ListAuthorizationPoliciesRequest, dict]): The request object. Request used with the ListAuthorizationPolicies method. parent (:class:`str`): @@ -275,17 +279,17 @@ async def list_authorization_policies( async def get_authorization_policy( self, - request: authorization_policy.GetAuthorizationPolicyRequest = None, + request: Union[authorization_policy.GetAuthorizationPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> authorization_policy.AuthorizationPolicy: r"""Gets details of a single AuthorizationPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.GetAuthorizationPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.GetAuthorizationPolicyRequest, dict]): The request object. Request used by the GetAuthorizationPolicy method. name (:class:`str`): @@ -352,12 +356,14 @@ async def get_authorization_policy( async def create_authorization_policy( self, - request: gcn_authorization_policy.CreateAuthorizationPolicyRequest = None, + request: Union[ + gcn_authorization_policy.CreateAuthorizationPolicyRequest, dict + ] = None, *, parent: str = None, authorization_policy: gcn_authorization_policy.AuthorizationPolicy = None, authorization_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -365,7 +371,7 @@ async def create_authorization_policy( and location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.CreateAuthorizationPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.CreateAuthorizationPolicyRequest, dict]): The request object. Request used by the CreateAuthorizationPolicy method. parent (:class:`str`): @@ -463,11 +469,13 @@ async def create_authorization_policy( async def update_authorization_policy( self, - request: gcn_authorization_policy.UpdateAuthorizationPolicyRequest = None, + request: Union[ + gcn_authorization_policy.UpdateAuthorizationPolicyRequest, dict + ] = None, *, authorization_policy: gcn_authorization_policy.AuthorizationPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -475,7 +483,7 @@ async def update_authorization_policy( AuthorizationPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.UpdateAuthorizationPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.UpdateAuthorizationPolicyRequest, dict]): The request object. Request used by the UpdateAuthorizationPolicy method. authorization_policy (:class:`google.cloud.network_security_v1beta1.types.AuthorizationPolicy`): @@ -565,17 +573,19 @@ async def update_authorization_policy( async def delete_authorization_policy( self, - request: authorization_policy.DeleteAuthorizationPolicyRequest = None, + request: Union[ + authorization_policy.DeleteAuthorizationPolicyRequest, dict + ] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single AuthorizationPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.DeleteAuthorizationPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.DeleteAuthorizationPolicyRequest, dict]): The request object. Request used by the DeleteAuthorizationPolicy method. name (:class:`str`): @@ -658,10 +668,10 @@ async def delete_authorization_policy( async def list_server_tls_policies( self, - request: server_tls_policy.ListServerTlsPoliciesRequest = None, + request: Union[server_tls_policy.ListServerTlsPoliciesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServerTlsPoliciesAsyncPager: @@ -669,7 +679,7 @@ async def list_server_tls_policies( location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.ListServerTlsPoliciesRequest`): + request (Union[google.cloud.network_security_v1beta1.types.ListServerTlsPoliciesRequest, dict]): The request object. Request used by the ListServerTlsPolicies method. parent (:class:`str`): @@ -740,17 +750,17 @@ async def list_server_tls_policies( async def get_server_tls_policy( self, - request: server_tls_policy.GetServerTlsPolicyRequest = None, + request: Union[server_tls_policy.GetServerTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> server_tls_policy.ServerTlsPolicy: r"""Gets details of a single ServerTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.GetServerTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.GetServerTlsPolicyRequest, dict]): The request object. Request used by the GetServerTlsPolicy method. name (:class:`str`): @@ -817,12 +827,12 @@ async def get_server_tls_policy( async def create_server_tls_policy( self, - request: gcn_server_tls_policy.CreateServerTlsPolicyRequest = None, + request: Union[gcn_server_tls_policy.CreateServerTlsPolicyRequest, dict] = None, *, parent: str = None, server_tls_policy: gcn_server_tls_policy.ServerTlsPolicy = None, server_tls_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -830,7 +840,7 @@ async def create_server_tls_policy( location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.CreateServerTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.CreateServerTlsPolicyRequest, dict]): The request object. Request used by the CreateServerTlsPolicy method. parent (:class:`str`): @@ -926,18 +936,18 @@ async def create_server_tls_policy( async def update_server_tls_policy( self, - request: gcn_server_tls_policy.UpdateServerTlsPolicyRequest = None, + request: Union[gcn_server_tls_policy.UpdateServerTlsPolicyRequest, dict] = None, *, server_tls_policy: gcn_server_tls_policy.ServerTlsPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single ServerTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.UpdateServerTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.UpdateServerTlsPolicyRequest, dict]): The request object. Request used by UpdateServerTlsPolicy method. server_tls_policy (:class:`google.cloud.network_security_v1beta1.types.ServerTlsPolicy`): @@ -1027,17 +1037,17 @@ async def update_server_tls_policy( async def delete_server_tls_policy( self, - request: server_tls_policy.DeleteServerTlsPolicyRequest = None, + request: Union[server_tls_policy.DeleteServerTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single ServerTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.DeleteServerTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.DeleteServerTlsPolicyRequest, dict]): The request object. Request used by the DeleteServerTlsPolicy method. name (:class:`str`): @@ -1120,10 +1130,10 @@ async def delete_server_tls_policy( async def list_client_tls_policies( self, - request: client_tls_policy.ListClientTlsPoliciesRequest = None, + request: Union[client_tls_policy.ListClientTlsPoliciesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListClientTlsPoliciesAsyncPager: @@ -1131,7 +1141,7 @@ async def list_client_tls_policies( location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.ListClientTlsPoliciesRequest`): + request (Union[google.cloud.network_security_v1beta1.types.ListClientTlsPoliciesRequest, dict]): The request object. Request used by the ListClientTlsPolicies method. parent (:class:`str`): @@ -1202,17 +1212,17 @@ async def list_client_tls_policies( async def get_client_tls_policy( self, - request: client_tls_policy.GetClientTlsPolicyRequest = None, + request: Union[client_tls_policy.GetClientTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> client_tls_policy.ClientTlsPolicy: r"""Gets details of a single ClientTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.GetClientTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.GetClientTlsPolicyRequest, dict]): The request object. Request used by the GetClientTlsPolicy method. name (:class:`str`): @@ -1278,12 +1288,12 @@ async def get_client_tls_policy( async def create_client_tls_policy( self, - request: gcn_client_tls_policy.CreateClientTlsPolicyRequest = None, + request: Union[gcn_client_tls_policy.CreateClientTlsPolicyRequest, dict] = None, *, parent: str = None, client_tls_policy: gcn_client_tls_policy.ClientTlsPolicy = None, client_tls_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: @@ -1291,7 +1301,7 @@ async def create_client_tls_policy( location. Args: - request (:class:`google.cloud.network_security_v1beta1.types.CreateClientTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.CreateClientTlsPolicyRequest, dict]): The request object. Request used by the CreateClientTlsPolicy method. parent (:class:`str`): @@ -1386,18 +1396,18 @@ async def create_client_tls_policy( async def update_client_tls_policy( self, - request: gcn_client_tls_policy.UpdateClientTlsPolicyRequest = None, + request: Union[gcn_client_tls_policy.UpdateClientTlsPolicyRequest, dict] = None, *, client_tls_policy: gcn_client_tls_policy.ClientTlsPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single ClientTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.UpdateClientTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.UpdateClientTlsPolicyRequest, dict]): The request object. Request used by UpdateClientTlsPolicy method. client_tls_policy (:class:`google.cloud.network_security_v1beta1.types.ClientTlsPolicy`): @@ -1486,17 +1496,17 @@ async def update_client_tls_policy( async def delete_client_tls_policy( self, - request: client_tls_policy.DeleteClientTlsPolicyRequest = None, + request: Union[client_tls_policy.DeleteClientTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single ClientTlsPolicy. Args: - request (:class:`google.cloud.network_security_v1beta1.types.DeleteClientTlsPolicyRequest`): + request (Union[google.cloud.network_security_v1beta1.types.DeleteClientTlsPolicyRequest, dict]): The request object. Request used by the DeleteClientTlsPolicy method. name (:class:`str`): diff --git a/google/cloud/network_security_v1beta1/services/network_security/client.py b/google/cloud/network_security_v1beta1/services/network_security/client.py index 30e7e6f..94c7338 100644 --- a/google/cloud/network_security_v1beta1/services/network_security/client.py +++ b/google/cloud/network_security_v1beta1/services/network_security/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.network_security_v1beta1.services.network_security import pagers @@ -412,7 +414,7 @@ def list_authorization_policies( ] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListAuthorizationPoliciesPager: @@ -498,7 +500,7 @@ def get_authorization_policy( request: Union[authorization_policy.GetAuthorizationPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> authorization_policy.AuthorizationPolicy: @@ -579,7 +581,7 @@ def create_authorization_policy( parent: str = None, authorization_policy: gcn_authorization_policy.AuthorizationPolicy = None, authorization_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -695,7 +697,7 @@ def update_authorization_policy( *, authorization_policy: gcn_authorization_policy.AuthorizationPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -802,7 +804,7 @@ def delete_authorization_policy( ] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -899,7 +901,7 @@ def list_server_tls_policies( request: Union[server_tls_policy.ListServerTlsPoliciesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListServerTlsPoliciesPager: @@ -981,7 +983,7 @@ def get_server_tls_policy( request: Union[server_tls_policy.GetServerTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> server_tls_policy.ServerTlsPolicy: @@ -1060,7 +1062,7 @@ def create_server_tls_policy( parent: str = None, server_tls_policy: gcn_server_tls_policy.ServerTlsPolicy = None, server_tls_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1168,7 +1170,7 @@ def update_server_tls_policy( *, server_tls_policy: gcn_server_tls_policy.ServerTlsPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1268,7 +1270,7 @@ def delete_server_tls_policy( request: Union[server_tls_policy.DeleteServerTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1361,7 +1363,7 @@ def list_client_tls_policies( request: Union[client_tls_policy.ListClientTlsPoliciesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListClientTlsPoliciesPager: @@ -1443,7 +1445,7 @@ def get_client_tls_policy( request: Union[client_tls_policy.GetClientTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> client_tls_policy.ClientTlsPolicy: @@ -1521,7 +1523,7 @@ def create_client_tls_policy( parent: str = None, client_tls_policy: gcn_client_tls_policy.ClientTlsPolicy = None, client_tls_policy_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1628,7 +1630,7 @@ def update_client_tls_policy( *, client_tls_policy: gcn_client_tls_policy.ClientTlsPolicy = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1727,7 +1729,7 @@ def delete_client_tls_policy( request: Union[client_tls_policy.DeleteClientTlsPolicyRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: diff --git a/google/cloud/network_security_v1beta1/services/network_security/transports/base.py b/google/cloud/network_security_v1beta1/services/network_security/transports/base.py index 0a8f566..f690d5e 100644 --- a/google/cloud/network_security_v1beta1/services/network_security/transports/base.py +++ b/google/cloud/network_security_v1beta1/services/network_security/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -50,15 +49,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class NetworkSecurityTransport(abc.ABC): """Abstract transport class for NetworkSecurity.""" @@ -108,7 +98,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -141,29 +131,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -254,7 +221,7 @@ def close(self): raise NotImplementedError() @property - def operations_client(self) -> operations_v1.OperationsClient: + def operations_client(self): """Return the client designed to process long-running operations.""" raise NotImplementedError() diff --git a/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py b/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py index 21b81ae..094c1da 100644 --- a/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py +++ b/google/cloud/network_security_v1beta1/services/network_security/transports/grpc.py @@ -121,7 +121,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py b/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py index d44b6af..435d337 100644 --- a/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py +++ b/google/cloud/network_security_v1beta1/services/network_security/transports/grpc_asyncio.py @@ -21,7 +21,6 @@ from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -168,7 +167,7 @@ def __init__( self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials self._stubs: Dict[str, Callable] = {} - self._operations_client = None + self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) diff --git a/google/cloud/network_security_v1beta1/types/authorization_policy.py b/google/cloud/network_security_v1beta1/types/authorization_policy.py index 3f933e2..25b426c 100644 --- a/google/cloud/network_security_v1beta1/types/authorization_policy.py +++ b/google/cloud/network_security_v1beta1/types/authorization_policy.py @@ -142,6 +142,8 @@ class Destination(proto.Message): class HttpHeaderMatch(proto.Message): r"""Specification of HTTP header match atrributes. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: regex_match (str): Required. The value of the header must match @@ -152,6 +154,7 @@ class HttpHeaderMatch(proto.Message): request, use a headerMatch with headerName set to Host and a regular expression that satisfies the RFC2616 Host header's port specifier. + This field is a member of `oneof`_ ``type``. header_name (str): Required. The name of the HTTP header to match. For matching against the HTTP request's diff --git a/google/cloud/network_security_v1beta1/types/tls.py b/google/cloud/network_security_v1beta1/types/tls.py index 5029d02..99760af 100644 --- a/google/cloud/network_security_v1beta1/types/tls.py +++ b/google/cloud/network_security_v1beta1/types/tls.py @@ -45,15 +45,24 @@ class ValidationCA(proto.Message): obtain the Certificate Authority certificate to validate the peer certificate. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: grpc_endpoint (google.cloud.network_security_v1beta1.types.GrpcEndpoint): gRPC specific configuration to access the gRPC server to obtain the CA certificate. + This field is a member of `oneof`_ ``type``. certificate_provider_instance (google.cloud.network_security_v1beta1.types.CertificateProviderInstance): The certificate provider instance specification that will be passed to the data plane, which will be used to load necessary credential information. + This field is a member of `oneof`_ ``type``. """ grpc_endpoint = proto.Field( @@ -88,15 +97,24 @@ class CertificateProvider(proto.Message): to obtain the certificate and private key for peer to peer authentication. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: grpc_endpoint (google.cloud.network_security_v1beta1.types.GrpcEndpoint): gRPC specific configuration to access the gRPC server to obtain the cert and private key. + This field is a member of `oneof`_ ``type``. certificate_provider_instance (google.cloud.network_security_v1beta1.types.CertificateProviderInstance): The certificate provider instance specification that will be passed to the data plane, which will be used to load necessary credential information. + This field is a member of `oneof`_ ``type``. """ grpc_endpoint = proto.Field( diff --git a/setup.py b/setup.py index 2085d1b..fee82e2 100644 --- a/setup.py +++ b/setup.py @@ -28,9 +28,8 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.15.0", - "packaging >= 14.3", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 3f7f11e..1e3ec8b 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -4,7 +4,5 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.26.0 +google-api-core==1.28.0 proto-plus==1.15.0 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is transitively required through google-api-core \ No newline at end of file diff --git a/tests/unit/gapic/network_security_v1beta1/test_network_security.py b/tests/unit/gapic/network_security_v1beta1/test_network_security.py index 5ca3ffe..a18f7cd 100644 --- a/tests/unit/gapic/network_security_v1beta1/test_network_security.py +++ b/tests/unit/gapic/network_security_v1beta1/test_network_security.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -43,9 +42,6 @@ ) from google.cloud.network_security_v1beta1.services.network_security import pagers from google.cloud.network_security_v1beta1.services.network_security import transports -from google.cloud.network_security_v1beta1.services.network_security.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.network_security_v1beta1.types import authorization_policy from google.cloud.network_security_v1beta1.types import ( authorization_policy as gcn_authorization_policy, @@ -67,20 +63,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -237,7 +219,7 @@ def test_network_security_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -254,7 +236,7 @@ def test_network_security_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -271,7 +253,7 @@ def test_network_security_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -300,7 +282,7 @@ def test_network_security_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -369,7 +351,7 @@ def test_network_security_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -411,7 +393,7 @@ def test_network_security_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -433,7 +415,7 @@ def test_network_security_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -464,7 +446,7 @@ def test_network_security_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -495,7 +477,7 @@ def test_network_security_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -4624,7 +4606,6 @@ def test_network_security_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_network_security_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -4645,26 +4626,6 @@ def test_network_security_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_network_security_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.network_security_v1beta1.services.network_security.transports.NetworkSecurityTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.NetworkSecurityTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_network_security_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -4676,7 +4637,6 @@ def test_network_security_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_network_security_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -4689,18 +4649,6 @@ def test_network_security_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_network_security_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - NetworkSecurityClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -4708,7 +4656,6 @@ def test_network_security_auth_adc_old_google_auth(): transports.NetworkSecurityGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_network_security_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -4722,26 +4669,6 @@ def test_network_security_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.NetworkSecurityGrpcTransport, - transports.NetworkSecurityGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_network_security_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [