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/07/03 06:38:44 UTC

[GitHub] [airflow] ashb commented on a change in pull request #5519: [AIRFLOW-4543] Update slack operator to support slackclient v2

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

 ##########
 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:
   PRs are _much_ easier to review if you don't make un-necessary/stylistic changes like this. Please back this sort of change out :)

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