mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
Improve external http client typing and add tests
This commit is contained in:
15
hyperglass/external/generic.py
vendored
15
hyperglass/external/generic.py
vendored
@@ -1,20 +1,29 @@
|
||||
"""Session handler for Generic HTTP API endpoint."""
|
||||
|
||||
# Standard Library
|
||||
import typing as t
|
||||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
from hyperglass.external._base import BaseExternal
|
||||
from hyperglass.models.webhook import Webhook
|
||||
|
||||
# Local
|
||||
from ._base import BaseExternal
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
# Project
|
||||
from hyperglass.models.config.logging import Http
|
||||
|
||||
|
||||
class GenericHook(BaseExternal, name="Generic"):
|
||||
"""Slack session handler."""
|
||||
|
||||
def __init__(self, config):
|
||||
def __init__(self: "GenericHook", config: "Http") -> None:
|
||||
"""Initialize external base class with http connection details."""
|
||||
|
||||
super().__init__(base_url=f"{config.host.scheme}://{config.host.host}", config=config)
|
||||
|
||||
async def send(self, query):
|
||||
async def send(self: "GenericHook", query: t.Dict[str, t.Any]):
|
||||
"""Send an incoming webhook to http endpoint."""
|
||||
|
||||
payload = Webhook(**query)
|
||||
|
Reference in New Issue
Block a user