serkef commented on a change in pull request #5519: [AIRFLOW-4543] Update slack 
operator to support slackclient v2
URL: https://github.com/apache/airflow/pull/5519#discussion_r302302278
 
 

 ##########
 File path: airflow/hooks/slack_hook.py
 ##########
 @@ -27,36 +29,53 @@ class SlackHook(BaseHook):
        Interact with Slack, using slackclient library.
     """
 
-    def __init__(self, token=None, slack_conn_id=None):
+    def __init__(self, token=None, slack_conn_id=None, **client_args):
         """
-        Takes both Slack API token directly and connection that has Slack API 
token.
+        Creates a Slack connection, to be used for calls.
 
+        Takes both Slack API token directly and connection that has Slack API 
token.
         If both supplied, Slack API token will be used.
 
+        Exposes also the rest of slack.WebClient args.
+
         :param token: Slack API token
         :type token: str
         :param slack_conn_id: connection that has Slack API token in the 
password field
         :type slack_conn_id: str
+        :param use_session: A boolean specifying if the client should take 
advantage of
+        connection pooling. Default is True.
+        :type base_url: bool
+        :param base_url: A string representing the Slack API base URL. Default 
is
+        `https://www.slack.com/api/`
+        :type base_url: str
+        :param timeout: The maximum number of seconds the client will wait
+            to connect and receive a response from Slack.
+            Default is 30 seconds.
+        :type timeout: int
         """
-        self.token = self.__get_token(token, slack_conn_id)
+        token = self.__get_token(token, slack_conn_id)
+        self.client = WebClient(token, **client_args)
 
     def __get_token(self, token, slack_conn_id):
         if token is not None:
             return token
-        elif slack_conn_id is not None:
+
+        if slack_conn_id is not None:
             conn = self.get_connection(slack_conn_id)
 
-            if not getattr(conn, 'password', None):
-                raise AirflowException('Missing token(password) in Slack 
connection')
+            if not getattr(conn, "password", None):
+                raise AirflowException("Missing token(password) in Slack 
connection")
 
 Review comment:
   ok, reverted.

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


With regards,
Apache Git Services

Reply via email to