mik-laj commented on a change in pull request #8008: Custom Facebook Ads 
Operator
URL: https://github.com/apache/airflow/pull/8008#discussion_r404421633
 
 

 ##########
 File path: airflow/providers/facebook/ads/operators/ads.py
 ##########
 @@ -0,0 +1,119 @@
+#
+# 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 Facebook Ad Reporting to GCS operators.
+"""
+import csv
+import tempfile
+from typing import Any, Dict, List
+
+from airflow.models import BaseOperator
+from airflow.providers.facebook.ads.hooks.ads import FacebookAdsReportingHook
+from airflow.providers.google.cloud.hooks.gcs import GCSHook
+from airflow.utils.decorators import apply_defaults
+
+
+class FacebookAdsReportToGcsOperator(BaseOperator):
+    """
+    Fetches the results from the Facebook Ads API as desired in the params
+    Converts and saves the data as a temporary JSON file
+    Uploads the JSON to Google Cloud Storage
+
+    .. seealso::
+        For more information on the Facebook Ads API, take a look at the API 
docs:
+        https://developers.facebook.com/docs/marketing-apis/
+
+    .. seealso::
+        For more information on the Facebook Ads Python SDK, take a look at 
the docs:
+        https://github.com/facebook/facebook-python-business-sdk
+
+    :param bucket: The GCS bucket to upload to
+    :type bucket: str
+    :param obj: GCS path to save the object. Must be the full file path (ex. 
`path/to/file.txt`)
+    :type obj: str
+    :param gcp_conn_id: Airflow Google Cloud Platform connection ID
+    :type gcp_conn_id: str
+    :param facebook_conn_id: Airflow Facebook Ads connection ID
+    :type facebook_conn_id: str
+    :param api_version: The version of Facebook API. Default to v6.0
+    :type api_version: str
+    :param fields: List of fields that is obtained from Facebook. Found in 
AdsInsights.Field class.
+        
https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0
+    :type fields: List[str]
+    :param params: Parameters that determine the query for Facebook
+        
https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0
+    :type params: Dict[str, Any]
+    :param sleep_time: Time to sleep when async call is happening
+    :type sleep_time: int
+    :param gzip: Option to compress local file or file data for upload
+    :type gzip: bool
+    """
+
+    template_fields = ("facebook_conn_id", "bucket_name", "object_name")
+
+    @apply_defaults
+    def __init__(
+        self,
+        bucket_name: str,
+        object_name: str,
+        fields: List[str],
+        params: Dict[str, Any],
+        gcp_conn_id: str = "google_cloud_default",
+        facebook_conn_id: str = "facebook_default",
+        api_version: str = "v6.0",
+        sleep_time: int = 5,
+        gzip: bool = False,
 
 Review comment:
   Connection parameters, i.e. conn_id, api_version should be last. At least, 
that's what we're trying to do for GCP.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to