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 EntityResponse, Job, ListResponse
|
||||
from app.services.store import JOBS
|
||||
|
||||
router = APIRouter(prefix='/jobs', tags=['jobs'])
|
||||
|
||||
|
||||
@router.get('', response_model=ListResponse[Job])
|
||||
def list_jobs() -> ListResponse[Job]:
|
||||
return ListResponse(count=len(JOBS), items=JOBS)
|
||||
|
||||
|
||||
@router.get('/{job_id}', response_model=EntityResponse[Job])
|
||||
def get_job(job_id: str) -> EntityResponse[Job]:
|
||||
for item in JOBS:
|
||||
if item.id == job_id:
|
||||
return EntityResponse(item=item)
|
||||
raise HTTPException(status_code=404, detail='Job not found')
|
||||
Reference in New Issue
Block a user