public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH v3 proxmox-backup 09/11] manager: render group filter properly
Date: Thu, 28 Oct 2021 15:00:56 +0200	[thread overview]
Message-ID: <20211028130058.1308810-11-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20211028130058.1308810-1-f.gruenbichler@proxmox.com>

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 src/bin/proxmox_backup_manager/sync.rs | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/bin/proxmox_backup_manager/sync.rs b/src/bin/proxmox_backup_manager/sync.rs
index 8bf490ea..0fd89a9c 100644
--- a/src/bin/proxmox_backup_manager/sync.rs
+++ b/src/bin/proxmox_backup_manager/sync.rs
@@ -8,6 +8,18 @@ use pbs_api_types::JOB_ID_SCHEMA;
 
 use proxmox_backup::api2;
 
+fn render_group_filter(value: &Value, _record: &Value) -> Result<String, Error> {
+    if let Some(group_filters) = value.as_array() {
+        let group_filters:Vec<&str> = group_filters
+            .iter()
+            .filter_map(Value::as_str)
+            .collect();
+        Ok(group_filters.join(" OR "))
+    } else {
+        Ok(String::from("all"))
+    }
+}
+
 #[api(
     input: {
         properties: {
@@ -35,6 +47,7 @@ fn list_sync_jobs(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value
         .column(ColumnConfig::new("remote"))
         .column(ColumnConfig::new("remote-store"))
         .column(ColumnConfig::new("schedule"))
+        .column(ColumnConfig::new("groups").renderer(render_group_filter))
         .column(ColumnConfig::new("comment"));
 
     format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
@@ -66,6 +79,12 @@ fn show_sync_job(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value,
         _ => unreachable!(),
     };
 
+    if let Some(groups) = data.get_mut("groups") {
+        if let Ok(rendered) = render_group_filter(groups, groups) {
+            *groups = Value::String(rendered);
+        }
+    }
+
     let options = default_table_format_options();
     format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
 
-- 
2.30.2





  parent reply	other threads:[~2021-10-28 13:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 13:00 [pbs-devel] [PATCH v3 proxmox-backup 0/12] pull/sync group filter Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox 1/1] updater: impl UpdaterType for Vec Fabian Grünbichler
2021-11-09  8:31   ` [pbs-devel] applied: " Dietmar Maurer
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 01/11] api-types: add schema for backup group Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 02/11] api: add GroupFilter(List) type Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 03/11] BackupGroup: add filter helper Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 04/11] pull: use BackupGroup consistently Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 05/11] pull/sync: extract passed along vars into struct Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 06/11] pull: allow pulling groups selectively Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 07/11] sync: add group filtering Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 08/11] remote: add backup group scanning Fabian Grünbichler
2021-10-28 13:00 ` Fabian Grünbichler [this message]
2021-10-28 13:00 ` [pbs-devel] [PATCH v3 proxmox-backup 10/11] docs: mention group filter in sync docs Fabian Grünbichler
2021-10-28 13:00 ` [pbs-devel] [RFC v3 proxmox-backup 11/11] fix #sync.cfg/pull: don't remove by default Fabian Grünbichler
2021-11-04  9:57 ` [pbs-devel] [PATCH v3 proxmox-backup 0/12] pull/sync group filter Dominik Csapak
2021-11-18 10:11 ` [pbs-devel] applied: " Thomas Lamprecht

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=20211028130058.1308810-11-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal