From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C569A69DA1; Mon, 16 Nov 2020 11:14:15 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B48DE2D072; Mon, 16 Nov 2020 11:14:15 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 79EBD2D065; Mon, 16 Nov 2020 11:14:14 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1052143544; Mon, 16 Nov 2020 11:14:14 +0100 (CET) To: Proxmox VE development discussion , Dominik Csapak , pbs-devel@lists.proxmox.com References: <20201113093852.28788-1-d.csapak@proxmox.com> <20201113093852.28788-3-d.csapak@proxmox.com> <49f2d016-5674-e20d-6dc4-475fdd2b7fb7@proxmox.com> From: Thomas Lamprecht Message-ID: <5e0e6b7b-bc9d-803d-d7b1-c620279af67c@proxmox.com> Date: Mon, 16 Nov 2020 11:14:13 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Thunderbird/83.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.094 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [proxmox-backup-client.rs, snapshot.rs] Subject: Re: [pve-devel] [PATCH proxmox-backup 2/2] client: add 'snapshot notes show/update' command X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Nov 2020 10:14:15 -0000 On 16.11.20 10:42, Dominik Csapak wrote: > On 11/16/20 10:37 AM, Thomas Lamprecht wrote: >> On 13.11.20 10:38, Dominik Csapak wrote: >>> to show and update snapshot notes from the cli >>> >>> Signed-off-by: Dominik Csapak >>> --- >>> =C2=A0 src/bin/proxmox-backup-client.rs=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 1 + >>> =C2=A0 src/bin/proxmox_backup_client/mod.rs=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0=C2=A0 2 + >>> =C2=A0 src/bin/proxmox_backup_client/snapshot.rs | 126 ++++++++++++++= ++++++++ >>> =C2=A0 3 files changed, 129 insertions(+) >>> =C2=A0 create mode 100644 src/bin/proxmox_backup_client/snapshot.rs >>> >>> diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backu= p-client.rs >>> index 54e11f08..1581fbd2 100644 >>> --- a/src/bin/proxmox-backup-client.rs >>> +++ b/src/bin/proxmox-backup-client.rs >>> @@ -2068,6 +2068,7 @@ fn main() { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .insert("prune= ", prune_cmd_def) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .insert("resto= re", restore_cmd_def) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .insert("snaps= hots", snapshots_cmd_def) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .insert("snapshot", snaps= hot_mgtm_cli()) >> >> makes the CLI interface slightly weirder, maybe moving `snapshots` >> into `snapshot list` could help (with hidden alias for backward compat= )? >=20 > mhmm.. yeah, but we do not have an alias for now AFAIK shouldn't be to hard, it's probably just a flag to hide it from the help message, but not to hard feelings, rather pointed it out - some additiona= l opinions would be good here. > i just did not want to add two new top-level commands that is appreciated. >>> + >>> +=C2=A0=C2=A0=C2=A0 let mut result =3D client.get(&path, Some(args)).= await?; >>> + >>> +=C2=A0=C2=A0=C2=A0 let comment =3D result["data"].take(); >>> + >>> +=C2=A0=C2=A0=C2=A0 if output_format =3D=3D "text" { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if let Some(comment) =3D = comment.as_str() { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 p= rintln!("{}", comment); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> +=C2=A0=C2=A0=C2=A0 } else { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 format_and_print_result( >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &= json!({ >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 "comment": comment, >> >> We could just return the notes directly, without wrapping into an obje= ct? >=20 > no, because the proxmox-backup-client calls in pve-storage always use -= -output-format json and tries to decode that (and fails in case of a sing= le string without options) >=20 But "foo" *is* valid JSON... > the default call just prints it anyway and having "proper" json makes i= t easier to consume for others > (it depends on the parser if a standalone string is valid json) the standard says so, both chromium's and Firefox JSON.parse('"foo"') wor= k as expected, so if serde can work with that I'd say a standard conform JS= ON parser is a OK requirement in general. Note not saying that we thus must = use it, but that we could just fine if it really makes sense for an endpoint.= Albeit, PBS seems to also return an object: $ GET /api2/json/admin/datastore/test/notes?backup-type=3Dvm&backup-id=3D= 101&backup-time=3D1598010396 {"data":"test comment 1234"} so not sure how close we should mirror this, I'm maybe just not that cont= ent with "notes" / "comment" discrepancy between the two.