michalslowikowski00 commented on a change in pull request #8174: Added 
GoogleDisplayVideo360DownloadLineItemsOperator
URL: https://github.com/apache/airflow/pull/8174#discussion_r406676405
 
 

 ##########
 File path: 
airflow/providers/google/marketing_platform/operators/display_video.py
 ##########
 @@ -336,3 +333,72 @@ def execute(self, context: Dict):
             self.params,
         )
         hook.run_query(query_id=self.report_id, params=self.params)
+
+
+class GoogleDisplayVideo360DownloadLineItemsOperator(BaseOperator):
+    """
+    Retrieves line items in CSV format.
+
+    .. seealso::
+        For more information on how to use this operator, take a look at the 
guide:
+        :ref:`howto/operator:GoogleDisplayVideo360DownloadLineItemsOperator`
+
+    .. seealso::
+        Check also the official API docs:
+        
`https://developers.google.com/bid-manager/v1.1/lineitems/downloadlineitems`
+
+    :param request_body: dictionary with parameters that should be passed into.
+            More information about it can be found here:
+            
https://developers.google.com/bid-manager/v1.1/lineitems/downloadlineitems
+    :type request_body: Dict[str, Any],
+    """
+
+    template_fields = ("request_body", "bucket_name", "object_name")
+
+    @apply_defaults
+    def __init__(
+        self,
+        request_body: Dict[str, Any],
+        bucket_name: str,
+        object_name: str,
+        gzip: bool = False,
+        api_version: str = "v1.1",
+        gcp_conn_id: str = "google_cloud_default",
+        delegate_to: Optional[str] = None,
+        *args,
+        **kwargs
+    ) -> None:
+        super().__init__(*args, **kwargs)
+        self.request_body = request_body
+        self.object_name = object_name
+        self.bucket_name = bucket_name
+        self.gzip = gzip
+        self.api_version = api_version
+        self.gcp_conn_id = gcp_conn_id
+        self.delegate_to = delegate_to
+
+    def execute(self, context: Dict) -> str:
+        gcs_hook = GCSHook(gcp_conn_id=self.gcp_conn_id, 
delegate_to=self.delegate_to)
+        hook = GoogleDisplayVideo360Hook(
+            gcp_conn_id=self.gcp_conn_id,
+            api_version=self.api_version,
+            delegate_to=self.delegate_to,
+        )
+
+        self.log.info("Retrieving report...")
+        content: List[str] = 
hook.download_line_items(request_body=self.request_body)
+        # lineItems: List[str] = content["lineItems]
+
+        with tempfile.NamedTemporaryFile("w+") as temp_file:
+            writer = csv.writer(temp_file)
+            writer.writerows(content)
+            # writer.writerows(lineItems)
 
 Review comment:
   Remove it.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to