"""URL helper — the common service URLs (health + the drf-spectacular OpenAPI schema & Swagger UI)
plus the service's own paths. A service's urls.py is then a one-liner:

    from andrea_svc_web.urls import service_urls
    from django.urls import path
    from myapp.views import ThingView
    urlpatterns = service_urls(extra=[path("thing", ThingView.as_view(), name="thing")])
"""
from django.urls import path
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView

from .health import HealthView
from .reload import ReloadConfigView


def service_urls(extra=None):
    """Return the service's urlpatterns: its own `extra` paths first, then the common
    health + OpenAPI (schema + docs) + live config-reload paths. `extra` is a list of
    django.urls.path() entries."""
    common = [
        path("health", HealthView.as_view(), name="health"),
        # rm#129 — the universal, no-argument secrets/config reload callback. Every basement service
        # inherits it, so a rotation is applied live (auth key → next request; DB creds → reconnect)
        # instead of needing a restart. AUTHENTICATED, unlike /health.
        path("admin/reload-config", ReloadConfigView.as_view(), name="reload-config"),
        path("api/schema", SpectacularAPIView.as_view(), name="schema"),
        path("api/docs", SpectacularSwaggerView.as_view(url_name="schema"), name="docs"),
    ]
    return list(extra or []) + common
