Defines API
This commit is contained in:
parent
4f56f2af26
commit
ea5ca24341
|
@ -209,6 +209,33 @@ proc initDataApi(node: CodexNodeRef, repoStore: RepoStore, router: var RestRoute
|
||||||
)
|
)
|
||||||
return RestApiResponse.response($json, contentType="application/json")
|
return RestApiResponse.response($json, contentType="application/json")
|
||||||
|
|
||||||
|
router.api(
|
||||||
|
MethodPut,
|
||||||
|
"api/codex/v1/pin/{cid}") do (
|
||||||
|
cid: Cid, resp: HttpResponseRef) -> RestApiResponse:
|
||||||
|
## Pins a file to the node. Node will keep the file in local storage while pinned.
|
||||||
|
##
|
||||||
|
if cid.isErr:
|
||||||
|
return RestApiResponse.error(
|
||||||
|
Http400,
|
||||||
|
$cid.error())
|
||||||
|
|
||||||
|
await node.pinCid(cid.get(), resp=resp)
|
||||||
|
|
||||||
|
router.api(
|
||||||
|
MethodDelete,
|
||||||
|
"api/codex/v1/pin/{cid}") do (
|
||||||
|
cid: Cid, resp: HttpResponseRef) -> RestApiResponse:
|
||||||
|
## Remove a pinned file from the node. Node will delete the local copy of the file.
|
||||||
|
##
|
||||||
|
if cid.isErr:
|
||||||
|
return RestApiResponse.error(
|
||||||
|
Http400,
|
||||||
|
$cid.error())
|
||||||
|
|
||||||
|
await node.unpinCid(cid.get(), resp=resp)
|
||||||
|
|
||||||
|
|
||||||
proc initSalesApi(node: CodexNodeRef, router: var RestRouter) =
|
proc initSalesApi(node: CodexNodeRef, router: var RestRouter) =
|
||||||
router.api(
|
router.api(
|
||||||
MethodGet,
|
MethodGet,
|
||||||
|
|
41
openapi.yaml
41
openapi.yaml
|
@ -475,6 +475,47 @@ paths:
|
||||||
"500":
|
"500":
|
||||||
description: "It's not working as planned"
|
description: "It's not working as planned"
|
||||||
|
|
||||||
|
"/pin/{cid}":
|
||||||
|
put:
|
||||||
|
summary: "Pins a file to the node. Node will keep the file in local storage while pinned."
|
||||||
|
tags: [ Data ]
|
||||||
|
operationId: pinToLocal
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: cid
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Cid"
|
||||||
|
description: File to be pinned.
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK. Node will start fetching the file from the network if needed.
|
||||||
|
"400":
|
||||||
|
description: Invalid CID is specified
|
||||||
|
"500":
|
||||||
|
description: Well it was bad-bad
|
||||||
|
|
||||||
|
delete:
|
||||||
|
summary: "Remove a pinned file from the node. Node will delete the local copy of the file."
|
||||||
|
tags: [ Data ]
|
||||||
|
operationId: unpinFromLocal
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: cid
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Cid"
|
||||||
|
description: Pinned CID to be removed.
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK. Node will delete the previously pinned file from local storage.
|
||||||
|
"400":
|
||||||
|
description: Invalid CID is specified
|
||||||
|
"404":
|
||||||
|
description: The provided CID was not previously pinned
|
||||||
|
"500":
|
||||||
|
description: Well it was bad-bad
|
||||||
|
|
||||||
"/sales/slots":
|
"/sales/slots":
|
||||||
get:
|
get:
|
||||||
summary: "Returns active slots"
|
summary: "Returns active slots"
|
||||||
|
|
Loading…
Reference in New Issue