Storage/purchases endpoint (#609)
* adds list of purchase ids to storage API * adds list of purchase ids to storage API * Updates openAPI * fixes openAPI type
This commit is contained in:
parent
80e2ef4eb5
commit
34a9c5e88d
|
@ -74,3 +74,10 @@ func getPurchase*(purchasing: Purchasing, id: PurchaseId): ?Purchase =
|
||||||
some purchasing.purchases[id]
|
some purchasing.purchases[id]
|
||||||
else:
|
else:
|
||||||
none Purchase
|
none Purchase
|
||||||
|
|
||||||
|
func getPurchaseIds*(purchasing: Purchasing): seq[PurchaseId] =
|
||||||
|
var pIds: seq[PurchaseId] = @[]
|
||||||
|
for key in purchasing.purchases.keys:
|
||||||
|
pIds.add(key)
|
||||||
|
return pIds
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,15 @@ proc initPurchasingApi(node: CodexNodeRef, router: var RestRouter) =
|
||||||
|
|
||||||
return RestApiResponse.response($json, contentType="application/json")
|
return RestApiResponse.response($json, contentType="application/json")
|
||||||
|
|
||||||
|
router.api(
|
||||||
|
MethodGet,
|
||||||
|
"/api/codex/v1/storage/purchases") do () -> RestApiResponse:
|
||||||
|
without contracts =? node.contracts.client:
|
||||||
|
return RestApiResponse.error(Http503, "Purchasing unavailable")
|
||||||
|
|
||||||
|
let purchaseIds = contracts.purchasing.getPurchaseIds()
|
||||||
|
return RestApiResponse.response($ %purchaseIds, contentType="application/json")
|
||||||
|
|
||||||
proc initDebugApi(node: CodexNodeRef, conf: CodexConf, router: var RestRouter) =
|
proc initDebugApi(node: CodexNodeRef, conf: CodexConf, router: var RestRouter) =
|
||||||
router.api(
|
router.api(
|
||||||
MethodGet,
|
MethodGet,
|
||||||
|
|
71
openapi.yaml
71
openapi.yaml
|
@ -412,6 +412,50 @@ paths:
|
||||||
"503":
|
"503":
|
||||||
description: Sales are unavailable
|
description: Sales are unavailable
|
||||||
|
|
||||||
|
"/storage/request/{cid}":
|
||||||
|
post:
|
||||||
|
summary: "Creates a new Request for storage"
|
||||||
|
tags: [ Marketplace ]
|
||||||
|
operationId: createStorageRequest
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: cid
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Cid"
|
||||||
|
description: CID of the uploaded data that should be stored
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/StorageRequestCreation"
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Returns the Request ID as decimal string
|
||||||
|
"400":
|
||||||
|
description: Invalid or missing Request ID
|
||||||
|
"404":
|
||||||
|
description: Request ID not found
|
||||||
|
"503":
|
||||||
|
description: Purchasing is unavailable
|
||||||
|
|
||||||
|
"/storage/purchases":
|
||||||
|
get:
|
||||||
|
summary: "Returns list of purchase IDs"
|
||||||
|
tags: [ Marketplace ]
|
||||||
|
operationId: getPurchases
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Gets all purchase IDs stored in node
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
"503":
|
||||||
|
description: Purchasing is unavailable
|
||||||
|
|
||||||
"/storage/purchases/{id}":
|
"/storage/purchases/{id}":
|
||||||
get:
|
get:
|
||||||
summary: "Returns purchase details"
|
summary: "Returns purchase details"
|
||||||
|
@ -440,33 +484,6 @@ paths:
|
||||||
"503":
|
"503":
|
||||||
description: Purchasing is unavailable
|
description: Purchasing is unavailable
|
||||||
|
|
||||||
"/storage/request/{cid}":
|
|
||||||
post:
|
|
||||||
summary: "Creates a new Request for storage"
|
|
||||||
tags: [ Marketplace ]
|
|
||||||
operationId: createStorageRequest
|
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: cid
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/Cid"
|
|
||||||
description: CID of the uploaded data that should be stored
|
|
||||||
requestBody:
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: "#/components/schemas/StorageRequestCreation"
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Returns the Request ID as decimal string
|
|
||||||
"400":
|
|
||||||
description: Invalid or missing Request ID
|
|
||||||
"404":
|
|
||||||
description: Request ID not found
|
|
||||||
"503":
|
|
||||||
description: Purchasing is unavailable
|
|
||||||
|
|
||||||
"/debug/chronicles/loglevel":
|
"/debug/chronicles/loglevel":
|
||||||
post:
|
post:
|
||||||
summary: "Set log level at run time"
|
summary: "Set log level at run time"
|
||||||
|
|
Loading…
Reference in New Issue