From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id C612F1FF15C for ; Fri, 3 Oct 2025 10:50:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0A7AB1EB49; Fri, 3 Oct 2025 10:50:50 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 3 Oct 2025 10:50:33 +0200 Message-ID: <20251003085045.1346864-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251003085045.1346864-1-d.csapak@proxmox.com> References: <20251003085045.1346864-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.026 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add api types for streaming content api call 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Main point are the two new structs * ContentType for api parameter to select a specific type of content to be returned * ContentListItem, which contains either - a namespace - a snapshot (including namespace) - a backup group (including namespace) Since the enums variants are newtypes, we need to annotate the 'serde tag' and given them an 'id-property' and 'id-schema' even though we don't need it, since it's only relevant for saving these on disk with section config. Signed-off-by: Dominik Csapak --- pbs-api-types/Cargo.toml | 1 + pbs-api-types/src/datastore.rs | 99 ++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml index 358536d9..b3dee41d 100644 --- a/pbs-api-types/Cargo.toml +++ b/pbs-api-types/Cargo.toml @@ -23,5 +23,6 @@ proxmox-lang.workspace=true proxmox-s3-client = { workspace = true, features = [ "api-types" ] } proxmox-schema = { workspace = true, features = [ "api-macro" ] } proxmox-serde.workspace = true +proxmox-section-config.workspace = true proxmox-time.workspace = true proxmox-uuid = { workspace = true, features = [ "serde" ] } diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index fe73cbc4..f2999007 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1479,6 +1479,96 @@ pub struct NamespaceListItem { pub comment: Option, } +#[api] +/// A type of content of a datastore +#[derive(Serialize, Deserialize)] +pub enum ContentType { + /// Namespace + Namespace, + /// Backup Group + Group, + /// Backup Snapshot + Snapshot, +} + +#[api( + properties: { + ns: { + type: BackupNamespace, + }, + snapshot: { + type: SnapshotListItem, + flatten: true, + }, + }, +)] +#[derive(Serialize, Deserialize)] +/// Represents a snapshot in a datastore with namespace information +pub struct SnapshotContentItem { + /// The namespace of the snapshot + ns: BackupNamespace, + #[serde(flatten)] + /// The snapshot information + snapshot: SnapshotListItem, +} + +#[api( + properties: { + ns: { + type: BackupNamespace, + }, + group: { + type: GroupListItem, + flatten: true, + }, + }, +)] +#[derive(Serialize, Deserialize)] +/// Represents a snapshot in a datastore with namespace information +pub struct GroupContentItem { + /// The namespace of the snapshot + ns: BackupNamespace, + #[serde(flatten)] + /// The backup group information + group: GroupListItem, +} + +#[api( + "id-property": "id", + "id-schema": { + type: String, + description: "ID", + }, +)] +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +#[serde(tag = "type")] +pub enum ContentListItem { + NameSpace(NamespaceListItem), + Group(GroupContentItem), + Snapshot(SnapshotContentItem), +} + +impl From for ContentListItem { + fn from(value: NamespaceListItem) -> Self { + ContentListItem::NameSpace(value) + } +} + +impl From<(BackupNamespace, GroupListItem)> for ContentListItem { + fn from(value: (BackupNamespace, GroupListItem)) -> Self { + let (ns, group) = value; + ContentListItem::Group(GroupContentItem { ns, group }) + } +} + +impl From<(BackupNamespace, SnapshotListItem)> for ContentListItem { + fn from(value: (BackupNamespace, SnapshotListItem)) -> Self { + let (ns, snapshot) = value; + ContentListItem::Snapshot(SnapshotContentItem { ns, snapshot }) + } +} + #[api( properties: { "backup": { type: BackupDir }, @@ -1759,6 +1849,15 @@ pub const ADMIN_DATASTORE_LIST_NAMESPACE_RETURN_TYPE: ReturnType = ReturnType { .schema(), }; +pub const ADMIN_DATASTORE_LIST_CONTENT_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "Returns the list of namespaces, backup groups and snapshots of a datastore.", + &ContentListItem::API_SCHEMA, + ) + .schema(), +}; + pub const ADMIN_DATASTORE_PRUNE_RETURN_TYPE: ReturnType = ReturnType { optional: false, schema: &ArraySchema::new( -- 2.47.3 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel