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 ClusterJobsCreateJobError {
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 ClusterJobsDeleteJobError {
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 ClusterJobsGetJobsError {
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 ClusterJobsReadJobError {
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 ClusterJobsScheduleAnalyzeError {
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 ClusterJobsSyncjobIndexError {
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 ClusterJobsUpdateJobError {
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_jobs_create_job(configuration: &configuration::Configuration, id: &str, cluster_jobs_create_job_request: models::ClusterJobsCreateJobRequest) -> Result<models::ClusterJobsCreateJobResponse, Error<ClusterJobsCreateJobError>> {
119 let p_path_id = id;
121 let p_body_cluster_jobs_create_job_request = cluster_jobs_create_job_request;
122
123 let uri_str = format!("{}/cluster/jobs/realm-sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
124 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
125
126 if let Some(ref user_agent) = configuration.user_agent {
127 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128 }
129 if let Some(ref apikey) = configuration.api_key {
130 let key = apikey.key.clone();
131 let value = match apikey.prefix {
132 Some(ref prefix) => format!("{} {}", prefix, key),
133 None => key,
134 };
135 req_builder = req_builder.header("Authorization", value);
136 };
137 if let Some(ref apikey) = configuration.api_key {
138 let key = apikey.key.clone();
139 let value = match apikey.prefix {
140 Some(ref prefix) => format!("{} {}", prefix, key),
141 None => key,
142 };
143 req_builder = req_builder.header("CSRFPreventionToken", value);
144 };
145 req_builder = req_builder.json(&p_body_cluster_jobs_create_job_request);
146
147 let req = req_builder.build()?;
148 let resp = configuration.client.execute(req).await?;
149
150 let status = resp.status();
151 let content_type = resp
152 .headers()
153 .get("content-type")
154 .and_then(|v| v.to_str().ok())
155 .unwrap_or("application/octet-stream");
156 let content_type = super::ContentType::from(content_type);
157
158 if !status.is_client_error() && !status.is_server_error() {
159 let content = resp.text().await?;
160 match content_type {
161 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsCreateJobResponse`"))),
163 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::ClusterJobsCreateJobResponse`")))),
164 }
165 } else {
166 let content = resp.text().await?;
167 let entity: Option<ClusterJobsCreateJobError> = serde_json::from_str(&content).ok();
168 Err(Error::ResponseError(ResponseContent { status, content, entity }))
169 }
170}
171
172pub async fn cluster_jobs_delete_job(configuration: &configuration::Configuration, id: &str) -> Result<models::ClusterJobsDeleteJobResponse, Error<ClusterJobsDeleteJobError>> {
174 let p_path_id = id;
176
177 let uri_str = format!("{}/cluster/jobs/realm-sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
178 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
179
180 if let Some(ref user_agent) = configuration.user_agent {
181 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
182 }
183 if let Some(ref apikey) = configuration.api_key {
184 let key = apikey.key.clone();
185 let value = match apikey.prefix {
186 Some(ref prefix) => format!("{} {}", prefix, key),
187 None => key,
188 };
189 req_builder = req_builder.header("Authorization", value);
190 };
191 if let Some(ref apikey) = configuration.api_key {
192 let key = apikey.key.clone();
193 let value = match apikey.prefix {
194 Some(ref prefix) => format!("{} {}", prefix, key),
195 None => key,
196 };
197 req_builder = req_builder.header("CSRFPreventionToken", value);
198 };
199
200 let req = req_builder.build()?;
201 let resp = configuration.client.execute(req).await?;
202
203 let status = resp.status();
204 let content_type = resp
205 .headers()
206 .get("content-type")
207 .and_then(|v| v.to_str().ok())
208 .unwrap_or("application/octet-stream");
209 let content_type = super::ContentType::from(content_type);
210
211 if !status.is_client_error() && !status.is_server_error() {
212 let content = resp.text().await?;
213 match content_type {
214 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
215 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsDeleteJobResponse`"))),
216 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::ClusterJobsDeleteJobResponse`")))),
217 }
218 } else {
219 let content = resp.text().await?;
220 let entity: Option<ClusterJobsDeleteJobError> = serde_json::from_str(&content).ok();
221 Err(Error::ResponseError(ResponseContent { status, content, entity }))
222 }
223}
224
225pub async fn cluster_jobs_get_jobs(configuration: &configuration::Configuration, ) -> Result<models::ClusterJobsGetJobsResponse, Error<ClusterJobsGetJobsError>> {
227
228 let uri_str = format!("{}/cluster/jobs", configuration.base_path);
229 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
230
231 if let Some(ref user_agent) = configuration.user_agent {
232 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
233 }
234 if let Some(ref apikey) = configuration.api_key {
235 let key = apikey.key.clone();
236 let value = match apikey.prefix {
237 Some(ref prefix) => format!("{} {}", prefix, key),
238 None => key,
239 };
240 req_builder = req_builder.header("Authorization", value);
241 };
242 if let Some(ref apikey) = configuration.api_key {
243 let key = apikey.key.clone();
244 let value = match apikey.prefix {
245 Some(ref prefix) => format!("{} {}", prefix, key),
246 None => key,
247 };
248 req_builder = req_builder.header("CSRFPreventionToken", value);
249 };
250
251 let req = req_builder.build()?;
252 let resp = configuration.client.execute(req).await?;
253
254 let status = resp.status();
255 let content_type = resp
256 .headers()
257 .get("content-type")
258 .and_then(|v| v.to_str().ok())
259 .unwrap_or("application/octet-stream");
260 let content_type = super::ContentType::from(content_type);
261
262 if !status.is_client_error() && !status.is_server_error() {
263 let content = resp.text().await?;
264 match content_type {
265 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
266 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsGetJobsResponse`"))),
267 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::ClusterJobsGetJobsResponse`")))),
268 }
269 } else {
270 let content = resp.text().await?;
271 let entity: Option<ClusterJobsGetJobsError> = serde_json::from_str(&content).ok();
272 Err(Error::ResponseError(ResponseContent { status, content, entity }))
273 }
274}
275
276pub async fn cluster_jobs_read_job(configuration: &configuration::Configuration, id: &str) -> Result<models::ClusterJobsReadJobResponse, Error<ClusterJobsReadJobError>> {
278 let p_path_id = id;
280
281 let uri_str = format!("{}/cluster/jobs/realm-sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
282 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
283
284 if let Some(ref user_agent) = configuration.user_agent {
285 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
286 }
287 if let Some(ref apikey) = configuration.api_key {
288 let key = apikey.key.clone();
289 let value = match apikey.prefix {
290 Some(ref prefix) => format!("{} {}", prefix, key),
291 None => key,
292 };
293 req_builder = req_builder.header("Authorization", value);
294 };
295 if let Some(ref apikey) = configuration.api_key {
296 let key = apikey.key.clone();
297 let value = match apikey.prefix {
298 Some(ref prefix) => format!("{} {}", prefix, key),
299 None => key,
300 };
301 req_builder = req_builder.header("CSRFPreventionToken", value);
302 };
303
304 let req = req_builder.build()?;
305 let resp = configuration.client.execute(req).await?;
306
307 let status = resp.status();
308 let content_type = resp
309 .headers()
310 .get("content-type")
311 .and_then(|v| v.to_str().ok())
312 .unwrap_or("application/octet-stream");
313 let content_type = super::ContentType::from(content_type);
314
315 if !status.is_client_error() && !status.is_server_error() {
316 let content = resp.text().await?;
317 match content_type {
318 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
319 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsReadJobResponse`"))),
320 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::ClusterJobsReadJobResponse`")))),
321 }
322 } else {
323 let content = resp.text().await?;
324 let entity: Option<ClusterJobsReadJobError> = serde_json::from_str(&content).ok();
325 Err(Error::ResponseError(ResponseContent { status, content, entity }))
326 }
327}
328
329pub async fn cluster_jobs_schedule_analyze(configuration: &configuration::Configuration, schedule: &str, iterations: Option<i32>, starttime: Option<i64>) -> Result<models::ClusterJobsScheduleAnalyzeResponse, Error<ClusterJobsScheduleAnalyzeError>> {
331 let p_query_schedule = schedule;
333 let p_query_iterations = iterations;
334 let p_query_starttime = starttime;
335
336 let uri_str = format!("{}/cluster/jobs/schedule-analyze", configuration.base_path);
337 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
338
339 if let Some(ref param_value) = p_query_iterations {
340 req_builder = req_builder.query(&[("iterations", ¶m_value.to_string())]);
341 }
342 req_builder = req_builder.query(&[("schedule", &p_query_schedule.to_string())]);
343 if let Some(ref param_value) = p_query_starttime {
344 req_builder = req_builder.query(&[("starttime", ¶m_value.to_string())]);
345 }
346 if let Some(ref user_agent) = configuration.user_agent {
347 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
348 }
349 if let Some(ref apikey) = configuration.api_key {
350 let key = apikey.key.clone();
351 let value = match apikey.prefix {
352 Some(ref prefix) => format!("{} {}", prefix, key),
353 None => key,
354 };
355 req_builder = req_builder.header("Authorization", value);
356 };
357 if let Some(ref apikey) = configuration.api_key {
358 let key = apikey.key.clone();
359 let value = match apikey.prefix {
360 Some(ref prefix) => format!("{} {}", prefix, key),
361 None => key,
362 };
363 req_builder = req_builder.header("CSRFPreventionToken", value);
364 };
365
366 let req = req_builder.build()?;
367 let resp = configuration.client.execute(req).await?;
368
369 let status = resp.status();
370 let content_type = resp
371 .headers()
372 .get("content-type")
373 .and_then(|v| v.to_str().ok())
374 .unwrap_or("application/octet-stream");
375 let content_type = super::ContentType::from(content_type);
376
377 if !status.is_client_error() && !status.is_server_error() {
378 let content = resp.text().await?;
379 match content_type {
380 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
381 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsScheduleAnalyzeResponse`"))),
382 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::ClusterJobsScheduleAnalyzeResponse`")))),
383 }
384 } else {
385 let content = resp.text().await?;
386 let entity: Option<ClusterJobsScheduleAnalyzeError> = serde_json::from_str(&content).ok();
387 Err(Error::ResponseError(ResponseContent { status, content, entity }))
388 }
389}
390
391pub async fn cluster_jobs_syncjob_index(configuration: &configuration::Configuration, ) -> Result<models::ClusterJobsSyncjobIndexResponse, Error<ClusterJobsSyncjobIndexError>> {
393
394 let uri_str = format!("{}/cluster/jobs/realm-sync", configuration.base_path);
395 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
396
397 if let Some(ref user_agent) = configuration.user_agent {
398 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
399 }
400 if let Some(ref apikey) = configuration.api_key {
401 let key = apikey.key.clone();
402 let value = match apikey.prefix {
403 Some(ref prefix) => format!("{} {}", prefix, key),
404 None => key,
405 };
406 req_builder = req_builder.header("Authorization", value);
407 };
408 if let Some(ref apikey) = configuration.api_key {
409 let key = apikey.key.clone();
410 let value = match apikey.prefix {
411 Some(ref prefix) => format!("{} {}", prefix, key),
412 None => key,
413 };
414 req_builder = req_builder.header("CSRFPreventionToken", value);
415 };
416
417 let req = req_builder.build()?;
418 let resp = configuration.client.execute(req).await?;
419
420 let status = resp.status();
421 let content_type = resp
422 .headers()
423 .get("content-type")
424 .and_then(|v| v.to_str().ok())
425 .unwrap_or("application/octet-stream");
426 let content_type = super::ContentType::from(content_type);
427
428 if !status.is_client_error() && !status.is_server_error() {
429 let content = resp.text().await?;
430 match content_type {
431 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
432 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsSyncjobIndexResponse`"))),
433 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::ClusterJobsSyncjobIndexResponse`")))),
434 }
435 } else {
436 let content = resp.text().await?;
437 let entity: Option<ClusterJobsSyncjobIndexError> = serde_json::from_str(&content).ok();
438 Err(Error::ResponseError(ResponseContent { status, content, entity }))
439 }
440}
441
442pub async fn cluster_jobs_update_job(configuration: &configuration::Configuration, id: &str, cluster_jobs_update_job_request: models::ClusterJobsUpdateJobRequest) -> Result<models::ClusterJobsUpdateJobResponse, Error<ClusterJobsUpdateJobError>> {
444 let p_path_id = id;
446 let p_body_cluster_jobs_update_job_request = cluster_jobs_update_job_request;
447
448 let uri_str = format!("{}/cluster/jobs/realm-sync/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
449 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
450
451 if let Some(ref user_agent) = configuration.user_agent {
452 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
453 }
454 if let Some(ref apikey) = configuration.api_key {
455 let key = apikey.key.clone();
456 let value = match apikey.prefix {
457 Some(ref prefix) => format!("{} {}", prefix, key),
458 None => key,
459 };
460 req_builder = req_builder.header("Authorization", value);
461 };
462 if let Some(ref apikey) = configuration.api_key {
463 let key = apikey.key.clone();
464 let value = match apikey.prefix {
465 Some(ref prefix) => format!("{} {}", prefix, key),
466 None => key,
467 };
468 req_builder = req_builder.header("CSRFPreventionToken", value);
469 };
470 req_builder = req_builder.json(&p_body_cluster_jobs_update_job_request);
471
472 let req = req_builder.build()?;
473 let resp = configuration.client.execute(req).await?;
474
475 let status = resp.status();
476 let content_type = resp
477 .headers()
478 .get("content-type")
479 .and_then(|v| v.to_str().ok())
480 .unwrap_or("application/octet-stream");
481 let content_type = super::ContentType::from(content_type);
482
483 if !status.is_client_error() && !status.is_server_error() {
484 let content = resp.text().await?;
485 match content_type {
486 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
487 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClusterJobsUpdateJobResponse`"))),
488 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::ClusterJobsUpdateJobResponse`")))),
489 }
490 } else {
491 let content = resp.text().await?;
492 let entity: Option<ClusterJobsUpdateJobError> = serde_json::from_str(&content).ok();
493 Err(Error::ResponseError(ResponseContent { status, content, entity }))
494 }
495}
496