1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

Complete directives implementation, refactor exceptions, deprecate VRFs, bump minimum Python version

This commit is contained in:
thatmattlove
2021-09-07 22:58:39 -07:00
parent b05e544e40
commit 5ccfe50792
58 changed files with 1222 additions and 1010 deletions

View File

@@ -15,7 +15,7 @@ from httpx import StatusCode
from hyperglass.log import log
from hyperglass.util import make_repr, parse_exception
from hyperglass.constants import __version__
from hyperglass.exceptions import HyperglassError
from hyperglass.exceptions.private import ExternalError
def _prepare_dict(_dict):
@@ -101,7 +101,7 @@ class BaseExternal:
if exc is not None:
message = f"{str(message)}: {str(exc)}"
return HyperglassError(message, str(level), **kwargs)
return ExternalError(message=message, level=level, **kwargs)
def _parse_response(self, response):
if self.parse:

View File

@@ -1,11 +1,11 @@
"""Convenience functions for webhooks."""
# Project
from hyperglass.exceptions import HyperglassError
from hyperglass.external._base import BaseExternal
from hyperglass.external.slack import SlackHook
from hyperglass.external.generic import GenericHook
from hyperglass.external.msteams import MSTeams
from hyperglass.exceptions.private import UnsupportedError
PROVIDER_MAP = {
"generic": GenericHook,
@@ -23,6 +23,7 @@ class Webhook(BaseExternal):
provider_class = PROVIDER_MAP[config.provider]
return provider_class(config)
except KeyError:
raise HyperglassError(
f"'{config.provider.title()}' is not yet supported as a webhook target."
raise UnsupportedError(
message="{p} is not yet supported as a webhook target.",
p=config.provider.title(),
)