Skip to content

Refactor Slack API Hook and add new Connection type #25852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

Taragolis
Copy link
Contributor

@Taragolis Taragolis commented Aug 21, 2022

Refactor Slack API hook

  1. Retrieve token and create client outside of __init__ method
  2. Create new connection type. Right now only Slack Webhook connection exists.
  3. Add test method to connection.
  4. Customise Slack API Connection UI.
  5. Show deprecation warning if user provide token in Hook argument. IMHO, there is not a good idea provide directly token better to use Connection.
  6. Keep compatible with generic connection.
  7. Mask token provided as hook argument.

Connection UI and Testing Connection

image

image

image

Examples:
.. code-block:: python
.. code-block:: python
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional indent required to proper formatted block in documentation and PyCharm

Without additional space
https://airflow.apache.org/docs/apache-airflow-providers-slack/stable/_api/airflow/providers/slack/hooks/slack/index.html#airflow.providers.slack.hooks.slack.SlackHook

With additional space
image

Might be possible avoid this "hack"?

Comment on lines 180 to +186
def __get_token(self, token: Any, slack_conn_id: Any) -> str:
warnings.warn(
"`SlackHook.__get_token` method deprecated and will be removed in a future releases.",
DeprecationWarning,
stacklevel=2,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also might be better just remove this method.
It not used after changes and it is hardly possible that someone override it

Comment on lines +37 to +43
class ConnectionExtraConfig:
"""Helper class for rom Connection Extra.

:param conn_type: Hook connection type.
:param conn_id: Connection ID uses for appropriate error messages.
:param extra: Connection extra dictionary.
"""
Copy link
Contributor Author

@Taragolis Taragolis Aug 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I create separate class for use in further steps

  1. Refactor airflow.providers.slack.hooks.slack_webhook.SlackWebhookHook which mostly designed for use with legacy Slack Integrations
  2. Create new hook and connection which will use slack_sdk.webhook.WebhookClient and create integration with Slack Incoming Webhook based on Slack API/App

@Taragolis Taragolis force-pushed the refactor-slack-api-hook branch 4 times, most recently from eb00fb8 to ed8a940 Compare August 27, 2022 16:59
@Taragolis Taragolis force-pushed the refactor-slack-api-hook branch from ed8a940 to 7ae8172 Compare August 27, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy