2024-06-28 16:04:57 +05:30
|
|
|
{.push raises: [].}
|
2023-10-05 14:00:09 +02:00
|
|
|
|
2025-04-11 17:20:23 +02:00
|
|
|
import chronicles, json_serialization, presto/[route, client], stew/byteutils
|
|
|
|
|
|
|
|
|
|
import ../serdes, ../rest_serdes, ./types
|
2023-10-05 14:00:09 +02:00
|
|
|
|
|
|
|
|
export types
|
|
|
|
|
|
|
|
|
|
logScope:
|
|
|
|
|
topics = "waku node rest admin api"
|
|
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc encodeBytes*(value: seq[string], contentType: string): RestResult[seq[byte]] =
|
2023-11-14 16:59:53 +01:00
|
|
|
return encodeBytesOf(value, contentType)
|
2023-10-05 14:00:09 +02:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc getPeers*(): RestResponse[seq[WakuPeer]] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peers", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
2023-10-05 14:00:09 +02:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc postPeers*(
|
|
|
|
|
body: seq[string]
|
|
|
|
|
): RestResponse[string] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peers", meth: HttpMethod.MethodPost
|
|
|
|
|
.}
|
2024-01-09 11:42:29 +01:00
|
|
|
|
2025-04-24 08:36:02 +02:00
|
|
|
proc getPeerById*(
|
|
|
|
|
peerId: string
|
|
|
|
|
): RestResponse[WakuPeer] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peer/{peerId}", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
|
|
|
|
|
2025-04-25 15:36:41 +02:00
|
|
|
proc getServicePeers*(): RestResponse[seq[WakuPeer]] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peers/service", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
|
|
|
|
|
2025-04-24 08:36:02 +02:00
|
|
|
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
|
|
|
|
|
.}
|
|
|
|
|
|
2025-04-25 15:36:41 +02:00
|
|
|
proc getRelayPeers*(): RestResponse[PeersOfShards] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peers/relay", meth: HttpMethod.MethodGet
|
2025-04-24 08:36:02 +02:00
|
|
|
.}
|
|
|
|
|
|
2025-04-25 15:36:41 +02:00
|
|
|
proc getRelayPeersByShard*(
|
2025-04-24 08:36:02 +02:00
|
|
|
shardId: uint16
|
|
|
|
|
): RestResponse[PeersOfShard] {.
|
2025-04-25 15:36:41 +02:00
|
|
|
rest, endpoint: "/admin/v1/peers/relay/on/{shardId}", meth: HttpMethod.MethodGet
|
2025-04-24 08:36:02 +02:00
|
|
|
.}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
.}
|
|
|
|
|
|
2025-06-10 02:10:06 +02:00
|
|
|
proc getPeersStats*(): RestResponse[PeerStats] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/peers/stats", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
|
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc getFilterSubscriptions*(): RestResponse[seq[FilterSubscription]] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/filter/subscriptions", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
2024-01-09 11:42:29 +01:00
|
|
|
|
2024-03-16 00:08:47 +01:00
|
|
|
proc getFilterSubscriptionsFilterNotMounted*(): RestResponse[string] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/filter/subscriptions", meth: HttpMethod.MethodGet
|
|
|
|
|
.}
|
2025-06-11 16:13:55 +05:30
|
|
|
|
|
|
|
|
proc postLogLevel*(
|
|
|
|
|
logLevel: string
|
|
|
|
|
): RestResponse[LogLevelResponse] {.
|
|
|
|
|
rest, endpoint: "/admin/v1/loglevel", meth: HttpMethod.MethodPost
|
|
|
|
|
.}
|