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 2022/09/23 12:24:24 UTC

[GitHub] [airflow] Taragolis commented on a diff in pull request #26374: Implements SqlToSlackApiFileOperator

Taragolis commented on code in PR #26374:
URL: https://github.com/apache/airflow/pull/26374#discussion_r978577850


##########
airflow/providers/slack/transfers/sql_to_slack.py:
##########
@@ -165,3 +193,115 @@ def execute(self, context: Context) -> None:
         self._render_and_send_slack_message(context, df)
 
         self.log.debug('Finished sending SQL data to Slack')
+
+
+class SqlToSlackApiFileOperator(BaseSqlToSlackOperator):

Review Comment:
   Let me just summarise what we have right not, what we use right now and what Slack supports
   
   **Send Message in Slack Channel supported by Airflow**:
   1. Slack API `chat.postMessage` method via [SlackHook.call](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack.py#L198-L213)  method
   2. Slack Incoming Webhook via [SlackHook.send_dict](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L317-L347), [SlackHook.send](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L349-L397) and [SlackHook.send_text](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L399-L415) methods
   3. Slack Webhook based on Legacy Integration via [SlackHook.send_dict](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L317-L347), [SlackHook.send](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L349-L397) and [SlackHook.send_text](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack_webhook.py#L399-L415) methods
   
   Full list for what could be use for [send message into Slack Channel](https://api.slack.com/messaging/sending#sending_methods)
   
   **Send File in Slack Channel (or Workspace) supported by Airflow**:
   1. Slack API `files.upload` method via [SlackHook.send_file](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack.py#L215-L265) or [SlackHook.call](https://github.com/apache/airflow/blob/55d11464c047d2e74f34cdde75d90b633a231df2/airflow/providers/slack/hooks/slack.py#L198-L213) methods
   
   ## Which parameters could be provided for different methods
   
   ### Slack API Method [chat.postMessage](https://api.slack.com/methods/chat.postMessage) (Mainstream)
   | **parameter**   |               **required**              |    **scope** |
   |:----------------|:---------------------------------------:|:-------------|
   | token           |                   Yes                   |      headers |
   | channel         |                   Yes                   | dict payload |
   | attachments     | At least one of attachments blocks text | dict payload |
   | blocks          | At least one of attachments blocks text | dict payload |
   | text            | At least one of attachments blocks text | dict payload |
   | as_user         |                    No                   | dict payload |
   | icon_emoji      |                    No                   | dict payload |
   | icon_url        |                    No                   | dict payload |
   | link_names      |                    No                   | dict payload |
   | metadata        |                    No                   | dict payload |
   | mrkdwn          |                    No                   | dict payload |
   | boolean         |                    No                   | dict payload |
   | parse           |                    No                   | dict payload |
   | reply_broadcast |                    No                   | dict payload |
   | thread_ts       |                    No                   | dict payload |
   | unfurl_links    |                    No                   | dict payload |
   | unfurl_media    |                    No                   | dict payload |
   | username        |                    No                   | dict payload |
   
   ### Slack API Method [files.upload](https://api.slack.com/methods/files.upload) (Mainstream)
   | **parameter**   |       **required**       | **scope**           |
   |:----------------|:------------------------:|:--------------------|
   | token           |            Yes           | headers             |
   | channels        |            No            | dict payload        |
   | content         |   No (if file provided)  | dict payload        |
   | file            | No (if content provided) | multipart/form-data |
   | filename        |            No            | dict payload        |
   | filetype        |            No            | dict payload        |
   | initial_comment |            No            | dict payload        |
   | thread_ts       |            No            | dict payload        |
   | title           |            No            | dict payload        |
   
   ### [Slack Incoming Webhook](https://api.slack.com/messaging/webhooks) (Mainstream)
   
   There is no information about end list of parameters, due to the code of [WebhookClient.send](https://github.com/slackapi/python-slack-sdk/blob/0782f566a0c26a534965d4a1127a3b402a4d726b/slack_sdk/webhook/client.py#L78-L122) from `slack_sdk` only this parameters allowed (but not for 100% sure)
   
   | **parameter**    |               **required**              | **scope**    |
   |:-----------------|:---------------------------------------:|:-------------|
   | token            |                   Yes                   | URL          |
   | attachments      | At least one of attachments blocks text | dict payload |
   | blocks           | At least one of attachments blocks text | dict payload |
   | text             | At least one of attachments blocks text | dict payload |
   | response_type    |                    No                   | dict payload |
   | replace_original |                    No                   | dict payload |
   | delete_original  |                    No                   | dict payload |
   | unfurl_links     |                    No                   | dict payload |
   | unfurl_media     |                    No                   | dict payload |
   
   ###  [Slack Webhook based on Legacy Integration](https://taragolisworkspace.slack.com/apps/A0F7XDUAZ-incoming-webhooks?tab=settings&next_id=0) (Legacy)
   
   Even less information than Slack Incoming Webhook. Due to investigation this parameters supported
   
   | **parameter**    |               **required**              | **scope**    |
   |:-----------------|:---------------------------------------:|:-------------|
   | token            |                   Yes                   | URL          |
   | channel         |                   No                   | dict payload |
   | attachments      | At least one of attachments blocks text | dict payload |
   | blocks           | At least one of attachments blocks text | dict payload |
   | text             | At least one of attachments blocks text | dict payload |
   | icon_emoji      |                    No                   | dict payload |
   | icon_url        |                    No                   | dict payload |
   | username        |                    No                   | dict payload |
   | unfurl_links     |                    No                   | dict payload |
   
   And this additional parameters might supported
   | **parameter**    |               **required**              | **scope**    |
   |:-----------------|:---------------------------------------:|:-------------|
   | response_type    |                    No                   | dict payload |
   | replace_original |                    No                   | dict payload |
   | delete_original  |                    No                   | dict payload |
   | unfurl_media     |                    No                   | dict payload |



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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org