api-types: introduce BackupType enum and Group/Dir api types

The type is a real enum.

All are API types and implement Display and FromStr. The
ordering is the same as it is in pbs-datastore.

Also, they are now flattened into a few structs instead of
being copied manually.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2022-04-14 15:05:58 +02:00
committed by Thomas Lamprecht
parent 33eb23d57e
commit 988d575dbb
23 changed files with 449 additions and 278 deletions

View File

@ -265,6 +265,13 @@ pub async fn complete_backup_snapshot_do(param: &HashMap<String, String>) -> Vec
item["backup-type"].as_str(),
item["backup-time"].as_i64(),
) {
let backup_type = match backup_type.parse() {
Ok(ty) => ty,
Err(_) => {
// FIXME: print error in completion?
continue;
}
};
if let Ok(snapshot) = BackupDir::new(backup_type, backup_id, backup_time) {
result.push(snapshot.relative_path().to_str().unwrap().to_owned());
}