josh-fell commented on a change in pull request #20377:
URL: https://github.com/apache/airflow/pull/20377#discussion_r779281653



##########
File path: airflow/providers/google/cloud/operators/dataplex.py
##########
@@ -0,0 +1,395 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+"""This module contains Google Dataplex operators."""
+from time import sleep
+from typing import Any, Dict, Optional, Sequence, Union
+
+from google.api_core.retry import exponential_sleep_generator
+from googleapiclient.errors import HttpError
+
+from airflow.models import BaseOperator
+from airflow.providers.google.cloud.hooks.dataplex import DataplexHook
+
+
+class DataplexCreateTaskOperator(BaseOperator):
+    """
+    Creates a task resource within a lake.
+
+    :param project_id: Required. The ID of the Google Cloud project that the 
task belongs to.
+    :type project_id: str
+    :param region: Required. The ID of the Google Cloud region that the task 
belongs to.
+    :type region: str
+    :param lake_id: Required. The ID of the Google Cloud lake that the task 
belongs to.
+    :type lake_id: str
+    :param body:  Required. The Request body contains an instance of Task.
+    :type body: Dict[str, Any]
+    :param dataplex_task_id: Required. Task identifier.
+    :type dataplex_task_id: str
+    :param validate_only: Optional. Only validate the request, but do not 
perform mutations. The default is
+        false.
+    :type validate_only: bool
+    :param api_version: The version of the api that will be requested for 
example 'v3'.
+    :type api_version: str
+    :param gcp_conn_id: The connection ID to use when fetching connection info.
+    :type gcp_conn_id: str
+    :param delegate_to: The account to impersonate, if any. For this to work, 
the service accountmaking the
+        request must have  domain-wide delegation enabled.
+    :type delegate_to: str
+    :param impersonation_chain: Optional service account to impersonate using 
short-term
+        credentials, or chained list of accounts required to get the 
access_token
+        of the last account in the list, which will be impersonated in the 
request.
+        If set as a string, the account must grant the originating account
+        the Service Account Token Creator IAM role.
+        If set as a sequence, the identities from the list must grant
+        Service Account Token Creator IAM role to the directly preceding 
identity, with first
+        account from the list granting this role to the originating account 
(templated).
+    :type impersonation_chain: Union[str, Sequence[str]]
+    :param asynchronous: Flag informing should the Dataplex task be created 
asynchronously.
+        This is useful for long running creating tasks and
+        waiting on them asynchronously using the DataplexTaskSensor
+    :type asynchronous: bool
+    """
+
+    template_fields = (
+        "project_id",
+        "dataplex_task_id",
+        "body",
+        "validate_only",
+        "delegate_to",
+        "impersonation_chain",
+    )
+    template_fields_renderers = {'body': 'json'}
+
+    def __init__(
+        self,
+        project_id: str,
+        region: str,
+        lake_id: str,
+        body: Dict[str, Any],
+        dataplex_task_id: str,
+        validate_only: Optional[bool] = None,
+        api_version: str = "v1",
+        gcp_conn_id: str = "google_cloud_default",
+        delegate_to: str = None,
+        impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
+        asynchronous: bool = False,
+        *args,
+        **kwargs,
+    ) -> None:
+        super().__init__(*args, **kwargs)
+        self.project_id = project_id
+        self.region = region
+        self.lake_id = lake_id
+        self.body = body
+        self.dataplex_task_id = dataplex_task_id
+        self.validate_only = validate_only
+        self.api_version = api_version
+        self.gcp_conn_id = gcp_conn_id
+        self.delegate_to = delegate_to
+        self.impersonation_chain = impersonation_chain
+        self.asynchronous = asynchronous
+
+    def execute(self, context: dict) -> dict:

Review comment:
       +1 Definitely worth automating.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to