"""
Admin API URL configuration.
Provides endpoints for admin dashboard functionality.
"""

from django.urls import include, path
from rest_framework.routers import DefaultRouter

from apps.core.api.alert_views import (
    RateLimitAlertConfigViewSet,
    RateLimitAlertViewSet,
    SystemAlertViewSet,
)
from apps.core.api.incident_views import IncidentViewSet

from . import views

app_name = "admin_api"

# Router for admin ViewSets
router = DefaultRouter()
router.register(r"system-alerts", SystemAlertViewSet, basename="system-alert")
router.register(r"rate-limit-alerts", RateLimitAlertViewSet, basename="rate-limit-alert")
router.register(r"rate-limit-config", RateLimitAlertConfigViewSet, basename="rate-limit-config")
router.register(r"incidents", IncidentViewSet, basename="incident")


urlpatterns = [
    # Alert ViewSets (via router)
    path("", include(router.urls)),
    # OSM Cache Stats
    path(
        "osm-usage-stats/",
        views.OSMUsageStatsView.as_view(),
        name="osm_usage_stats",
    ),
    # Rate Limit Metrics
    path(
        "rate-limit-metrics/",
        views.RateLimitMetricsView.as_view(),
        name="rate_limit_metrics",
    ),
    # Database Manager (admin CRUD operations)
    path(
        "database-manager/",
        views.DatabaseManagerView.as_view(),
        name="database_manager",
    ),
    # Celery Task Status (read-only)
    path(
        "tasks/status/",
        views.CeleryTaskStatusView.as_view(),
        name="task_status",
    ),
    # Anomaly Detection
    path(
        "anomalies/detect/",
        views.DetectAnomaliesView.as_view(),
        name="detect_anomalies",
    ),
    # Metrics Collection
    path(
        "metrics/collect/",
        views.CollectMetricsView.as_view(),
        name="collect_metrics",
    ),
    # Pipeline Integrity Scan
    path(
        "pipeline/integrity-scan/",
        views.PipelineIntegrityScanView.as_view(),
        name="pipeline_integrity_scan",
    ),
    # Admin Settings (key-value store for preferences)
    path(
        "settings/",
        views.AdminSettingsView.as_view(),
        name="admin_settings",
    ),
]
