From 75054859ff11f1b24f84a104fcde765350816727 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 19 Apr 2021 13:02:01 +0200 Subject: [PATCH] api2/types: add necessary types for node status we want to use concrete types instead of value Signed-off-by: Dominik Csapak --- 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 9d1bd301..6868b131 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). @@ -1507,3 +1506,49 @@ pub struct JobScheduleStatus { #[serde(skip_serializing_if="Option::is_none")] pub last_run_endtime: Option, } + +#[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, +}