From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 8AF2C1FF0B7 for ; Fri, 13 Nov 2026 10:07:08 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 356162185C; Fri, 13 Nov 2026 10:06:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stuttgart.de; s=s1022; t=1794560285; bh=4htjPkI2gp1LGdpyTfkyPOPK7NZS2zGilbI60UdZQes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JPbLSRaq30zyChYvNVtqJ0uYJex9zfDfyb5BZuUBHVjNFWJrq4iBu6svIAIYfWdZZ 56GLxwKaGtRWTs/dFo/BIXVKzDyKw8hgWmINF1o+YQtB+nb7MflRXn3fYgzhe2jK8F DguDelQXfeSoykdi1Ry8o6jiiOtqaJCz4yQTAtOtFeRb3jV5WeF0nNXISY0XcG84gq OSf7wG/2NBI0MdEnUb4WWf+EvZDHN0Td7levR0/xZA5Ljyo2gO7eDQfzLED8gywOy8 R1lK//Q4UDPokYY3m+aGdAUi8kXIhx26p9M8kf3GZpdy+bvj27Pck2Rh/Gb57mzqhB f4AjpaYyGaiFQ== From: Jakob-Tobias Winter To: pbs-devel@lists.proxmox.com Subject: [RFC PATCH proxmox 01/12] pbs-api-types: add types and schemas for snapshot attributes Date: Fri, 13 Nov 2026 09:56:28 +0100 Message-ID: <20261113085637.57360-4-tobias@stuttgart.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261113085637.57360-3-tobias@stuttgart.de> References: <20261113085637.57360-3-tobias@stuttgart.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.023 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: GZMPRZCYDMEBKKM4JUZFRITERWBF6PLR X-Message-ID-Hash: GZMPRZCYDMEBKKM4JUZFRITERWBF6PLR X-MailFrom: prvs=d19b210678=tobias@stuttgart.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Jakob-Tobias Winter X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Snapshots get attributes, each of them a key with a list of values. They are meant for information a client knows about the source of a backup, like the tags and the resource pool of a Proxmox VE guest. An attribute is passed as 'KEY=VALUE', once per value of a key. A value is never joined with other values into one string, so a list of tags cannot be garbled by a separator. Signed-off-by: Jakob-Tobias Winter --- pbs-api-types/src/datastore.rs | 22 +++++++++++++++++++++- pbs-api-types/src/lib.rs | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index 7685deee..978253ee 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1,4 +1,5 @@ use std::borrow::Borrow; +use std::collections::{BTreeMap, BTreeSet}; use std::convert::{AsRef, TryFrom}; use std::fmt; use std::hash::{Hash, Hasher}; @@ -28,7 +29,7 @@ use crate::{ DATASTORE_NOTIFY_STRING_SCHEMA, Fingerprint, GC_SCHEDULE_SCHEMA, GROUP_OR_SNAPSHOT_PATH_REGEX_STR, GroupFilter, MaintenanceMode, MaintenanceType, PROXMOX_SAFE_ID_FORMAT, PROXMOX_SAFE_ID_REGEX_STR, PRUNE_SCHEDULE_SCHEMA, SHA256_HEX_REGEX, - SINGLE_LINE_COMMENT_SCHEMA, SNAPSHOT_PATH_REGEX_STR, UPID, Userid, + SINGLE_LINE_COMMENT_SCHEMA, SNAPSHOT_ATTRIBUTE_RE, SNAPSHOT_PATH_REGEX_STR, UPID, Userid, VERIFY_JOB_READ_THREADS_SCHEMA, VERIFY_JOB_VERIFY_THREADS_SCHEMA, }; @@ -52,6 +53,8 @@ const_regex! { pub GROUP_OR_SNAPSHOT_PATH_REGEX = concatcp!(r"^", GROUP_OR_SNAPSHOT_PATH_REGEX_STR, r"$"); pub DATASTORE_MAP_REGEX = concatcp!(r"^(?:", PROXMOX_SAFE_ID_REGEX_STR, r"=)?", PROXMOX_SAFE_ID_REGEX_STR, r"$"); + + pub SNAPSHOT_ATTRIBUTE_REGEX = concatcp!(r"^", SNAPSHOT_ATTRIBUTE_RE, r"$"); } pub const CHUNK_DIGEST_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&SHA256_HEX_REGEX); @@ -90,6 +93,23 @@ pub const BACKUP_GROUP_SCHEMA: Schema = StringSchema::new("Backup Group") .format(&BACKUP_GROUP_FORMAT) .schema(); +pub const SNAPSHOT_ATTRIBUTE_FORMAT: ApiStringFormat = + ApiStringFormat::Pattern(&SNAPSHOT_ATTRIBUTE_REGEX); + +pub const SNAPSHOT_ATTRIBUTE_SCHEMA: Schema = StringSchema::new( + "Snapshot attribute, a key and one of its values. A key with several values is given once \ + per value.", +) +.format(&SNAPSHOT_ATTRIBUTE_FORMAT) +.type_text("KEY=VALUE") +.schema(); + +pub const SNAPSHOT_ATTRIBUTE_LIST_SCHEMA: Schema = + ArraySchema::new("List of snapshot attributes.", &SNAPSHOT_ATTRIBUTE_SCHEMA).schema(); + +/// The attributes of a snapshot, each key has a set of values. +pub type SnapshotAttributes = BTreeMap>; + /// The maximal, inclusive depth for namespaces from the root ns downwards /// /// The datastore root name space is at depth zero (0), so we have in total eight (8) levels diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 21ef733d..cb1c231c 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -94,6 +94,9 @@ pub const GROUP_OR_SNAPSHOT_PATH_REGEX_STR: &str = r"(", BACKUP_TYPE_RE, ")/(", BACKUP_ID_RE, ")(?:/(", BACKUP_TIME_RE, r"))?", ); +#[rustfmt::skip] +pub const SNAPSHOT_ATTRIBUTE_RE: &str = r"[a-z][a-z0-9\-]{0,31}=[A-Za-z0-9._+/\-]{1,128}"; + mod acl; pub use acl::*; base-commit: 9bf4383b6ad4225367c7824023ad74769388de8f -- 2.53.0