You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/03/06 17:04:18 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #22022: feat: add an operator to run a transfer job

mik-laj commented on a change in pull request #22022:
URL: https://github.com/apache/airflow/pull/22022#discussion_r820260905



##########
File path: airflow/providers/google/cloud/operators/cloud_storage_transfer_service.py
##########
@@ -326,6 +326,64 @@ def execute(self, context: 'Context') -> dict:
         return hook.update_transfer_job(job_name=self.job_name, body=self.body)
 
 
+class CloudDataTransferServiceRunJobOperator(BaseOperator):
+    """
+    Runs a transfer job in Google Storage Transfer Service.
+
+    :param job_name: (Required) Name of the transfer job.
+    :param gcp_conn_id: The connection ID used to connect to Google Cloud.
+    :param api_version: API version used (e.g. v1).
+    :param google_impersonation_chain: Optional Google 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).
+    """
+
+    # [START gcp_transfer_job_run_template_fields]
+    template_fields: Sequence[str] = (
+        "job_name",
+        "gcp_conn_id",
+        "api_version",
+        "google_impersonation_chain",
+    )
+    # [END gcp_transfer_job_run_template_fields]
+
+    def __init__(
+        self,
+        *,
+        job_name: str,
+        project_id: str,
+        gcp_conn_id: str = "google_cloud_default",
+        api_version: str = "v1",
+        google_impersonation_chain: Optional[Union[str, Sequence[str]]] = None,
+        **kwargs,
+    ) -> None:
+        self.job_name = job_name
+        self.project_id = project_id
+        self.gcp_conn_id = gcp_conn_id
+        self.api_version = api_version
+        self.google_impersonation_chain = google_impersonation_chain
+        self.body = {PROJECT_ID: project_id}

Review comment:
       Can you add fallback to default_project_id from connection? To do it, you should use     `@GoogleBaseHook.fallback_to_default_project_id` decorator.




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org