Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions airflow/providers/discord/hooks/discord_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ class DiscordWebhookHook(HttpHook):
conn_type = "discord"
hook_name = "Discord"

@classmethod
def get_connection_form_widgets(cls) -> dict[str, Any]:
"""Returns connection widgets to add to connection form."""
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from flask_babel import lazy_gettext
from wtforms import StringField
from wtforms.validators import Optional

return {
"webhook_endpoint": StringField(
lazy_gettext("Webhook Endpoint"),
widget=BS3TextFieldWidget(),
validators=[Optional()],
default=None,
),
}

def __init__(
self,
http_conn_id: str | None = None,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.



.. _howto/connection:http:

Discord Webhook Connection
==========================

The Discord connection enables connections to Discord webhooks.
The Discord connection uses the HTTP connection to perform the webhook request.

Authenticating with HTTP
------------------------

Login and Password authentication can be used along with any authentication method using headers.
Headers can be given in json format in the Extras field.

Default Connection IDs
----------------------

The Discord webhook operators and hooks use ``discord_default`` by default.

Configuring the Connection
--------------------------

Login (optional)
Specify the login for the discord server you would like to connect too.

Password (optional)
Specify the password of the user for the discord server you would like to connect too.

Host (optional)
Specify the entire url or the base of the url for the discord server.

Port (optional)
Specify a port number if applicable.

Schema (optional)
Specify the service type etc: http/https.

Webhook Endpoint
The endpoint that will be used to perform the HTTP request.

Extras (optional)
Specify headers in json format.
7 changes: 7 additions & 0 deletions docs/apache-airflow-providers-discord/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
Changelog <changelog>
Security <security>

.. toctree::
:hidden:
:maxdepth: 1
:caption: Guides

Connection types <connections/discord-webhook>

.. toctree::
:hidden:
:maxdepth: 1
Expand Down