Files
site/apps/api/app/modules/zootech/wesp_compat_sync.py
T

31 lines
951 B
Python

"""WESP /api/sync/clients compat — maps to orchestrator farm hubs."""
from __future__ import annotations
from fastapi import APIRouter, Depends, HTTPException, Query, status
from app.modules.sync import repository as sync_repo
from app.modules.sync.tenant import TenantContext, require_enterprise_zootech
router = APIRouter()
@router.get("/sync/clients")
def list_sync_clients(
enterprise_id: str = Query(...),
tenant: TenantContext = Depends(require_enterprise_zootech),
):
if tenant.enterprise_id != enterprise_id:
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="ENTERPRISE_FORBIDDEN")
hubs = sync_repo.list_farm_hubs(enterprise_id)
return [
{
"id": h.id,
"node_id": h.hub_site_id,
"client_name": h.name,
"status": h.status,
"last_seen": h.last_seen.isoformat() if h.last_seen else None,
}
for h in hubs
]