airflow.providers.discord.hooks.discord_webhook¶
Classes¶
Contains the common functionality. |
|
This hook allows you to post messages to Discord using incoming webhooks. |
|
This hook allows you to post messages to Discord using incoming webhooks using async HTTP. |
Module Contents¶
- class airflow.providers.discord.hooks.discord_webhook.DiscordCommonHandler[source]¶
Contains the common functionality.
- get_webhook_endpoint(conn, webhook_endpoint)[source]¶
Return the default webhook endpoint or override if a webhook_endpoint is manually supplied.
- validate_embed(*, embed)[source]¶
Validate Discord Embed JSON payload.
- Validates the embed object against Discord limits. See:
https://discord.com/developers/docs/resources/message#embed-object-embed-limits
- Parameters:
embed (airflow.providers.discord.notifications.embed.Embed) – Discord embed object.
- Returns:
Discord embed object.
- Return type:
- build_discord_payload(*, tts, message, username, avatar_url, embed=None)[source]¶
Build a valid Discord JSON payload.
- Parameters:
tts (bool) – Is a text-to-speech message
message (str) – The message you want to send to your Discord channel (max 2000 characters)
username (str | None) – Override the default username of the webhook
avatar_url (str | None) – Override the default avatar of the webhook
embed (airflow.providers.discord.notifications.embed.Embed | None) – Discord embed object.
- Returns:
Discord payload (str) to send
- Return type:
- class airflow.providers.discord.hooks.discord_webhook.DiscordWebhookHook(http_conn_id=None, webhook_endpoint=None, message='', username=None, avatar_url=None, tts=False, proxy=None, embed=None, *args, **kwargs)[source]¶
Bases:
airflow.providers.http.hooks.http.HttpHookThis hook allows you to post messages to Discord using incoming webhooks.
Takes a Discord connection ID with a default relative webhook endpoint. The default endpoint can be overridden using the webhook_endpoint parameter (https://discordapp.com/developers/docs/resources/webhook).
Each Discord webhook can be pre-configured to use a specific username and avatar_url. You can override these defaults in this hook.
- Parameters:
http_conn_id (str | None) – Http connection ID with host as “https://discord.com/api/” and default webhook endpoint in the extra field in the form of {“webhook_endpoint”: “webhooks/{webhook.id}/{webhook.token}”}
webhook_endpoint (str | None) – Discord webhook endpoint in the form of “webhooks/{webhook.id}/{webhook.token}”
message (str) – The message you want to send to your Discord channel (max 2000 characters)
username (str | None) – Override the default username of the webhook
avatar_url (str | None) – Override the default avatar of the webhook
tts (bool) – Is a text-to-speech message
proxy (str | None) – Proxy to use to make the Discord webhook call
embed (airflow.providers.discord.notifications.embed.Embed | None) – Discord embed object.
- class airflow.providers.discord.hooks.discord_webhook.DiscordWebhookAsyncHook(*, http_conn_id='', webhook_endpoint=None, message='', username=None, avatar_url=None, tts=False, proxy=None, embed=None, **kwargs)[source]¶
Bases:
airflow.providers.http.hooks.http.HttpAsyncHookThis hook allows you to post messages to Discord using incoming webhooks using async HTTP.
Takes a Discord connection ID with a default relative webhook endpoint. The default endpoint can be overridden using the webhook_endpoint parameter (https://discordapp.com/developers/docs/resources/webhook).
Each Discord webhook can be pre-configured to use a specific username and avatar_url. You can override these defaults in this hook.
- Parameters:
http_conn_id (str) – Http connection ID with host as “https://discord.com/api/” and default webhook endpoint in the extra field in the form of {“webhook_endpoint”: “webhooks/{webhook.id}/{webhook.token}”}
webhook_endpoint (str | None) – Discord webhook endpoint in the form of “webhooks/{webhook.id}/{webhook.token}”
message (str) – The message you want to send to your Discord channel (max 2000 characters)
username (str | None) – Override the default username of the webhook
avatar_url (str | None) – Override the default avatar of the webhook
tts (bool) – Is a text-to-speech message
proxy (str | None) – Proxy to use to make the Discord webhook call
embed (airflow.providers.discord.notifications.embed.Embed | None) – Discord embed object.