Skip to content
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

Slack: use default_conn_name by default #34548

Merged
merged 3 commits into from
Sep 22, 2023
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
2 changes: 1 addition & 1 deletion airflow/providers/slack/hooks/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class SlackHook(BaseHook):
def __init__(
self,
*,
slack_conn_id: str,
slack_conn_id: str = default_conn_name,
base_url: str | None = None,
timeout: int | None = None,
proxy: str | None = None,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/slack/notifications/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SlackNotifier(BaseNotifier):
def __init__(
self,
*,
slack_conn_id: str = "slack_api_default",
slack_conn_id: str = SlackHook.default_conn_name,
text: str = "This is a default message",
channel: str = "#general",
username: str = "Airflow",
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/slack/operators/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SlackAPIOperator(BaseOperator):
def __init__(
self,
*,
slack_conn_id: str,
slack_conn_id: str = SlackHook.default_conn_name,
method: str | None = None,
api_params: dict | None = None,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/slack/transfers/sql_to_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def __init__(
sql_conn_id: str,
sql_hook_params: dict | None = None,
parameters: Iterable | Mapping[str, Any] | None = None,
slack_conn_id: str,
slack_conn_id: str = SlackHook.default_conn_name,
slack_filename: str,
slack_channels: str | Sequence[str] | None = None,
slack_initial_comment: str | None = None,
Expand Down
7 changes: 2 additions & 5 deletions docs/apache-airflow-providers-slack/connections/slack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ Authenticating to Slack
Authenticate to Slack using a `Slack API token
<https://slack.com/help/articles/215770388-Create-and-regenerate-API-tokens>`_.

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

.. warning::

The SlackHook and community provided operators not intend to use any Slack API Connection by default right now.
It might change in the future to ``slack_api_default``.
The default Slack API Connection ID is ``slack_api_default``.

Configuring the Connection
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions tests/providers/slack/hooks/test_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,7 @@ def test_empty_string_ignored_non_prefixed(self):
params = hook._get_conn_params()
assert "proxy" not in params
assert "base_url" not in params

def test_default_conn_name(self):
hook = SlackHook()
assert hook.slack_conn_id == SlackHook.default_conn_name