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

Fix hooks extended from http hook #16109

Merged
merged 7 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions airflow/providers/airbyte/hooks/airbyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class AirbyteHook(HttpHook):
:type api_version: str
"""

conn_name_attr = 'airbyte_conn_id'
default_conn_name = 'airbyte_default'
conn_type = 'airbyte'
hook_name = 'Airbyte'

RUNNING = "running"
SUCCEEDED = "succeeded"
CANCELLED = "cancelled"
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/dingding/hooks/dingding.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class DingdingHook(HttpHook):
:type at_all: bool
"""

conn_name_attr = 'dingding_conn_id'
default_conn_name = 'dingding_default'
conn_type = 'dingding'
hook_name = 'Dingding'

def __init__(
self,
dingding_conn_id='dingding_default',
Expand Down
5 changes: 5 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,11 @@ class DiscordWebhookHook(HttpHook):
:type proxy: str
"""

conn_name_attr = 'http_conn_id'
default_conn_name = 'discord_default'
conn_type = 'discord'
hook_name = 'Discord'

def __init__(
self,
http_conn_id: Optional[str] = None,
Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/opsgenie/hooks/opsgenie_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class OpsgenieAlertHook(HttpHook):

"""

conn_name_attr = 'opsgenie_conn_id'
default_conn_name = 'opsgenie_default'
conn_type = 'opsgenie'
hook_name = 'Opsgenie'

def __init__(self, opsgenie_conn_id: str = 'opsgenie_default', *args, **kwargs) -> None:
super().__init__(http_conn_id=opsgenie_conn_id, *args, **kwargs) # type: ignore[misc]

Expand Down
5 changes: 5 additions & 0 deletions airflow/providers/slack/hooks/slack_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class SlackWebhookHook(HttpHook):
:type proxy: str
"""

conn_name_attr = 'http_conn_id'
default_conn_name = 'slack_default'
conn_type = 'slackwebhook'
hook_name = 'Slack Webhook'

# pylint: disable=too-many-arguments
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function discover_all_hooks() {
group_start "Listing available hooks via 'airflow providers hooks'"
COLUMNS=180 airflow providers hooks

local expected_number_of_hooks=65
local expected_number_of_hooks=66
local actual_number_of_hooks
actual_number_of_hooks=$(airflow providers hooks --output table | grep -c "| apache" | xargs)
if [[ ${actual_number_of_hooks} != "${expected_number_of_hooks}" ]]; then
Expand Down
5 changes: 4 additions & 1 deletion tests/providers/airbyte/hooks/test_airbyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ class TestAirbyteHook(unittest.TestCase):
def setUp(self):
db.merge_conn(
Connection(
conn_id='airbyte_conn_id_test', conn_type='http', host='http://test-airbyte', port=8001
conn_id='airbyte_conn_id_test',
conn_type='airbyte',
host='http://test-airbyte',
port=8001
)
)
self.hook = AirbyteHook(airbyte_conn_id=self.airbyte_conn_id)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/dingding/hooks/test_dingding.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setUp(self):
db.merge_conn(
Connection(
conn_id=self.conn_id,
conn_type='http',
conn_type='dingding',
host='https://oapi.dingtalk.com',
password='you_token_here',
)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/discord/hooks/test_discord_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setUp(self):
db.merge_conn(
Connection(
conn_id='default-discord-webhook',
conn_type='http',
conn_type='discord',
host='https://discordapp.com/api/',
extra='{"webhook_endpoint": "webhooks/00000/some-discord-token_000"}',
)
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/opsgenie/hooks/test_opsgenie_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def setUp(self):
db.merge_conn(
Connection(
conn_id=self.conn_id,
conn_type='http',
conn_type='opsgenie',
host='https://api.opsgenie.com/',
password='eb243592-faa2-4ba2-a551q-1afdf565c889',
)
Expand Down
10 changes: 6 additions & 4 deletions tests/providers/slack/hooks/test_slack_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,28 @@ def setUp(self):
db.merge_conn(
Connection(
conn_id='slack-webhook-default',
conn_type='http',
conn_type='slackwebhook',
extra='{"webhook_token": "your_token_here"}',
)
)
db.merge_conn(
Connection(
conn_id='slack-webhook-url',
conn_type='http',
conn_type='slackwebhook',
host='https://hooks.slack.com/services/T000/B000/XXX',
)
)
db.merge_conn(
Connection(
conn_id='slack-webhook-host', conn_type='http', host='https://hooks.slack.com/services/T000/'
conn_id='slack-webhook-host',
conn_type='slackwebhook',
host='https://hooks.slack.com/services/T000/'
)
)
db.merge_conn(
Connection(
conn_id='slack-webhook-with-password',
conn_type='http',
conn_type='slackwebhook',
password='your_token_here',
)
)
Expand Down