From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] api2/admin/datastore: add delete for groups
Date: Fri, 14 May 2021 16:36:02 +0200 [thread overview]
Message-ID: <20210514143603.6713-1-d.csapak@proxmox.com> (raw)
so that a user can delete a whole group at once, until now, the fastest
way for this was to prune to one snapshot, and delete that
code is basically a copy/paste from the snapshot delete, sans
the 'backup-time' parameter
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/admin/datastore.rs | 43 +++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index 97860910..e0dfeecc 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -219,6 +219,48 @@ pub fn list_groups(
Ok(group_info)
}
+#[api(
+ input: {
+ properties: {
+ store: {
+ schema: DATASTORE_SCHEMA,
+ },
+ "backup-type": {
+ schema: BACKUP_TYPE_SCHEMA,
+ },
+ "backup-id": {
+ schema: BACKUP_ID_SCHEMA,
+ },
+ },
+ },
+ access: {
+ permission: &Permission::Privilege(
+ &["datastore", "{store}"],
+ PRIV_DATASTORE_MODIFY| PRIV_DATASTORE_PRUNE,
+ true),
+ },
+)]
+/// Delete backup group including all snapshots.
+pub fn delete_group(
+ store: String,
+ backup_type: String,
+ backup_id: String,
+ _info: &ApiMethod,
+ rpcenv: &mut dyn RpcEnvironment,
+) -> Result<Value, Error> {
+
+ let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
+
+ let group = BackupGroup::new(backup_type, backup_id);
+ let datastore = DataStore::lookup_datastore(&store)?;
+
+ check_priv_or_backup_owner(&datastore, &group, &auth_id, PRIV_DATASTORE_MODIFY)?;
+
+ datastore.remove_backup_group(&group)?;
+
+ Ok(Value::Null)
+}
+
#[api(
input: {
properties: {
@@ -1722,6 +1764,7 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
"groups",
&Router::new()
.get(&API_METHOD_LIST_GROUPS)
+ .delete(&API_METHOD_DELETE_GROUP)
),
(
"notes",
--
2.20.1
next reply other threads:[~2021-05-14 14:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 14:36 Dominik Csapak [this message]
2021-05-14 14:36 ` [pbs-devel] [PATCH proxmox-backup 2/2] ui: datastore/Content: add forget button " Dominik Csapak
2021-05-17 6:46 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] api2/admin/datastore: add delete " Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210514143603.6713-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox