from typing import List, Optional

from fastapi import APIRouter, Depends
from fastapi.responses import JSONResponse
from pydantic import BaseModel, Field

from src.aeros_project.router import router as aeros_project_router
from src.aeros_simulation.router import router as aeros_simulation_router, airflow_router
from src.auth.service import JWTBearer
from src.dashboard_model.router import router as dashboard_model_router
from src.aeros_equipment.router import router as aeros_equipment_router
from src.aeros_contribution.router import router as aeros_contribution_router

class ErrorMessage(BaseModel):
    msg: str = Field(..., max_length=255)


class ErrorResponse(BaseModel):
    detail: Optional[List[ErrorMessage]]


api_router = APIRouter(
    default_response_class=JSONResponse,
)


@api_router.get("/healthcheck", include_in_schema=False)
def healthcheck():
    return {"status": "ok"}


authenticated_api_router = APIRouter(
    dependencies=[Depends(JWTBearer())],
)

authenticated_api_router.include_router(
    dashboard_model_router, prefix="/dashboard_model"
)

aeros_routes = APIRouter(prefix="/aeros")

aeros_routes.include_router(aeros_simulation_router, prefix="/simulation")
aeros_routes.include_router(aeros_project_router, prefix="/project")
aeros_routes.include_router(aeros_equipment_router, prefix="/equipment")
aeros_routes.include_router(aeros_contribution_router, prefix="/contribution")


authenticated_api_router.include_router(aeros_routes)

api_router.include_router(airflow_router, prefix="/airflow")
api_router.include_router(authenticated_api_router)
