[pdm-devel] [PATCH datacenter-manager 2/7] api: pbs: add /pbs/realms endpoint
Lukas Wagner
l.wagner at proxmox.com
Mon Dec 29 14:44:40 CET 2025
This one allows us to enumerate available authentication realms for PBS
remotes.
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
server/src/api/pbs/mod.rs | 55 +++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/server/src/api/pbs/mod.rs b/server/src/api/pbs/mod.rs
index badefc39..73f8fdd8 100644
--- a/server/src/api/pbs/mod.rs
+++ b/server/src/api/pbs/mod.rs
@@ -33,6 +33,10 @@ const SUBDIRS: SubdirMap = &sorted!([
("remotes", &REMOTES_ROUTER),
("scan", &Router::new().post(&API_METHOD_SCAN_REMOTE_PBS)),
("probe-tls", &Router::new().post(&API_METHOD_PROBE_TLS)),
+ (
+ "realms",
+ &Router::new().get(&API_METHOD_LIST_REALM_REMOTE_PBS)
+ )
]);
const REMOTES_ROUTER: Router = Router::new()
@@ -290,6 +294,57 @@ pub async fn scan_remote_pbs(
Ok(remote)
}
+#[api(
+ input: {
+ properties: {
+ hostname: {
+ type: String,
+ format: &HOST_OPTIONAL_PORT_FORMAT,
+ description: "Hostname (with optional port) of the target remote",
+ },
+ fingerprint: {
+ type: String,
+ description: "Fingerprint of the target remote.",
+ optional: true,
+ },
+ },
+ },
+ access: {
+ permission:
+ &Permission::Privilege(&["/"], PRIV_SYS_MODIFY, false),
+ },
+ returns: {
+ type: Array,
+ description: "A list of realms of a PBS remote.",
+ items: {
+ type: pbs_api_types::BasicRealmInfo,
+ }
+ },
+)]
+/// List available authentication realms of a PBS remote.
+pub async fn list_realm_remote_pbs(
+ hostname: String,
+ fingerprint: Option<String>,
+) -> Result<Vec<pbs_api_types::BasicRealmInfo>, Error> {
+ // dummy remote to connect
+ let remote = Remote {
+ ty: RemoteType::Pbs,
+ id: String::new(),
+ nodes: vec![PropertyString::new(NodeUrl {
+ hostname,
+ fingerprint,
+ })],
+ authid: "root at pam".parse()?,
+ token: String::new(),
+ web_url: None,
+ };
+
+ let client = connection::make_pbs_client(&remote)?;
+ let list = client.list_domains().await?;
+
+ Ok(list)
+}
+
#[api(
input: {
properties: {
--
2.47.3
More information about the pdm-devel
mailing list