From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager v2 02/13] pdm-api-types: add types for remote upgrade summary
Date: Fri, 17 Oct 2025 14:09:58 +0200 [thread overview]
Message-ID: <20251017121009.212499-3-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251017121009.212499-1-l.wagner@proxmox.com>
This type contains the number of available updates per remote node,
without any details. This is useful for a global "give me the update
availability for all managed nodes" API endpoint.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Shannon Sterz <s.sterz@proxmox.com>
Tested-by: Shannon Sterz <s.sterz@proxmox.com>
---
Notes:
Changes since v1:
- Changed order/style of use statements
- Make RemoteUpdateSummaryWrapper a tuple struct
- Make NodeUpdateSummaryWrapper a tuple struct
Thank you Shannon!
lib/pdm-api-types/src/lib.rs | 2 +
lib/pdm-api-types/src/remote_updates.rs | 119 ++++++++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 lib/pdm-api-types/src/remote_updates.rs
diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
index a3566142..2fb61ef7 100644
--- a/lib/pdm-api-types/src/lib.rs
+++ b/lib/pdm-api-types/src/lib.rs
@@ -96,6 +96,8 @@ pub use openid::*;
pub mod remotes;
+pub mod remote_updates;
+
pub mod resource;
pub mod rrddata;
diff --git a/lib/pdm-api-types/src/remote_updates.rs b/lib/pdm-api-types/src/remote_updates.rs
new file mode 100644
index 00000000..e42b6a96
--- /dev/null
+++ b/lib/pdm-api-types/src/remote_updates.rs
@@ -0,0 +1,119 @@
+use std::collections::HashMap;
+use std::ops::{Deref, DerefMut};
+
+use serde::{Deserialize, Serialize};
+
+use proxmox_schema::{api, ApiType, ObjectSchema};
+
+use crate::remotes::RemoteType;
+
+#[api]
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+/// Update summary for all remotes.
+pub struct UpdateSummary {
+ /// Map containing the update summary each remote.
+ pub remotes: RemoteUpdateSummaryWrapper,
+}
+
+// This is a hack to allow actual 'maps' (mapping remote name to per-remote data)
+// within the realms of our API macro.
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+pub struct RemoteUpdateSummaryWrapper(HashMap<String, RemoteUpdateSummary>);
+
+impl ApiType for RemoteUpdateSummaryWrapper {
+ const API_SCHEMA: proxmox_schema::Schema =
+ ObjectSchema::new("Map of per-remote update summaries", &[])
+ .additional_properties(true)
+ .schema();
+}
+
+impl Deref for RemoteUpdateSummaryWrapper {
+ type Target = HashMap<String, RemoteUpdateSummary>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl DerefMut for RemoteUpdateSummaryWrapper {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
+#[api]
+#[derive(Clone, Debug, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+/// Update summary for a single remote.
+pub struct RemoteUpdateSummary {
+ /// Map containing the update summary for each node of this remote.
+ pub nodes: NodeUpdateSummaryWrapper,
+ pub remote_type: RemoteType,
+ pub status: RemoteUpdateStatus,
+}
+
+#[api]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Status for the entire remote.
+pub enum RemoteUpdateStatus {
+ /// Successfully polled remote.
+ Success,
+ /// Remote could not be polled.
+ Error,
+ /// Remote has not been polled yet.
+ Unknown,
+}
+
+#[derive(Clone, Debug, Default, Deserialize, Serialize)]
+#[serde(rename_all = "kebab-case")]
+pub struct NodeUpdateSummaryWrapper(HashMap<String, NodeUpdateSummary>);
+
+impl ApiType for NodeUpdateSummaryWrapper {
+ const API_SCHEMA: proxmox_schema::Schema =
+ ObjectSchema::new("Map of per-node update summaries", &[])
+ .additional_properties(true)
+ .schema();
+}
+
+impl Deref for NodeUpdateSummaryWrapper {
+ type Target = HashMap<String, NodeUpdateSummary>;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+impl DerefMut for NodeUpdateSummaryWrapper {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.0
+ }
+}
+
+#[api]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Status for the entire remote.
+pub enum NodeUpdateStatus {
+ /// Successfully polled node.
+ Success,
+ /// Node could not be polled.
+ Error,
+}
+
+#[api]
+#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Per-node update summary.
+pub struct NodeUpdateSummary {
+ /// Number of available updates.
+ pub number_of_updates: u32,
+ /// Unix timestamp of the last refresh.
+ pub last_refresh: i64,
+ /// Status
+ pub status: NodeUpdateStatus,
+ /// Status message (e.g. error message)
+ pub status_message: Option<String>,
+}
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-10-17 12:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 12:09 [pdm-devel] [PATCH datacenter-manager v2 00/13] add global remote update view Lukas Wagner
2025-10-17 12:09 ` [pdm-devel] [PATCH datacenter-manager v2 01/13] metric collection task: tests: add missing parameter for cluster_metric_export Lukas Wagner
2025-10-21 19:24 ` [pdm-devel] applied: " Thomas Lamprecht
2025-10-17 12:09 ` Lukas Wagner [this message]
2025-10-17 12:09 ` [pdm-devel] [PATCH datacenter-manager v2 03/13] remote updates: add cache for remote update availability Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 04/13] api: add API for retrieving/refreshing the remote update summary Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 05/13] unprivileged api daemon: tasks: add remote update refresh task Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 06/13] pdm-client: add API methods for remote update summaries Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 07/13] pbs-client: add bindings for APT-related API calls Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 08/13] task cache: use separate functions for tracking PVE and PBS tasks Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 09/13] remote updates: add support for PBS remotes Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 10/13] api: add APT endpoints " Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 11/13] ui: add remote update view Lukas Wagner
2025-10-21 19:18 ` Thomas Lamprecht
2025-10-22 10:22 ` Lukas Wagner
2025-10-23 8:36 ` Thomas Lamprecht
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 12/13] ui: show new remote update view in the 'Remotes' section Lukas Wagner
2025-10-17 12:10 ` [pdm-devel] [PATCH datacenter-manager v2 13/13] remote updates: avoid unnecessary clone Lukas Wagner
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=20251017121009.212499-3-l.wagner@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=pdm-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.