1#[derive(Debug, Clone)]
2pub struct CurrentClient<T> {
3 client: T,
4 path: String,
5}
6impl<T> CurrentClient<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, "/current"),
14 }
15 }
16}
17impl<T> CurrentClient<T>
18where
19 T: crate::client::Client,
20{
21 #[doc = "Get virtual machine status."]
22 #[doc = ""]
23 #[doc = "Permission check: perm(\"/vms/{vmid}\", [\"VM.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 GetOutput {
30 pub fn new(ha: HaGetOutputHa, status: Status, vmid: VmidInt) -> Self {
31 Self {
32 ha,
33 status,
34 vmid,
35 agent: ::std::default::Default::default(),
36 clipboard: ::std::default::Default::default(),
37 cpu: ::std::default::Default::default(),
38 cpus: ::std::default::Default::default(),
39 diskread: ::std::default::Default::default(),
40 diskwrite: ::std::default::Default::default(),
41 lock: ::std::default::Default::default(),
42 maxdisk: ::std::default::Default::default(),
43 maxmem: ::std::default::Default::default(),
44 mem: ::std::default::Default::default(),
45 memhost: ::std::default::Default::default(),
46 name: ::std::default::Default::default(),
47 netin: ::std::default::Default::default(),
48 netout: ::std::default::Default::default(),
49 pid: ::std::default::Default::default(),
50 pressurecpufull: ::std::default::Default::default(),
51 pressurecpusome: ::std::default::Default::default(),
52 pressureiofull: ::std::default::Default::default(),
53 pressureiosome: ::std::default::Default::default(),
54 pressurememoryfull: ::std::default::Default::default(),
55 pressurememorysome: ::std::default::Default::default(),
56 qmpstatus: ::std::default::Default::default(),
57 running_machine: ::std::default::Default::default(),
58 running_qemu: ::std::default::Default::default(),
59 serial: ::std::default::Default::default(),
60 spice: ::std::default::Default::default(),
61 tags: ::std::default::Default::default(),
62 template: ::std::default::Default::default(),
63 uptime: ::std::default::Default::default(),
64 additional_properties: ::std::default::Default::default(),
65 }
66 }
67}
68#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize)]
69pub struct GetOutput {
70 #[serde(
71 serialize_with = "crate::types::serialize_bool_optional",
72 deserialize_with = "crate::types::deserialize_bool_optional"
73 )]
74 #[serde(skip_serializing_if = "Option::is_none", default)]
75 #[doc = "QEMU Guest Agent is enabled in config."]
76 #[doc = ""]
77 pub agent: Option<bool>,
78 #[serde(skip_serializing_if = "Option::is_none", default)]
79 #[doc = "Enable a specific clipboard. If not set, depending on the display type the SPICE one will be added."]
80 #[doc = ""]
81 pub clipboard: Option<Clipboard>,
82 #[serde(
83 serialize_with = "crate::types::serialize_number_optional",
84 deserialize_with = "crate::types::deserialize_number_optional"
85 )]
86 #[serde(skip_serializing_if = "Option::is_none", default)]
87 #[doc = "Current CPU usage."]
88 #[doc = ""]
89 pub cpu: Option<f64>,
90 #[serde(
91 serialize_with = "crate::types::serialize_number_optional",
92 deserialize_with = "crate::types::deserialize_number_optional"
93 )]
94 #[serde(skip_serializing_if = "Option::is_none", default)]
95 #[doc = "Maximum usable CPUs."]
96 #[doc = ""]
97 pub cpus: Option<f64>,
98 #[serde(
99 serialize_with = "crate::types::serialize_int_optional",
100 deserialize_with = "crate::types::deserialize_int_optional"
101 )]
102 #[serde(skip_serializing_if = "Option::is_none", default)]
103 #[doc = "The amount of bytes the guest read from it's block devices since the guest was started. (Note: This info is not available for all storage types.)"]
104 #[doc = ""]
105 pub diskread: Option<i64>,
106 #[serde(
107 serialize_with = "crate::types::serialize_int_optional",
108 deserialize_with = "crate::types::deserialize_int_optional"
109 )]
110 #[serde(skip_serializing_if = "Option::is_none", default)]
111 #[doc = "The amount of bytes the guest wrote from it's block devices since the guest was started. (Note: This info is not available for all storage types.)"]
112 #[doc = ""]
113 pub diskwrite: Option<i64>,
114 #[doc = "HA manager service status."]
115 #[doc = ""]
116 pub ha: HaGetOutputHa,
117 #[serde(skip_serializing_if = "Option::is_none", default)]
118 #[doc = "The current config lock, if any."]
119 #[doc = ""]
120 pub lock: Option<String>,
121 #[serde(
122 serialize_with = "crate::types::serialize_int_optional",
123 deserialize_with = "crate::types::deserialize_int_optional"
124 )]
125 #[serde(skip_serializing_if = "Option::is_none", default)]
126 #[doc = "Root disk size in bytes."]
127 #[doc = ""]
128 pub maxdisk: Option<i64>,
129 #[serde(
130 serialize_with = "crate::types::serialize_int_optional",
131 deserialize_with = "crate::types::deserialize_int_optional"
132 )]
133 #[serde(skip_serializing_if = "Option::is_none", default)]
134 #[doc = "Maximum memory in bytes."]
135 #[doc = ""]
136 pub maxmem: Option<i64>,
137 #[serde(
138 serialize_with = "crate::types::serialize_int_optional",
139 deserialize_with = "crate::types::deserialize_int_optional"
140 )]
141 #[serde(skip_serializing_if = "Option::is_none", default)]
142 #[doc = "Currently used memory in bytes."]
143 #[doc = ""]
144 pub mem: Option<i64>,
145 #[serde(
146 serialize_with = "crate::types::serialize_int_optional",
147 deserialize_with = "crate::types::deserialize_int_optional"
148 )]
149 #[serde(skip_serializing_if = "Option::is_none", default)]
150 #[doc = "Current memory usage on the host."]
151 #[doc = ""]
152 pub memhost: Option<i64>,
153 #[serde(skip_serializing_if = "Option::is_none", default)]
154 #[doc = "VM (host)name."]
155 #[doc = ""]
156 pub name: Option<String>,
157 #[serde(
158 serialize_with = "crate::types::serialize_int_optional",
159 deserialize_with = "crate::types::deserialize_int_optional"
160 )]
161 #[serde(skip_serializing_if = "Option::is_none", default)]
162 #[doc = "The amount of traffic in bytes that was sent to the guest over the network since it was started."]
163 #[doc = ""]
164 pub netin: Option<i64>,
165 #[serde(
166 serialize_with = "crate::types::serialize_int_optional",
167 deserialize_with = "crate::types::deserialize_int_optional"
168 )]
169 #[serde(skip_serializing_if = "Option::is_none", default)]
170 #[doc = "The amount of traffic in bytes that was sent from the guest over the network since it was started."]
171 #[doc = ""]
172 pub netout: Option<i64>,
173 #[serde(
174 serialize_with = "crate::types::serialize_int_optional",
175 deserialize_with = "crate::types::deserialize_int_optional"
176 )]
177 #[serde(skip_serializing_if = "Option::is_none", default)]
178 #[doc = "PID of the QEMU process, if the VM is running."]
179 #[doc = ""]
180 pub pid: Option<i64>,
181 #[serde(
182 serialize_with = "crate::types::serialize_number_optional",
183 deserialize_with = "crate::types::deserialize_number_optional"
184 )]
185 #[serde(skip_serializing_if = "Option::is_none", default)]
186 #[doc = "CPU Full pressure stall average over the last 10 seconds."]
187 #[doc = ""]
188 pub pressurecpufull: Option<f64>,
189 #[serde(
190 serialize_with = "crate::types::serialize_number_optional",
191 deserialize_with = "crate::types::deserialize_number_optional"
192 )]
193 #[serde(skip_serializing_if = "Option::is_none", default)]
194 #[doc = "CPU Some pressure stall average over the last 10 seconds."]
195 #[doc = ""]
196 pub pressurecpusome: Option<f64>,
197 #[serde(
198 serialize_with = "crate::types::serialize_number_optional",
199 deserialize_with = "crate::types::deserialize_number_optional"
200 )]
201 #[serde(skip_serializing_if = "Option::is_none", default)]
202 #[doc = "IO Full pressure stall average over the last 10 seconds."]
203 #[doc = ""]
204 pub pressureiofull: Option<f64>,
205 #[serde(
206 serialize_with = "crate::types::serialize_number_optional",
207 deserialize_with = "crate::types::deserialize_number_optional"
208 )]
209 #[serde(skip_serializing_if = "Option::is_none", default)]
210 #[doc = "IO Some pressure stall average over the last 10 seconds."]
211 #[doc = ""]
212 pub pressureiosome: Option<f64>,
213 #[serde(
214 serialize_with = "crate::types::serialize_number_optional",
215 deserialize_with = "crate::types::deserialize_number_optional"
216 )]
217 #[serde(skip_serializing_if = "Option::is_none", default)]
218 #[doc = "Memory Full pressure stall average over the last 10 seconds."]
219 #[doc = ""]
220 pub pressurememoryfull: Option<f64>,
221 #[serde(
222 serialize_with = "crate::types::serialize_number_optional",
223 deserialize_with = "crate::types::deserialize_number_optional"
224 )]
225 #[serde(skip_serializing_if = "Option::is_none", default)]
226 #[doc = "Memory Some pressure stall average over the last 10 seconds."]
227 #[doc = ""]
228 pub pressurememorysome: Option<f64>,
229 #[serde(skip_serializing_if = "Option::is_none", default)]
230 #[doc = "VM run state from the 'query-status' QMP monitor command."]
231 #[doc = ""]
232 pub qmpstatus: Option<String>,
233 #[serde(rename = "running-machine")]
234 #[serde(skip_serializing_if = "Option::is_none", default)]
235 #[doc = "The currently running machine type (if running)."]
236 #[doc = ""]
237 pub running_machine: Option<String>,
238 #[serde(rename = "running-qemu")]
239 #[serde(skip_serializing_if = "Option::is_none", default)]
240 #[doc = "The QEMU version the VM is currently using (if running)."]
241 #[doc = ""]
242 pub running_qemu: Option<String>,
243 #[serde(
244 serialize_with = "crate::types::serialize_bool_optional",
245 deserialize_with = "crate::types::deserialize_bool_optional"
246 )]
247 #[serde(skip_serializing_if = "Option::is_none", default)]
248 #[doc = "Guest has serial device configured."]
249 #[doc = ""]
250 pub serial: Option<bool>,
251 #[serde(
252 serialize_with = "crate::types::serialize_bool_optional",
253 deserialize_with = "crate::types::deserialize_bool_optional"
254 )]
255 #[serde(skip_serializing_if = "Option::is_none", default)]
256 #[doc = "QEMU VGA configuration supports spice."]
257 #[doc = ""]
258 pub spice: Option<bool>,
259 #[doc = "QEMU process status."]
260 #[doc = ""]
261 pub status: Status,
262 #[serde(skip_serializing_if = "Option::is_none", default)]
263 #[doc = "The current configured tags, if any"]
264 #[doc = ""]
265 pub tags: Option<String>,
266 #[serde(
267 serialize_with = "crate::types::serialize_bool_optional",
268 deserialize_with = "crate::types::deserialize_bool_optional"
269 )]
270 #[serde(skip_serializing_if = "Option::is_none", default)]
271 #[doc = "Determines if the guest is a template."]
272 #[doc = ""]
273 pub template: Option<bool>,
274 #[serde(
275 serialize_with = "crate::types::serialize_int_optional",
276 deserialize_with = "crate::types::deserialize_int_optional"
277 )]
278 #[serde(skip_serializing_if = "Option::is_none", default)]
279 #[doc = "Uptime in seconds."]
280 #[doc = ""]
281 pub uptime: Option<i64>,
282 #[doc = "The (unique) ID of the VM."]
283 #[doc = ""]
284 pub vmid: VmidInt,
285 #[serde(
286 flatten,
287 default,
288 skip_serializing_if = "::std::collections::HashMap::is_empty"
289 )]
290 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
291}
292#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, Default)]
293pub struct HaGetOutputHa {
294 #[serde(
295 flatten,
296 default,
297 skip_serializing_if = "::std::collections::HashMap::is_empty"
298 )]
299 pub additional_properties: ::std::collections::HashMap<String, ::serde_json::Value>,
300}
301#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
302#[doc = "Enable a specific clipboard. If not set, depending on the display type the SPICE one will be added."]
303#[doc = ""]
304pub enum Clipboard {
305 #[serde(rename = "vnc")]
306 Vnc,
307}
308impl TryFrom<&str> for Clipboard {
309 type Error = String;
310 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
311 match value {
312 "vnc" => Ok(Self::Vnc),
313 v => Err(format!("Unknown variant {v}")),
314 }
315 }
316}
317#[derive(Clone, Debug, :: serde :: Serialize, :: serde :: Deserialize, PartialEq)]
318#[doc = "QEMU process status."]
319#[doc = ""]
320pub enum Status {
321 #[serde(rename = "running")]
322 Running,
323 #[serde(rename = "stopped")]
324 Stopped,
325}
326impl TryFrom<&str> for Status {
327 type Error = String;
328 fn try_from(value: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
329 match value {
330 "running" => Ok(Self::Running),
331 "stopped" => Ok(Self::Stopped),
332 v => Err(format!("Unknown variant {v}")),
333 }
334 }
335}
336#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
337pub struct VmidInt(i128);
338impl crate::types::bounded_integer::BoundedInteger for VmidInt {
339 const MIN: Option<i128> = Some(100i128);
340 const MAX: Option<i128> = Some(999999999i128);
341 const DEFAULT: Option<i128> = None::<i128>;
342 const TYPE_DESCRIPTION: &'static str = "an integer between 100 and 999999999";
343 fn get(&self) -> i128 {
344 self.0
345 }
346 fn new(value: i128) -> Result<Self, crate::types::bounded_integer::BoundedIntegerError> {
347 Self::validate(value)?;
348 Ok(Self(value))
349 }
350}
351impl std::convert::TryFrom<i128> for VmidInt {
352 type Error = crate::types::bounded_integer::BoundedIntegerError;
353 fn try_from(value: i128) -> Result<Self, Self::Error> {
354 crate::types::bounded_integer::BoundedInteger::new(value)
355 }
356}
357impl ::serde::Serialize for VmidInt {
358 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
359 where
360 S: ::serde::Serializer,
361 {
362 crate::types::bounded_integer::serialize_bounded_integer(self, serializer)
363 }
364}
365impl<'de> ::serde::Deserialize<'de> for VmidInt {
366 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
367 where
368 D: ::serde::Deserializer<'de>,
369 {
370 crate::types::bounded_integer::deserialize_bounded_integer(deserializer)
371 }
372}