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
.
create_report = GoogleDisplayVideo360CreateReportOperator(body=REPORT, task_id="create_report")
report_id = cast(str, XComArg(create_report, key="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
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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.