2020-06-26 12:23:11 -07:00
|
|
|
"""Session handler for Microsoft Teams API."""
|
|
|
|
|
|
|
|
# Project
|
|
|
|
from hyperglass.log import log
|
|
|
|
from hyperglass.external._base import BaseExternal
|
2020-10-05 12:07:34 -07:00
|
|
|
from hyperglass.models.webhook import Webhook
|
2020-06-26 12:23:11 -07:00
|
|
|
|
|
|
|
|
|
|
|
class MSTeams(BaseExternal, name="MSTeams"):
|
|
|
|
"""Microsoft Teams session handler."""
|
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
"""Initialize external base class with Microsoft Teams connection details."""
|
|
|
|
|
|
|
|
super().__init__(
|
|
|
|
base_url="https://outlook.office.com", config=config, parse=False
|
|
|
|
)
|
|
|
|
|
|
|
|
async def send(self, query):
|
|
|
|
"""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())
|