"""Backups service definition.

Backups is modeled as a service type so it can be configured, named, and
multi-instanced like other services. Reports arrive via the existing REST
report endpoint; the ``ingestion_label`` disambiguates multi-instance
ingestion.
"""

from __future__ import annotations

from media_library_viewer_api.integrations.base import (
    ServiceConfigBase,
    ServiceDefinition,
    WidgetConfigBase,
    widget_kind,
)


class BackupsConfig(ServiceConfigBase):
    """Non-secret Backups connection config."""

    ingestion_label: str = "default"


class BackupsSummaryWidgetConfig(WidgetConfigBase):
    """Backup dashboard summary (jobs, runs, alerts)."""

    # No user-overridable fields; the widget reads the internal backup tables.
    pass


DEFINITION = ServiceDefinition(
    service_type="backups",
    name="Backups",
    description="Backup job monitoring, run history, and alerting.",
    config_model=BackupsConfig,
    secret_fields=[],
    widget_kinds=[
        widget_kind(
            kind="summary",
            name="Summary",
            description="Backup job summary and active alerts.",
            model_cls=BackupsSummaryWidgetConfig,
            default_config={},
            refresh_interval_ms=60_000,
        ),
    ],
)
