From 1e0c87d48f38ff78247b079dcc42efe1a0231bb9 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sun, 24 Apr 2022 20:24:42 +0200 Subject: [PATCH] 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 --- pbs-api-types/src/datastore.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 010fcc6e..af60d435 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1213,6 +1213,22 @@ pub struct GroupListItem { pub comment: Option, } +#[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, +} + #[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(