Source code for fmn.rules.notification

# SPDX-FileCopyrightText: Contributors to the Fedora Project
#
# SPDX-License-Identifier: MIT

from typing import Annotated, Literal

from pydantic import BaseModel, Field


[docs]class FrozenModel(BaseModel):
[docs] class Config: frozen = True
[docs]class EmailNotificationHeaders(FrozenModel): To: str Subject: str
[docs]class EmailNotificationContent(FrozenModel): headers: EmailNotificationHeaders body: str
[docs]class EmailNotification(FrozenModel): protocol: Literal["email"] content: EmailNotificationContent
[docs]class IRCNotificationContent(FrozenModel): to: str message: str
[docs]class IRCNotification(FrozenModel): protocol: Literal["irc"] content: IRCNotificationContent
[docs]class MatrixNotificationContent(FrozenModel): to: str message: str
[docs]class MatrixNotification(FrozenModel): protocol: Literal["matrix"] content: MatrixNotificationContent
[docs]class Notification(FrozenModel): __root__: Annotated[ EmailNotification | IRCNotification | MatrixNotification, Field(discriminator="protocol") ] def __getattr__(self, attr): return getattr(self.__root__, attr)