|
30 | 30 | from airflow.providers.google.marketing_platform.hooks.display_video import GoogleDisplayVideo360Hook |
31 | 31 | from airflow.providers.google.marketing_platform.operators.display_video import ( |
32 | 32 | GoogleDisplayVideo360CreateQueryOperator, |
33 | | - GoogleDisplayVideo360CreateReportOperator, |
34 | 33 | GoogleDisplayVideo360CreateSDFDownloadTaskOperator, |
35 | 34 | GoogleDisplayVideo360DeleteReportOperator, |
36 | 35 | GoogleDisplayVideo360DownloadLineItemsOperator, |
37 | | - GoogleDisplayVideo360DownloadReportOperator, |
38 | 36 | GoogleDisplayVideo360DownloadReportV2Operator, |
39 | 37 | GoogleDisplayVideo360RunQueryOperator, |
40 | | - GoogleDisplayVideo360RunReportOperator, |
41 | 38 | GoogleDisplayVideo360SDFtoGCSOperator, |
42 | 39 | GoogleDisplayVideo360UploadLineItemsOperator, |
43 | 40 | ) |
44 | 41 | from airflow.providers.google.marketing_platform.sensors.display_video import ( |
45 | 42 | GoogleDisplayVideo360GetSDFDownloadOperationSensor, |
46 | | - GoogleDisplayVideo360ReportSensor, |
47 | 43 | GoogleDisplayVideo360RunQuerySensor, |
48 | 44 | ) |
49 | 45 |
|
|
60 | 56 | ENTITY_TYPE = os.environ.get("GMP_ENTITY_TYPE", "LineItem") |
61 | 57 | ERF_SOURCE_OBJECT = GoogleDisplayVideo360Hook.erf_uri(GMP_PARTNER_ID, ENTITY_TYPE) |
62 | 58 |
|
63 | | -REPORT = { |
64 | | - "kind": "doubleclickbidmanager#query", |
65 | | - "metadata": { |
66 | | - "title": "Polidea Test Report", |
67 | | - "dataRange": "LAST_7_DAYS", |
68 | | - "format": "CSV", |
69 | | - "sendNotification": False, |
70 | | - }, |
71 | | - "params": { |
72 | | - "type": "TYPE_GENERAL", |
73 | | - "groupBys": ["FILTER_DATE", "FILTER_PARTNER"], |
74 | | - "filters": [{"type": "FILTER_PARTNER", "value": 1486931}], |
75 | | - "metrics": ["METRIC_IMPRESSIONS", "METRIC_CLICKS"], |
76 | | - "includeInviteData": True, |
77 | | - }, |
78 | | - "schedule": {"frequency": "ONE_TIME"}, |
79 | | -} |
80 | | - |
81 | 59 | REPORT_V2 = { |
82 | 60 | "metadata": { |
83 | 61 | "title": "Airflow Test Report", |
|
109 | 87 |
|
110 | 88 | START_DATE = datetime(2021, 1, 1) |
111 | 89 |
|
112 | | -with models.DAG( |
113 | | - "example_display_video", |
114 | | - start_date=START_DATE, |
115 | | - catchup=False, |
116 | | -) as dag1: |
117 | | - # [START howto_google_display_video_createquery_report_operator] |
118 | | - create_report = GoogleDisplayVideo360CreateReportOperator(body=REPORT, task_id="create_report") |
119 | | - report_id = cast(str, XComArg(create_report, key="report_id")) |
120 | | - # [END howto_google_display_video_createquery_report_operator] |
121 | | - |
122 | | - # [START howto_google_display_video_runquery_report_operator] |
123 | | - run_report = GoogleDisplayVideo360RunReportOperator( |
124 | | - report_id=report_id, parameters=PARAMETERS, task_id="run_report" |
125 | | - ) |
126 | | - # [END howto_google_display_video_runquery_report_operator] |
127 | | - |
128 | | - # [START howto_google_display_video_wait_report_operator] |
129 | | - wait_for_report = GoogleDisplayVideo360ReportSensor(task_id="wait_for_report", report_id=report_id) |
130 | | - # [END howto_google_display_video_wait_report_operator] |
131 | | - |
132 | | - # [START howto_google_display_video_getquery_report_operator] |
133 | | - get_report = GoogleDisplayVideo360DownloadReportOperator( |
134 | | - report_id=report_id, |
135 | | - task_id="get_report", |
136 | | - bucket_name=BUCKET, |
137 | | - report_name="test1.csv", |
138 | | - ) |
139 | | - # [END howto_google_display_video_getquery_report_operator] |
140 | | - |
141 | | - # [START howto_google_display_video_deletequery_report_operator] |
142 | | - delete_report = GoogleDisplayVideo360DeleteReportOperator(report_id=report_id, task_id="delete_report") |
143 | | - # [END howto_google_display_video_deletequery_report_operator] |
144 | | - |
145 | | - run_report >> wait_for_report >> get_report >> delete_report |
146 | | - |
147 | | - # Task dependencies created via `XComArgs`: |
148 | | - # create_report >> run_report |
149 | | - # create_report >> wait_for_report |
150 | | - # create_report >> get_report |
151 | | - # create_report >> delete_report |
152 | | - |
153 | | - |
154 | 90 | with models.DAG( |
155 | 91 | "example_display_video_misc", |
156 | 92 | start_date=START_DATE, |
|
0 commit comments