diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 108063d..eecb84c 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:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 + digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d08d984..e446644 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,9 +3,10 @@ # # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax +# Note: This file is autogenerated. To make changes to the codeowner team, please update .repo-metadata.json. -# The @googleapis/yoshi-python is the default owner for changes in this repo -* @googleapis/yoshi-python +# @googleapis/yoshi-python is the default owner for changes in this repo +* @googleapis/yoshi-python - -/samples/ @googleapis/python-samples-owners \ No newline at end of file +# @googleapis/python-samples-reviewers is the default owner for samples changes +/samples/ @googleapis/python-samples-reviewers diff --git a/.github/release-please.yml b/.github/release-please.yml index 4507ad0..466597e 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: python +handleGHRelease: true diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 0000000..d4ca941 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 53777f0..3179064 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-data-fusion python3 setup.py sdist bdist_wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 00438df..13cca2a 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-data-fusion/.kokoro/release.sh" } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } +} + # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/.repo-metadata.json b/.repo-metadata.json index 552a941..97c48f1 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,14 +2,15 @@ "name": "datafusion", "name_pretty": "Cloud Data Fusion", "product_documentation": "https://cloud.google.com/data-fusion", - "client_documentation": "https://googleapis.dev/python/datafusion/latest", + "client_documentation": "https://cloud.google.com/python/docs/reference/datafusion/latest", "issue_tracker": "", - "release_level": "ga", + "release_level": "stable", "language": "python", "library_type": "GAPIC_AUTO", "repo": "googleapis/python-data-fusion", "distribution_name": "google-cloud-data-fusion", "api_id": "datafusion.googleapis.com", "default_version": "v1", - "codeowner_team": "" + "codeowner_team": "", + "api_shortname": "datafusion" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3254c25..5d08eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [1.3.0](https://github.com/googleapis/python-data-fusion/compare/v1.2.1...v1.3.0) (2022-01-14) + + +### Features + +* update definitions for cloud/datafusion/v1 and cloud/datafusion/v1beta1 ([#58](https://github.com/googleapis/python-data-fusion/issues/58)) ([6b38819](https://github.com/googleapis/python-data-fusion/commit/6b38819f26fb72dc67ac2a4dda1c543d91b7f835)) + ### [1.2.1](https://www.github.com/googleapis/python-data-fusion/compare/v1.2.0...v1.2.1) (2021-11-01) diff --git a/README.rst b/README.rst index cbfb900..07bebe6 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ data from siloed on-premises platforms. .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-data-fusion.svg :target: https://pypi.org/project/google-cloud-data-fusion/ .. _Cloud Data Fusion: https://cloud.google.com/data-fusion -.. _Client Library Documentation: https://googleapis.dev/python/datafusion/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/datafusion/latest .. _Product Documentation: https://cloud.google.com/data-fusion/docs Quick Start diff --git a/google/cloud/data_fusion_v1/services/data_fusion/async_client.py b/google/cloud/data_fusion_v1/services/data_fusion/async_client.py index e49aec6..10fc16a 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/async_client.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/async_client.py @@ -19,14 +19,17 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -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.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -51,6 +54,8 @@ class DataFusionAsyncClient: DEFAULT_ENDPOINT = DataFusionClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = DataFusionClient.DEFAULT_MTLS_ENDPOINT + crypto_key_path = staticmethod(DataFusionClient.crypto_key_path) + parse_crypto_key_path = staticmethod(DataFusionClient.parse_crypto_key_path) instance_path = staticmethod(DataFusionClient.instance_path) parse_instance_path = staticmethod(DataFusionClient.parse_instance_path) common_billing_account_path = staticmethod( @@ -373,8 +378,8 @@ async def create_instance( The request object. Request message for creating a Data Fusion instance. parent (:class:`str`): - The instance's project and location - in the format + Required. The instance's project and + location in the format projects/{project}/locations/{location}. This corresponds to the ``parent`` field @@ -386,7 +391,9 @@ async def create_instance( on the ``request`` instance; if ``request`` is provided, this should not be set. instance_id (:class:`str`): - The name of the instance to create. + Required. The name of the instance to + create. + This corresponds to the ``instance_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -470,8 +477,8 @@ async def delete_instance( The request object. Request message for deleting a Data Fusion instance. name (:class:`str`): - The instance resource name in the - format + Required. The instance resource name + in the format projects/{project}/locations/{location}/instances/{instance} This corresponds to the ``name`` field @@ -561,14 +568,17 @@ async def update_instance( Args: request (Union[google.cloud.data_fusion_v1.types.UpdateInstanceRequest, dict]): - The request object. + The request object. Request message for updating a Data + Fusion instance. Data Fusion allows updating the labels, + options, and stack driver settings. This is also used + for CDF version upgrade. instance (:class:`google.cloud.data_fusion_v1.types.Instance`): - The instance resource that replaces - the resource on the server. Currently, - Data Fusion only allows replacing - labels, options, and stack driver - settings. All other fields will be - ignored. + Required. The instance resource that + replaces the resource on the server. + Currently, Data Fusion only allows + replacing labels, options, and stack + driver settings. All other fields will + be ignored. This corresponds to the ``instance`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/data_fusion_v1/services/data_fusion/client.py b/google/cloud/data_fusion_v1/services/data_fusion/client.py index fbfd514..1a1d81d 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/client.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/client.py @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -163,6 +165,27 @@ def transport(self) -> DataFusionTransport: """ return self._transport + @staticmethod + def crypto_key_path( + project: str, location: str, key_ring: str, crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def instance_path(project: str, location: str, instance: str,) -> str: """Returns a fully-qualified instance string.""" @@ -289,8 +312,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None @@ -565,8 +595,8 @@ def create_instance( The request object. Request message for creating a Data Fusion instance. parent (str): - The instance's project and location - in the format + Required. The instance's project and + location in the format projects/{project}/locations/{location}. This corresponds to the ``parent`` field @@ -578,7 +608,9 @@ def create_instance( on the ``request`` instance; if ``request`` is provided, this should not be set. instance_id (str): - The name of the instance to create. + Required. The name of the instance to + create. + This corresponds to the ``instance_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -662,8 +694,8 @@ def delete_instance( The request object. Request message for deleting a Data Fusion instance. name (str): - The instance resource name in the - format + Required. The instance resource name + in the format projects/{project}/locations/{location}/instances/{instance} This corresponds to the ``name`` field @@ -753,14 +785,17 @@ def update_instance( Args: request (Union[google.cloud.data_fusion_v1.types.UpdateInstanceRequest, dict]): - The request object. + The request object. Request message for updating a Data + Fusion instance. Data Fusion allows updating the labels, + options, and stack driver settings. This is also used + for CDF version upgrade. instance (google.cloud.data_fusion_v1.types.Instance): - The instance resource that replaces - the resource on the server. Currently, - Data Fusion only allows replacing - labels, options, and stack driver - settings. All other fields will be - ignored. + Required. The instance resource that + replaces the resource on the server. + Currently, Data Fusion only allows + replacing labels, options, and stack + driver settings. All other fields will + be ignored. This corresponds to the ``instance`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/data_fusion_v1/services/data_fusion/transports/base.py b/google/cloud/data_fusion_v1/services/data_fusion/transports/base.py index 05abf0a..bc3ff50 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/transports/base.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/transports/base.py @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore @@ -103,7 +103,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc.py b/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc.py index 43311c6..42304b2 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc.py @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc_asyncio.py b/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc_asyncio.py index 6ec2391..81d776c 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc_asyncio.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/transports/grpc_asyncio.py @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/data_fusion_v1/types/datafusion.py b/google/cloud/data_fusion_v1/types/datafusion.py index 1ceaaa0..5dd9edb 100644 --- a/google/cloud/data_fusion_v1/types/datafusion.py +++ b/google/cloud/data_fusion_v1/types/datafusion.py @@ -86,11 +86,23 @@ class Version(proto.Message): available_features (Sequence[str]): Represents a list of available feature names for a given version. + type_ (google.cloud.data_fusion_v1.types.Version.Type): + Type represents the release availability of + the version """ + class Type(proto.Enum): + r"""Each type represents the release availability of a CDF + version + """ + TYPE_UNSPECIFIED = 0 + TYPE_PREVIEW = 1 + TYPE_GENERAL_AVAILABILITY = 2 + version_number = proto.Field(proto.STRING, number=1,) default_version = proto.Field(proto.BOOL, number=2,) available_features = proto.RepeatedField(proto.STRING, number=3,) + type_ = proto.Field(proto.ENUM, number=4, enum=Type,) class Accelerator(proto.Message): @@ -230,6 +242,9 @@ class Instance(proto.Message): The crypto key configuration. This field is used by the Customer-Managed Encryption Keys (CMEK) feature. + disabled_reason (Sequence[google.cloud.data_fusion_v1.types.Instance.DisabledReason]): + Output only. If the instance state is + DISABLED, the reason for disabling the instance. """ class Type(proto.Enum): @@ -253,6 +268,14 @@ class State(proto.Enum): UPDATING = 7 AUTO_UPDATING = 8 AUTO_UPGRADING = 9 + DISABLED = 10 + + class DisabledReason(proto.Enum): + r"""The reason for disabling the instance if the state is + DISABLED. + """ + DISABLED_REASON_UNSPECIFIED = 0 + KMS_KEY_ISSUE = 1 name = proto.Field(proto.STRING, number=1,) description = proto.Field(proto.STRING, number=2,) @@ -289,6 +312,7 @@ class State(proto.Enum): crypto_key_config = proto.Field( proto.MESSAGE, number=28, message="CryptoKeyConfig", ) + disabled_reason = proto.RepeatedField(proto.ENUM, number=29, enum=DisabledReason,) class ListInstancesRequest(proto.Message): @@ -296,8 +320,8 @@ class ListInstancesRequest(proto.Message): Attributes: parent (str): - The project and location for which to - retrieve instance information in the format + Required. The project and location for which + to retrieve instance information in the format projects/{project}/locations/{location}. If the location is specified as '-' (wildcard), then all regions available to the project are @@ -397,7 +421,8 @@ class GetInstanceRequest(proto.Message): Attributes: name (str): - The instance resource name in the format + Required. The instance resource name in the + format projects/{project}/locations/{location}/instances/{instance}. """ @@ -409,10 +434,11 @@ class CreateInstanceRequest(proto.Message): Attributes: parent (str): - The instance's project and location in the - format projects/{project}/locations/{location}. + Required. The instance's project and location + in the format + projects/{project}/locations/{location}. instance_id (str): - The name of the instance to create. + Required. The name of the instance to create. instance (google.cloud.data_fusion_v1.types.Instance): An instance resource. """ @@ -427,7 +453,8 @@ class DeleteInstanceRequest(proto.Message): Attributes: name (str): - The instance resource name in the format + Required. The instance resource name in the + format projects/{project}/locations/{location}/instances/{instance} """ @@ -435,15 +462,17 @@ class DeleteInstanceRequest(proto.Message): class UpdateInstanceRequest(proto.Message): - r""" + r"""Request message for updating a Data Fusion instance. + Data Fusion allows updating the labels, options, and stack + driver settings. This is also used for CDF version upgrade. Attributes: instance (google.cloud.data_fusion_v1.types.Instance): - The instance resource that replaces the - resource on the server. Currently, Data Fusion - only allows replacing labels, options, and stack - driver settings. All other fields will be - ignored. + Required. The instance resource that replaces + the resource on the server. Currently, Data + Fusion only allows replacing labels, options, + and stack driver settings. All other fields will + be ignored. update_mask (google.protobuf.field_mask_pb2.FieldMask): Field mask is used to specify the fields that the update will overwrite in an instance resource. The fields specified @@ -465,8 +494,8 @@ class RestartInstanceRequest(proto.Message): Attributes: name (str): - Name of the Data Fusion instance which need - to be restarted in the form of + Required. Name of the Data Fusion instance + which need to be restarted in the form of projects/{project}/locations/{location}/instances/{instance} """ diff --git a/setup.py b/setup.py index 700fb44..c896879 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-data-fusion" description = "Cloud Data Fusion API client library" -version = "1.2.1" +version = "1.3.0" release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-data-fusion" dependencies = [ diff --git a/tests/unit/gapic/data_fusion_v1/test_data_fusion.py b/tests/unit/gapic/data_fusion_v1/test_data_fusion.py index e4b9d77..14c9051 100644 --- a/tests/unit/gapic/data_fusion_v1/test_data_fusion.py +++ b/tests/unit/gapic/data_fusion_v1/test_data_fusion.py @@ -243,20 +243,20 @@ def test_data_fusion_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -313,7 +313,7 @@ def test_data_fusion_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -408,7 +408,7 @@ def test_data_fusion_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(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -439,7 +439,7 @@ def test_data_fusion_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(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -470,9 +470,10 @@ def test_data_fusion_client_client_options_from_dict(): ) -def test_list_available_versions( - transport: str = "grpc", request_type=datafusion.ListAvailableVersionsRequest -): +@pytest.mark.parametrize( + "request_type", [datafusion.ListAvailableVersionsRequest, dict,] +) +def test_list_available_versions(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -501,10 +502,6 @@ def test_list_available_versions( assert response.next_page_token == "next_page_token_value" -def test_list_available_versions_from_dict(): - test_list_available_versions(request_type=dict) - - def test_list_available_versions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -634,7 +631,9 @@ def test_list_available_versions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_available_versions_flattened_error(): @@ -670,7 +669,9 @@ async def test_list_available_versions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -685,8 +686,10 @@ async def test_list_available_versions_flattened_error_async(): ) -def test_list_available_versions_pager(): - client = DataFusionClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_available_versions_pager(transport_name: str = "grpc"): + client = DataFusionClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -727,8 +730,10 @@ def test_list_available_versions_pager(): assert all(isinstance(i, datafusion.Version) for i in results) -def test_list_available_versions_pages(): - client = DataFusionClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_available_versions_pages(transport_name: str = "grpc"): + client = DataFusionClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -839,9 +844,8 @@ async def test_list_available_versions_async_pages(): assert page_.raw_page.next_page_token == token -def test_list_instances( - transport: str = "grpc", request_type=datafusion.ListInstancesRequest -): +@pytest.mark.parametrize("request_type", [datafusion.ListInstancesRequest, dict,]) +def test_list_instances(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -869,10 +873,6 @@ def test_list_instances( assert response.unreachable == ["unreachable_value"] -def test_list_instances_from_dict(): - test_list_instances(request_type=dict) - - def test_list_instances_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -978,8 +978,10 @@ async def test_list_instances_field_headers_async(): assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] -def test_list_instances_pager(): - client = DataFusionClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pager(transport_name: str = "grpc"): + client = DataFusionClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1016,8 +1018,10 @@ def test_list_instances_pager(): assert all(isinstance(i, datafusion.Instance) for i in results) -def test_list_instances_pages(): - client = DataFusionClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_instances_pages(transport_name: str = "grpc"): + client = DataFusionClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_instances), "__call__") as call: @@ -1116,9 +1120,8 @@ async def test_list_instances_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_instance( - transport: str = "grpc", request_type=datafusion.GetInstanceRequest -): +@pytest.mark.parametrize("request_type", [datafusion.GetInstanceRequest, dict,]) +def test_get_instance(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1150,6 +1153,7 @@ def test_get_instance( tenant_project_id="tenant_project_id_value", dataproc_service_account="dataproc_service_account_value", enable_rbac=True, + disabled_reason=[datafusion.Instance.DisabledReason.KMS_KEY_ISSUE], ) response = client.get_instance(request) @@ -1179,10 +1183,9 @@ def test_get_instance( assert response.tenant_project_id == "tenant_project_id_value" assert response.dataproc_service_account == "dataproc_service_account_value" assert response.enable_rbac is True - - -def test_get_instance_from_dict(): - test_get_instance(request_type=dict) + assert response.disabled_reason == [ + datafusion.Instance.DisabledReason.KMS_KEY_ISSUE + ] def test_get_instance_empty_call(): @@ -1236,6 +1239,7 @@ async def test_get_instance_async( tenant_project_id="tenant_project_id_value", dataproc_service_account="dataproc_service_account_value", enable_rbac=True, + disabled_reason=[datafusion.Instance.DisabledReason.KMS_KEY_ISSUE], ) ) response = await client.get_instance(request) @@ -1266,6 +1270,9 @@ async def test_get_instance_async( assert response.tenant_project_id == "tenant_project_id_value" assert response.dataproc_service_account == "dataproc_service_account_value" assert response.enable_rbac is True + assert response.disabled_reason == [ + datafusion.Instance.DisabledReason.KMS_KEY_ISSUE + ] @pytest.mark.asyncio @@ -1322,9 +1329,8 @@ async def test_get_instance_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_create_instance( - transport: str = "grpc", request_type=datafusion.CreateInstanceRequest -): +@pytest.mark.parametrize("request_type", [datafusion.CreateInstanceRequest, dict,]) +def test_create_instance(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1348,10 +1354,6 @@ def test_create_instance( assert isinstance(response, future.Future) -def test_create_instance_from_dict(): - test_create_instance(request_type=dict) - - def test_create_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1471,9 +1473,15 @@ def test_create_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance == datafusion.Instance(name="name_value") - assert args[0].instance_id == "instance_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance + mock_val = datafusion.Instance(name="name_value") + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val def test_create_instance_flattened_error(): @@ -1514,9 +1522,15 @@ async def test_create_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].instance == datafusion.Instance(name="name_value") - assert args[0].instance_id == "instance_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].instance + mock_val = datafusion.Instance(name="name_value") + assert arg == mock_val + arg = args[0].instance_id + mock_val = "instance_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1534,9 +1548,8 @@ async def test_create_instance_flattened_error_async(): ) -def test_delete_instance( - transport: str = "grpc", request_type=datafusion.DeleteInstanceRequest -): +@pytest.mark.parametrize("request_type", [datafusion.DeleteInstanceRequest, dict,]) +def test_delete_instance(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1560,10 +1573,6 @@ def test_delete_instance( assert isinstance(response, future.Future) -def test_delete_instance_from_dict(): - test_delete_instance(request_type=dict) - - def test_delete_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1679,7 +1688,9 @@ def test_delete_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_instance_flattened_error(): @@ -1713,7 +1724,9 @@ async def test_delete_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1728,9 +1741,8 @@ async def test_delete_instance_flattened_error_async(): ) -def test_update_instance( - transport: str = "grpc", request_type=datafusion.UpdateInstanceRequest -): +@pytest.mark.parametrize("request_type", [datafusion.UpdateInstanceRequest, dict,]) +def test_update_instance(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1754,10 +1766,6 @@ def test_update_instance( assert isinstance(response, future.Future) -def test_update_instance_from_dict(): - test_update_instance(request_type=dict) - - def test_update_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1880,8 +1888,12 @@ def test_update_instance_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].instance == datafusion.Instance(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].instance + mock_val = datafusion.Instance(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_instance_flattened_error(): @@ -1920,8 +1932,12 @@ async def test_update_instance_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].instance == datafusion.Instance(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].instance + mock_val = datafusion.Instance(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -1938,9 +1954,8 @@ async def test_update_instance_flattened_error_async(): ) -def test_restart_instance( - transport: str = "grpc", request_type=datafusion.RestartInstanceRequest -): +@pytest.mark.parametrize("request_type", [datafusion.RestartInstanceRequest, dict,]) +def test_restart_instance(request_type, transport: str = "grpc"): client = DataFusionClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1964,10 +1979,6 @@ def test_restart_instance( assert isinstance(response, future.Future) -def test_restart_instance_from_dict(): - test_restart_instance(request_type=dict) - - def test_restart_instance_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2482,10 +2493,36 @@ def test_data_fusion_grpc_lro_async_client(): assert transport.operations_client is transport.operations_client -def test_instance_path(): +def test_crypto_key_path(): project = "squid" location = "clam" - instance = "whelk" + key_ring = "whelk" + crypto_key = "octopus" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, location=location, key_ring=key_ring, crypto_key=crypto_key, + ) + actual = DataFusionClient.crypto_key_path(project, location, key_ring, crypto_key) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + "key_ring": "cuttlefish", + "crypto_key": "mussel", + } + path = DataFusionClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = DataFusionClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_instance_path(): + project = "winkle" + location = "nautilus" + instance = "scallop" expected = "projects/{project}/locations/{location}/instances/{instance}".format( project=project, location=location, instance=instance, ) @@ -2495,9 +2532,9 @@ def test_instance_path(): def test_parse_instance_path(): expected = { - "project": "octopus", - "location": "oyster", - "instance": "nudibranch", + "project": "abalone", + "location": "squid", + "instance": "clam", } path = DataFusionClient.instance_path(**expected) @@ -2507,7 +2544,7 @@ def test_parse_instance_path(): def test_common_billing_account_path(): - billing_account = "cuttlefish" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -2517,7 +2554,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "mussel", + "billing_account": "octopus", } path = DataFusionClient.common_billing_account_path(**expected) @@ -2527,7 +2564,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "winkle" + folder = "oyster" expected = "folders/{folder}".format(folder=folder,) actual = DataFusionClient.common_folder_path(folder) assert expected == actual @@ -2535,7 +2572,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nautilus", + "folder": "nudibranch", } path = DataFusionClient.common_folder_path(**expected) @@ -2545,7 +2582,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "scallop" + organization = "cuttlefish" expected = "organizations/{organization}".format(organization=organization,) actual = DataFusionClient.common_organization_path(organization) assert expected == actual @@ -2553,7 +2590,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "abalone", + "organization": "mussel", } path = DataFusionClient.common_organization_path(**expected) @@ -2563,7 +2600,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "squid" + project = "winkle" expected = "projects/{project}".format(project=project,) actual = DataFusionClient.common_project_path(project) assert expected == actual @@ -2571,7 +2608,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "clam", + "project": "nautilus", } path = DataFusionClient.common_project_path(**expected) @@ -2581,8 +2618,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "whelk" - location = "octopus" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -2592,8 +2629,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "oyster", - "location": "nudibranch", + "project": "squid", + "location": "clam", } path = DataFusionClient.common_location_path(**expected) @@ -2602,7 +2639,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object(