Change GPU buy/sell endpoints to use gpu_id path parameter
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 12s
Python Tests / test-python (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled

This commit is contained in:
aitbc
2026-04-28 18:11:11 +02:00
parent 70b725e13c
commit aeaae04544

View File

@@ -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,