diff --git a/app/routers/take.py b/app/routers/take.py index f0cd112..5085ce7 100644 --- a/app/routers/take.py +++ b/app/routers/take.py @@ -9,10 +9,17 @@ from app.storage import redis router = fastapi.APIRouter() +class Task(pydantic.BaseModel): + id: str + attempt: int + payload: dict + + class Response(pydantic.BaseModel): id: str attempt: int payload: dict + task: Task|None @router.get('/api/v1/take', responses={404: {'description': 'Not found'}}) @@ -20,4 +27,4 @@ async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response: task = await tasks.take_task(queue) if not task: raise fastapi.HTTPException(404) - return Response(id=str(task._id), attempt=task.attempts, payload=task.payload) + return Response(id=str(task._id), attempt=task.attempts, payload=task.payload, task=Task(id=str(task._id), attempt=task.attempts, payload=task.payload))