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