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 ClusterQemuConfigError {
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 ClusterQemuCreateCustomCpuModelsError {
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 ClusterQemuDeleteCustomCpuModelsError {
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 ClusterQemuGetCpuFlagsError {
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 ClusterQemuGetQemuError {
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 ClusterQemuInfoError {
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#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum ClusterQemuUpdateCustomCpuModelsError {
106 Status400(models::PveError),
107 Status401(models::PveError),
108 Status403(models::PveError),
109 Status404(models::PveError),
110 Status500(models::PveError),
111 Status501(models::PveError),
112 Status503(models::PveError),
113 UnknownValue(serde_json::Value),
114}
115
116
117pub async fn cluster_qemu_config(configuration: &configuration::Configuration, ) -> Result<models::ClusterQemuConfigResponse, Error<ClusterQemuConfigError>> {
119
120 let uri_str = format!("{}/cluster/qemu/custom-cpu-models", configuration.base_path);
121 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
122
123 if let Some(ref user_agent) = configuration.user_agent {
124 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
125 }
126 if let Some(ref apikey) = configuration.api_key {
127 let key = apikey.key.clone();
128 let value = match apikey.prefix {
129 Some(ref prefix) => format!("{} {}", prefix, key),
130 None => key,
131 };
132 req_builder = req_builder.header("Authorization", value);
133 };
134 if let Some(ref apikey) = configuration.api_key {
135 let key = apikey.key.clone();
136 let value = match apikey.prefix {
137 Some(ref prefix) => format!("{} {}", prefix, key),
138 None => key,
139 };
140 req_builder = req_builder.header("CSRFPreventionToken", value);
141 };
142
143 let req = req_builder.build()?;
144 let resp = configuration.client.execute(req).await?;
145
146 let status = resp.status();
147 let content_type = resp
148 .headers()
149 .get("content-type")
150 .and_then(|v| v.to_str().ok())
151 .unwrap_or("application/octet-stream");
152 let content_type = super::ContentType::from(content_type);
153
154 if !status.is_client_error() && !status.is_server_error() {
155 let content = resp.text().await?;
156 match content_type {
157 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
158 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuConfigResponse`"))),
159 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::ClusterQemuConfigResponse`")))),
160 }
161 } else {
162 let content = resp.text().await?;
163 let entity: Option<ClusterQemuConfigError> = serde_json::from_str(&content).ok();
164 Err(Error::ResponseError(ResponseContent { status, content, entity }))
165 }
166}
167
168pub async fn cluster_qemu_create_custom_cpu_models(configuration: &configuration::Configuration, cluster_qemu_create_custom_cpu_models_request: models::ClusterQemuCreateCustomCpuModelsRequest) -> Result<models::ClusterQemuCreateCustomCpuModelsResponse, Error<ClusterQemuCreateCustomCpuModelsError>> {
170 let p_body_cluster_qemu_create_custom_cpu_models_request = cluster_qemu_create_custom_cpu_models_request;
172
173 let uri_str = format!("{}/cluster/qemu/custom-cpu-models", configuration.base_path);
174 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
175
176 if let Some(ref user_agent) = configuration.user_agent {
177 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
178 }
179 if let Some(ref apikey) = configuration.api_key {
180 let key = apikey.key.clone();
181 let value = match apikey.prefix {
182 Some(ref prefix) => format!("{} {}", prefix, key),
183 None => key,
184 };
185 req_builder = req_builder.header("Authorization", value);
186 };
187 if let Some(ref apikey) = configuration.api_key {
188 let key = apikey.key.clone();
189 let value = match apikey.prefix {
190 Some(ref prefix) => format!("{} {}", prefix, key),
191 None => key,
192 };
193 req_builder = req_builder.header("CSRFPreventionToken", value);
194 };
195 req_builder = req_builder.json(&p_body_cluster_qemu_create_custom_cpu_models_request);
196
197 let req = req_builder.build()?;
198 let resp = configuration.client.execute(req).await?;
199
200 let status = resp.status();
201 let content_type = resp
202 .headers()
203 .get("content-type")
204 .and_then(|v| v.to_str().ok())
205 .unwrap_or("application/octet-stream");
206 let content_type = super::ContentType::from(content_type);
207
208 if !status.is_client_error() && !status.is_server_error() {
209 let content = resp.text().await?;
210 match content_type {
211 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
212 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuCreateCustomCpuModelsResponse`"))),
213 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::ClusterQemuCreateCustomCpuModelsResponse`")))),
214 }
215 } else {
216 let content = resp.text().await?;
217 let entity: Option<ClusterQemuCreateCustomCpuModelsError> = serde_json::from_str(&content).ok();
218 Err(Error::ResponseError(ResponseContent { status, content, entity }))
219 }
220}
221
222pub async fn cluster_qemu_delete_custom_cpu_models(configuration: &configuration::Configuration, cputype: &str) -> Result<models::ClusterQemuDeleteCustomCpuModelsResponse, Error<ClusterQemuDeleteCustomCpuModelsError>> {
224 let p_path_cputype = cputype;
226
227 let uri_str = format!("{}/cluster/qemu/custom-cpu-models/{cputype}", configuration.base_path, cputype=crate::apis::urlencode(p_path_cputype));
228 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
229
230 if let Some(ref user_agent) = configuration.user_agent {
231 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
232 }
233 if let Some(ref apikey) = configuration.api_key {
234 let key = apikey.key.clone();
235 let value = match apikey.prefix {
236 Some(ref prefix) => format!("{} {}", prefix, key),
237 None => key,
238 };
239 req_builder = req_builder.header("Authorization", value);
240 };
241 if let Some(ref apikey) = configuration.api_key {
242 let key = apikey.key.clone();
243 let value = match apikey.prefix {
244 Some(ref prefix) => format!("{} {}", prefix, key),
245 None => key,
246 };
247 req_builder = req_builder.header("CSRFPreventionToken", value);
248 };
249
250 let req = req_builder.build()?;
251 let resp = configuration.client.execute(req).await?;
252
253 let status = resp.status();
254 let content_type = resp
255 .headers()
256 .get("content-type")
257 .and_then(|v| v.to_str().ok())
258 .unwrap_or("application/octet-stream");
259 let content_type = super::ContentType::from(content_type);
260
261 if !status.is_client_error() && !status.is_server_error() {
262 let content = resp.text().await?;
263 match content_type {
264 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
265 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuDeleteCustomCpuModelsResponse`"))),
266 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::ClusterQemuDeleteCustomCpuModelsResponse`")))),
267 }
268 } else {
269 let content = resp.text().await?;
270 let entity: Option<ClusterQemuDeleteCustomCpuModelsError> = serde_json::from_str(&content).ok();
271 Err(Error::ResponseError(ResponseContent { status, content, entity }))
272 }
273}
274
275pub async fn cluster_qemu_get_cpu_flags(configuration: &configuration::Configuration, accel: Option<models::PveAccelEnum>, arch: Option<models::PveArchEnum>) -> Result<models::ClusterQemuGetCpuFlagsResponse, Error<ClusterQemuGetCpuFlagsError>> {
277 let p_query_accel = accel;
279 let p_query_arch = arch;
280
281 let uri_str = format!("{}/cluster/qemu/cpu-flags", configuration.base_path);
282 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
283
284 if let Some(ref param_value) = p_query_accel {
285 req_builder = req_builder.query(&[("accel", ¶m_value.to_string())]);
286 }
287 if let Some(ref param_value) = p_query_arch {
288 req_builder = req_builder.query(&[("arch", ¶m_value.to_string())]);
289 }
290 if let Some(ref user_agent) = configuration.user_agent {
291 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
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("Authorization", value);
300 };
301 if let Some(ref apikey) = configuration.api_key {
302 let key = apikey.key.clone();
303 let value = match apikey.prefix {
304 Some(ref prefix) => format!("{} {}", prefix, key),
305 None => key,
306 };
307 req_builder = req_builder.header("CSRFPreventionToken", value);
308 };
309
310 let req = req_builder.build()?;
311 let resp = configuration.client.execute(req).await?;
312
313 let status = resp.status();
314 let content_type = resp
315 .headers()
316 .get("content-type")
317 .and_then(|v| v.to_str().ok())
318 .unwrap_or("application/octet-stream");
319 let content_type = super::ContentType::from(content_type);
320
321 if !status.is_client_error() && !status.is_server_error() {
322 let content = resp.text().await?;
323 match content_type {
324 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
325 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuGetCpuFlagsResponse`"))),
326 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::ClusterQemuGetCpuFlagsResponse`")))),
327 }
328 } else {
329 let content = resp.text().await?;
330 let entity: Option<ClusterQemuGetCpuFlagsError> = serde_json::from_str(&content).ok();
331 Err(Error::ResponseError(ResponseContent { status, content, entity }))
332 }
333}
334
335pub async fn cluster_qemu_get_qemu(configuration: &configuration::Configuration, ) -> Result<models::ClusterQemuGetQemuResponse, Error<ClusterQemuGetQemuError>> {
337
338 let uri_str = format!("{}/cluster/qemu", configuration.base_path);
339 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
340
341 if let Some(ref user_agent) = configuration.user_agent {
342 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
343 }
344 if let Some(ref apikey) = configuration.api_key {
345 let key = apikey.key.clone();
346 let value = match apikey.prefix {
347 Some(ref prefix) => format!("{} {}", prefix, key),
348 None => key,
349 };
350 req_builder = req_builder.header("Authorization", value);
351 };
352 if let Some(ref apikey) = configuration.api_key {
353 let key = apikey.key.clone();
354 let value = match apikey.prefix {
355 Some(ref prefix) => format!("{} {}", prefix, key),
356 None => key,
357 };
358 req_builder = req_builder.header("CSRFPreventionToken", value);
359 };
360
361 let req = req_builder.build()?;
362 let resp = configuration.client.execute(req).await?;
363
364 let status = resp.status();
365 let content_type = resp
366 .headers()
367 .get("content-type")
368 .and_then(|v| v.to_str().ok())
369 .unwrap_or("application/octet-stream");
370 let content_type = super::ContentType::from(content_type);
371
372 if !status.is_client_error() && !status.is_server_error() {
373 let content = resp.text().await?;
374 match content_type {
375 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
376 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuGetQemuResponse`"))),
377 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::ClusterQemuGetQemuResponse`")))),
378 }
379 } else {
380 let content = resp.text().await?;
381 let entity: Option<ClusterQemuGetQemuError> = serde_json::from_str(&content).ok();
382 Err(Error::ResponseError(ResponseContent { status, content, entity }))
383 }
384}
385
386pub async fn cluster_qemu_info(configuration: &configuration::Configuration, cputype: &str) -> Result<models::ClusterQemuInfoResponse, Error<ClusterQemuInfoError>> {
388 let p_path_cputype = cputype;
390
391 let uri_str = format!("{}/cluster/qemu/custom-cpu-models/{cputype}", configuration.base_path, cputype=crate::apis::urlencode(p_path_cputype));
392 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
393
394 if let Some(ref user_agent) = configuration.user_agent {
395 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
396 }
397 if let Some(ref apikey) = configuration.api_key {
398 let key = apikey.key.clone();
399 let value = match apikey.prefix {
400 Some(ref prefix) => format!("{} {}", prefix, key),
401 None => key,
402 };
403 req_builder = req_builder.header("Authorization", value);
404 };
405 if let Some(ref apikey) = configuration.api_key {
406 let key = apikey.key.clone();
407 let value = match apikey.prefix {
408 Some(ref prefix) => format!("{} {}", prefix, key),
409 None => key,
410 };
411 req_builder = req_builder.header("CSRFPreventionToken", value);
412 };
413
414 let req = req_builder.build()?;
415 let resp = configuration.client.execute(req).await?;
416
417 let status = resp.status();
418 let content_type = resp
419 .headers()
420 .get("content-type")
421 .and_then(|v| v.to_str().ok())
422 .unwrap_or("application/octet-stream");
423 let content_type = super::ContentType::from(content_type);
424
425 if !status.is_client_error() && !status.is_server_error() {
426 let content = resp.text().await?;
427 match content_type {
428 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
429 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuInfoResponse`"))),
430 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::ClusterQemuInfoResponse`")))),
431 }
432 } else {
433 let content = resp.text().await?;
434 let entity: Option<ClusterQemuInfoError> = serde_json::from_str(&content).ok();
435 Err(Error::ResponseError(ResponseContent { status, content, entity }))
436 }
437}
438
439pub async fn cluster_qemu_update_custom_cpu_models(configuration: &configuration::Configuration, cputype: &str, cluster_qemu_update_custom_cpu_models_request: Option<models::ClusterQemuUpdateCustomCpuModelsRequest>) -> Result<models::ClusterQemuUpdateCustomCpuModelsResponse, Error<ClusterQemuUpdateCustomCpuModelsError>> {
441 let p_path_cputype = cputype;
443 let p_body_cluster_qemu_update_custom_cpu_models_request = cluster_qemu_update_custom_cpu_models_request;
444
445 let uri_str = format!("{}/cluster/qemu/custom-cpu-models/{cputype}", configuration.base_path, cputype=crate::apis::urlencode(p_path_cputype));
446 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
447
448 if let Some(ref user_agent) = configuration.user_agent {
449 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
450 }
451 if let Some(ref apikey) = configuration.api_key {
452 let key = apikey.key.clone();
453 let value = match apikey.prefix {
454 Some(ref prefix) => format!("{} {}", prefix, key),
455 None => key,
456 };
457 req_builder = req_builder.header("Authorization", value);
458 };
459 if let Some(ref apikey) = configuration.api_key {
460 let key = apikey.key.clone();
461 let value = match apikey.prefix {
462 Some(ref prefix) => format!("{} {}", prefix, key),
463 None => key,
464 };
465 req_builder = req_builder.header("CSRFPreventionToken", value);
466 };
467 req_builder = req_builder.json(&p_body_cluster_qemu_update_custom_cpu_models_request);
468
469 let req = req_builder.build()?;
470 let resp = configuration.client.execute(req).await?;
471
472 let status = resp.status();
473 let content_type = resp
474 .headers()
475 .get("content-type")
476 .and_then(|v| v.to_str().ok())
477 .unwrap_or("application/octet-stream");
478 let content_type = super::ContentType::from(content_type);
479
480 if !status.is_client_error() && !status.is_server_error() {
481 let content = resp.text().await?;
482 match content_type {
483 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
484 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterQemuUpdateCustomCpuModelsResponse`"))),
485 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::ClusterQemuUpdateCustomCpuModelsResponse`")))),
486 }
487 } else {
488 let content = resp.text().await?;
489 let entity: Option<ClusterQemuUpdateCustomCpuModelsError> = serde_json::from_str(&content).ok();
490 Err(Error::ResponseError(ResponseContent { status, content, entity }))
491 }
492}
493