api2: nodes: add missing node list api call

to have an api call for api path traversal

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-09-09 15:48:19 +02:00 committed by Thomas Lamprecht
parent 36c6e7bb82
commit 957133077f
2 changed files with 12 additions and 4 deletions

View File

@ -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),

View File

@ -315,6 +315,12 @@ fn upgrade_to_websocket(
.boxed()
}
#[api]
/// List Nodes (only for compatiblity)
fn list_nodes() -> Result<Value, Error> {
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);