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

32 lines
967 B
Python
Raw Normal View History

2020-06-26 12:23:11 -07:00
"""Session handler for Microsoft Teams API."""
2021-12-15 00:50:20 -07:00
# Standard Library
import typing as t
2020-06-26 12:23:11 -07:00
# Project
from hyperglass.log import log
from hyperglass.external._base import BaseExternal
from hyperglass.models.webhook import Webhook
2020-06-26 12:23:11 -07:00
if t.TYPE_CHECKING:
2021-12-15 00:50:20 -07:00
# Project
from hyperglass.models.config.logging import Http
2020-06-26 12:23:11 -07:00
class MSTeams(BaseExternal, name="MSTeams"):
"""Microsoft Teams session handler."""
def __init__(self: "MSTeams", config: "Http") -> None:
2020-06-26 12:23:11 -07:00
"""Initialize external base class with Microsoft Teams connection details."""
2021-09-12 15:09:24 -07:00
super().__init__(base_url="https://outlook.office.com", config=config, parse=False)
2020-06-26 12:23:11 -07:00
async def send(self: "MSTeams", query: t.Dict[str, t.Any]):
2020-06-26 12:23:11 -07:00
"""Send an incoming webhook to Microsoft Teams."""
payload = Webhook(**query)
log.debug("Sending query data to Microsoft Teams:\n{}", payload)
return await self._apost(endpoint=self.config.host.path, data=payload.msteams())