"""
AwoooP Operator Console — Tenants List API
==========================================
ADR-106（AwoooP Agent Platform），ADR-115（Tenant Onboarding）
2026-05-05 ogt + Claude Sonnet 4.6
"""

from __future__ import annotations

from datetime import datetime
from decimal import Decimal
from typing import Any
from uuid import UUID

from fastapi import APIRouter
from pydantic import BaseModel

from src.services.platform_operator_service import list_tenants as list_tenants_svc

router = APIRouter()


class TenantItem(BaseModel):
    project_id: str
    display_name: str
    migration_mode: str
    budget_limit_usd: Decimal | None
    is_active: bool
    created_at: datetime


class ListTenantsResponse(BaseModel):
    tenants: list[TenantItem]
    total: int


@router.get(
    "/tenants",
    response_model=ListTenantsResponse,
    summary="列出所有租戶",
    description=(
        "返回所有 awooop_projects 記錄（含已停用）。\n\n"
        "ADR-106/ADR-115：Operator Console 使用，不依 RLS 過濾。"
    ),
)
async def list_tenants() -> dict[str, Any]:
    return await list_tenants_svc()
