airflow.providers.google.cloud.transfers.facebook_ads_to_gcs

This module contains Facebook Ad Reporting to GCS operators.

Module Contents

Classes

FlushAction

Facebook Ads Export Options

FacebookAdsReportToGcsOperator

Fetches the results from the Facebook Ads API as desired in the params

class airflow.providers.google.cloud.transfers.facebook_ads_to_gcs.FlushAction[source]

Bases: enum.Enum

Facebook Ads Export Options

EXPORT_ONCE = ExportAtOnce[source]
EXPORT_EVERY_ACCOUNT = ExportEveryAccount[source]
class airflow.providers.google.cloud.transfers.facebook_ads_to_gcs.FacebookAdsReportToGcsOperator(*, bucket_name, object_name, fields, parameters=None, gzip=False, upload_as_account=False, api_version=None, gcp_conn_id='google_cloud_default', facebook_conn_id='facebook_default', impersonation_chain=None, **kwargs)[source]

Bases: airflow.models.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

See also

For more information on the Facebook Ads API, take a look at the API docs: https://developers.facebook.com/docs/marketing-apis/

See also

For more information on the Facebook Ads Python SDK, take a look at the docs: https://github.com/facebook/facebook-python-business-sdk

See also

For more information on how to use this operator, take a look at the guide: FacebookAdsReportToGcsOperator

Parameters
  • bucket_name (str) – The GCS bucket to upload to

  • object_name (str) – GCS path to save the object. Must be the full file path (ex. path/to/file.txt)

  • gcp_conn_id (str) – Airflow Google Cloud connection ID

  • facebook_conn_id (str) – Airflow Facebook Ads connection ID

  • api_version (Optional[str]) – The version of Facebook API. Default to None. If it is None, it will use the Facebook business SDK default version.

  • fields (List[str]) – List of fields that is obtained from Facebook. Found in AdsInsights.Field class. https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0

  • parameters (Optional[Dict[str, Any]]) – Parameters that determine the query for Facebook https://developers.facebook.com/docs/marketing-api/insights/parameters/v6.0

  • gzip (bool) – Option to compress local file or file data for upload

  • upload_as_account (bool) – Option to export file with account_id This parameter only works if Account Id sets as array in Facebook Connection If set as True, each file will be exported in a separate file that has a prefix of account_id If set as False, a single file will be exported for all account_id

  • impersonation_chain (Optional[Union[str, Sequence[str]]]) – 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).

template_fields :Sequence[str] = ['facebook_conn_id', 'bucket_name', 'object_name', 'impersonation_chain', 'parameters'][source]
execute(context)[source]

This is the main method to derive when creating an operator. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?