Add Pydantic models and FastAPI router structure for agent and backend
CI / basic-check (push) Has been cancelled
CI / basic-check (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.schemas import DiscoveryRun, EntityResponse, ListResponse
|
||||
from app.services.store import DISCOVERY_RUNS
|
||||
|
||||
router = APIRouter(prefix='/discoveries', tags=['discoveries'])
|
||||
|
||||
|
||||
@router.get('', response_model=ListResponse[DiscoveryRun])
|
||||
def list_discoveries() -> ListResponse[DiscoveryRun]:
|
||||
return ListResponse(count=len(DISCOVERY_RUNS), items=DISCOVERY_RUNS)
|
||||
|
||||
|
||||
@router.get('/{discovery_id}', response_model=EntityResponse[DiscoveryRun])
|
||||
def get_discovery(discovery_id: str) -> EntityResponse[DiscoveryRun]:
|
||||
for item in DISCOVERY_RUNS:
|
||||
if item.id == discovery_id:
|
||||
return EntityResponse(item=item)
|
||||
raise HTTPException(status_code=404, detail='Discovery not found')
|
||||
Reference in New Issue
Block a user