From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id EA9D6A324
 for <pbs-devel@lists.proxmox.com>; Wed, 30 Aug 2023 09:37:36 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id BB1D5102B1
 for <pbs-devel@lists.proxmox.com>; Wed, 30 Aug 2023 09:37:06 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pbs-devel@lists.proxmox.com>; Wed, 30 Aug 2023 09:37:05 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BAE5D4775C
 for <pbs-devel@lists.proxmox.com>; Wed, 30 Aug 2023 09:37:05 +0200 (CEST)
Message-ID: <7dd35be8-86a0-bd3d-d489-d3797a1c0271@proxmox.com>
Date: Wed, 30 Aug 2023 09:37:04 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.14.0
Content-Language: en-US
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Gabriel Goller <g.goller@proxmox.com>
References: <20230829111310.90248-1-g.goller@proxmox.com>
From: Fiona Ebner <f.ebner@proxmox.com>
In-Reply-To: <20230829111310.90248-1-g.goller@proxmox.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.547 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -1.242 Looks like a legit reply (A)
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [group.rs, main.rs]
Subject: Re: [pbs-devel] [PATCH proxmox-backup] close #4763: client: added
 command to forget backup group
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 30 Aug 2023 07:37:37 -0000

Am 29.08.23 um 13:13 schrieb Gabriel Goller:
> diff --git a/Cargo.toml b/Cargo.toml
> index c7773f0e..e0f12806 100644
> --- a/Cargo.toml
> +++ b/Cargo.toml
> @@ -264,8 +264,8 @@ proxmox-rrd.workspace = true
>  #proxmox-sortable-macro = { path = "../proxmox/proxmox-sortable-macro" }
>  #proxmox-human-byte = { path = "../proxmox/proxmox-human-byte" }
>  
> -#proxmox-apt = { path = "../proxmox-apt" }
> -#proxmox-openid = { path = "../proxmox-openid-rs" }
> +#proxmox-apt = { path = "../proxmox/proxmox-apt" }
> +#proxmox-openid = { path = "../proxmox/proxmox-openid" }
>  #pathpatterns = {path = "../pathpatterns" }
>  

Should be a separate patch. Each patch should do one thing semantically.

>  #pxar = { path = "../pxar" }
> diff --git a/proxmox-backup-client/src/group.rs b/proxmox-backup-client/src/group.rs
> new file mode 100644
> index 00000000..84b73b67
> --- /dev/null
> +++ b/proxmox-backup-client/src/group.rs
> @@ -0,0 +1,68 @@
> +use anyhow::{bail, Error};
> +use pbs_api_types::{BackupGroup, BackupNamespace};
> +use pbs_client::tools::{connect, extract_repository_from_value};
> +use proxmox_router::cli::{ask_for_confirmation, CliCommand, CliCommandMap};
> +use proxmox_schema::api;
> +use serde_json::Value;
> +

Nit: I think we usually group proxmox includes, pbs includes and other
includes separately.

> +use crate::{
> +    complete_backup_group, complete_namespace, complete_repository, merge_group_into,
> +    REPO_URL_SCHEMA,
> +};
> +
> +pub fn group_mgtm_cli() -> CliCommandMap {

typo: mgtm -> mgmt

(...)

> +    let path = format!("api2/json/admin/datastore/{}/snapshots", repo.store());
> +    let result = client.get(&path, Some(api_params.clone())).await?;
> +    let snapshots = result["data"].as_array().unwrap().len();
> +    if snapshots == 0 {
> +        bail!("Backup group doesn't exist.");
> +    }

A group being empty doesn't necessarily mean that it doesn't exist.
Removing an empty group could also be considered valid, to get rid of
the owner, right?

> +
> +    ask_for_confirmation(format!(
> +        "Delete group \"{}\" with {} snapshots?",

Nit: using "snapshot(s)" would also read correctly when it's just 1 snapshot

> +        backup_group, snapshots
> +    ))?;

The second patch you sent should be sorted first, because it is a
prerequisite. Please mention that a dependency bump is needed below the
"---" below the commit message.

> +
> +    let path = format!("api2/json/admin/datastore/{}/groups", repo.store());
> +    let _ = client.delete(&path, Some(api_params)).await?;
> +
> +    println!("Successfully deleted group!");
> +    Ok(Value::Null)
> +}
> diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
> index 1a13291a..76d45b84 100644
> --- a/proxmox-backup-client/src/main.rs
> +++ b/proxmox-backup-client/src/main.rs
> @@ -72,6 +72,8 @@ mod catalog;
>  pub use catalog::*;
>  mod snapshot;
>  pub use snapshot::*;
> +mod group;
> +pub use group::*;
>  pub mod key;
>  pub mod namespace;
>  
> @@ -1606,7 +1608,6 @@ async fn prune(
>      }
>  
>      format_and_print_result_full(&mut data, return_type, &output_format, &options);
> -
>      Ok(Value::Null)
>  }
>  

This hunk does not belong in this patch either.