From eabe551b06222bf811699dcabde20246674756bc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 22 Oct 2021 15:09:38 -0400 Subject: [PATCH 1/5] chore: fix docstring formatting (#42) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: fix docstring formatting Committer: @parthea PiperOrigin-RevId: 405015203 Source-Link: https://github.com/googleapis/googleapis/commit/974ad5bdfc9ba768db16b3eda2850aadd8c10a2c Source-Link: https://github.com/googleapis/googleapis-gen/commit/9cea0b99368edae46bd9cebd53fc1aca75faaead Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWNlYTBiOTkzNjhlZGFlNDZiZDljZWJkNTNmYzFhY2E3NWZhYWVhZCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../service_v1beta1/types/environments.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py b/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py index 0ab17e7..eed87d6 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/types/environments.py @@ -910,19 +910,19 @@ class EncryptionConfig(proto.Message): class MaintenanceWindow(proto.Message): - r"""The configuration settings for Cloud Composer maintenance - window. The following example: + r"""The configuration settings for Cloud Composer maintenance window. + The following example: - .. code-block:: none + :: - { - "startTime":"2019-08-01T01:00:00Z" - "endTime":"2019-08-01T07:00:00Z" - "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" - } + { + "startTime":"2019-08-01T01:00:00Z" + "endTime":"2019-08-01T07:00:00Z" + "recurrence":"FREQ=WEEKLY;BYDAY=TU,WE" + } - would define a maintenance window between 01 and 07 hours UTC - during each Tuesday and Wednesday. + would define a maintenance window between 01 and 07 hours UTC during + each Tuesday and Wednesday. Attributes: start_time (google.protobuf.timestamp_pb2.Timestamp): From 300a643709d3d9a92670d11a9f8ab2784e1c46cf Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 25 Oct 2021 20:55:32 -0400 Subject: [PATCH 2/5] chore(python): omit google/__init__.py in coverage (#44) Source-Link: https://github.com/googleapis/synthtool/commit/694118b039b09551fb5d445fceb361a7dbb06400 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ec49167c606648a063d1222220b48119c912562849a0528f35bfb592a9f72737 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/docs/common.cfg | 1 + noxfile.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7d98291..cb89b2e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b + digest: sha256:ec49167c606648a063d1222220b48119c912562849a0528f35bfb592a9f72737 diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index 362de19..026bf1e 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -30,6 +30,7 @@ env_vars: { env_vars: { key: "V2_STAGING_BUCKET" + # Push google cloud library docs to the Cloud RAD bucket `docs-staging-v2` value: "docs-staging-v2" } diff --git a/noxfile.py b/noxfile.py index 2bb4cf7..2a2001c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,7 +101,7 @@ def default(session): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud", + "--cov=google", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", From c3711f668253a866aecb5d48e5b5da43fecdc150 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 26 Oct 2021 12:08:00 -0400 Subject: [PATCH 3/5] chore: delete owlbot.py (#38) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: delete owlbot.py * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * use the latest post processor image * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- docs/index.rst | 9 +++- owlbot.py | 112 ------------------------------------------------- 2 files changed, 7 insertions(+), 114 deletions(-) delete mode 100644 owlbot.py diff --git a/docs/index.rst b/docs/index.rst index 0e3b6c9..3f33345 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,6 +2,10 @@ .. include:: multiprocessing.rst +This package includes clients for multiple versions of Cloud Composer. +By default, you will get version ``service_v1``. + + API Reference ------------- .. toctree:: @@ -18,12 +22,13 @@ API Reference service_v1beta1/services service_v1beta1/types + Changelog --------- For a list of all ``google-cloud-orchestration-airflow`` releases: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - changelog \ No newline at end of file + changelog diff --git a/owlbot.py b/owlbot.py deleted file mode 100644 index a7e331c..0000000 --- a/owlbot.py +++ /dev/null @@ -1,112 +0,0 @@ -# Copyright 2021 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. - -import synthtool as s -import synthtool.gcp as gcp -from synthtool.languages import python - -# ---------------------------------------------------------------------------- -# Copy the generated client from the owl-bot staging directory -# ---------------------------------------------------------------------------- - -default_version = "v1" - -for library in s.get_staging_dirs(default_version): - # Work around issue with docs generation with missing code-block - s.replace(library / f"google/cloud/orchestration/airflow/service_{library.name}/types/environments.py", - r"""The following example:\n - {""", - r"""The following example:\n - .. code-block:: none\n - {""" - ) - - # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902 - s.replace(library / f"google/cloud/orchestration/airflow/service_{library.name}/types/*.py", - r""". - Attributes:""", - r""".\n - Attributes:""", - ) - - s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) -s.remove_staging_dirs() - -# ---------------------------------------------------------------------------- -# Add templated files -# ---------------------------------------------------------------------------- - -templated_files = gcp.CommonTemplates().py_library(microgenerator=True) -python.py_samples(skip_readmes=True) -s.move(templated_files, excludes=[".coveragerc"]) # the microgenerator has a good coveragerc file - -# Remove the replacements below once https://github.com/googleapis/synthtool/pull/1188 is merged - -# Update googleapis/repo-automation-bots repo to main in .kokoro/*.sh files -s.replace(".kokoro/*.sh", "repo-automation-bots/tree/master", "repo-automation-bots/tree/main") - -# Customize CONTRIBUTING.rst to replace master with main -s.replace( - "CONTRIBUTING.rst", - "fetch and merge changes from upstream into master", - "fetch and merge changes from upstream into main", -) - -s.replace( - "CONTRIBUTING.rst", - "git merge upstream/master", - "git merge upstream/main", -) - -s.replace( - "CONTRIBUTING.rst", - """export GOOGLE_CLOUD_TESTING_BRANCH=\"master\"""", - """export GOOGLE_CLOUD_TESTING_BRANCH=\"main\"""", -) - -s.replace( - "CONTRIBUTING.rst", - "remote \(``master``\)", - "remote (``main``)", -) - -s.replace( - "CONTRIBUTING.rst", - "blob/master/CONTRIBUTING.rst", - "blob/main/CONTRIBUTING.rst", -) - -s.replace( - "CONTRIBUTING.rst", - "blob/master/noxfile.py", - "blob/main/noxfile.py", -) - -s.replace( - "docs/conf.py", - "master_doc", - "root_doc", -) - -s.replace( - "docs/conf.py", - "# The master toctree document.", - "# The root toctree document.", -) - -# ---------------------------------------------------------------------------- -# Run blacken session -# ---------------------------------------------------------------------------- - -s.shell.run(["nox", "-s", "blacken"], hide_output=False) From be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc 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 00:18:13 +0000 Subject: [PATCH 4/5] chore: use gapic-generator-python 0.53.4 (#45) - [ ] 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/environments/async_client.py | 34 +++---- .../services/environments/client.py | 12 ++- .../services/environments/transports/base.py | 37 +------- .../services/environments/transports/grpc.py | 2 +- .../environments/transports/grpc_asyncio.py | 3 +- .../services/image_versions/async_client.py | 10 +- .../services/image_versions/client.py | 4 +- .../image_versions/transports/base.py | 35 +------ .../image_versions/transports/grpc_asyncio.py | 1 - .../airflow/service_v1/types/environments.py | 11 +++ .../services/environments/async_client.py | 46 +++++----- .../services/environments/client.py | 16 ++-- .../services/environments/transports/base.py | 37 +------- .../services/environments/transports/grpc.py | 2 +- .../environments/transports/grpc_asyncio.py | 3 +- .../services/image_versions/async_client.py | 10 +- .../services/image_versions/client.py | 4 +- .../image_versions/transports/base.py | 35 +------ .../image_versions/transports/grpc_asyncio.py | 1 - setup.py | 3 +- testing/constraints-3.6.txt | 4 +- .../gapic/service_v1/test_environments.py | 91 ++----------------- .../gapic/service_v1/test_image_versions.py | 91 ++----------------- .../service_v1beta1/test_environments.py | 91 ++----------------- .../service_v1beta1/test_image_versions.py | 91 ++----------------- 25 files changed, 135 insertions(+), 539 deletions(-) diff --git a/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py b/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py index ef1b199..7b674b8 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/environments/async_client.py +++ b/google/cloud/orchestration/airflow/service_v1/services/environments/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.orchestration.airflow.service_v1.services.environments import pagers @@ -165,18 +167,18 @@ def __init__( async def create_environment( self, - request: environments.CreateEnvironmentRequest = None, + request: Union[environments.CreateEnvironmentRequest, dict] = None, *, parent: str = None, environment: environments.Environment = 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"""Create a new environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.CreateEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.CreateEnvironmentRequest, dict]): The request object. Create a new environment. parent (:class:`str`): The parent must be of the form @@ -254,17 +256,17 @@ async def create_environment( async def get_environment( self, - request: environments.GetEnvironmentRequest = None, + request: Union[environments.GetEnvironmentRequest, 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]] = (), ) -> environments.Environment: r"""Get an existing environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.GetEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.GetEnvironmentRequest, dict]): The request object. Get an environment. name (:class:`str`): The resource name of the environment @@ -325,17 +327,17 @@ async def get_environment( async def list_environments( self, - request: environments.ListEnvironmentsRequest = None, + request: Union[environments.ListEnvironmentsRequest, 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.ListEnvironmentsAsyncPager: r"""List environments. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.ListEnvironmentsRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.ListEnvironmentsRequest, dict]): The request object. List environments in a project and location. parent (:class:`str`): @@ -406,19 +408,19 @@ async def list_environments( async def update_environment( self, - request: environments.UpdateEnvironmentRequest = None, + request: Union[environments.UpdateEnvironmentRequest, dict] = None, *, name: str = None, environment: environments.Environment = 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"""Update an environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.UpdateEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.UpdateEnvironmentRequest, dict]): The request object. Update an environment. name (:class:`str`): The relative resource name of the @@ -669,17 +671,17 @@ async def update_environment( async def delete_environment( self, - request: environments.DeleteEnvironmentRequest = None, + request: Union[environments.DeleteEnvironmentRequest, 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"""Delete an environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.DeleteEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.DeleteEnvironmentRequest, dict]): The request object. Delete an environment. name (:class:`str`): The environment to delete, in the diff --git a/google/cloud/orchestration/airflow/service_v1/services/environments/client.py b/google/cloud/orchestration/airflow/service_v1/services/environments/client.py index 6371c38..4959606 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/environments/client.py +++ b/google/cloud/orchestration/airflow/service_v1/services/environments/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.orchestration.airflow.service_v1.services.environments import pagers @@ -357,7 +359,7 @@ def create_environment( *, parent: str = None, environment: environments.Environment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -445,7 +447,7 @@ def get_environment( request: Union[environments.GetEnvironmentRequest, 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]] = (), ) -> environments.Environment: @@ -516,7 +518,7 @@ def list_environments( request: Union[environments.ListEnvironmentsRequest, 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.ListEnvironmentsPager: @@ -599,7 +601,7 @@ def update_environment( name: str = None, environment: environments.Environment = 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: @@ -860,7 +862,7 @@ def delete_environment( request: Union[environments.DeleteEnvironmentRequest, 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/orchestration/airflow/service_v1/services/environments/transports/base.py b/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py index bbf2037..850ecb4 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/environments/transports/base.py +++ b/google/cloud/orchestration/airflow/service_v1/services/environments/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 @@ -39,15 +38,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 EnvironmentsTransport(abc.ABC): """Abstract transport class for Environments.""" @@ -97,7 +87,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 @@ -130,29 +120,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 = { @@ -183,7 +150,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/orchestration/airflow/service_v1/services/environments/transports/grpc.py b/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py index a80d06b..29941bc 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py +++ b/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc.py @@ -112,7 +112,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/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py b/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py index f210586..f5796ca 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/orchestration/airflow/service_v1/services/environments/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 @@ -159,7 +158,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/orchestration/airflow/service_v1/services/image_versions/async_client.py b/google/cloud/orchestration/airflow/service_v1/services/image_versions/async_client.py index c953e4b..5775fcc 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/image_versions/async_client.py +++ b/google/cloud/orchestration/airflow/service_v1/services/image_versions/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.cloud.orchestration.airflow.service_v1.services.image_versions import pagers from google.cloud.orchestration.airflow.service_v1.types import image_versions from .transports.base import ImageVersionsTransport, DEFAULT_CLIENT_INFO @@ -161,17 +163,17 @@ def __init__( async def list_image_versions( self, - request: image_versions.ListImageVersionsRequest = None, + request: Union[image_versions.ListImageVersionsRequest, 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.ListImageVersionsAsyncPager: r"""List ImageVersions for provided location. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1.types.ListImageVersionsRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1.types.ListImageVersionsRequest, dict]): The request object. List ImageVersions in a project and location. parent (:class:`str`): diff --git a/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py b/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py index 7480b0f..c8a4840 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/image_versions/client.py +++ b/google/cloud/orchestration/airflow/service_v1/services/image_versions/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.cloud.orchestration.airflow.service_v1.services.image_versions import pagers from google.cloud.orchestration.airflow.service_v1.types import image_versions from .transports.base import ImageVersionsTransport, DEFAULT_CLIENT_INFO @@ -334,7 +336,7 @@ def list_image_versions( request: Union[image_versions.ListImageVersionsRequest, 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.ListImageVersionsPager: diff --git a/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py b/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py index 3ec017c..0bd0270 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/base.py +++ b/google/cloud/orchestration/airflow/service_v1/services/image_versions/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 @@ -37,15 +36,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 ImageVersionsTransport(abc.ABC): """Abstract transport class for ImageVersions.""" @@ -95,7 +85,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 @@ -128,29 +118,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 = { diff --git a/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py b/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py index 6d20107..3387af1 100644 --- a/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py +++ b/google/cloud/orchestration/airflow/service_v1/services/image_versions/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # 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 diff --git a/google/cloud/orchestration/airflow/service_v1/types/environments.py b/google/cloud/orchestration/airflow/service_v1/types/environments.py index c78d2eb..bcd0b0f 100644 --- a/google/cloud/orchestration/airflow/service_v1/types/environments.py +++ b/google/cloud/orchestration/airflow/service_v1/types/environments.py @@ -555,6 +555,13 @@ class IPAllocationPolicy(proto.Message): r"""Configuration for controlling how IPs are allocated in the GKE cluster running the Apache Airflow software. + 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: use_ip_aliases (bool): Optional. Whether or not to enable Alias IPs in the GKE @@ -565,6 +572,7 @@ class IPAllocationPolicy(proto.Message): This field is applicable only when ``use_ip_aliases`` is true. + This field is a member of `oneof`_ ``cluster_ip_allocation``. cluster_ipv4_cidr_block (str): Optional. The IP address range used to allocate IP addresses to pods in the GKE cluster. @@ -583,12 +591,14 @@ class IPAllocationPolicy(proto.Message): notation (e.g. ``10.96.0.0/14``) from the RFC-1918 private networks (e.g. ``10.0.0.0/8``, ``172.16.0.0/12``, ``192.168.0.0/16``) to pick a specific range to use. + This field is a member of `oneof`_ ``cluster_ip_allocation``. services_secondary_range_name (str): Optional. The name of the services' secondary range used to allocate IP addresses to the GKE cluster. This field is applicable only when ``use_ip_aliases`` is true. + This field is a member of `oneof`_ ``services_ip_allocation``. services_ipv4_cidr_block (str): Optional. The IP address range of the services IP addresses in this GKE cluster. @@ -607,6 +617,7 @@ class IPAllocationPolicy(proto.Message): notation (e.g. ``10.96.0.0/14``) from the RFC-1918 private networks (e.g. ``10.0.0.0/8``, ``172.16.0.0/12``, ``192.168.0.0/16``) to pick a specific range to use. + This field is a member of `oneof`_ ``services_ip_allocation``. """ use_ip_aliases = proto.Field(proto.BOOL, number=1,) diff --git a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py index 09c5208..967794e 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/async_client.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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.orchestration.airflow.service_v1beta1.services.environments import ( @@ -167,18 +169,18 @@ def __init__( async def create_environment( self, - request: environments.CreateEnvironmentRequest = None, + request: Union[environments.CreateEnvironmentRequest, dict] = None, *, parent: str = None, environment: environments.Environment = 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"""Create a new environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.CreateEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.CreateEnvironmentRequest, dict]): The request object. Create a new environment. parent (:class:`str`): The parent must be of the form @@ -256,17 +258,17 @@ async def create_environment( async def get_environment( self, - request: environments.GetEnvironmentRequest = None, + request: Union[environments.GetEnvironmentRequest, 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]] = (), ) -> environments.Environment: r"""Get an existing environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.GetEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.GetEnvironmentRequest, dict]): The request object. Get an environment. name (:class:`str`): The resource name of the environment @@ -327,17 +329,17 @@ async def get_environment( async def list_environments( self, - request: environments.ListEnvironmentsRequest = None, + request: Union[environments.ListEnvironmentsRequest, 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.ListEnvironmentsAsyncPager: r"""List environments. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.ListEnvironmentsRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.ListEnvironmentsRequest, dict]): The request object. List environments in a project and location. parent (:class:`str`): @@ -408,19 +410,19 @@ async def list_environments( async def update_environment( self, - request: environments.UpdateEnvironmentRequest = None, + request: Union[environments.UpdateEnvironmentRequest, dict] = None, *, name: str = None, environment: environments.Environment = 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"""Update an environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.UpdateEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.UpdateEnvironmentRequest, dict]): The request object. Update an environment. name (:class:`str`): The relative resource name of the @@ -691,17 +693,17 @@ async def update_environment( async def delete_environment( self, - request: environments.DeleteEnvironmentRequest = None, + request: Union[environments.DeleteEnvironmentRequest, 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"""Delete an environment. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.DeleteEnvironmentRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.DeleteEnvironmentRequest, dict]): The request object. Delete an environment. name (:class:`str`): The environment to delete, in the @@ -783,16 +785,16 @@ async def delete_environment( async def restart_web_server( self, - request: environments.RestartWebServerRequest = None, + request: Union[environments.RestartWebServerRequest, dict] = 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"""Restart Airflow web server. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.RestartWebServerRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.RestartWebServerRequest, dict]): The request object. Restart Airflow web server. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. @@ -842,9 +844,9 @@ async def restart_web_server( async def check_upgrade( self, - request: environments.CheckUpgradeRequest = None, + request: Union[environments.CheckUpgradeRequest, dict] = 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: @@ -854,7 +856,7 @@ async def check_upgrade( returned Operation. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.CheckUpgradeRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.CheckUpgradeRequest, dict]): The request object. Request to check whether image upgrade will succeed. retry (google.api_core.retry.Retry): Designation of what errors, if any, diff --git a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py index 969c8b6..bfeee07 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/client.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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.orchestration.airflow.service_v1beta1.services.environments import ( @@ -359,7 +361,7 @@ def create_environment( *, parent: str = None, environment: environments.Environment = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -447,7 +449,7 @@ def get_environment( request: Union[environments.GetEnvironmentRequest, 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]] = (), ) -> environments.Environment: @@ -518,7 +520,7 @@ def list_environments( request: Union[environments.ListEnvironmentsRequest, 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.ListEnvironmentsPager: @@ -601,7 +603,7 @@ def update_environment( name: str = None, environment: environments.Environment = 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: @@ -882,7 +884,7 @@ def delete_environment( request: Union[environments.DeleteEnvironmentRequest, 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: @@ -973,7 +975,7 @@ def restart_web_server( self, request: Union[environments.RestartWebServerRequest, dict] = None, *, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: @@ -1033,7 +1035,7 @@ def check_upgrade( self, request: Union[environments.CheckUpgradeRequest, dict] = 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/orchestration/airflow/service_v1beta1/services/environments/transports/base.py b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py index cb3063e..04ef5b5 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/base.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 @@ -39,15 +38,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 EnvironmentsTransport(abc.ABC): """Abstract transport class for Environments.""" @@ -97,7 +87,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 @@ -130,29 +120,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 = { @@ -189,7 +156,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/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py index 2354fde..b16bd94 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc.py @@ -112,7 +112,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/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py index 56b3307..4a3fb1a 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/environments/transports/grpc_asyncio.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/environments/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 @@ -159,7 +158,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/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py index c424397..5aed5b9 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/async_client.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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.cloud.orchestration.airflow.service_v1beta1.services.image_versions import ( pagers, ) @@ -163,17 +165,17 @@ def __init__( async def list_image_versions( self, - request: image_versions.ListImageVersionsRequest = None, + request: Union[image_versions.ListImageVersionsRequest, 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.ListImageVersionsAsyncPager: r"""List ImageVersions for provided location. Args: - request (:class:`google.cloud.orchestration.airflow.service_v1beta1.types.ListImageVersionsRequest`): + request (Union[google.cloud.orchestration.airflow.service_v1beta1.types.ListImageVersionsRequest, dict]): The request object. List ImageVersions in a project and location. parent (:class:`str`): diff --git a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py index 1f5d56d..757597e 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/client.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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.cloud.orchestration.airflow.service_v1beta1.services.image_versions import ( pagers, ) @@ -336,7 +338,7 @@ def list_image_versions( request: Union[image_versions.ListImageVersionsRequest, 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.ListImageVersionsPager: diff --git a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py index 683bd93..cd81865 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/base.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/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 @@ -37,15 +36,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 ImageVersionsTransport(abc.ABC): """Abstract transport class for ImageVersions.""" @@ -95,7 +85,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 @@ -128,29 +118,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 = { diff --git a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py index 3747e4e..65c5c73 100644 --- a/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py +++ b/google/cloud/orchestration/airflow/service_v1beta1/services/image_versions/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # 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 diff --git a/setup.py b/setup.py index 58387ef..1dcb728 100644 --- a/setup.py +++ b/setup.py @@ -29,9 +29,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.22.2, < 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 fe11de2..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 si transitively required through google-api-core \ No newline at end of file diff --git a/tests/unit/gapic/service_v1/test_environments.py b/tests/unit/gapic/service_v1/test_environments.py index ed313cb..fab6a84 100644 --- a/tests/unit/gapic/service_v1/test_environments.py +++ b/tests/unit/gapic/service_v1/test_environments.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -45,9 +44,6 @@ from google.cloud.orchestration.airflow.service_v1.services.environments import ( transports, ) -from google.cloud.orchestration.airflow.service_v1.services.environments.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.orchestration.airflow.service_v1.types import environments from google.cloud.orchestration.airflow.service_v1.types import operations from google.longrunning import operations_pb2 @@ -57,20 +53,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" @@ -218,7 +200,7 @@ def test_environments_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, @@ -235,7 +217,7 @@ def test_environments_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, @@ -252,7 +234,7 @@ def test_environments_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, @@ -281,7 +263,7 @@ def test_environments_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, @@ -338,7 +320,7 @@ def test_environments_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 @@ -380,7 +362,7 @@ def test_environments_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, @@ -402,7 +384,7 @@ def test_environments_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, @@ -433,7 +415,7 @@ def test_environments_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, @@ -464,7 +446,7 @@ def test_environments_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", @@ -1841,7 +1823,6 @@ def test_environments_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_environments_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1862,26 +1843,6 @@ def test_environments_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_environments_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.orchestration.airflow.service_v1.services.environments.transports.EnvironmentsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EnvironmentsTransport( - 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_environments_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( @@ -1893,7 +1854,6 @@ def test_environments_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_environments_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1906,18 +1866,6 @@ def test_environments_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_environments_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) - EnvironmentsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1925,7 +1873,6 @@ def test_environments_auth_adc_old_google_auth(): transports.EnvironmentsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_environments_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1939,26 +1886,6 @@ def test_environments_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.EnvironmentsGrpcTransport, - transports.EnvironmentsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_environments_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", [ diff --git a/tests/unit/gapic/service_v1/test_image_versions.py b/tests/unit/gapic/service_v1/test_image_versions.py index 44a10b0..86cb75b 100644 --- a/tests/unit/gapic/service_v1/test_image_versions.py +++ b/tests/unit/gapic/service_v1/test_image_versions.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -42,28 +41,11 @@ from google.cloud.orchestration.airflow.service_v1.services.image_versions import ( transports, ) -from google.cloud.orchestration.airflow.service_v1.services.image_versions.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.orchestration.airflow.service_v1.types import image_versions from google.oauth2 import service_account 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" @@ -220,7 +202,7 @@ def test_image_versions_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, @@ -237,7 +219,7 @@ def test_image_versions_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, @@ -254,7 +236,7 @@ def test_image_versions_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, @@ -283,7 +265,7 @@ def test_image_versions_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, @@ -342,7 +324,7 @@ def test_image_versions_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 @@ -384,7 +366,7 @@ def test_image_versions_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, @@ -406,7 +388,7 @@ def test_image_versions_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, @@ -437,7 +419,7 @@ def test_image_versions_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, @@ -468,7 +450,7 @@ def test_image_versions_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", @@ -993,7 +975,6 @@ def test_image_versions_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_image_versions_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1014,26 +995,6 @@ def test_image_versions_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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.orchestration.airflow.service_v1.services.image_versions.transports.ImageVersionsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ImageVersionsTransport( - 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_image_versions_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( @@ -1045,7 +1006,6 @@ def test_image_versions_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_image_versions_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1058,18 +1018,6 @@ def test_image_versions_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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) - ImageVersionsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1077,7 +1025,6 @@ def test_image_versions_auth_adc_old_google_auth(): transports.ImageVersionsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_image_versions_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1091,26 +1038,6 @@ def test_image_versions_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.ImageVersionsGrpcTransport, - transports.ImageVersionsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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", [ diff --git a/tests/unit/gapic/service_v1beta1/test_environments.py b/tests/unit/gapic/service_v1beta1/test_environments.py index 454bf42..82d5ee8 100644 --- a/tests/unit/gapic/service_v1beta1/test_environments.py +++ b/tests/unit/gapic/service_v1beta1/test_environments.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -47,9 +46,6 @@ from google.cloud.orchestration.airflow.service_v1beta1.services.environments import ( transports, ) -from google.cloud.orchestration.airflow.service_v1beta1.services.environments.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.orchestration.airflow.service_v1beta1.types import environments from google.cloud.orchestration.airflow.service_v1beta1.types import operations from google.longrunning import operations_pb2 @@ -59,20 +55,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" @@ -220,7 +202,7 @@ def test_environments_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, @@ -237,7 +219,7 @@ def test_environments_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, @@ -254,7 +236,7 @@ def test_environments_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, @@ -283,7 +265,7 @@ def test_environments_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, @@ -340,7 +322,7 @@ def test_environments_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 @@ -382,7 +364,7 @@ def test_environments_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, @@ -404,7 +386,7 @@ def test_environments_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, @@ -435,7 +417,7 @@ def test_environments_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, @@ -466,7 +448,7 @@ def test_environments_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", @@ -2115,7 +2097,6 @@ def test_environments_base_transport(): transport.operations_client -@requires_google_auth_gte_1_25_0 def test_environments_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2136,26 +2117,6 @@ def test_environments_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_environments_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.orchestration.airflow.service_v1beta1.services.environments.transports.EnvironmentsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.EnvironmentsTransport( - 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_environments_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( @@ -2167,7 +2128,6 @@ def test_environments_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_environments_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2180,18 +2140,6 @@ def test_environments_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_environments_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) - EnvironmentsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2199,7 +2147,6 @@ def test_environments_auth_adc_old_google_auth(): transports.EnvironmentsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_environments_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2213,26 +2160,6 @@ def test_environments_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.EnvironmentsGrpcTransport, - transports.EnvironmentsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_environments_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", [ diff --git a/tests/unit/gapic/service_v1beta1/test_image_versions.py b/tests/unit/gapic/service_v1beta1/test_image_versions.py index a616b44..87ab2a8 100644 --- a/tests/unit/gapic/service_v1beta1/test_image_versions.py +++ b/tests/unit/gapic/service_v1beta1/test_image_versions.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -44,28 +43,11 @@ from google.cloud.orchestration.airflow.service_v1beta1.services.image_versions import ( transports, ) -from google.cloud.orchestration.airflow.service_v1beta1.services.image_versions.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.orchestration.airflow.service_v1beta1.types import image_versions from google.oauth2 import service_account 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" @@ -222,7 +204,7 @@ def test_image_versions_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, @@ -239,7 +221,7 @@ def test_image_versions_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, @@ -256,7 +238,7 @@ def test_image_versions_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, @@ -285,7 +267,7 @@ def test_image_versions_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, @@ -344,7 +326,7 @@ def test_image_versions_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 @@ -386,7 +368,7 @@ def test_image_versions_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, @@ -408,7 +390,7 @@ def test_image_versions_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, @@ -439,7 +421,7 @@ def test_image_versions_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, @@ -470,7 +452,7 @@ def test_image_versions_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", @@ -995,7 +977,6 @@ def test_image_versions_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_image_versions_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -1016,26 +997,6 @@ def test_image_versions_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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.orchestration.airflow.service_v1beta1.services.image_versions.transports.ImageVersionsTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.ImageVersionsTransport( - 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_image_versions_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( @@ -1047,7 +1008,6 @@ def test_image_versions_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_image_versions_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -1060,18 +1020,6 @@ def test_image_versions_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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) - ImageVersionsClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -1079,7 +1027,6 @@ def test_image_versions_auth_adc_old_google_auth(): transports.ImageVersionsGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_image_versions_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1093,26 +1040,6 @@ def test_image_versions_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.ImageVersionsGrpcTransport, - transports.ImageVersionsGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_image_versions_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", [ From 713dc16c666c6546a3b5f6713a6b54f8698622b6 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Tue, 2 Nov 2021 17:48:14 +0000 Subject: [PATCH 5/5] chore: release 1.2.1 (#46) :robot: I have created a release \*beep\* \*boop\* --- ### [1.2.1](https://www.github.com/googleapis/python-orchestration-airflow/compare/v1.2.0...v1.2.1) (2021-11-01) ### Bug Fixes * **deps:** drop packaging dependency ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) * **deps:** require google-api-core >= 1.28.0 ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) ### Documentation * list oneofs in docstring ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 13 +++++++++++++ setup.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f84f10..f1a62c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +### [1.2.1](https://www.github.com/googleapis/python-orchestration-airflow/compare/v1.2.0...v1.2.1) (2021-11-01) + + +### Bug Fixes + +* **deps:** drop packaging dependency ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) +* **deps:** require google-api-core >= 1.28.0 ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) + + +### Documentation + +* list oneofs in docstring ([be8de44](https://www.github.com/googleapis/python-orchestration-airflow/commit/be8de448aa7b0bdfb40edf5c41b0a2d5a411b9cc)) + ## [1.2.0](https://www.github.com/googleapis/python-orchestration-airflow/compare/v1.1.0...v1.2.0) (2021-10-18) diff --git a/setup.py b/setup.py index 1dcb728..9da867d 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-orchestration-airflow" description = "Cloud Composer API client library" -version = "1.2.0" +version = "1.2.1" release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-orchestration-airflow" dependencies = [