From 6b38819f26fb72dc67ac2a4dda1c543d91b7f835 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 14 Jan 2022 00:30:13 +0000 Subject: [PATCH] feat: update definitions for cloud/datafusion/v1 and cloud/datafusion/v1beta1 (#58) fix(v1): multiple fields now have field_behavior REQUIRED fix(v1beta1): multiple fields now have field_behavior REQUIRED - [ ] Regenerate this pull request now. Committer: @viacheslav-rostovtsev PiperOrigin-RevId: 421416031 Source-Link: https://github.com/googleapis/googleapis/commit/5438a17c9bcedf933854df8eb288ab300cc70a1d Source-Link: https://github.com/googleapis/googleapis-gen/commit/cc7213f0c2ac6623c4e8d4ba572337c837990bf5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2M3MjEzZjBjMmFjNjYyM2M0ZThkNGJhNTcyMzM3YzgzNzk5MGJmNSJ9 --- .../services/data_fusion/async_client.py | 31 +++++---- .../services/data_fusion/client.py | 50 ++++++++++---- .../cloud/data_fusion_v1/types/datafusion.py | 59 ++++++++++++---- .../gapic/data_fusion_v1/test_data_fusion.py | 68 ++++++++++++++----- 4 files changed, 152 insertions(+), 56 deletions(-) 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 f1592e4..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 @@ -54,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( @@ -376,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 @@ -389,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. @@ -473,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 @@ -564,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 1183e9e..1a1d81d 100644 --- a/google/cloud/data_fusion_v1/services/data_fusion/client.py +++ b/google/cloud/data_fusion_v1/services/data_fusion/client.py @@ -165,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.""" @@ -574,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 @@ -587,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. @@ -671,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 @@ -762,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/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/tests/unit/gapic/data_fusion_v1/test_data_fusion.py b/tests/unit/gapic/data_fusion_v1/test_data_fusion.py index e62e67d..14c9051 100644 --- a/tests/unit/gapic/data_fusion_v1/test_data_fusion.py +++ b/tests/unit/gapic/data_fusion_v1/test_data_fusion.py @@ -1153,6 +1153,7 @@ def test_get_instance(request_type, transport: str = "grpc"): 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) @@ -1182,6 +1183,9 @@ def test_get_instance(request_type, transport: str = "grpc"): 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 + ] def test_get_instance_empty_call(): @@ -1235,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) @@ -1265,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 @@ -2485,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, ) @@ -2498,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) @@ -2510,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, ) @@ -2520,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) @@ -2530,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 @@ -2538,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) @@ -2548,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 @@ -2556,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) @@ -2566,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 @@ -2574,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) @@ -2584,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, ) @@ -2595,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)