orangeqs.juice.alerting._schemas#

Schema definitions for OrangeQS Juice Alerting.

Module Contents#

Classes#

SenderInterface

Base class for protocol classes.

SenderConfig

Configuration schema describing a sender implementation type.

AlertRouting

Configuration schema for the Alert Routing layer.

AlertDefinition

Base class for configurations that can be loaded from disk.

SmtpSecretsConfig

Configuration schema for SMTP credentials.

SmtpSenderConfig

Configuration schema for non-sensitive SMTP sender settings.

JuiceAlerts

Configuration schema for the Juice Alerts module.

AlertEvent

Event class for alert messages.

API#

class orangeqs.juice.alerting._schemas.SenderInterface#

Bases: typing.Protocol

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).

For example::

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::

class GenProto[T](Protocol):
    def meth(self) -> T:
        ...
async send(topic: str, title: str, body: str) None#

Delivers a fully rendered alert message to the specified receivers.

Parameters#

  • topic (str): The alert topic.

  • title (str): A short, human-readable summary of the alert.

  • body (str): The complete alert message.

Raises#

  • (Exception): If the alert could not be delivered.

class orangeqs.juice.alerting._schemas.SenderConfig(/, **data: Any)#

Bases: pydantic.BaseModel

Configuration schema describing a sender implementation type.

sender_type: str#

None

class orangeqs.juice.alerting._schemas.AlertRouting(/, **data: Any)#

Bases: orangeqs.juice.settings.Configurable

Configuration schema for the Alert Routing layer.

filename: ClassVar[str]#

‘alert-routing.toml’

juice_alert_routing: dict[str, list[orangeqs.juice.alerting._schemas.SenderConfig]]#

None

Mapping of alert topics to lists of sender configurations.

default_alert_routing: list[orangeqs.juice.alerting._schemas.SenderConfig]#

None

class orangeqs.juice.alerting._schemas.AlertDefinition(/, **data: Any)#

Bases: orangeqs.juice.settings.Configurable

Base class for configurations that can be loaded from disk.

This method should be subclassed by any model that needs to load its configuration from disk. The filename class variable defines which files to load, which should be unique across all configurations in an OrangeQS Juice installation.

Examples#

Create a subclass of Configurable to define your configuration model:

class ExampleConfig(Configurable):
    filename = "example"

    some_setting: str = "default_value"
    another_setting: int = 42

config = ExampleConfig.load()
assert config.some_setting == "default_value"
filename: ClassVar[str]#

‘alert-definitions’

topic: str#

None

title_template: str#

None

body_template: str#

None

required_context: list[str]#

None

cooldown_seconds: int#

0

class orangeqs.juice.alerting._schemas.SmtpSecretsConfig(/, **data: Any)#

Bases: orangeqs.juice.settings.Configurable

Configuration schema for SMTP credentials.

filename: ClassVar[str]#

‘smtp-email-secrets’

username: str#

None

password: str#

None

class orangeqs.juice.alerting._schemas.SmtpSenderConfig(/, **data: Any)#

Bases: orangeqs.juice.settings.Configurable

Configuration schema for non-sensitive SMTP sender settings.

filename: ClassVar[str]#

‘smtp-email-sender-config’

host: str#

None

sender_email: str#

None

default_receivers: list[str]#

None

topic_receivers: dict[str, list[str]]#

None

port: int#

587

use_ssl: bool#

False

use_starttls: bool#

True

class orangeqs.juice.alerting._schemas.JuiceAlerts(/, **data: Any)#

Bases: orangeqs.juice.settings.Configurable

Configuration schema for the Juice Alerts module.

filename: ClassVar[str]#

‘juice-alerts-config’

juice_alert_definitions: dict[str, orangeqs.juice.alerting._schemas.AlertDefinition]#

None

class orangeqs.juice.alerting._schemas.AlertEvent(/, **data: Any)#

Bases: orangeqs.juice.messaging.protocol.Event

Event class for alert messages.

measurement: ClassVar[str]#

‘alert_event’

alert_topic: str#

None