api2/admin/datastore: add delete for groups
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>
This commit is contained in:
parent
8f33fe8e59
commit
f32791b4b2
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue