36 lines
1 KiB
Python
36 lines
1 KiB
Python
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
class Site(BaseModel):
|
|
id: str
|
|
name: str
|
|
location: str
|
|
status: str
|
|
rack_count: int
|
|
total_power_kw: float
|
|
pue: float
|
|
|
|
|
|
# Static stub data — will be replaced by DB queries in Phase 2
|
|
SITES: list[Site] = [
|
|
Site(id="sg-01", name="Singapore DC01", location="Singapore", status="ok", rack_count=128, total_power_kw=847.0, pue=1.42),
|
|
Site(id="sg-02", name="Singapore DC02", location="Singapore", status="warning", rack_count=64, total_power_kw=412.0, pue=1.51),
|
|
Site(id="lon-01", name="London DC01", location="London", status="ok", rack_count=96, total_power_kw=631.0, pue=1.38),
|
|
]
|
|
|
|
|
|
@router.get("", response_model=list[Site])
|
|
async def list_sites():
|
|
return SITES
|
|
|
|
|
|
@router.get("/{site_id}", response_model=Site)
|
|
async def get_site(site_id: str):
|
|
for site in SITES:
|
|
if site.id == site_id:
|
|
return site
|
|
from fastapi import HTTPException
|
|
raise HTTPException(status_code=404, detail="Site not found")
|