airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] efolgar commented on a change in pull request #6169: [AIRFLOW-4970][Don't merge] Add Google Campaign Manager integration
Date Thu, 26 Sep 2019 19:37:25 GMT
efolgar commented on a change in pull request #6169: [AIRFLOW-4970][Don't merge] Add Google
Campaign Manager integration
URL: https://github.com/apache/airflow/pull/6169#discussion_r328745412
 
 

 ##########
 File path: airflow/gcp/operators/campaign_manager.py
 ##########
 @@ -0,0 +1,347 @@
+# -*- coding: utf-8 -*-
+#
+# 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 CampaignManager operators.
+"""
+import tempfile
+from typing import Any, Dict, Optional, Union
+
+from googleapiclient import http
+
+from airflow.gcp.hooks.gcs import GoogleCloudStorageHook
+from airflow.gcp.hooks.campaign_manager import GoogleCampaignManagerHook
+from airflow.models.baseoperator import BaseOperator
+from airflow.utils.decorators import apply_defaults
+
+
+class GoogleCampaignManagerDeleteReportOperator(BaseOperator):
+    """
+    Deletes a report by its ID.
+
+    .. seealso::
+        Check official API docs:
+        https://developers.google.com/doubleclick-advertisers/v3.3/reports/delete
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:GoogleCampaignManagerDeleteReportOperator`
+
+    :param profile_id: The DFA user profile ID.
+    :type profile_id: str
+    :param report_id: The ID of the report.
+    :type report_id: str
+    :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
+    """
+
+    template_fields = (
+        "profile_id",
+        "report_id",
+        "api_version",
+        "gcp_conn_id",
+        "delegate_to",
+    )
+
+    @apply_defaults
+    def __init__(
+        self,
+        profile_id: str,
+        report_id: str,
+        api_version: str = "v3.3",
+        gcp_conn_id: str = "google_cloud_default",
+        delegate_to: Optional[str] = None,
+        *args,
+        **kwargs
+    ):
+        super().__init__(*args, **kwargs)
+        self.profile_id = profile_id
+        self.report_id = report_id
+        self.api_version = api_version
+        self.gcp_conn_id = gcp_conn_id
+        self.delegate_to = delegate_to
+
+    def execute(self, context: Dict):
+        hook = GoogleCampaignManagerHook(
+            gcp_conn_id=self.gcp_conn_id,
+            delegate_to=self.delegate_to,
+            api_version=self.api_version,
+        )
+        self.log.info("Deleting Campaign Manager report: %s", self.report_id)
+        hook.delete_report(profile_id=self.profile_id, report_id=self.report_id)
+        self.log.info("Report deleted.")
+
+
+class GoogleCampaignManagerDownloadReportOperator(BaseOperator):
+    """
+    Retrieves a report and uploads it to GCS bucket.
+
+    .. seealso::
+        Check official API docs:
+        https://developers.google.com/doubleclick-advertisers/v3.3/reports/files/get
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the guide:
+        :ref:`howto/operator:GoogleCampaignManagerDownloadReportOperator`
+
+    :param profile_id: The DFA user profile ID.
+    :type profile_id: str
+    :param report_id: The ID of the report.
+    :type report_id: str
+    :param file_id: The ID of the report file.
+    :type file_id: str
+    :param bucket_name: The bucket to upload to.
+    :type bucket_name: str
+    :param report_name: The report name to set when uploading the local file.
+    :type report_name: str
+    :param gzip: Option to compress local file or file data for upload
+    :type gzip: bool
+    :param chunk_size: File will be downloaded in chunks of this many bytes.
+    :type chunk_size: int
+    :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
+    """
+
+    template_fields = (
+        "profile_id",
+        "report_id",
+        "file_id",
+        "bucket_name",
+        "report_name",
+        "chunk_size",
+        "api_version",
+        "gcp_conn_id",
+        "delegate_to",
+    )
+
+    @apply_defaults
+    def __init__(  # pylint:disable=too-many-arguments
+        self,
+        profile_id: str,
+        report_id: str,
+        file_id: str,
+        bucket_name: str,
+        report_name: str,
 
 Review comment:
   Can we make report_name optional and use the [fileName](https://developers.google.com/doubleclick-advertisers/v3.3/reports/files#resource)
provided by Campaign Manager as a default?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message