# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .alerting_monitor_config import AlertingMonitorConfig
from .alerting_webhook_notifier import AlertingWebhookNotifier


class AlertingSettings(UncheckedBaseModel):
    """
    Alerting configuration used at both per-agent and per-workspace level.

    All fields are optional overrides; the cascade resolver fills in defaults
    when they are unset. Notifiers stack and dedupe (by URL) across the
    workspace and agent layers rather than overriding each other.

    Cascade order for per-monitor threshold and auto-resolve: agent → workspace →
    system default.
    """

    monitor_configs: typing.Optional[typing.Dict[str, AlertingMonitorConfig]] = pydantic.Field(default=None)
    """
    Alerting configuration keyed by monitor name.
    """

    auto_resolve_after_inactive_minutes: typing.Optional[int] = pydantic.Field(default=None)
    """
    How many minutes an alert can stay inactive before it is auto-resolved. Unset values fall through to the next layer.
    """

    notifiers: typing.Optional[typing.List[AlertingWebhookNotifier]] = pydantic.Field(default=None)
    """
    Delivery channels for alert lifecycle notifications. Stacked and deduped by URL with other layers.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
