[pbs-devel] [PATCH proxmox-backup 1/6] api2/types: add necessary types for node status

Dominik Csapak d.csapak at proxmox.com
Mon Apr 19 13:02:01 CEST 2021


we want to use concrete types instead of value

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/api2/types/mod.rs | 49 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/api2/types/mod.rs b/src/api2/types/mod.rs
index 19186ea2..ac4957ac 100644
--- a/src/api2/types/mod.rs
+++ b/src/api2/types/mod.rs
@@ -751,9 +751,8 @@ impl Default for GarbageCollectionStatus {
     }
 }
 
-
 #[api()]
-#[derive(Serialize, Deserialize)]
+#[derive(Default, Serialize, Deserialize)]
 /// Storage space usage information.
 pub struct StorageStatus {
     /// Total space (bytes).
@@ -1504,3 +1503,49 @@ pub struct JobScheduleStatus {
     #[serde(skip_serializing_if="Option::is_none")]
     pub last_run_endtime: Option<i64>,
 }
+
+#[api]
+#[derive(Serialize, Deserialize, Default)]
+#[serde(rename_all = "kebab-case")]
+/// Node memory usage counters
+pub struct NodeMemoryCounters {
+    /// Total memory
+    pub total: u64,
+    /// Used memory
+    pub used: u64,
+    /// Free memory
+    pub free: u64,
+}
+
+#[api]
+#[derive(Serialize,Deserialize,Default)]
+#[serde(rename_all = "kebab-case")]
+/// Contains general node information such as the fingerprint`
+pub struct NodeInformation {
+    /// The SSL Fingerprint
+    pub fingerprint: String,
+}
+
+#[api(
+    properties: {
+        memory: {
+            type: NodeMemoryCounters,
+        },
+        root: {
+            type: StorageStatus,
+        },
+        info: {
+            type: NodeInformation,
+        }
+    },
+)]
+#[derive(Serialize, Deserialize, Default)]
+#[serde(rename_all = "kebab-case")]
+/// The Node status
+pub struct NodeStatus {
+    pub memory: NodeMemoryCounters,
+    pub root: StorageStatus,
+    /// Total CPU usage since last query.
+    pub cpu: f64,
+    pub info: NodeInformation,
+}
-- 
2.20.1






More information about the pbs-devel mailing list