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 NodesServicesGetServicesError {
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 NodesServicesServiceReloadError {
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 NodesServicesServiceRestartError {
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 NodesServicesServiceStartError {
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 NodesServicesServiceStateError {
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 NodesServicesServiceStopError {
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 NodesServicesSrvcmdidxError {
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 nodes_services_get_services(configuration: &configuration::Configuration, node: &str) -> Result<models::NodesServicesGetServicesResponse, Error<NodesServicesGetServicesError>> {
119 let p_path_node = node;
121
122 let uri_str = format!("{}/nodes/{node}/services", configuration.base_path, node=crate::apis::urlencode(p_path_node));
123 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
124
125 if let Some(ref user_agent) = configuration.user_agent {
126 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
127 }
128 if let Some(ref apikey) = configuration.api_key {
129 let key = apikey.key.clone();
130 let value = match apikey.prefix {
131 Some(ref prefix) => format!("{} {}", prefix, key),
132 None => key,
133 };
134 req_builder = req_builder.header("Authorization", value);
135 };
136 if let Some(ref apikey) = configuration.api_key {
137 let key = apikey.key.clone();
138 let value = match apikey.prefix {
139 Some(ref prefix) => format!("{} {}", prefix, key),
140 None => key,
141 };
142 req_builder = req_builder.header("CSRFPreventionToken", value);
143 };
144
145 let req = req_builder.build()?;
146 let resp = configuration.client.execute(req).await?;
147
148 let status = resp.status();
149 let content_type = resp
150 .headers()
151 .get("content-type")
152 .and_then(|v| v.to_str().ok())
153 .unwrap_or("application/octet-stream");
154 let content_type = super::ContentType::from(content_type);
155
156 if !status.is_client_error() && !status.is_server_error() {
157 let content = resp.text().await?;
158 match content_type {
159 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
160 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesServicesGetServicesResponse`"))),
161 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::NodesServicesGetServicesResponse`")))),
162 }
163 } else {
164 let content = resp.text().await?;
165 let entity: Option<NodesServicesGetServicesError> = serde_json::from_str(&content).ok();
166 Err(Error::ResponseError(ResponseContent { status, content, entity }))
167 }
168}
169
170pub async fn nodes_services_service_reload(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesServiceReloadResponse, Error<NodesServicesServiceReloadError>> {
172 let p_path_node = node;
174 let p_path_service = service;
175
176 let uri_str = format!("{}/nodes/{node}/services/{service}/reload", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
177 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
178
179 if let Some(ref user_agent) = configuration.user_agent {
180 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
181 }
182 if let Some(ref apikey) = configuration.api_key {
183 let key = apikey.key.clone();
184 let value = match apikey.prefix {
185 Some(ref prefix) => format!("{} {}", prefix, key),
186 None => key,
187 };
188 req_builder = req_builder.header("Authorization", value);
189 };
190 if let Some(ref apikey) = configuration.api_key {
191 let key = apikey.key.clone();
192 let value = match apikey.prefix {
193 Some(ref prefix) => format!("{} {}", prefix, key),
194 None => key,
195 };
196 req_builder = req_builder.header("CSRFPreventionToken", value);
197 };
198
199 let req = req_builder.build()?;
200 let resp = configuration.client.execute(req).await?;
201
202 let status = resp.status();
203 let content_type = resp
204 .headers()
205 .get("content-type")
206 .and_then(|v| v.to_str().ok())
207 .unwrap_or("application/octet-stream");
208 let content_type = super::ContentType::from(content_type);
209
210 if !status.is_client_error() && !status.is_server_error() {
211 let content = resp.text().await?;
212 match content_type {
213 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
214 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesServicesServiceReloadResponse`"))),
215 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::NodesServicesServiceReloadResponse`")))),
216 }
217 } else {
218 let content = resp.text().await?;
219 let entity: Option<NodesServicesServiceReloadError> = serde_json::from_str(&content).ok();
220 Err(Error::ResponseError(ResponseContent { status, content, entity }))
221 }
222}
223
224pub async fn nodes_services_service_restart(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesServiceRestartResponse, Error<NodesServicesServiceRestartError>> {
226 let p_path_node = node;
228 let p_path_service = service;
229
230 let uri_str = format!("{}/nodes/{node}/services/{service}/restart", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
231 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
232
233 if let Some(ref user_agent) = configuration.user_agent {
234 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
235 }
236 if let Some(ref apikey) = configuration.api_key {
237 let key = apikey.key.clone();
238 let value = match apikey.prefix {
239 Some(ref prefix) => format!("{} {}", prefix, key),
240 None => key,
241 };
242 req_builder = req_builder.header("Authorization", value);
243 };
244 if let Some(ref apikey) = configuration.api_key {
245 let key = apikey.key.clone();
246 let value = match apikey.prefix {
247 Some(ref prefix) => format!("{} {}", prefix, key),
248 None => key,
249 };
250 req_builder = req_builder.header("CSRFPreventionToken", value);
251 };
252
253 let req = req_builder.build()?;
254 let resp = configuration.client.execute(req).await?;
255
256 let status = resp.status();
257 let content_type = resp
258 .headers()
259 .get("content-type")
260 .and_then(|v| v.to_str().ok())
261 .unwrap_or("application/octet-stream");
262 let content_type = super::ContentType::from(content_type);
263
264 if !status.is_client_error() && !status.is_server_error() {
265 let content = resp.text().await?;
266 match content_type {
267 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
268 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesServicesServiceRestartResponse`"))),
269 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::NodesServicesServiceRestartResponse`")))),
270 }
271 } else {
272 let content = resp.text().await?;
273 let entity: Option<NodesServicesServiceRestartError> = serde_json::from_str(&content).ok();
274 Err(Error::ResponseError(ResponseContent { status, content, entity }))
275 }
276}
277
278pub async fn nodes_services_service_start(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesServiceStartResponse, Error<NodesServicesServiceStartError>> {
280 let p_path_node = node;
282 let p_path_service = service;
283
284 let uri_str = format!("{}/nodes/{node}/services/{service}/start", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
285 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
286
287 if let Some(ref user_agent) = configuration.user_agent {
288 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
289 }
290 if let Some(ref apikey) = configuration.api_key {
291 let key = apikey.key.clone();
292 let value = match apikey.prefix {
293 Some(ref prefix) => format!("{} {}", prefix, key),
294 None => key,
295 };
296 req_builder = req_builder.header("Authorization", value);
297 };
298 if let Some(ref apikey) = configuration.api_key {
299 let key = apikey.key.clone();
300 let value = match apikey.prefix {
301 Some(ref prefix) => format!("{} {}", prefix, key),
302 None => key,
303 };
304 req_builder = req_builder.header("CSRFPreventionToken", value);
305 };
306
307 let req = req_builder.build()?;
308 let resp = configuration.client.execute(req).await?;
309
310 let status = resp.status();
311 let content_type = resp
312 .headers()
313 .get("content-type")
314 .and_then(|v| v.to_str().ok())
315 .unwrap_or("application/octet-stream");
316 let content_type = super::ContentType::from(content_type);
317
318 if !status.is_client_error() && !status.is_server_error() {
319 let content = resp.text().await?;
320 match content_type {
321 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
322 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesServicesServiceStartResponse`"))),
323 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::NodesServicesServiceStartResponse`")))),
324 }
325 } else {
326 let content = resp.text().await?;
327 let entity: Option<NodesServicesServiceStartError> = serde_json::from_str(&content).ok();
328 Err(Error::ResponseError(ResponseContent { status, content, entity }))
329 }
330}
331
332pub async fn nodes_services_service_state(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesServiceStateResponse, Error<NodesServicesServiceStateError>> {
334 let p_path_node = node;
336 let p_path_service = service;
337
338 let uri_str = format!("{}/nodes/{node}/services/{service}/state", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
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::NodesServicesServiceStateResponse`"))),
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::NodesServicesServiceStateResponse`")))),
378 }
379 } else {
380 let content = resp.text().await?;
381 let entity: Option<NodesServicesServiceStateError> = serde_json::from_str(&content).ok();
382 Err(Error::ResponseError(ResponseContent { status, content, entity }))
383 }
384}
385
386pub async fn nodes_services_service_stop(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesServiceStopResponse, Error<NodesServicesServiceStopError>> {
388 let p_path_node = node;
390 let p_path_service = service;
391
392 let uri_str = format!("{}/nodes/{node}/services/{service}/stop", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
393 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
394
395 if let Some(ref user_agent) = configuration.user_agent {
396 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
397 }
398 if let Some(ref apikey) = configuration.api_key {
399 let key = apikey.key.clone();
400 let value = match apikey.prefix {
401 Some(ref prefix) => format!("{} {}", prefix, key),
402 None => key,
403 };
404 req_builder = req_builder.header("Authorization", value);
405 };
406 if let Some(ref apikey) = configuration.api_key {
407 let key = apikey.key.clone();
408 let value = match apikey.prefix {
409 Some(ref prefix) => format!("{} {}", prefix, key),
410 None => key,
411 };
412 req_builder = req_builder.header("CSRFPreventionToken", value);
413 };
414
415 let req = req_builder.build()?;
416 let resp = configuration.client.execute(req).await?;
417
418 let status = resp.status();
419 let content_type = resp
420 .headers()
421 .get("content-type")
422 .and_then(|v| v.to_str().ok())
423 .unwrap_or("application/octet-stream");
424 let content_type = super::ContentType::from(content_type);
425
426 if !status.is_client_error() && !status.is_server_error() {
427 let content = resp.text().await?;
428 match content_type {
429 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
430 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::NodesServicesServiceStopResponse`"))),
431 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::NodesServicesServiceStopResponse`")))),
432 }
433 } else {
434 let content = resp.text().await?;
435 let entity: Option<NodesServicesServiceStopError> = serde_json::from_str(&content).ok();
436 Err(Error::ResponseError(ResponseContent { status, content, entity }))
437 }
438}
439
440pub async fn nodes_services_srvcmdidx(configuration: &configuration::Configuration, node: &str, service: models::PveServiceEnum) -> Result<models::NodesServicesSrvcmdidxResponse, Error<NodesServicesSrvcmdidxError>> {
442 let p_path_node = node;
444 let p_path_service = service;
445
446 let uri_str = format!("{}/nodes/{node}/services/{service}", configuration.base_path, node=crate::apis::urlencode(p_path_node), service=p_path_service.to_string());
447 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
448
449 if let Some(ref user_agent) = configuration.user_agent {
450 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
451 }
452 if let Some(ref apikey) = configuration.api_key {
453 let key = apikey.key.clone();
454 let value = match apikey.prefix {
455 Some(ref prefix) => format!("{} {}", prefix, key),
456 None => key,
457 };
458 req_builder = req_builder.header("Authorization", value);
459 };
460 if let Some(ref apikey) = configuration.api_key {
461 let key = apikey.key.clone();
462 let value = match apikey.prefix {
463 Some(ref prefix) => format!("{} {}", prefix, key),
464 None => key,
465 };
466 req_builder = req_builder.header("CSRFPreventionToken", value);
467 };
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::NodesServicesSrvcmdidxResponse`"))),
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::NodesServicesSrvcmdidxResponse`")))),
486 }
487 } else {
488 let content = resp.text().await?;
489 let entity: Option<NodesServicesSrvcmdidxError> = serde_json::from_str(&content).ok();
490 Err(Error::ResponseError(ResponseContent { status, content, entity }))
491 }
492}
493