From 957133077f17b0d7001245555028a85a96249497 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 9 Sep 2021 15:48:19 +0200 Subject: [PATCH] api2: nodes: add missing node list api call to have an api call for api path traversal Signed-off-by: Dominik Csapak --- src/api2/mod.rs | 4 +--- src/api2/node/mod.rs | 12 +++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/api2/mod.rs b/src/api2/mod.rs index 132e2c2a..0ede4165 100644 --- a/src/api2/mod.rs +++ b/src/api2/mod.rs @@ -18,14 +18,12 @@ use proxmox::api::router::SubdirMap; use proxmox::api::Router; use proxmox::list_subdirs_api_method; -const NODES_ROUTER: Router = Router::new().match_all("node", &node::ROUTER); - const SUBDIRS: SubdirMap = &[ ("access", &access::ROUTER), ("admin", &admin::ROUTER), ("backup", &backup::ROUTER), ("config", &config::ROUTER), - ("nodes", &NODES_ROUTER), + ("nodes", &node::ROUTER), ("ping", &ping::ROUTER), ("pull", &pull::ROUTER), ("reader", &reader::ROUTER), diff --git a/src/api2/node/mod.rs b/src/api2/node/mod.rs index f1a17934..194ec920 100644 --- a/src/api2/node/mod.rs +++ b/src/api2/node/mod.rs @@ -315,6 +315,12 @@ fn upgrade_to_websocket( .boxed() } +#[api] +/// List Nodes (only for compatiblity) +fn list_nodes() -> Result { + Ok(json!([ { "node": proxmox::tools::nodename().to_string() } ])) +} + pub const SUBDIRS: SubdirMap = &[ ("apt", &apt::ROUTER), ("certificates", &certificates::ROUTER), @@ -338,6 +344,10 @@ pub const SUBDIRS: SubdirMap = &[ ), ]; -pub const ROUTER: Router = Router::new() +pub const ITEM_ROUTER: Router = Router::new() .get(&list_subdirs_api_method!(SUBDIRS)) .subdirs(SUBDIRS); + +pub const ROUTER: Router = Router::new() + .get(&API_METHOD_LIST_NODES) + .match_all("node", &ITEM_ROUTER);