From aeaae04544db586da71db24c44220be13aa45863 Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 28 Apr 2026 18:11:11 +0200 Subject: [PATCH] Change GPU buy/sell endpoints to use gpu_id path parameter --- .../src/app/routers/marketplace_gpu.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/coordinator-api/src/app/routers/marketplace_gpu.py b/apps/coordinator-api/src/app/routers/marketplace_gpu.py index 7d58902a..2c7d0d7e 100755 --- a/apps/coordinator-api/src/app/routers/marketplace_gpu.py +++ b/apps/coordinator-api/src/app/routers/marketplace_gpu.py @@ -224,19 +224,20 @@ async def get_gpu_details(gpu_id: str, session: Annotated[Session, Depends(get_s return result -@router.post("/marketplace/gpu/buy") +@router.post("/marketplace/gpu/{gpu_id}/purchase") async def buy_gpu( + gpu_id: str, request: GPUBuyRequest, session: Annotated[Session, Depends(get_session)], engine: DynamicPricingEngine = Depends(get_pricing_engine), ) -> dict[str, Any]: """Buy GPU compute from marketplace with blockchain payment.""" - gpu = _get_gpu_or_404(session, request.gpu_id) + gpu = _get_gpu_or_404(session, gpu_id) if gpu.status != "available": raise HTTPException( status_code=http_status.HTTP_409_CONFLICT, - detail=f"GPU {request.gpu_id} is not available for purchase", + detail=f"GPU {gpu_id} is not available for purchase", ) # Create booking for the purchase @@ -262,7 +263,7 @@ async def buy_gpu( booking_id = str(uuid4()) booking = GPUBooking( id=booking_id, - gpu_id=request.gpu_id, + gpu_id=gpu_id, job_id=f"purchase_{request.buyer_id[:8]}", duration_hours=request.duration_hours, total_cost=total_cost, @@ -281,7 +282,7 @@ async def buy_gpu( return { "purchase_id": booking_id, - "gpu_id": request.gpu_id, + "gpu_id": gpu_id, "buyer_id": request.buyer_id, "duration_hours": request.duration_hours, "total_cost": total_cost, @@ -293,7 +294,7 @@ async def buy_gpu( } -@router.post("/marketplace/gpu/{gpu_id}/sell") +@router.post("/marketplace/gpu/{gpu_id}/list_for_sale") async def sell_gpu( gpu_id: str, request: GPUSellRequest,