You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/09/23 12:50:07 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #6169: [AIRFLOW-4970][Don't merge] Add Google Campaign Manager integration

mik-laj commented on a change in pull request #6169: [AIRFLOW-4970][Don't merge] Add Google Campaign Manager integration
URL: https://github.com/apache/airflow/pull/6169#discussion_r327094894
 
 

 ##########
 File path: airflow/gcp/hooks/campaign_manager.py
 ##########
 @@ -0,0 +1,244 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+This module contains Google Campaign Manager hook.
+"""
+from typing import Any, Dict, Optional
+
+from googleapiclient.discovery import build, Resource
+from googleapiclient import http
+
+from airflow.contrib.hooks.gcp_api_base_hook import GoogleCloudBaseHook
+
+
+class GoogleCampaignManagerHook(GoogleCloudBaseHook):
+    """
+    Hook for Google Campaign Manager.
+    """
+
+    _conn = None  # type: Optional[Resource]
+
+    def __init__(
+        self,
+        api_version: str = "v3.2",
+        gcp_conn_id: str = "google_cloud_default",
+        delegate_to: Optional[str] = None,
+    ) -> None:
+        super().__init__(gcp_conn_id, delegate_to)
+        self.api_version = api_version
+
+    def get_conn(self) -> Resource:
+        """
+        Retrieves connection to Campaign Manager.
+        """
+        if not self._conn:
+            http_authorized = self._authorize()
+            self._conn = build(
+                "dfareporting",
+                self.api_version,
+                http=http_authorized,
+                cache_discovery=False,
+            )
+        return self._conn
+
+    def delete(self, profile_id: str, report_id: str) -> Any:
 
 Review comment:
   ```suggestion
       def delete_report(self, profile_id: str, report_id: str) -> Any:
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services