22 lines
610 B
Python
22 lines
610 B
Python
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from ..db import get_session
|
|
from ..schemas import AcceptedResponse, HeartbeatRequest
|
|
from ..services.ingestion import upsert_agent_heartbeat
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post(
|
|
"/heartbeat",
|
|
response_model=AcceptedResponse,
|
|
status_code=status.HTTP_202_ACCEPTED,
|
|
)
|
|
async def heartbeat(
|
|
body: HeartbeatRequest, session: AsyncSession = Depends(get_session)
|
|
) -> AcceptedResponse:
|
|
await upsert_agent_heartbeat(session, body)
|
|
await session.commit()
|
|
return AcceptedResponse(accepted=True)
|