From ad20d19877ae50bf1f997ed0bfc2aeb2045fedc9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 2 Mar 2019 16:28:36 +0100 Subject: [PATCH] src/api2/admin/datastore.rs: rename get_group_list to list_groups, cleanups --- src/api2/admin/datastore.rs | 13 +++++++------ src/bin/proxmox-backup-client.rs | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index bf3d8b53..8e614e6e 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -52,7 +52,7 @@ fn mark_selections, &BackupInfo) -> String> ( } } -fn get_group_list( +fn list_groups( param: Value, _info: &ApiMethod, _rpcenv: &mut RpcEnvironment, @@ -76,10 +76,11 @@ fn get_group_list( let group = &info.backup_dir.group; groups.push(json!({ - "backup_type": group.backup_type, - "backup_id": group.backup_id, - "last_backup": info.backup_dir.backup_time.timestamp(), - "num_backups": list.len() as u64, + "backup-type": group.backup_type, + "backup-id": group.backup_id, + "last-backup": info.backup_dir.backup_time.timestamp(), + "backup-count": list.len() as u64, + "files": info.files, })); } @@ -372,7 +373,7 @@ pub fn router() -> Router { "groups", Router::new() .get(ApiMethod::new( - get_group_list, + list_groups, ObjectSchema::new("List backup groups.") .required("store", store_schema.clone())))) .subdir( diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs index 19595435..f4e7759f 100644 --- a/src/bin/proxmox-backup-client.rs +++ b/src/bin/proxmox-backup-client.rs @@ -155,11 +155,11 @@ fn list_backup_groups( for item in list { - let id = item["backup_id"].as_str().unwrap(); - let btype = item["backup_type"].as_str().unwrap(); - let epoch = item["last_backup"].as_i64().unwrap(); + let id = item["backup-id"].as_str().unwrap(); + let btype = item["backup-type"].as_str().unwrap(); + let epoch = item["last-backup"].as_i64().unwrap(); let last_backup = Local.timestamp(epoch, 0); - let num_backups = item["num_backups"].as_u64().unwrap(); + let backup_count = item["backup-count"].as_u64().unwrap(); let group = BackupGroup { backup_type: btype.to_string(), @@ -167,7 +167,14 @@ fn list_backup_groups( }; let path = group.group_path().to_str().unwrap().to_owned(); - println!("{} | {} | {}", path, last_backup.format("%c"), num_backups); + + let files = item["files"].as_array().unwrap().iter() + .map(|v| { + v.as_str().unwrap().to_owned() + }).collect(); + + println!("{} | {} | {} | {}", path, last_backup.format("%c"), + backup_count, tools::join(&files, ' ')); } //Ok(result)