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 4592D1FF187 for ; Mon, 8 Sep 2025 16:04:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3DA1139BE; Mon, 8 Sep 2025 16:04:35 +0200 (CEST) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Mon, 8 Sep 2025 16:04:11 +0200 Message-ID: <20250908140424.3376082-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250908140424.3376082-1-d.csapak@proxmox.com> References: <20250908140424.3376082-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.127 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 POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes 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-api-types 3/3] regenerate with new node storage status api 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" Signed-off-by: Dominik Csapak --- pve-api-types/src/generated/code.rs | 12 +- pve-api-types/src/generated/types.rs | 172 +++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/pve-api-types/src/generated/code.rs b/pve-api-types/src/generated/code.rs index 21daf32..6dee304 100644 --- a/pve-api-types/src/generated/code.rs +++ b/pve-api-types/src/generated/code.rs @@ -357,7 +357,6 @@ /// - /nodes/{node}/storage/{storage}/prunebackups /// - /nodes/{node}/storage/{storage}/rrd /// - /nodes/{node}/storage/{storage}/rrddata -/// - /nodes/{node}/storage/{storage}/status /// - /nodes/{node}/storage/{storage}/upload /// - /nodes/{node}/suspendall /// - /nodes/{node}/syslog @@ -730,6 +729,11 @@ pub trait PveClient { Err(Error::Other("stop_task not implemented")) } + /// Read storage status. + async fn storage_status(&self, node: &str, storage: &str) -> Result { + Err(Error::Other("storage_status not implemented")) + } + /// This is used to resynchronize the package index files from their sources /// (apt-get update). async fn update_apt_database( @@ -1226,6 +1230,12 @@ where self.0.delete(url).await?.nodata() } + /// Read storage status. + async fn storage_status(&self, node: &str, storage: &str) -> Result { + let url = &format!("/api2/extjs/nodes/{node}/storage/{storage}/status"); + Ok(self.0.get(url).await?.expect_json()?.data) + } + /// This is used to resynchronize the package index files from their sources /// (apt-get update). async fn update_apt_database( diff --git a/pve-api-types/src/generated/types.rs b/pve-api-types/src/generated/types.rs index b752f29..623ea76 100644 --- a/pve-api-types/src/generated/types.rs +++ b/pve-api-types/src/generated/types.rs @@ -9791,6 +9791,101 @@ mod storage_info_content { } } +const STORAGE_STATUS_CONTENT: Schema = + proxmox_schema::ArraySchema::new("list", &StorageContent::API_SCHEMA).schema(); + +mod storage_status_content { + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + + #[doc(hidden)] + pub trait Ser: Sized { + fn ser(&self, serializer: S) -> Result; + fn de<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>; + } + + impl Deserialize<'a>> Ser for Vec { + fn ser(&self, serializer: S) -> Result + where + S: Serializer, + { + super::stringlist::serialize(&self[..], serializer, &super::STORAGE_STATUS_CONTENT) + } + + fn de<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + super::stringlist::deserialize(deserializer, &super::STORAGE_STATUS_CONTENT) + } + } + + impl Ser for Option { + fn ser(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + None => serializer.serialize_none(), + Some(inner) => inner.ser(serializer), + } + } + + fn de<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + use std::fmt; + use std::marker::PhantomData; + + struct V(PhantomData); + + impl<'de, T: Ser> serde::de::Visitor<'de> for V { + type Value = Option; + + fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str("an optional string") + } + + fn visit_none(self) -> Result { + Ok(None) + } + + fn visit_some(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + T::de(deserializer).map(Some) + } + + fn visit_str(self, value: &str) -> Result { + use serde::de::IntoDeserializer; + T::de(value.into_deserializer()).map(Some) + } + } + + deserializer.deserialize_option(V::(PhantomData)) + } + } + + pub fn serialize(this: &T, serializer: S) -> Result + where + S: serde::Serializer, + T: Ser, + { + this.ser(serializer) + } + + pub fn deserialize<'de, T, D>(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + T: Ser, + { + T::de(deserializer) + } +} + const_regex! { SDN_CONTROLLER_ISIS_IFACES_RE = r##"^[a-zA-Z][a-zA-Z0-9_]{1,20}([:\.]\d+)?$"##; @@ -11157,6 +11252,83 @@ pub struct StorageInfo { pub used_fraction: Option, } +#[api( + properties: { + active: { + default: false, + optional: true, + }, + avail: { + optional: true, + type: Integer, + }, + content: { + format: &ApiStringFormat::PropertyString(&STORAGE_STATUS_CONTENT), + type: String, + }, + enabled: { + default: false, + optional: true, + }, + shared: { + default: false, + optional: true, + }, + total: { + optional: true, + type: Integer, + }, + type: { + type: String, + }, + used: { + optional: true, + type: Integer, + }, + }, +)] +/// Object. +#[derive(Debug, serde::Deserialize, serde::Serialize)] +pub struct StorageStatus { + /// Set when storage is accessible. + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub active: Option, + + /// Available storage space in bytes. + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub avail: Option, + + /// Allowed storage content types. + #[serde(with = "storage_status_content")] + pub content: Vec, + + /// Set when storage is enabled (not disabled). + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub enabled: Option, + + /// Shared flag from storage configuration. + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_bool")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub shared: Option, + + /// Total storage space in bytes. + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub total: Option, + + /// Storage type. + #[serde(rename = "type")] + pub ty: String, + + /// Used storage space in bytes. + #[serde(deserialize_with = "proxmox_serde::perl::deserialize_i64")] + #[serde(default, skip_serializing_if = "Option::is_none")] + pub used: Option, +} + #[api( properties: { n: { -- 2.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel