"""Prometheus metrics endpoint — admin-only."""

from __future__ import annotations

from fastapi import APIRouter, Depends
from fastapi.responses import PlainTextResponse

from app.core.monitoring import generate_metrics
from app.deps import get_current_user

router = APIRouter(tags=["metrics"])


@router.get(
    "/api/v1/metrics",
    response_class=PlainTextResponse,
    dependencies=[Depends(get_current_user)],
)
async def metrics():
    """Prometheus metrics endpoint.

    Returns Prometheus-formatted text/plain metrics.
    Requires admin role — 403 for non-admin users.
    """
    data = generate_metrics()
    return PlainTextResponse(
        content=data.decode("utf-8"),
        media_type="text/plain; version=0.0.4; charset=utf-8",
    )
