airflow.providers.slack.hooks.slack_webhook
¶
Module Contents¶
Classes¶
This class provide a thin wrapper around the |
Functions¶
|
Check WebhookResponse and raise an error if status code != 200. |
Attributes¶
- airflow.providers.slack.hooks.slack_webhook.LEGACY_INTEGRATION_PARAMS = ('channel', 'username', 'icon_emoji', 'icon_url')[source]¶
- airflow.providers.slack.hooks.slack_webhook.check_webhook_response(func)[source]¶
Check WebhookResponse and raise an error if status code != 200.
- class airflow.providers.slack.hooks.slack_webhook.SlackWebhookHook(*, slack_webhook_conn_id, timeout=None, proxy=None, retry_handlers=None, **extra_client_args)[source]¶
Bases:
airflow.hooks.base.BaseHook
This class provide a thin wrapper around the
slack_sdk.WebhookClient
.This hook allows you to post messages to Slack by using Incoming Webhooks.
See also
Note
You cannot override the default channel (chosen by the user who installed your app), username, or icon when you’re using Incoming Webhooks to post messages. Instead, these values will always inherit from the associated Slack App configuration (link). It is possible to change this values only in Legacy Slack Integration Incoming Webhook.
Warning
This hook intend to use Slack Incoming Webhook connection and might not work correctly with Slack API connection.
- Examples:
# Create hook hook = SlackWebhookHook(slack_webhook_conn_id="slack_default") # Post message in Slack channel by JSON formatted message # See: https://api.slack.com/messaging/webhooks#posting_with_webhooks hook.send_dict({"text": "Hello world!"}) # Post simple message in Slack channel hook.send_text("Hello world!") # Use ``slack_sdk.WebhookClient`` hook.client.send(text="Hello world!")
- Parameters
slack_webhook_conn_id (str) – Slack Incoming Webhook connection id that has Incoming Webhook token in the password field.
timeout (int | None) – The maximum number of seconds the client will wait to connect and receive a response from Slack. If not set than default WebhookClient value will use.
proxy (str | None) – Proxy to make the Slack Incoming Webhook call.
retry_handlers (list[slack_sdk.http_retry.RetryHandler] | None) – List of handlers to customize retry logic in
slack_sdk.WebhookClient
.
- send_dict(body, *, headers=None)[source]¶
Perform a Slack Incoming Webhook request with given JSON data block.
- send(*, text=None, blocks=None, response_type=None, replace_original=None, delete_original=None, unfurl_links=None, unfurl_media=None, headers=None, attachments=None, **kwargs)[source]¶
Perform a Slack Incoming Webhook request with given arguments.
- Parameters
text (str | None) – The text message (even when having blocks, setting this as well is recommended as it works as fallback).
blocks (list[dict[str, Any]] | None) – A collection of Block Kit UI components.
response_type (str | None) – The type of message (either ‘in_channel’ or ‘ephemeral’).
replace_original (bool | None) – True if you use this option for response_url requests.
delete_original (bool | None) – True if you use this option for response_url requests.
unfurl_links (bool | None) – Option to indicate whether text url should unfurl.
unfurl_media (bool | None) – Option to indicate whether media url should unfurl.
headers (dict[str, str] | None) – Request headers for this request.
attachments (list[dict[str, Any]] | None) – (legacy) A collection of attachments.
- send_text(text, *, unfurl_links=None, unfurl_media=None, headers=None)[source]¶
Perform a Slack Incoming Webhook request with given text.