Google Display & Video 360 Operators

Google Display & Video 360 has the end-to-end campaign management features you need.

Prerequisite Tasks

Creating a report

To create Display&Video 360 report use GoogleDisplayVideo360CreateReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

create_report = GoogleDisplayVideo360CreateReportOperator(body=REPORT, task_id="create_report")
report_id = create_report.output["report_id"]

Use Jinja templating with body, impersonation_chain parameters which allow you to dynamically determine values. You can provide body definition using `` .json`` file as this operator supports this template extension. The result is saved to XCom, which allows the result to be used by other operators.

Deleting a report

To delete Display&Video 360 report use GoogleDisplayVideo360DeleteReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

delete_report = GoogleDisplayVideo360DeleteReportOperator(report_id=report_id, task_id="delete_report")

You can use Jinja templating with report_id, impersonation_chain parameters which allow you to dynamically determine values.

Waiting for report

To wait for the report use GoogleDisplayVideo360ReportSensor.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

wait_for_report = GoogleDisplayVideo360ReportSensor(task_id="wait_for_report", report_id=report_id)

Use Jinja templating with report_id, impersonation_chain parameters which allow you to dynamically determine values.

Downloading a report

To download a report to GCS bucket use GoogleDisplayVideo360DownloadReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

get_report = GoogleDisplayVideo360DownloadReportOperator(
    report_id=report_id,
    task_id="get_report",
    bucket_name=BUCKET,
    report_name="test1.csv",
)

Use Jinja templating with report_id, bucket_name, report_name, impersonation_chain parameters which allow you to dynamically determine values.

Running a report

To run Display&Video 360 report use GoogleDisplayVideo360RunReportOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

run_report = GoogleDisplayVideo360RunReportOperator(
    report_id=report_id, parameters=PARAMETERS, task_id="run_report"
)

Use Jinja templating with report_id, parameters, impersonation_chain parameters which allow you to dynamically determine values.

Downloading Line Items

The operator accepts body request:

  • consistent with Google API

    REQUEST_BODY = {
    "filterType": ADVERTISER_ID,
    "format": "CSV",
    "fileSpec": "EWF"
    }
    

To download line items in CSV format report use GoogleDisplayVideo360DownloadLineItemsOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

download_line_items = GoogleDisplayVideo360DownloadLineItemsOperator(
    task_id="download_line_items",
    request_body=DOWNLOAD_LINE_ITEMS_REQUEST,
    bucket_name=BUCKET,
    object_name=OBJECT_NAME,
    gzip=False,
)

Use Jinja templating with request_body, bucket_name, object_name, impersonation_chain parameters which allow you to dynamically determine values.

Upload line items

To run Display&Video 360 uploading line items use GoogleDisplayVideo360UploadLineItemsOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

upload_line_items = GoogleDisplayVideo360UploadLineItemsOperator(
    task_id="upload_line_items",
    bucket_name=BUCKET,
    object_name=BUCKET_FILE_LOCATION,
)

Use Jinja templating with bucket_name, object_name, impersonation_chain parameters which allow you to dynamically determine values.

Create SDF download task

To create SDF download task use GoogleDisplayVideo360CreateSDFDownloadTaskOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

create_sdf_download_task = GoogleDisplayVideo360CreateSDFDownloadTaskOperator(
    task_id="create_sdf_download_task", body_request=CREATE_SDF_DOWNLOAD_TASK_BODY_REQUEST
)
operation_name = '{{ task_instance.xcom_pull("create_sdf_download_task")["name"] }}'

Use Jinja templating with body_request, impersonation_chain parameters which allow you to dynamically determine values.

Save SDF files in the Google Cloud Storage

To save SDF files and save them in the Google Cloud Storage use GoogleDisplayVideo360SDFtoGCSOperator.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

save_sdf_in_gcs = GoogleDisplayVideo360SDFtoGCSOperator(
    task_id="save_sdf_in_gcs",
    operation_name=operation_name,
    bucket_name=BUCKET,
    object_name=BUCKET_FILE_LOCATION,
    gzip=False,
)

Use Jinja templating with operation_name, bucket_name, object_name, impersonation_chain parameters which allow you to dynamically determine values.

Waiting for SDF operation

Wait for SDF operation is executed by: GoogleDisplayVideo360GetSDFDownloadOperationSensor.

airflow/providers/google/marketing_platform/example_dags/example_display_video.pyView Source

wait_for_operation = GoogleDisplayVideo360GetSDFDownloadOperationSensor(
    task_id="wait_for_operation",
    operation_name=operation_name,
)

Use Jinja templating with operation_name, impersonation_chain parameters which allow you to dynamically determine values.

Was this entry helpful?