mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-01-05 09:17:59 +03:00
api types: implement api type for BackupGroupDeleteStats
Make the `BackupGroupDeleteStats` exposable via the API by implementing the ApiTypes trait via the api macro invocation and add an additional field to account for the number of deleted groups. Further, add a method to add up the statistics. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
d1e5e4533c
commit
f982c915f5
@ -1581,8 +1581,28 @@ pub fn print_store_and_ns(store: &str, ns: &BackupNamespace) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub const DELETE_STATS_COUNT_SCHEMA: Schema =
|
||||
IntegerSchema::new("Number of entities").minimum(0).schema();
|
||||
|
||||
#[api(
|
||||
properties: {
|
||||
"removed-groups": {
|
||||
schema: DELETE_STATS_COUNT_SCHEMA,
|
||||
},
|
||||
"protected-snapshots": {
|
||||
schema: DELETE_STATS_COUNT_SCHEMA,
|
||||
},
|
||||
"removed-snapshots": {
|
||||
schema: DELETE_STATS_COUNT_SCHEMA,
|
||||
},
|
||||
},
|
||||
)]
|
||||
#[derive(Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
/// Statistics for removed backup groups
|
||||
pub struct BackupGroupDeleteStats {
|
||||
// Count of removed groups
|
||||
removed_groups: usize,
|
||||
// Count of protected snapshots, therefore not removed
|
||||
protected_snapshots: usize,
|
||||
// Count of deleted snapshots
|
||||
@ -1594,6 +1614,10 @@ impl BackupGroupDeleteStats {
|
||||
self.protected_snapshots == 0
|
||||
}
|
||||
|
||||
pub fn removed_groups(&self) -> usize {
|
||||
self.removed_groups
|
||||
}
|
||||
|
||||
pub fn removed_snapshots(&self) -> usize {
|
||||
self.removed_snapshots
|
||||
}
|
||||
@ -1602,6 +1626,16 @@ impl BackupGroupDeleteStats {
|
||||
self.protected_snapshots
|
||||
}
|
||||
|
||||
pub fn add(&mut self, rhs: &Self) {
|
||||
self.removed_groups += rhs.removed_groups;
|
||||
self.protected_snapshots += rhs.protected_snapshots;
|
||||
self.removed_snapshots += rhs.removed_snapshots;
|
||||
}
|
||||
|
||||
pub fn increment_removed_groups(&mut self) {
|
||||
self.removed_groups += 1;
|
||||
}
|
||||
|
||||
pub fn increment_removed_snapshots(&mut self) {
|
||||
self.removed_snapshots += 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user