From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 3B8A21FF179 for ; Wed, 15 Oct 2025 14:47:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 264D11B0B0; Wed, 15 Oct 2025 14:47:23 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Date: Wed, 15 Oct 2025 14:47:01 +0200 Message-ID: <20251015124711.312943-3-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251015124711.312943-1-l.wagner@proxmox.com> References: <20251015124711.312943-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1760532436806 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: [pdm-devel] [PATCH proxmox-datacenter-manager 02/12] pdm-api-types: add types for remote upgrade summary X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- lib/pdm-api-types/src/lib.rs | 2 + lib/pdm-api-types/src/remote_updates.rs | 126 ++++++++++++++++++++++++ 2 files changed, 128 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..d04a7a79 --- /dev/null +++ b/lib/pdm-api-types/src/remote_updates.rs @@ -0,0 +1,126 @@ +use std::{ + collections::HashMap, + ops::{Deref, DerefMut}, +}; + +use proxmox_schema::{api, ApiType, ObjectSchema}; +use serde::{Deserialize, Serialize}; + +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 { + #[serde(flatten)] + remotes: HashMap, +} + +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; + + fn deref(&self) -> &Self::Target { + &self.remotes + } +} + +impl DerefMut for RemoteUpdateSummaryWrapper { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.remotes + } +} + +#[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 { + #[serde(flatten)] + nodes: HashMap, +} + +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; + + fn deref(&self) -> &Self::Target { + &self.nodes + } +} + +impl DerefMut for NodeUpdateSummaryWrapper { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.nodes + } +} + +#[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, +} -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel