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 ClusterCephCephindexError {
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 ClusterCephGetAllFlagsError {
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 ClusterCephGetFlagError {
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 ClusterCephMetadataError {
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 ClusterCephSetFlagsError {
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 ClusterCephStatusError {
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 ClusterCephUpdateFlagError {
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_ceph_cephindex(configuration: &configuration::Configuration, ) -> Result<models::ClusterCephCephindexResponse, Error<ClusterCephCephindexError>> {
119
120 let uri_str = format!("{}/cluster/ceph", 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::ClusterCephCephindexResponse`"))),
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::ClusterCephCephindexResponse`")))),
160 }
161 } else {
162 let content = resp.text().await?;
163 let entity: Option<ClusterCephCephindexError> = serde_json::from_str(&content).ok();
164 Err(Error::ResponseError(ResponseContent { status, content, entity }))
165 }
166}
167
168pub async fn cluster_ceph_get_all_flags(configuration: &configuration::Configuration, ) -> Result<models::ClusterCephGetAllFlagsResponse, Error<ClusterCephGetAllFlagsError>> {
170
171 let uri_str = format!("{}/cluster/ceph/flags", configuration.base_path);
172 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
173
174 if let Some(ref user_agent) = configuration.user_agent {
175 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
176 }
177 if let Some(ref apikey) = configuration.api_key {
178 let key = apikey.key.clone();
179 let value = match apikey.prefix {
180 Some(ref prefix) => format!("{} {}", prefix, key),
181 None => key,
182 };
183 req_builder = req_builder.header("Authorization", value);
184 };
185 if let Some(ref apikey) = configuration.api_key {
186 let key = apikey.key.clone();
187 let value = match apikey.prefix {
188 Some(ref prefix) => format!("{} {}", prefix, key),
189 None => key,
190 };
191 req_builder = req_builder.header("CSRFPreventionToken", value);
192 };
193
194 let req = req_builder.build()?;
195 let resp = configuration.client.execute(req).await?;
196
197 let status = resp.status();
198 let content_type = resp
199 .headers()
200 .get("content-type")
201 .and_then(|v| v.to_str().ok())
202 .unwrap_or("application/octet-stream");
203 let content_type = super::ContentType::from(content_type);
204
205 if !status.is_client_error() && !status.is_server_error() {
206 let content = resp.text().await?;
207 match content_type {
208 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
209 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephGetAllFlagsResponse`"))),
210 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::ClusterCephGetAllFlagsResponse`")))),
211 }
212 } else {
213 let content = resp.text().await?;
214 let entity: Option<ClusterCephGetAllFlagsError> = serde_json::from_str(&content).ok();
215 Err(Error::ResponseError(ResponseContent { status, content, entity }))
216 }
217}
218
219pub async fn cluster_ceph_get_flag(configuration: &configuration::Configuration, flag: models::PveFlagEnum) -> Result<models::ClusterCephGetFlagResponse, Error<ClusterCephGetFlagError>> {
221 let p_path_flag = flag;
223
224 let uri_str = format!("{}/cluster/ceph/flags/{flag}", configuration.base_path, flag=p_path_flag.to_string());
225 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
226
227 if let Some(ref user_agent) = configuration.user_agent {
228 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
229 }
230 if let Some(ref apikey) = configuration.api_key {
231 let key = apikey.key.clone();
232 let value = match apikey.prefix {
233 Some(ref prefix) => format!("{} {}", prefix, key),
234 None => key,
235 };
236 req_builder = req_builder.header("Authorization", value);
237 };
238 if let Some(ref apikey) = configuration.api_key {
239 let key = apikey.key.clone();
240 let value = match apikey.prefix {
241 Some(ref prefix) => format!("{} {}", prefix, key),
242 None => key,
243 };
244 req_builder = req_builder.header("CSRFPreventionToken", value);
245 };
246
247 let req = req_builder.build()?;
248 let resp = configuration.client.execute(req).await?;
249
250 let status = resp.status();
251 let content_type = resp
252 .headers()
253 .get("content-type")
254 .and_then(|v| v.to_str().ok())
255 .unwrap_or("application/octet-stream");
256 let content_type = super::ContentType::from(content_type);
257
258 if !status.is_client_error() && !status.is_server_error() {
259 let content = resp.text().await?;
260 match content_type {
261 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
262 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephGetFlagResponse`"))),
263 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::ClusterCephGetFlagResponse`")))),
264 }
265 } else {
266 let content = resp.text().await?;
267 let entity: Option<ClusterCephGetFlagError> = serde_json::from_str(&content).ok();
268 Err(Error::ResponseError(ResponseContent { status, content, entity }))
269 }
270}
271
272pub async fn cluster_ceph_metadata(configuration: &configuration::Configuration, scope: Option<models::PveClusterCephScopeEnum>) -> Result<models::ClusterCephMetadataResponse, Error<ClusterCephMetadataError>> {
274 let p_query_scope = scope;
276
277 let uri_str = format!("{}/cluster/ceph/metadata", configuration.base_path);
278 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
279
280 if let Some(ref param_value) = p_query_scope {
281 req_builder = req_builder.query(&[("scope", ¶m_value.to_string())]);
282 }
283 if let Some(ref user_agent) = configuration.user_agent {
284 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
285 }
286 if let Some(ref apikey) = configuration.api_key {
287 let key = apikey.key.clone();
288 let value = match apikey.prefix {
289 Some(ref prefix) => format!("{} {}", prefix, key),
290 None => key,
291 };
292 req_builder = req_builder.header("Authorization", value);
293 };
294 if let Some(ref apikey) = configuration.api_key {
295 let key = apikey.key.clone();
296 let value = match apikey.prefix {
297 Some(ref prefix) => format!("{} {}", prefix, key),
298 None => key,
299 };
300 req_builder = req_builder.header("CSRFPreventionToken", value);
301 };
302
303 let req = req_builder.build()?;
304 let resp = configuration.client.execute(req).await?;
305
306 let status = resp.status();
307 let content_type = resp
308 .headers()
309 .get("content-type")
310 .and_then(|v| v.to_str().ok())
311 .unwrap_or("application/octet-stream");
312 let content_type = super::ContentType::from(content_type);
313
314 if !status.is_client_error() && !status.is_server_error() {
315 let content = resp.text().await?;
316 match content_type {
317 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
318 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephMetadataResponse`"))),
319 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::ClusterCephMetadataResponse`")))),
320 }
321 } else {
322 let content = resp.text().await?;
323 let entity: Option<ClusterCephMetadataError> = serde_json::from_str(&content).ok();
324 Err(Error::ResponseError(ResponseContent { status, content, entity }))
325 }
326}
327
328pub async fn cluster_ceph_set_flags(configuration: &configuration::Configuration, cluster_ceph_set_flags_request: Option<models::ClusterCephSetFlagsRequest>) -> Result<models::ClusterCephSetFlagsResponse, Error<ClusterCephSetFlagsError>> {
330 let p_body_cluster_ceph_set_flags_request = cluster_ceph_set_flags_request;
332
333 let uri_str = format!("{}/cluster/ceph/flags", configuration.base_path);
334 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
335
336 if let Some(ref user_agent) = configuration.user_agent {
337 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338 }
339 if let Some(ref apikey) = configuration.api_key {
340 let key = apikey.key.clone();
341 let value = match apikey.prefix {
342 Some(ref prefix) => format!("{} {}", prefix, key),
343 None => key,
344 };
345 req_builder = req_builder.header("Authorization", value);
346 };
347 if let Some(ref apikey) = configuration.api_key {
348 let key = apikey.key.clone();
349 let value = match apikey.prefix {
350 Some(ref prefix) => format!("{} {}", prefix, key),
351 None => key,
352 };
353 req_builder = req_builder.header("CSRFPreventionToken", value);
354 };
355 req_builder = req_builder.json(&p_body_cluster_ceph_set_flags_request);
356
357 let req = req_builder.build()?;
358 let resp = configuration.client.execute(req).await?;
359
360 let status = resp.status();
361 let content_type = resp
362 .headers()
363 .get("content-type")
364 .and_then(|v| v.to_str().ok())
365 .unwrap_or("application/octet-stream");
366 let content_type = super::ContentType::from(content_type);
367
368 if !status.is_client_error() && !status.is_server_error() {
369 let content = resp.text().await?;
370 match content_type {
371 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
372 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephSetFlagsResponse`"))),
373 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::ClusterCephSetFlagsResponse`")))),
374 }
375 } else {
376 let content = resp.text().await?;
377 let entity: Option<ClusterCephSetFlagsError> = serde_json::from_str(&content).ok();
378 Err(Error::ResponseError(ResponseContent { status, content, entity }))
379 }
380}
381
382pub async fn cluster_ceph_status(configuration: &configuration::Configuration, ) -> Result<models::ClusterCephStatusResponse, Error<ClusterCephStatusError>> {
384
385 let uri_str = format!("{}/cluster/ceph/status", configuration.base_path);
386 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
387
388 if let Some(ref user_agent) = configuration.user_agent {
389 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
390 }
391 if let Some(ref apikey) = configuration.api_key {
392 let key = apikey.key.clone();
393 let value = match apikey.prefix {
394 Some(ref prefix) => format!("{} {}", prefix, key),
395 None => key,
396 };
397 req_builder = req_builder.header("Authorization", value);
398 };
399 if let Some(ref apikey) = configuration.api_key {
400 let key = apikey.key.clone();
401 let value = match apikey.prefix {
402 Some(ref prefix) => format!("{} {}", prefix, key),
403 None => key,
404 };
405 req_builder = req_builder.header("CSRFPreventionToken", value);
406 };
407
408 let req = req_builder.build()?;
409 let resp = configuration.client.execute(req).await?;
410
411 let status = resp.status();
412 let content_type = resp
413 .headers()
414 .get("content-type")
415 .and_then(|v| v.to_str().ok())
416 .unwrap_or("application/octet-stream");
417 let content_type = super::ContentType::from(content_type);
418
419 if !status.is_client_error() && !status.is_server_error() {
420 let content = resp.text().await?;
421 match content_type {
422 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
423 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephStatusResponse`"))),
424 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::ClusterCephStatusResponse`")))),
425 }
426 } else {
427 let content = resp.text().await?;
428 let entity: Option<ClusterCephStatusError> = serde_json::from_str(&content).ok();
429 Err(Error::ResponseError(ResponseContent { status, content, entity }))
430 }
431}
432
433pub async fn cluster_ceph_update_flag(configuration: &configuration::Configuration, flag: models::PveFlagEnum, cluster_ceph_update_flag_request: models::ClusterCephUpdateFlagRequest) -> Result<models::ClusterCephUpdateFlagResponse, Error<ClusterCephUpdateFlagError>> {
435 let p_path_flag = flag;
437 let p_body_cluster_ceph_update_flag_request = cluster_ceph_update_flag_request;
438
439 let uri_str = format!("{}/cluster/ceph/flags/{flag}", configuration.base_path, flag=p_path_flag.to_string());
440 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
441
442 if let Some(ref user_agent) = configuration.user_agent {
443 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
444 }
445 if let Some(ref apikey) = configuration.api_key {
446 let key = apikey.key.clone();
447 let value = match apikey.prefix {
448 Some(ref prefix) => format!("{} {}", prefix, key),
449 None => key,
450 };
451 req_builder = req_builder.header("Authorization", value);
452 };
453 if let Some(ref apikey) = configuration.api_key {
454 let key = apikey.key.clone();
455 let value = match apikey.prefix {
456 Some(ref prefix) => format!("{} {}", prefix, key),
457 None => key,
458 };
459 req_builder = req_builder.header("CSRFPreventionToken", value);
460 };
461 req_builder = req_builder.json(&p_body_cluster_ceph_update_flag_request);
462
463 let req = req_builder.build()?;
464 let resp = configuration.client.execute(req).await?;
465
466 let status = resp.status();
467 let content_type = resp
468 .headers()
469 .get("content-type")
470 .and_then(|v| v.to_str().ok())
471 .unwrap_or("application/octet-stream");
472 let content_type = super::ContentType::from(content_type);
473
474 if !status.is_client_error() && !status.is_server_error() {
475 let content = resp.text().await?;
476 match content_type {
477 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
478 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterCephUpdateFlagResponse`"))),
479 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::ClusterCephUpdateFlagResponse`")))),
480 }
481 } else {
482 let content = resp.text().await?;
483 let entity: Option<ClusterCephUpdateFlagError> = serde_json::from_str(&content).ok();
484 Err(Error::ResponseError(ResponseContent { status, content, entity }))
485 }
486}
487