from fastapi import APIRouter
from datetime import datetime
from typing import Dict, List
from pydantic import BaseModel
import structlog

router = APIRouter(tags=["health"])
logger = structlog.get_logger("health.routes")

VERSION = "2.0.0"


class HealthResponse(BaseModel):
    status: str
    version: str
    timestamp: str
    services: Dict[str, str]


class MetricsResponse(BaseModel):
    version: str
    timestamp: str
    services: List[str]


@router.get("/health", response_model=HealthResponse)
async def health():
    """
    Health check endpoint

    BACKWARD COMPATIBLE - Returns service health status
    """
    logger.debug("health_check_requested")

    return HealthResponse(
        status="ok",
        version=VERSION,
        timestamp=datetime.utcnow().isoformat() + "Z",
        services={
            "translation": "enabled",
            "wine_pairing": "enabled",
            "menu_extraction": "enabled",
            "create_restaurant_offer": "enabled",
            "generate_ai_image": "enabled",
        }
    )


@router.get("/metrics", response_model=MetricsResponse)
async def get_metrics():
    """Get service metrics"""
    logger.debug("metrics_requested")

    return MetricsResponse(
        version=VERSION,
        timestamp=datetime.utcnow().isoformat() + "Z",
        services=["translation", "wine_pairing", "menu_extraction", "create_restaurant_offer", "generate_ai_image"]
    )
