1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum NodesCapabilitiesCapabilitiesError {
22 Status400(models::PveError),
23 Status401(models::PveError),
24 Status403(models::PveError),
25 Status404(models::PveError),
26 Status500(models::PveError),
27 Status501(models::PveError),
28 Status503(models::PveError),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum NodesCapabilitiesGetCapabilitiesError {
36 Status400(models::PveError),
37 Status401(models::PveError),
38 Status403(models::PveError),
39 Status404(models::PveError),
40 Status500(models::PveError),
41 Status501(models::PveError),
42 Status503(models::PveError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum NodesCapabilitiesGetCpuError {
50 Status400(models::PveError),
51 Status401(models::PveError),
52 Status403(models::PveError),
53 Status404(models::PveError),
54 Status500(models::PveError),
55 Status501(models::PveError),
56 Status503(models::PveError),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum NodesCapabilitiesGetCpuFlagsError {
64 Status400(models::PveError),
65 Status401(models::PveError),
66 Status403(models::PveError),
67 Status404(models::PveError),
68 Status500(models::PveError),
69 Status501(models::PveError),
70 Status503(models::PveError),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum NodesCapabilitiesQemuCapsIndexError {
78 Status400(models::PveError),
79 Status401(models::PveError),
80 Status403(models::PveError),
81 Status404(models::PveError),
82 Status500(models::PveError),
83 Status501(models::PveError),
84 Status503(models::PveError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum NodesCapabilitiesTypesError {
92 Status400(models::PveError),
93 Status401(models::PveError),
94 Status403(models::PveError),
95 Status404(models::PveError),
96 Status500(models::PveError),
97 Status501(models::PveError),
98 Status503(models::PveError),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn nodes_capabilities_capabilities(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCapabilitiesCapabilitiesResponse, Error<NodesCapabilitiesCapabilitiesError>> {
105 let p_path_node = node;
107
108 let uri_str = format!("{}/nodes/{node}/capabilities/qemu/migration", configuration.base_path, node=crate::apis::urlencode(p_path_node));
109 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
110
111 if let Some(ref user_agent) = configuration.user_agent {
112 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113 }
114 if let Some(ref apikey) = configuration.api_key {
115 let key = apikey.key.clone();
116 let value = match apikey.prefix {
117 Some(ref prefix) => format!("{} {}", prefix, key),
118 None => key,
119 };
120 req_builder = req_builder.header("Authorization", value);
121 };
122 if let Some(ref apikey) = configuration.api_key {
123 let key = apikey.key.clone();
124 let value = match apikey.prefix {
125 Some(ref prefix) => format!("{} {}", prefix, key),
126 None => key,
127 };
128 req_builder = req_builder.header("CSRFPreventionToken", value);
129 };
130
131 let req = req_builder.build()?;
132 let resp = configuration.client.execute(req).await?;
133
134 let status = resp.status();
135 let content_type = resp
136 .headers()
137 .get("content-type")
138 .and_then(|v| v.to_str().ok())
139 .unwrap_or("application/octet-stream");
140 let content_type = super::ContentType::from(content_type);
141
142 if !status.is_client_error() && !status.is_server_error() {
143 let content = resp.text().await?;
144 match content_type {
145 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
146 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesCapabilitiesResponse`"))),
147 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesCapabilitiesResponse`")))),
148 }
149 } else {
150 let content = resp.text().await?;
151 let entity: Option<NodesCapabilitiesCapabilitiesError> = serde_json::from_str(&content).ok();
152 Err(Error::ResponseError(ResponseContent { status, content, entity }))
153 }
154}
155
156pub async fn nodes_capabilities_get_capabilities(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCapabilitiesGetCapabilitiesResponse, Error<NodesCapabilitiesGetCapabilitiesError>> {
158 let p_path_node = node;
160
161 let uri_str = format!("{}/nodes/{node}/capabilities", configuration.base_path, node=crate::apis::urlencode(p_path_node));
162 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
163
164 if let Some(ref user_agent) = configuration.user_agent {
165 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
166 }
167 if let Some(ref apikey) = configuration.api_key {
168 let key = apikey.key.clone();
169 let value = match apikey.prefix {
170 Some(ref prefix) => format!("{} {}", prefix, key),
171 None => key,
172 };
173 req_builder = req_builder.header("Authorization", value);
174 };
175 if let Some(ref apikey) = configuration.api_key {
176 let key = apikey.key.clone();
177 let value = match apikey.prefix {
178 Some(ref prefix) => format!("{} {}", prefix, key),
179 None => key,
180 };
181 req_builder = req_builder.header("CSRFPreventionToken", value);
182 };
183
184 let req = req_builder.build()?;
185 let resp = configuration.client.execute(req).await?;
186
187 let status = resp.status();
188 let content_type = resp
189 .headers()
190 .get("content-type")
191 .and_then(|v| v.to_str().ok())
192 .unwrap_or("application/octet-stream");
193 let content_type = super::ContentType::from(content_type);
194
195 if !status.is_client_error() && !status.is_server_error() {
196 let content = resp.text().await?;
197 match content_type {
198 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
199 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesGetCapabilitiesResponse`"))),
200 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesGetCapabilitiesResponse`")))),
201 }
202 } else {
203 let content = resp.text().await?;
204 let entity: Option<NodesCapabilitiesGetCapabilitiesError> = serde_json::from_str(&content).ok();
205 Err(Error::ResponseError(ResponseContent { status, content, entity }))
206 }
207}
208
209pub async fn nodes_capabilities_get_cpu(configuration: &configuration::Configuration, node: &str, arch: Option<models::PveArchEnum>) -> Result<models::NodesCapabilitiesGetCpuResponse, Error<NodesCapabilitiesGetCpuError>> {
211 let p_path_node = node;
213 let p_query_arch = arch;
214
215 let uri_str = format!("{}/nodes/{node}/capabilities/qemu/cpu", configuration.base_path, node=crate::apis::urlencode(p_path_node));
216 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
217
218 if let Some(ref param_value) = p_query_arch {
219 req_builder = req_builder.query(&[("arch", ¶m_value.to_string())]);
220 }
221 if let Some(ref user_agent) = configuration.user_agent {
222 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
223 }
224 if let Some(ref apikey) = configuration.api_key {
225 let key = apikey.key.clone();
226 let value = match apikey.prefix {
227 Some(ref prefix) => format!("{} {}", prefix, key),
228 None => key,
229 };
230 req_builder = req_builder.header("Authorization", value);
231 };
232 if let Some(ref apikey) = configuration.api_key {
233 let key = apikey.key.clone();
234 let value = match apikey.prefix {
235 Some(ref prefix) => format!("{} {}", prefix, key),
236 None => key,
237 };
238 req_builder = req_builder.header("CSRFPreventionToken", value);
239 };
240
241 let req = req_builder.build()?;
242 let resp = configuration.client.execute(req).await?;
243
244 let status = resp.status();
245 let content_type = resp
246 .headers()
247 .get("content-type")
248 .and_then(|v| v.to_str().ok())
249 .unwrap_or("application/octet-stream");
250 let content_type = super::ContentType::from(content_type);
251
252 if !status.is_client_error() && !status.is_server_error() {
253 let content = resp.text().await?;
254 match content_type {
255 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
256 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesGetCpuResponse`"))),
257 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesGetCpuResponse`")))),
258 }
259 } else {
260 let content = resp.text().await?;
261 let entity: Option<NodesCapabilitiesGetCpuError> = serde_json::from_str(&content).ok();
262 Err(Error::ResponseError(ResponseContent { status, content, entity }))
263 }
264}
265
266pub async fn nodes_capabilities_get_cpu_flags(configuration: &configuration::Configuration, node: &str, accel: Option<&str>, arch: Option<models::PveArchEnum>) -> Result<models::NodesCapabilitiesGetCpuFlagsResponse, Error<NodesCapabilitiesGetCpuFlagsError>> {
268 let p_path_node = node;
270 let p_query_accel = accel;
271 let p_query_arch = arch;
272
273 let uri_str = format!("{}/nodes/{node}/capabilities/qemu/cpu-flags", configuration.base_path, node=crate::apis::urlencode(p_path_node));
274 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
275
276 if let Some(ref param_value) = p_query_accel {
277 req_builder = req_builder.query(&[("accel", ¶m_value.to_string())]);
278 }
279 if let Some(ref param_value) = p_query_arch {
280 req_builder = req_builder.query(&[("arch", ¶m_value.to_string())]);
281 }
282 if let Some(ref user_agent) = configuration.user_agent {
283 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
284 }
285 if let Some(ref apikey) = configuration.api_key {
286 let key = apikey.key.clone();
287 let value = match apikey.prefix {
288 Some(ref prefix) => format!("{} {}", prefix, key),
289 None => key,
290 };
291 req_builder = req_builder.header("Authorization", value);
292 };
293 if let Some(ref apikey) = configuration.api_key {
294 let key = apikey.key.clone();
295 let value = match apikey.prefix {
296 Some(ref prefix) => format!("{} {}", prefix, key),
297 None => key,
298 };
299 req_builder = req_builder.header("CSRFPreventionToken", value);
300 };
301
302 let req = req_builder.build()?;
303 let resp = configuration.client.execute(req).await?;
304
305 let status = resp.status();
306 let content_type = resp
307 .headers()
308 .get("content-type")
309 .and_then(|v| v.to_str().ok())
310 .unwrap_or("application/octet-stream");
311 let content_type = super::ContentType::from(content_type);
312
313 if !status.is_client_error() && !status.is_server_error() {
314 let content = resp.text().await?;
315 match content_type {
316 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
317 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesGetCpuFlagsResponse`"))),
318 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesGetCpuFlagsResponse`")))),
319 }
320 } else {
321 let content = resp.text().await?;
322 let entity: Option<NodesCapabilitiesGetCpuFlagsError> = serde_json::from_str(&content).ok();
323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
324 }
325}
326
327pub async fn nodes_capabilities_qemu_caps_index(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesCapabilitiesQemuCapsIndexResponse, Error<NodesCapabilitiesQemuCapsIndexError>> {
329 let p_path_node = node;
331
332 let uri_str = format!("{}/nodes/{node}/capabilities/qemu", configuration.base_path, node=crate::apis::urlencode(p_path_node));
333 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
334
335 if let Some(ref user_agent) = configuration.user_agent {
336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337 }
338 if let Some(ref apikey) = configuration.api_key {
339 let key = apikey.key.clone();
340 let value = match apikey.prefix {
341 Some(ref prefix) => format!("{} {}", prefix, key),
342 None => key,
343 };
344 req_builder = req_builder.header("Authorization", value);
345 };
346 if let Some(ref apikey) = configuration.api_key {
347 let key = apikey.key.clone();
348 let value = match apikey.prefix {
349 Some(ref prefix) => format!("{} {}", prefix, key),
350 None => key,
351 };
352 req_builder = req_builder.header("CSRFPreventionToken", value);
353 };
354
355 let req = req_builder.build()?;
356 let resp = configuration.client.execute(req).await?;
357
358 let status = resp.status();
359 let content_type = resp
360 .headers()
361 .get("content-type")
362 .and_then(|v| v.to_str().ok())
363 .unwrap_or("application/octet-stream");
364 let content_type = super::ContentType::from(content_type);
365
366 if !status.is_client_error() && !status.is_server_error() {
367 let content = resp.text().await?;
368 match content_type {
369 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesQemuCapsIndexResponse`"))),
371 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesQemuCapsIndexResponse`")))),
372 }
373 } else {
374 let content = resp.text().await?;
375 let entity: Option<NodesCapabilitiesQemuCapsIndexError> = serde_json::from_str(&content).ok();
376 Err(Error::ResponseError(ResponseContent { status, content, entity }))
377 }
378}
379
380pub async fn nodes_capabilities_types(configuration: &configuration::Configuration, node: &str, arch: Option<models::PveArchEnum>) -> Result<models::NodesCapabilitiesTypesResponse, Error<NodesCapabilitiesTypesError>> {
382 let p_path_node = node;
384 let p_query_arch = arch;
385
386 let uri_str = format!("{}/nodes/{node}/capabilities/qemu/machines", configuration.base_path, node=crate::apis::urlencode(p_path_node));
387 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
388
389 if let Some(ref param_value) = p_query_arch {
390 req_builder = req_builder.query(&[("arch", ¶m_value.to_string())]);
391 }
392 if let Some(ref user_agent) = configuration.user_agent {
393 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
394 }
395 if let Some(ref apikey) = configuration.api_key {
396 let key = apikey.key.clone();
397 let value = match apikey.prefix {
398 Some(ref prefix) => format!("{} {}", prefix, key),
399 None => key,
400 };
401 req_builder = req_builder.header("Authorization", value);
402 };
403 if let Some(ref apikey) = configuration.api_key {
404 let key = apikey.key.clone();
405 let value = match apikey.prefix {
406 Some(ref prefix) => format!("{} {}", prefix, key),
407 None => key,
408 };
409 req_builder = req_builder.header("CSRFPreventionToken", value);
410 };
411
412 let req = req_builder.build()?;
413 let resp = configuration.client.execute(req).await?;
414
415 let status = resp.status();
416 let content_type = resp
417 .headers()
418 .get("content-type")
419 .and_then(|v| v.to_str().ok())
420 .unwrap_or("application/octet-stream");
421 let content_type = super::ContentType::from(content_type);
422
423 if !status.is_client_error() && !status.is_server_error() {
424 let content = resp.text().await?;
425 match content_type {
426 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
427 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesCapabilitiesTypesResponse`"))),
428 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::NodesCapabilitiesTypesResponse`")))),
429 }
430 } else {
431 let content = resp.text().await?;
432 let entity: Option<NodesCapabilitiesTypesError> = serde_json::from_str(&content).ok();
433 Err(Error::ResponseError(ResponseContent { status, content, entity }))
434 }
435}
436