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 AC2121FF16F for ; Tue, 14 Oct 2025 14:31:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CCF5D2907; Tue, 14 Oct 2025 14:31:31 +0200 (CEST) Date: Tue, 14 Oct 2025 14:31:25 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20251008134344.3512958-1-d.csapak@proxmox.com> <20251008134344.3512958-2-d.csapak@proxmox.com> In-Reply-To: <20251008134344.3512958-2-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1760445008.k2jozl9zn0.astroid@yuna.none> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760445051328 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.049 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH proxmox v2 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" On October 8, 2025 3:43 pm, Dominik Csapak wrote: > Main point is the new struct > * DatastoreContent, 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 > --- > changes from v1: > * no contenttype anymore (not necessary currently) > * make properties public (else we can't use them in the ui) > * rename the '*List' types to something better > > pbs-api-types/Cargo.toml | 1 + > pbs-api-types/src/datastore.rs | 89 ++++++++++++++++++++++++++++++++++ > 2 files changed, 90 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..9b4b9cfa 100644 > --- a/pbs-api-types/src/datastore.rs > +++ b/pbs-api-types/src/datastore.rs > @@ -1479,6 +1479,86 @@ pub struct NamespaceListItem { > pub comment: Option, > } > > +#[api( > + properties: { > + ns: { > + type: BackupNamespace, > + }, > + snapshot: { > + type: SnapshotListItem, > + flatten: true, > + }, > + }, > +)] > +#[derive(Serialize, Deserialize)] > +#[serde(rename_all = "kebab-case")] > +/// Represents a snapshot in a datastore with namespace information > +pub struct SnapshotWithNamespace { > + /// The namespace of the snapshot > + pub ns: BackupNamespace, > + #[serde(flatten)] > + /// The snapshot information > + pub snapshot: SnapshotListItem, > +} > + > +#[api( > + properties: { > + ns: { > + type: BackupNamespace, > + }, > + group: { > + type: GroupListItem, > + flatten: true, > + }, > + }, > +)] > +#[derive(Serialize, Deserialize)] > +#[serde(rename_all = "kebab-case")] > +/// Represents a snapshot in a datastore with namespace information > +pub struct BackupGroupWithNamespace { > + /// The namespace of the snapshot > + pub ns: BackupNamespace, > + #[serde(flatten)] > + /// The backup group information > + pub 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 DatastoreContent { > + NameSpace(NamespaceListItem), nit: Name*s*pace - that's how we capitalize it everywhere, and it would get serialized as 'name-space' at the moment which is rather strange ;) > + Group(BackupGroupWithNamespace), > + Snapshot(SnapshotWithNamespace), > +} > + > +impl From for DatastoreContent { > + fn from(value: NamespaceListItem) -> Self { > + DatastoreContent::NameSpace(value) > + } > +} > + > +impl From<(BackupNamespace, GroupListItem)> for DatastoreContent { > + fn from(value: (BackupNamespace, GroupListItem)) -> Self { > + let (ns, group) = value; > + DatastoreContent::Group(BackupGroupWithNamespace { ns, group }) > + } > +} > + > +impl From<(BackupNamespace, SnapshotListItem)> for DatastoreContent { > + fn from(value: (BackupNamespace, SnapshotListItem)) -> Self { > + let (ns, snapshot) = value; > + DatastoreContent::Snapshot(SnapshotWithNamespace { ns, snapshot }) > + } > +} > + > #[api( > properties: { > "backup": { type: BackupDir }, > @@ -1759,6 +1839,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.", > + &DatastoreContent::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 > > > _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel