1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AdminAppsListError {
20 Status400(models::ValidationError),
21 Status403(models::GenericError),
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum AdminModelsListError {
29 Status400(models::ValidationError),
30 Status403(models::GenericError),
31 UnknownValue(serde_json::Value),
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum AdminSettingsPartialUpdateError {
38 Status400(models::ValidationError),
39 Status403(models::GenericError),
40 UnknownValue(serde_json::Value),
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum AdminSettingsRetrieveError {
47 Status400(models::ValidationError),
48 Status403(models::GenericError),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum AdminSettingsUpdateError {
56 Status400(models::ValidationError),
57 Status403(models::GenericError),
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum AdminSystemCreateError {
65 Status400(models::ValidationError),
66 Status403(models::GenericError),
67 UnknownValue(serde_json::Value),
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum AdminSystemRetrieveError {
74 Status400(models::ValidationError),
75 Status403(models::GenericError),
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum AdminVersionHistoryListError {
83 Status400(models::ValidationError),
84 Status403(models::GenericError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum AdminVersionHistoryRetrieveError {
92 Status400(models::ValidationError),
93 Status403(models::GenericError),
94 UnknownValue(serde_json::Value),
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
99#[serde(untagged)]
100pub enum AdminVersionRetrieveError {
101 Status400(models::ValidationError),
102 Status403(models::GenericError),
103 UnknownValue(serde_json::Value),
104}
105
106pub async fn admin_apps_list(
108 configuration: &configuration::Configuration,
109) -> Result<Vec<models::App>, Error<AdminAppsListError>> {
110 let uri_str = format!("{}/admin/apps/", configuration.base_path);
111 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
112
113 if let Some(ref user_agent) = configuration.user_agent {
114 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
115 }
116 if let Some(ref token) = configuration.bearer_access_token {
117 req_builder = req_builder.bearer_auth(token.to_owned());
118 };
119
120 let req = req_builder.build()?;
121 let resp = configuration.client.execute(req).await?;
122
123 let status = resp.status();
124 let content_type = resp
125 .headers()
126 .get("content-type")
127 .and_then(|v| v.to_str().ok())
128 .unwrap_or("application/octet-stream");
129 let content_type = super::ContentType::from(content_type);
130
131 if !status.is_client_error() && !status.is_server_error() {
132 let content = resp.text().await?;
133 match content_type {
134 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
135 ContentType::Text => {
136 return Err(Error::from(serde_json::Error::custom(
137 "Received `text/plain` content type response that cannot be converted to `Vec<models::App>`",
138 )))
139 }
140 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
141 "Received `{unknown_type}` content type response that cannot be converted to `Vec<models::App>`"
142 )))),
143 }
144 } else {
145 let content = resp.text().await?;
146 let entity: Option<AdminAppsListError> = serde_json::from_str(&content).ok();
147 Err(Error::ResponseError(ResponseContent {
148 status,
149 content,
150 entity,
151 }))
152 }
153}
154
155pub async fn admin_models_list(
157 configuration: &configuration::Configuration,
158) -> Result<Vec<models::App>, Error<AdminModelsListError>> {
159 let uri_str = format!("{}/admin/models/", configuration.base_path);
160 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
161
162 if let Some(ref user_agent) = configuration.user_agent {
163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164 }
165 if let Some(ref token) = configuration.bearer_access_token {
166 req_builder = req_builder.bearer_auth(token.to_owned());
167 };
168
169 let req = req_builder.build()?;
170 let resp = configuration.client.execute(req).await?;
171
172 let status = resp.status();
173 let content_type = resp
174 .headers()
175 .get("content-type")
176 .and_then(|v| v.to_str().ok())
177 .unwrap_or("application/octet-stream");
178 let content_type = super::ContentType::from(content_type);
179
180 if !status.is_client_error() && !status.is_server_error() {
181 let content = resp.text().await?;
182 match content_type {
183 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
184 ContentType::Text => {
185 return Err(Error::from(serde_json::Error::custom(
186 "Received `text/plain` content type response that cannot be converted to `Vec<models::App>`",
187 )))
188 }
189 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
190 "Received `{unknown_type}` content type response that cannot be converted to `Vec<models::App>`"
191 )))),
192 }
193 } else {
194 let content = resp.text().await?;
195 let entity: Option<AdminModelsListError> = serde_json::from_str(&content).ok();
196 Err(Error::ResponseError(ResponseContent {
197 status,
198 content,
199 entity,
200 }))
201 }
202}
203
204pub async fn admin_settings_partial_update(
206 configuration: &configuration::Configuration,
207 patched_settings_request: Option<models::PatchedSettingsRequest>,
208) -> Result<models::Settings, Error<AdminSettingsPartialUpdateError>> {
209 let p_body_patched_settings_request = patched_settings_request;
211
212 let uri_str = format!("{}/admin/settings/", configuration.base_path);
213 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
214
215 if let Some(ref user_agent) = configuration.user_agent {
216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217 }
218 if let Some(ref token) = configuration.bearer_access_token {
219 req_builder = req_builder.bearer_auth(token.to_owned());
220 };
221 req_builder = req_builder.json(&p_body_patched_settings_request);
222
223 let req = req_builder.build()?;
224 let resp = configuration.client.execute(req).await?;
225
226 let status = resp.status();
227 let content_type = resp
228 .headers()
229 .get("content-type")
230 .and_then(|v| v.to_str().ok())
231 .unwrap_or("application/octet-stream");
232 let content_type = super::ContentType::from(content_type);
233
234 if !status.is_client_error() && !status.is_server_error() {
235 let content = resp.text().await?;
236 match content_type {
237 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238 ContentType::Text => {
239 return Err(Error::from(serde_json::Error::custom(
240 "Received `text/plain` content type response that cannot be converted to `models::Settings`",
241 )))
242 }
243 ContentType::Unsupported(unknown_type) => {
244 return Err(Error::from(serde_json::Error::custom(format!(
245 "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
246 ))))
247 }
248 }
249 } else {
250 let content = resp.text().await?;
251 let entity: Option<AdminSettingsPartialUpdateError> = serde_json::from_str(&content).ok();
252 Err(Error::ResponseError(ResponseContent {
253 status,
254 content,
255 entity,
256 }))
257 }
258}
259
260pub async fn admin_settings_retrieve(
262 configuration: &configuration::Configuration,
263) -> Result<models::Settings, Error<AdminSettingsRetrieveError>> {
264 let uri_str = format!("{}/admin/settings/", configuration.base_path);
265 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
266
267 if let Some(ref user_agent) = configuration.user_agent {
268 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
269 }
270 if let Some(ref token) = configuration.bearer_access_token {
271 req_builder = req_builder.bearer_auth(token.to_owned());
272 };
273
274 let req = req_builder.build()?;
275 let resp = configuration.client.execute(req).await?;
276
277 let status = resp.status();
278 let content_type = resp
279 .headers()
280 .get("content-type")
281 .and_then(|v| v.to_str().ok())
282 .unwrap_or("application/octet-stream");
283 let content_type = super::ContentType::from(content_type);
284
285 if !status.is_client_error() && !status.is_server_error() {
286 let content = resp.text().await?;
287 match content_type {
288 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
289 ContentType::Text => {
290 return Err(Error::from(serde_json::Error::custom(
291 "Received `text/plain` content type response that cannot be converted to `models::Settings`",
292 )))
293 }
294 ContentType::Unsupported(unknown_type) => {
295 return Err(Error::from(serde_json::Error::custom(format!(
296 "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
297 ))))
298 }
299 }
300 } else {
301 let content = resp.text().await?;
302 let entity: Option<AdminSettingsRetrieveError> = serde_json::from_str(&content).ok();
303 Err(Error::ResponseError(ResponseContent {
304 status,
305 content,
306 entity,
307 }))
308 }
309}
310
311pub async fn admin_settings_update(
313 configuration: &configuration::Configuration,
314 settings_request: models::SettingsRequest,
315) -> Result<models::Settings, Error<AdminSettingsUpdateError>> {
316 let p_body_settings_request = settings_request;
318
319 let uri_str = format!("{}/admin/settings/", configuration.base_path);
320 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
321
322 if let Some(ref user_agent) = configuration.user_agent {
323 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
324 }
325 if let Some(ref token) = configuration.bearer_access_token {
326 req_builder = req_builder.bearer_auth(token.to_owned());
327 };
328 req_builder = req_builder.json(&p_body_settings_request);
329
330 let req = req_builder.build()?;
331 let resp = configuration.client.execute(req).await?;
332
333 let status = resp.status();
334 let content_type = resp
335 .headers()
336 .get("content-type")
337 .and_then(|v| v.to_str().ok())
338 .unwrap_or("application/octet-stream");
339 let content_type = super::ContentType::from(content_type);
340
341 if !status.is_client_error() && !status.is_server_error() {
342 let content = resp.text().await?;
343 match content_type {
344 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345 ContentType::Text => {
346 return Err(Error::from(serde_json::Error::custom(
347 "Received `text/plain` content type response that cannot be converted to `models::Settings`",
348 )))
349 }
350 ContentType::Unsupported(unknown_type) => {
351 return Err(Error::from(serde_json::Error::custom(format!(
352 "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
353 ))))
354 }
355 }
356 } else {
357 let content = resp.text().await?;
358 let entity: Option<AdminSettingsUpdateError> = serde_json::from_str(&content).ok();
359 Err(Error::ResponseError(ResponseContent {
360 status,
361 content,
362 entity,
363 }))
364 }
365}
366
367pub async fn admin_system_create(
369 configuration: &configuration::Configuration,
370) -> Result<models::SystemInfo, Error<AdminSystemCreateError>> {
371 let uri_str = format!("{}/admin/system/", configuration.base_path);
372 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
373
374 if let Some(ref user_agent) = configuration.user_agent {
375 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
376 }
377 if let Some(ref token) = configuration.bearer_access_token {
378 req_builder = req_builder.bearer_auth(token.to_owned());
379 };
380
381 let req = req_builder.build()?;
382 let resp = configuration.client.execute(req).await?;
383
384 let status = resp.status();
385 let content_type = resp
386 .headers()
387 .get("content-type")
388 .and_then(|v| v.to_str().ok())
389 .unwrap_or("application/octet-stream");
390 let content_type = super::ContentType::from(content_type);
391
392 if !status.is_client_error() && !status.is_server_error() {
393 let content = resp.text().await?;
394 match content_type {
395 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
396 ContentType::Text => {
397 return Err(Error::from(serde_json::Error::custom(
398 "Received `text/plain` content type response that cannot be converted to `models::SystemInfo`",
399 )))
400 }
401 ContentType::Unsupported(unknown_type) => {
402 return Err(Error::from(serde_json::Error::custom(format!(
403 "Received `{unknown_type}` content type response that cannot be converted to `models::SystemInfo`"
404 ))))
405 }
406 }
407 } else {
408 let content = resp.text().await?;
409 let entity: Option<AdminSystemCreateError> = serde_json::from_str(&content).ok();
410 Err(Error::ResponseError(ResponseContent {
411 status,
412 content,
413 entity,
414 }))
415 }
416}
417
418pub async fn admin_system_retrieve(
420 configuration: &configuration::Configuration,
421) -> Result<models::SystemInfo, Error<AdminSystemRetrieveError>> {
422 let uri_str = format!("{}/admin/system/", configuration.base_path);
423 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
424
425 if let Some(ref user_agent) = configuration.user_agent {
426 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
427 }
428 if let Some(ref token) = configuration.bearer_access_token {
429 req_builder = req_builder.bearer_auth(token.to_owned());
430 };
431
432 let req = req_builder.build()?;
433 let resp = configuration.client.execute(req).await?;
434
435 let status = resp.status();
436 let content_type = resp
437 .headers()
438 .get("content-type")
439 .and_then(|v| v.to_str().ok())
440 .unwrap_or("application/octet-stream");
441 let content_type = super::ContentType::from(content_type);
442
443 if !status.is_client_error() && !status.is_server_error() {
444 let content = resp.text().await?;
445 match content_type {
446 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
447 ContentType::Text => {
448 return Err(Error::from(serde_json::Error::custom(
449 "Received `text/plain` content type response that cannot be converted to `models::SystemInfo`",
450 )))
451 }
452 ContentType::Unsupported(unknown_type) => {
453 return Err(Error::from(serde_json::Error::custom(format!(
454 "Received `{unknown_type}` content type response that cannot be converted to `models::SystemInfo`"
455 ))))
456 }
457 }
458 } else {
459 let content = resp.text().await?;
460 let entity: Option<AdminSystemRetrieveError> = serde_json::from_str(&content).ok();
461 Err(Error::ResponseError(ResponseContent {
462 status,
463 content,
464 entity,
465 }))
466 }
467}
468
469pub async fn admin_version_history_list(
471 configuration: &configuration::Configuration,
472 build: Option<&str>,
473 ordering: Option<&str>,
474 search: Option<&str>,
475 version: Option<&str>,
476) -> Result<Vec<models::VersionHistory>, Error<AdminVersionHistoryListError>> {
477 let p_query_build = build;
479 let p_query_ordering = ordering;
480 let p_query_search = search;
481 let p_query_version = version;
482
483 let uri_str = format!("{}/admin/version/history/", configuration.base_path);
484 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
485
486 if let Some(ref param_value) = p_query_build {
487 req_builder = req_builder.query(&[("build", ¶m_value.to_string())]);
488 }
489 if let Some(ref param_value) = p_query_ordering {
490 req_builder = req_builder.query(&[("ordering", ¶m_value.to_string())]);
491 }
492 if let Some(ref param_value) = p_query_search {
493 req_builder = req_builder.query(&[("search", ¶m_value.to_string())]);
494 }
495 if let Some(ref param_value) = p_query_version {
496 req_builder = req_builder.query(&[("version", ¶m_value.to_string())]);
497 }
498 if let Some(ref user_agent) = configuration.user_agent {
499 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
500 }
501 if let Some(ref token) = configuration.bearer_access_token {
502 req_builder = req_builder.bearer_auth(token.to_owned());
503 };
504
505 let req = req_builder.build()?;
506 let resp = configuration.client.execute(req).await?;
507
508 let status = resp.status();
509 let content_type = resp
510 .headers()
511 .get("content-type")
512 .and_then(|v| v.to_str().ok())
513 .unwrap_or("application/octet-stream");
514 let content_type = super::ContentType::from(content_type);
515
516 if !status.is_client_error() && !status.is_server_error() {
517 let content = resp.text().await?;
518 match content_type {
519 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
520 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::VersionHistory>`"))),
521 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::VersionHistory>`")))),
522 }
523 } else {
524 let content = resp.text().await?;
525 let entity: Option<AdminVersionHistoryListError> = serde_json::from_str(&content).ok();
526 Err(Error::ResponseError(ResponseContent {
527 status,
528 content,
529 entity,
530 }))
531 }
532}
533
534pub async fn admin_version_history_retrieve(
536 configuration: &configuration::Configuration,
537 id: i32,
538) -> Result<models::VersionHistory, Error<AdminVersionHistoryRetrieveError>> {
539 let p_path_id = id;
541
542 let uri_str = format!(
543 "{}/admin/version/history/{id}/",
544 configuration.base_path,
545 id = p_path_id
546 );
547 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
548
549 if let Some(ref user_agent) = configuration.user_agent {
550 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
551 }
552 if let Some(ref token) = configuration.bearer_access_token {
553 req_builder = req_builder.bearer_auth(token.to_owned());
554 };
555
556 let req = req_builder.build()?;
557 let resp = configuration.client.execute(req).await?;
558
559 let status = resp.status();
560 let content_type = resp
561 .headers()
562 .get("content-type")
563 .and_then(|v| v.to_str().ok())
564 .unwrap_or("application/octet-stream");
565 let content_type = super::ContentType::from(content_type);
566
567 if !status.is_client_error() && !status.is_server_error() {
568 let content = resp.text().await?;
569 match content_type {
570 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
571 ContentType::Text => {
572 return Err(Error::from(serde_json::Error::custom(
573 "Received `text/plain` content type response that cannot be converted to `models::VersionHistory`",
574 )))
575 }
576 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
577 "Received `{unknown_type}` content type response that cannot be converted to `models::VersionHistory`"
578 )))),
579 }
580 } else {
581 let content = resp.text().await?;
582 let entity: Option<AdminVersionHistoryRetrieveError> = serde_json::from_str(&content).ok();
583 Err(Error::ResponseError(ResponseContent {
584 status,
585 content,
586 entity,
587 }))
588 }
589}
590
591pub async fn admin_version_retrieve(
593 configuration: &configuration::Configuration,
594) -> Result<models::Version, Error<AdminVersionRetrieveError>> {
595 let uri_str = format!("{}/admin/version/", configuration.base_path);
596 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
597
598 if let Some(ref user_agent) = configuration.user_agent {
599 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
600 }
601 if let Some(ref token) = configuration.bearer_access_token {
602 req_builder = req_builder.bearer_auth(token.to_owned());
603 };
604
605 let req = req_builder.build()?;
606 let resp = configuration.client.execute(req).await?;
607
608 let status = resp.status();
609 let content_type = resp
610 .headers()
611 .get("content-type")
612 .and_then(|v| v.to_str().ok())
613 .unwrap_or("application/octet-stream");
614 let content_type = super::ContentType::from(content_type);
615
616 if !status.is_client_error() && !status.is_server_error() {
617 let content = resp.text().await?;
618 match content_type {
619 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
620 ContentType::Text => {
621 return Err(Error::from(serde_json::Error::custom(
622 "Received `text/plain` content type response that cannot be converted to `models::Version`",
623 )))
624 }
625 ContentType::Unsupported(unknown_type) => {
626 return Err(Error::from(serde_json::Error::custom(format!(
627 "Received `{unknown_type}` content type response that cannot be converted to `models::Version`"
628 ))))
629 }
630 }
631 } else {
632 let content = resp.text().await?;
633 let entity: Option<AdminVersionRetrieveError> = serde_json::from_str(&content).ok();
634 Err(Error::ResponseError(ResponseContent {
635 status,
636 content,
637 entity,
638 }))
639 }
640}