1#[derive(Debug, Clone)]
2pub struct StatusClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> StatusClient<T>
7where
8 T: crate::client::Client,
9{
10 pub fn new(client: T, parent_path: &str) -> Self {
11 Self {
12 client,
13 path: format!("{}{}", parent_path, "/status"),
14 }
15 }
16}
17impl<T> StatusClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Read node status"]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.Audit\"])"]
24 pub async fn get(&self) -> Result<GetOutput, T::Error> {
25 let path = self.path.to_string();
26 self.client.get(&path, &()).await
27 }
28}
29impl<T> StatusClient<T>
30where
31 T: crate::client::Client,
32{
33 #[doc = "Reboot or shutdown a node."]
34 #[doc = ""]
35 #[doc = "Permission check: perm(\"/nodes/{node}\", [\"Sys.PowerMgmt\"])"]
36 pub async fn post(&self, params: PostParams) -> Result<(), T::Error> {
37 let path = self.path.to_string();
38 self.client.post(&path, ¶ms).await
39 }
40}
41impl BootInfoGetOutputBootInfo {
42 pub fn new(mode: Mode) -> Self {
43 Self {
44 mode,
45 secureboot: ::std::default::Default::default(),
46 additional_properties: ::std::default::Default::default(),
47 }
48 }
49}
50#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
51pub struct BootInfoGetOutputBootInfo {
52 #[doc = "Through which firmware the system got booted."]
53 #[doc = ""]
54 pub mode: Mode,
55 #[serde(
56 serialize_with = "crate::types::serialize_bool_optional",
57 deserialize_with = "crate::types::deserialize_bool_optional"
58 )]
59 #[serde(skip_serializing_if = "Option::is_none", default)]
60 #[doc = "System is booted in secure mode, only applicable for the \"efi\" mode."]
61 #[doc = ""]
62 pub secureboot: Option<bool>,
63 #[serde(
64 flatten,
65 default,
66 skip_serializing_if = "::std::collections::HashMap::is_empty"
67 )]
68 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
69}
70impl CpuinfoGetOutputCpuinfo {
71 pub fn new(cores: i64, cpus: i64, model: String, sockets: i64) -> Self {
72 Self {
73 cores,
74 cpus,
75 model,
76 sockets,
77 additional_properties: ::std::default::Default::default(),
78 }
79 }
80}
81#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
82pub struct CpuinfoGetOutputCpuinfo {
83 #[serde(
84 serialize_with = "crate::types::serialize_int",
85 deserialize_with = "crate::types::deserialize_int"
86 )]
87 #[doc = "The number of physical cores of the CPU."]
88 #[doc = ""]
89 pub cores: i64,
90 #[serde(
91 serialize_with = "crate::types::serialize_int",
92 deserialize_with = "crate::types::deserialize_int"
93 )]
94 #[doc = "The number of logical threads of the CPU."]
95 #[doc = ""]
96 pub cpus: i64,
97 #[doc = "The CPU model"]
98 #[doc = ""]
99 pub model: String,
100 #[serde(
101 serialize_with = "crate::types::serialize_int",
102 deserialize_with = "crate::types::deserialize_int"
103 )]
104 #[doc = "The number of logical threads of the CPU."]
105 #[doc = ""]
106 pub sockets: i64,
107 #[serde(
108 flatten,
109 default,
110 skip_serializing_if = "::std::collections::HashMap::is_empty"
111 )]
112 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
113}
114impl CurrentKernelGetOutputCurrentKernel {
115 pub fn new(machine: String, release: String, sysname: String, version: String) -> Self {
116 Self {
117 machine,
118 release,
119 sysname,
120 version,
121 additional_properties: ::std::default::Default::default(),
122 }
123 }
124}
125#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
126pub struct CurrentKernelGetOutputCurrentKernel {
127 #[doc = "Hardware (architecture) type"]
128 #[doc = ""]
129 pub machine: String,
130 #[doc = "OS kernel release (e.g., \"6.8.0\")"]
131 #[doc = ""]
132 pub release: String,
133 #[doc = "OS kernel name (e.g., \"Linux\")"]
134 #[doc = ""]
135 pub sysname: String,
136 #[doc = "OS kernel version with build info"]
137 #[doc = ""]
138 pub version: String,
139 #[serde(
140 flatten,
141 default,
142 skip_serializing_if = "::std::collections::HashMap::is_empty"
143 )]
144 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
145}
146impl GetOutput {
147 pub fn new(
148 boot_info: BootInfoGetOutputBootInfo,
149 cpu: f64,
150 cpuinfo: CpuinfoGetOutputCpuinfo,
151 current_kernel: CurrentKernelGetOutputCurrentKernel,
152 loadavg: Vec<String>,
153 memory: MemoryGetOutputMemory,
154 pveversion: String,
155 rootfs: RootfsGetOutputRootfs,
156 ) -> Self {
157 Self {
158 boot_info,
159 cpu,
160 cpuinfo,
161 current_kernel,
162 loadavg,
163 memory,
164 pveversion,
165 rootfs,
166 additional_properties: ::std::default::Default::default(),
167 }
168 }
169}
170#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
171pub struct GetOutput {
172 #[serde(rename = "boot-info")]
173 #[doc = "Meta-information about the boot mode."]
174 #[doc = ""]
175 pub boot_info: BootInfoGetOutputBootInfo,
176 #[serde(
177 serialize_with = "crate::types::serialize_number",
178 deserialize_with = "crate::types::deserialize_number"
179 )]
180 #[doc = "The current cpu usage."]
181 #[doc = ""]
182 pub cpu: f64,
183 pub cpuinfo: CpuinfoGetOutputCpuinfo,
184 #[serde(rename = "current-kernel")]
185 #[doc = "Meta-information about the currently booted kernel of this node."]
186 #[doc = ""]
187 pub current_kernel: CurrentKernelGetOutputCurrentKernel,
188 #[serde(skip_serializing_if = "::std::vec::Vec::is_empty", default)]
189 #[doc = "An array of load avg for 1, 5 and 15 minutes respectively."]
190 #[doc = ""]
191 pub loadavg: Vec<String>,
192 pub memory: MemoryGetOutputMemory,
193 #[doc = "The PVE version string."]
194 #[doc = ""]
195 pub pveversion: String,
196 pub rootfs: RootfsGetOutputRootfs,
197 #[serde(
198 flatten,
199 default,
200 skip_serializing_if = "::std::collections::HashMap::is_empty"
201 )]
202 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
203}
204impl MemoryGetOutputMemory {
205 pub fn new(available: i64, free: i64, total: i64, used: i64) -> Self {
206 Self {
207 available,
208 free,
209 total,
210 used,
211 additional_properties: ::std::default::Default::default(),
212 }
213 }
214}
215#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
216pub struct MemoryGetOutputMemory {
217 #[serde(
218 serialize_with = "crate::types::serialize_int",
219 deserialize_with = "crate::types::deserialize_int"
220 )]
221 #[doc = "The available memory in bytes."]
222 #[doc = ""]
223 pub available: i64,
224 #[serde(
225 serialize_with = "crate::types::serialize_int",
226 deserialize_with = "crate::types::deserialize_int"
227 )]
228 #[doc = "The free memory in bytes."]
229 #[doc = ""]
230 pub free: i64,
231 #[serde(
232 serialize_with = "crate::types::serialize_int",
233 deserialize_with = "crate::types::deserialize_int"
234 )]
235 #[doc = "The total memory in bytes."]
236 #[doc = ""]
237 pub total: i64,
238 #[serde(
239 serialize_with = "crate::types::serialize_int",
240 deserialize_with = "crate::types::deserialize_int"
241 )]
242 #[doc = "The used memory in bytes."]
243 #[doc = ""]
244 pub used: i64,
245 #[serde(
246 flatten,
247 default,
248 skip_serializing_if = "::std::collections::HashMap::is_empty"
249 )]
250 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
251}
252impl PostParams {
253 pub fn new(command: Command) -> Self {
254 Self {
255 command,
256 additional_properties: ::std::default::Default::default(),
257 }
258 }
259}
260#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
261pub struct PostParams {
262 #[doc = "Specify the command."]
263 #[doc = ""]
264 pub command: Command,
265 #[serde(
266 flatten,
267 default,
268 skip_serializing_if = "::std::collections::HashMap::is_empty"
269 )]
270 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
271}
272impl RootfsGetOutputRootfs {
273 pub fn new(avail: i64, free: i64, total: i64, used: i64) -> Self {
274 Self {
275 avail,
276 free,
277 total,
278 used,
279 additional_properties: ::std::default::Default::default(),
280 }
281 }
282}
283#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
284pub struct RootfsGetOutputRootfs {
285 #[serde(
286 serialize_with = "crate::types::serialize_int",
287 deserialize_with = "crate::types::deserialize_int"
288 )]
289 #[doc = "The available bytes in the root filesystem."]
290 #[doc = ""]
291 pub avail: i64,
292 #[serde(
293 serialize_with = "crate::types::serialize_int",
294 deserialize_with = "crate::types::deserialize_int"
295 )]
296 #[doc = "The free bytes on the root filesystem."]
297 #[doc = ""]
298 pub free: i64,
299 #[serde(
300 serialize_with = "crate::types::serialize_int",
301 deserialize_with = "crate::types::deserialize_int"
302 )]
303 #[doc = "The total size of the root filesystem in bytes."]
304 #[doc = ""]
305 pub total: i64,
306 #[serde(
307 serialize_with = "crate::types::serialize_int",
308 deserialize_with = "crate::types::deserialize_int"
309 )]
310 #[doc = "The used bytes in the root filesystem."]
311 #[doc = ""]
312 pub used: i64,
313 #[serde(
314 flatten,
315 default,
316 skip_serializing_if = "::std::collections::HashMap::is_empty"
317 )]
318 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
319}
320#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
321#[doc = "Specify the command."]
322#[doc = ""]
323pub enum Command {
324 #[serde(rename = "reboot")]
325 Reboot,
326 #[serde(rename = "shutdown")]
327 Shutdown,
328}
329impl TryFrom<&str> for Command {
330 type Error = String;
331 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
332 match value {
333 "reboot" => Ok(Self::Reboot),
334 "shutdown" => Ok(Self::Shutdown),
335 v => Err(format!("Unknown variant {v}")),
336 }
337 }
338}
339#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
340#[doc = "Through which firmware the system got booted."]
341#[doc = ""]
342pub enum Mode {
343 #[serde(rename = "efi")]
344 Efi,
345 #[serde(rename = "legacy-bios")]
346 LegacyBios,
347}
348impl TryFrom<&str> for Mode {
349 type Error = String;
350 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
351 match value {
352 "efi" => Ok(Self::Efi),
353 "legacy-bios" => Ok(Self::LegacyBios),
354 v => Err(format!("Unknown variant {v}")),
355 }
356 }
357}