From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add api types for streaming content api call
Date: Fri, 3 Oct 2025 10:50:33 +0200 [thread overview]
Message-ID: <20251003085045.1346864-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251003085045.1346864-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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<String>,
}
+#[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<NamespaceListItem> 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
next prev parent reply other threads:[~2025-10-03 8:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 8:50 [pbs-devel] [PATCH proxmox{, -backup} 0/7] introduce " Dominik Csapak
2025-10-03 8:50 ` Dominik Csapak [this message]
2025-10-07 8:59 ` [pbs-devel] [PATCH proxmox 1/1] pbs-api-types: add api types for " Wolfgang Bumiller
2025-10-08 6:41 ` Dominik Csapak
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 1/6] backup: hierarchy: add new can_access_any_namespace_in_range helper Dominik Csapak
2025-10-03 9:52 ` Thomas Lamprecht
2025-10-03 10:10 ` Dominik Csapak
2025-10-03 10:21 ` Thomas Lamprecht
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 2/6] backup: hierarchy: reuse 'NS_PRIVS_OK' for namespace helper Dominik Csapak
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 3/6] api: admin: datastore: refactor BackupGroup to GroupListItem conversion Dominik Csapak
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 4/6] api: admin: datastore: factor out 'get_group_owner' Dominik Csapak
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 5/6] api: admin: datastore: optimize `groups` api call Dominik Csapak
2025-10-03 10:18 ` Thomas Lamprecht
2025-10-03 10:51 ` Dominik Csapak
2025-10-03 12:37 ` Thomas Lamprecht
2025-10-03 8:50 ` [pbs-devel] [PATCH proxmox-backup 6/6] api: admin: datastore: implement streaming content " Dominik Csapak
2025-10-03 11:55 ` Thomas Lamprecht
2025-10-07 12:51 ` Wolfgang Bumiller
2025-10-07 14:22 ` Thomas Lamprecht
2025-10-07 14:31 ` Wolfgang Bumiller
2025-10-07 15:05 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251003085045.1346864-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox