api: namespace management endpoints

allow to list any namespace with privileges on it and allow to create
and delete namespaces if the user has modify permissions on the parent
namespace.

Creation is only allowed if the parent NS already exists.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2022-04-24 20:24:42 +02:00
parent 15a9272495
commit 18934ae56b
5 changed files with 212 additions and 0 deletions

View File

@ -1213,6 +1213,22 @@ pub struct GroupListItem {
pub comment: Option<String>,
}
#[api()]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
/// Basic information about a backup namespace.
pub struct NamespaceListItem {
/// A backup namespace
pub ns: BackupNamespace,
// TODO?
//pub group_count: u64,
//pub ns_count: u64,
/// The first line from the namespace's "notes"
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
}
#[api(
properties: {
"backup": { type: BackupDir },
@ -1431,6 +1447,15 @@ pub const ADMIN_DATASTORE_LIST_GROUPS_RETURN_TYPE: ReturnType = ReturnType {
.schema(),
};
pub const ADMIN_DATASTORE_LIST_NAMESPACE_RETURN_TYPE: ReturnType = ReturnType {
optional: false,
schema: &ArraySchema::new(
"Returns the list of backup namespaces.",
&NamespaceListItem::API_SCHEMA,
)
.schema(),
};
pub const ADMIN_DATASTORE_PRUNE_RETURN_TYPE: ReturnType = ReturnType {
optional: false,
schema: &ArraySchema::new(