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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 808FB9683C for ; Wed, 25 Jan 2023 13:19:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5BA5CF94E for ; Wed, 25 Jan 2023 13:19:29 +0100 (CET) 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 ; Wed, 25 Jan 2023 13:19:28 +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 E08D34616E for ; Wed, 25 Jan 2023 13:19:27 +0100 (CET) From: Christoph Heiss To: pbs-devel@lists.proxmox.com Date: Wed, 25 Jan 2023 13:18:56 +0100 Message-Id: <20230125121902.404950-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230125121902.404950-1-c.heiss@proxmox.com> References: <20230125121902.404950-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.140 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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.com, version.rs, lib.rs] Subject: [pbs-devel] [RFC PATCH v2 proxmox-backup 1/7] api2: Introduce server features discovery mechanism X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jan 2023 12:19:59 -0000 This is vaguely based on the idea to introduce some sort of API compatibility mechansim, to detect whether e.g. a new API parameter is supported by the server or not. [0] Essentially, a new `features` field is added to the `/version` endpoint, which is an array (of strings) of supported (backwards-incompatible) features by the server. Clients can retrieve this and act accordingly. Features are internally described as an enum, with kebab-case'd names for external consumption through the API. Some inspriration was taken from how proxmox backup support in QEMU works, using `query-proxmox-support` command. This is intended as a first proposal on how this mechanism could work. [0] https://lists.proxmox.com/pipermail/pbs-devel/2023-January/005867.html ff. Signed-off-by: Christoph Heiss --- Changes v1 -> v2: * New patch pbs-api-types/src/lib.rs | 9 +++++++++ src/api2/version.rs | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 5e043954..dda2bd5b 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -531,3 +531,12 @@ pub struct BasicRealmInfo { #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option, } + +#[api] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +/// List of features a server can supported. +pub enum ServerFeature { + /// Indicates that the `protected` parameter on the /finish endpoint is suppported + FinishHasProtectedParam, +} diff --git a/src/api2/version.rs b/src/api2/version.rs index 0e91688b..0d6e66c4 100644 --- a/src/api2/version.rs +++ b/src/api2/version.rs @@ -3,6 +3,7 @@ use anyhow::Error; use serde_json::{json, Value}; +use pbs_api_types::ServerFeature; use proxmox_router::{ApiHandler, ApiMethod, Permission, Router, RpcEnvironment}; use proxmox_schema::ObjectSchema; @@ -14,7 +15,8 @@ fn get_version( Ok(json!({ "version": pbs_buildcfg::PROXMOX_PKG_VERSION, "release": pbs_buildcfg::PROXMOX_PKG_RELEASE, - "repoid": pbs_buildcfg::PROXMOX_PKG_REPOID + "repoid": pbs_buildcfg::PROXMOX_PKG_REPOID, + "features": [ServerFeature::FinishHasProtectedParam], })) } -- 2.34.1