spektom commented on a change in pull request #5785: [AIRFLOW-5176] Add Azure 
Data Explorer (Kusto) operator
URL: https://github.com/apache/airflow/pull/5785#discussion_r314977300
 
 

 ##########
 File path: airflow/contrib/hooks/azure_data_explorer_hook.py
 ##########
 @@ -0,0 +1,146 @@
+# -*- 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 Azure Data Explorer hook"""
+
+from azure.kusto.data.request import KustoClient, 
KustoConnectionStringBuilder, ClientRequestProperties
+from azure.kusto.data.exceptions import KustoServiceError
+
+from airflow.hooks.base_hook import BaseHook
+from airflow.exceptions import AirflowException
+
+
+class AzureDataExplorerHook(BaseHook):
+    """
+    Interacts with Azure Data Explorer (Kusto).
+
+    Extra JSON field contains the following parameters:
+
+    .. code-block:: json
+
+        {
+            "tenant": "<Tenant ID>",
+            "auth_method": "<Authentication method>",
+            "certificate": "<Application PEM certificate>",
+            "thumbprint": "<Application certificate thumbprint>"
+        }
+
+    **Cluster**:
+
+    Azure Data Explorer cluster is specified by a URL, for example: 
"https://help.kusto.windows.net";.
+    The parameter must be provided through `Host` connection detail.
+
+    **Tenant ID**:
+
+    To learn about tenants refer to: 
https://docs.microsoft.com/en-us/onedrive/find-your-office-365-tenant-id
+
+    **Authentication methods**:
+
+    Authentication method must be provided through "auth_method" extra 
parameter.
+    Available authentication methods are:
+
+      - AAD_APP : Authentication with AAD application certificate. Extra 
parameters:
+                  "tenant" is required when using this method. Provide 
application ID
+                  and application key through username and password parameters.
+
+      - AAD_APP_CERT: Authentication with AAD application certificate. Extra 
parameters:
+                      "tenant", "certificate" and "thumbprint" are required
+                      when using this method.
+
+      - AAD_CREDS : Authentication with AAD username and password. Extra 
parameters:
+                    "tenant" is required when using this method. Username and 
password
+                    parameters are used for authentication with AAD.
+
+      - AAD_DEVICE : Authenticate with AAD device code. Please note that if 
you choose
+                     this option, you'll need to authenticate for every new 
instance
+                     that is initialized. It is highly recommended to create 
one instance
+                     and use it for all queries.
+
+    :param azure_data_explorer_conn_id: Reference to the Azure Data Explorer 
connection.
+    :type azure_data_explorer_conn_id: str
+    """
+    def __init__(self,
+                 azure_data_explorer_conn_id='azure_data_explorer_default'):
+        self.conn_id = azure_data_explorer_conn_id
+        self.connection = self.get_conn()
+
+    def get_conn(self):
+        """Return a KustoClient object."""
+        conn = self.get_connection(self.conn_id)
 
 Review comment:
   There's in fact no precedent of passing `conn_id` parameter into 
`get_conn()`. Just run `grep get_conn\(self, *.py` in hooks/ and got nothing.

----------------------------------------------------------------
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