mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-05 15:33:08 +00:00
* Extended /admin/v1 RESP API with different option to look at current connected/relay/mesh state of the node * Added score information for peer info retrievals
70 lines
1.9 KiB
Nim
70 lines
1.9 KiB
Nim
{.push raises: [].}
|
|
|
|
import chronicles, json_serialization, presto/[route, client], stew/byteutils
|
|
|
|
import ../serdes, ../rest_serdes, ./types
|
|
|
|
export types
|
|
|
|
logScope:
|
|
topics = "waku node rest admin api"
|
|
|
|
proc encodeBytes*(value: seq[string], contentType: string): RestResult[seq[byte]] =
|
|
return encodeBytesOf(value, contentType)
|
|
|
|
proc getPeers*(): RestResponse[seq[WakuPeer]] {.
|
|
rest, endpoint: "/admin/v1/peers", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc postPeers*(
|
|
body: seq[string]
|
|
): RestResponse[string] {.
|
|
rest, endpoint: "/admin/v1/peers", meth: HttpMethod.MethodPost
|
|
.}
|
|
|
|
proc getPeerById*(
|
|
peerId: string
|
|
): RestResponse[WakuPeer] {.
|
|
rest, endpoint: "/admin/v1/peer/{peerId}", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getConnectedPeers*(): RestResponse[seq[WakuPeer]] {.
|
|
rest, endpoint: "/admin/v1/peers/connected", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getConnectedPeersByShard*(
|
|
shardId: uint16
|
|
): RestResponse[seq[WakuPeer]] {.
|
|
rest, endpoint: "/admin/v1/peers/connected/on/{shardId}", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getConnectedRelayPeers*(): RestResponse[PeersOfShards] {.
|
|
rest, endpoint: "/admin/v1/peers/connected/relay", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getConnectedRelayPeersByShard*(
|
|
shardId: uint16
|
|
): RestResponse[PeersOfShard] {.
|
|
rest,
|
|
endpoint: "/admin/v1/peers/connected/relay/on/{shardId}",
|
|
meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getMeshPeers*(): RestResponse[PeersOfShards] {.
|
|
rest, endpoint: "/admin/v1/peers/mesh", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getMeshPeersByShard*(
|
|
shardId: uint16
|
|
): RestResponse[PeersOfShard] {.
|
|
rest, endpoint: "/admin/v1/peers/mesh/on/{shardId}", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getFilterSubscriptions*(): RestResponse[seq[FilterSubscription]] {.
|
|
rest, endpoint: "/admin/v1/filter/subscriptions", meth: HttpMethod.MethodGet
|
|
.}
|
|
|
|
proc getFilterSubscriptionsFilterNotMounted*(): RestResponse[string] {.
|
|
rest, endpoint: "/admin/v1/filter/subscriptions", meth: HttpMethod.MethodGet
|
|
.}
|