mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
25 lines
658 B
Python
25 lines
658 B
Python
![]() |
"""Convenience functions for webhooks."""
|
||
|
|
||
|
# Project
|
||
|
from hyperglass.exceptions import HyperglassError
|
||
|
from hyperglass.external._base import BaseExternal
|
||
|
from hyperglass.external.slack import SlackHook
|
||
|
|
||
|
PROVIDER_MAP = {
|
||
|
"slack": SlackHook,
|
||
|
}
|
||
|
|
||
|
|
||
|
class Webhook(BaseExternal):
|
||
|
"""Get webhook for provider name."""
|
||
|
|
||
|
def __new__(cls, provider):
|
||
|
"""Return instance for correct provider handler."""
|
||
|
try:
|
||
|
provider_class = PROVIDER_MAP[provider]
|
||
|
return provider_class()
|
||
|
except KeyError:
|
||
|
raise HyperglassError(
|
||
|
f"{provider} is not yet supported as a webhook target."
|
||
|
)
|