Skip to main content

authentik_client/apis/
admin_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2026.2.1
7 * Contact: hello@goauthentik.io
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15use tokio::fs::File as TokioFile;
16use tokio_util::codec::{BytesCodec, FramedRead};
17
18/// struct for typed errors of method [`admin_apps_list`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AdminAppsListError {
22    Status400(models::ValidationError),
23    Status403(models::GenericError),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`admin_file_create`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum AdminFileCreateError {
31    Status400(models::ValidationError),
32    Status403(models::GenericError),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`admin_file_destroy`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum AdminFileDestroyError {
40    Status400(models::ValidationError),
41    Status403(models::GenericError),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`admin_file_list`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum AdminFileListError {
49    Status400(models::ValidationError),
50    Status403(models::GenericError),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`admin_file_used_by_list`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum AdminFileUsedByListError {
58    Status400(models::ValidationError),
59    Status403(models::GenericError),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`admin_models_list`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum AdminModelsListError {
67    Status400(models::ValidationError),
68    Status403(models::GenericError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`admin_settings_partial_update`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum AdminSettingsPartialUpdateError {
76    Status400(models::ValidationError),
77    Status403(models::GenericError),
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`admin_settings_retrieve`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum AdminSettingsRetrieveError {
85    Status400(models::ValidationError),
86    Status403(models::GenericError),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`admin_settings_update`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum AdminSettingsUpdateError {
94    Status400(models::ValidationError),
95    Status403(models::GenericError),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`admin_system_create`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum AdminSystemCreateError {
103    Status400(models::ValidationError),
104    Status403(models::GenericError),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`admin_system_retrieve`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum AdminSystemRetrieveError {
112    Status400(models::ValidationError),
113    Status403(models::GenericError),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`admin_version_history_list`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum AdminVersionHistoryListError {
121    Status400(models::ValidationError),
122    Status403(models::GenericError),
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`admin_version_history_retrieve`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum AdminVersionHistoryRetrieveError {
130    Status400(models::ValidationError),
131    Status403(models::GenericError),
132    UnknownValue(serde_json::Value),
133}
134
135/// struct for typed errors of method [`admin_version_retrieve`]
136#[derive(Debug, Clone, Serialize, Deserialize)]
137#[serde(untagged)]
138pub enum AdminVersionRetrieveError {
139    Status400(models::ValidationError),
140    Status403(models::GenericError),
141    UnknownValue(serde_json::Value),
142}
143
144/// Read-only view list all installed apps
145pub async fn admin_apps_list(
146    configuration: &configuration::Configuration,
147) -> Result<Vec<models::App>, Error<AdminAppsListError>> {
148    let uri_str = format!("{}/admin/apps/", configuration.base_path);
149    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
150
151    if let Some(ref user_agent) = configuration.user_agent {
152        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
153    }
154    if let Some(ref token) = configuration.bearer_access_token {
155        req_builder = req_builder.bearer_auth(token.to_owned());
156    };
157
158    let req = req_builder.build()?;
159    let resp = configuration.client.execute(req).await?;
160
161    let status = resp.status();
162    let content_type = resp
163        .headers()
164        .get("content-type")
165        .and_then(|v| v.to_str().ok())
166        .unwrap_or("application/octet-stream");
167    let content_type = super::ContentType::from(content_type);
168
169    if !status.is_client_error() && !status.is_server_error() {
170        let content = resp.text().await?;
171        match content_type {
172            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
173            ContentType::Text => {
174                return Err(Error::from(serde_json::Error::custom(
175                    "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::App&gt;`",
176                )))
177            }
178            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
179                "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::App&gt;`"
180            )))),
181        }
182    } else {
183        let content = resp.text().await?;
184        let entity: Option<AdminAppsListError> = serde_json::from_str(&content).ok();
185        Err(Error::ResponseError(ResponseContent {
186            status,
187            content,
188            entity,
189        }))
190    }
191}
192
193/// Upload file to storage backend.
194pub async fn admin_file_create(
195    configuration: &configuration::Configuration,
196    file: std::path::PathBuf,
197    name: Option<&str>,
198    usage: Option<&str>,
199) -> Result<(), Error<AdminFileCreateError>> {
200    // add a prefix to parameters to efficiently prevent name collisions
201    let p_form_file = file;
202    let p_form_name = name;
203    let p_form_usage = usage;
204
205    let uri_str = format!("{}/admin/file/", configuration.base_path);
206    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
207
208    if let Some(ref user_agent) = configuration.user_agent {
209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210    }
211    if let Some(ref token) = configuration.bearer_access_token {
212        req_builder = req_builder.bearer_auth(token.to_owned());
213    };
214    let mut multipart_form = reqwest::multipart::Form::new();
215    let file = TokioFile::open(&p_form_file).await?;
216    let stream = FramedRead::new(file, BytesCodec::new());
217    let file_name = p_form_file
218        .file_name()
219        .map(|n| n.to_string_lossy().to_string())
220        .unwrap_or_default();
221    let file_part = reqwest::multipart::Part::stream(reqwest::Body::wrap_stream(stream)).file_name(file_name);
222    multipart_form = multipart_form.part("file", file_part);
223    if let Some(param_value) = p_form_name {
224        multipart_form = multipart_form.text("name", param_value.to_string());
225    }
226    if let Some(param_value) = p_form_usage {
227        multipart_form = multipart_form.text("usage", param_value.to_string());
228    }
229    req_builder = req_builder.multipart(multipart_form);
230
231    let req = req_builder.build()?;
232    let resp = configuration.client.execute(req).await?;
233
234    let status = resp.status();
235
236    if !status.is_client_error() && !status.is_server_error() {
237        Ok(())
238    } else {
239        let content = resp.text().await?;
240        let entity: Option<AdminFileCreateError> = serde_json::from_str(&content).ok();
241        Err(Error::ResponseError(ResponseContent {
242            status,
243            content,
244            entity,
245        }))
246    }
247}
248
249/// Delete file from storage backend.
250pub async fn admin_file_destroy(
251    configuration: &configuration::Configuration,
252    name: Option<&str>,
253    usage: Option<&str>,
254) -> Result<(), Error<AdminFileDestroyError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    let p_query_name = name;
257    let p_query_usage = usage;
258
259    let uri_str = format!("{}/admin/file/", configuration.base_path);
260    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
261
262    if let Some(ref param_value) = p_query_name {
263        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
264    }
265    if let Some(ref param_value) = p_query_usage {
266        req_builder = req_builder.query(&[("usage", &param_value.to_string())]);
267    }
268    if let Some(ref user_agent) = configuration.user_agent {
269        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
270    }
271    if let Some(ref token) = configuration.bearer_access_token {
272        req_builder = req_builder.bearer_auth(token.to_owned());
273    };
274
275    let req = req_builder.build()?;
276    let resp = configuration.client.execute(req).await?;
277
278    let status = resp.status();
279
280    if !status.is_client_error() && !status.is_server_error() {
281        Ok(())
282    } else {
283        let content = resp.text().await?;
284        let entity: Option<AdminFileDestroyError> = serde_json::from_str(&content).ok();
285        Err(Error::ResponseError(ResponseContent {
286            status,
287            content,
288            entity,
289        }))
290    }
291}
292
293/// List files from storage backend.
294pub async fn admin_file_list(
295    configuration: &configuration::Configuration,
296    manageable_only: Option<bool>,
297    search: Option<&str>,
298    usage: Option<&str>,
299) -> Result<Vec<models::FileList>, Error<AdminFileListError>> {
300    // add a prefix to parameters to efficiently prevent name collisions
301    let p_query_manageable_only = manageable_only;
302    let p_query_search = search;
303    let p_query_usage = usage;
304
305    let uri_str = format!("{}/admin/file/", configuration.base_path);
306    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
307
308    if let Some(ref param_value) = p_query_manageable_only {
309        req_builder = req_builder.query(&[("manageable_only", &param_value.to_string())]);
310    }
311    if let Some(ref param_value) = p_query_search {
312        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
313    }
314    if let Some(ref param_value) = p_query_usage {
315        req_builder = req_builder.query(&[("usage", &param_value.to_string())]);
316    }
317    if let Some(ref user_agent) = configuration.user_agent {
318        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
319    }
320    if let Some(ref token) = configuration.bearer_access_token {
321        req_builder = req_builder.bearer_auth(token.to_owned());
322    };
323
324    let req = req_builder.build()?;
325    let resp = configuration.client.execute(req).await?;
326
327    let status = resp.status();
328    let content_type = resp
329        .headers()
330        .get("content-type")
331        .and_then(|v| v.to_str().ok())
332        .unwrap_or("application/octet-stream");
333    let content_type = super::ContentType::from(content_type);
334
335    if !status.is_client_error() && !status.is_server_error() {
336        let content = resp.text().await?;
337        match content_type {
338            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
339            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::FileList&gt;`"))),
340            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&lt;models::FileList&gt;`")))),
341        }
342    } else {
343        let content = resp.text().await?;
344        let entity: Option<AdminFileListError> = serde_json::from_str(&content).ok();
345        Err(Error::ResponseError(ResponseContent {
346            status,
347            content,
348            entity,
349        }))
350    }
351}
352
353pub async fn admin_file_used_by_list(
354    configuration: &configuration::Configuration,
355    name: Option<&str>,
356) -> Result<Vec<models::UsedBy>, Error<AdminFileUsedByListError>> {
357    // add a prefix to parameters to efficiently prevent name collisions
358    let p_query_name = name;
359
360    let uri_str = format!("{}/admin/file/used_by/", configuration.base_path);
361    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
362
363    if let Some(ref param_value) = p_query_name {
364        req_builder = req_builder.query(&[("name", &param_value.to_string())]);
365    }
366    if let Some(ref user_agent) = configuration.user_agent {
367        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
368    }
369    if let Some(ref token) = configuration.bearer_access_token {
370        req_builder = req_builder.bearer_auth(token.to_owned());
371    };
372
373    let req = req_builder.build()?;
374    let resp = configuration.client.execute(req).await?;
375
376    let status = resp.status();
377    let content_type = resp
378        .headers()
379        .get("content-type")
380        .and_then(|v| v.to_str().ok())
381        .unwrap_or("application/octet-stream");
382    let content_type = super::ContentType::from(content_type);
383
384    if !status.is_client_error() && !status.is_server_error() {
385        let content = resp.text().await?;
386        match content_type {
387            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
388            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::UsedBy&gt;`"))),
389            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&lt;models::UsedBy&gt;`")))),
390        }
391    } else {
392        let content = resp.text().await?;
393        let entity: Option<AdminFileUsedByListError> = serde_json::from_str(&content).ok();
394        Err(Error::ResponseError(ResponseContent {
395            status,
396            content,
397            entity,
398        }))
399    }
400}
401
402/// Read-only view list all installed models
403pub async fn admin_models_list(
404    configuration: &configuration::Configuration,
405) -> Result<Vec<models::App>, Error<AdminModelsListError>> {
406    let uri_str = format!("{}/admin/models/", configuration.base_path);
407    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
408
409    if let Some(ref user_agent) = configuration.user_agent {
410        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
411    }
412    if let Some(ref token) = configuration.bearer_access_token {
413        req_builder = req_builder.bearer_auth(token.to_owned());
414    };
415
416    let req = req_builder.build()?;
417    let resp = configuration.client.execute(req).await?;
418
419    let status = resp.status();
420    let content_type = resp
421        .headers()
422        .get("content-type")
423        .and_then(|v| v.to_str().ok())
424        .unwrap_or("application/octet-stream");
425    let content_type = super::ContentType::from(content_type);
426
427    if !status.is_client_error() && !status.is_server_error() {
428        let content = resp.text().await?;
429        match content_type {
430            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
431            ContentType::Text => {
432                return Err(Error::from(serde_json::Error::custom(
433                    "Received `text/plain` content type response that cannot be converted to `Vec&lt;models::App&gt;`",
434                )))
435            }
436            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
437                "Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::App&gt;`"
438            )))),
439        }
440    } else {
441        let content = resp.text().await?;
442        let entity: Option<AdminModelsListError> = serde_json::from_str(&content).ok();
443        Err(Error::ResponseError(ResponseContent {
444            status,
445            content,
446            entity,
447        }))
448    }
449}
450
451/// Settings view
452pub async fn admin_settings_partial_update(
453    configuration: &configuration::Configuration,
454    patched_settings_request: Option<models::PatchedSettingsRequest>,
455) -> Result<models::Settings, Error<AdminSettingsPartialUpdateError>> {
456    // add a prefix to parameters to efficiently prevent name collisions
457    let p_body_patched_settings_request = patched_settings_request;
458
459    let uri_str = format!("{}/admin/settings/", configuration.base_path);
460    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
461
462    if let Some(ref user_agent) = configuration.user_agent {
463        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
464    }
465    if let Some(ref token) = configuration.bearer_access_token {
466        req_builder = req_builder.bearer_auth(token.to_owned());
467    };
468    req_builder = req_builder.json(&p_body_patched_settings_request);
469
470    let req = req_builder.build()?;
471    let resp = configuration.client.execute(req).await?;
472
473    let status = resp.status();
474    let content_type = resp
475        .headers()
476        .get("content-type")
477        .and_then(|v| v.to_str().ok())
478        .unwrap_or("application/octet-stream");
479    let content_type = super::ContentType::from(content_type);
480
481    if !status.is_client_error() && !status.is_server_error() {
482        let content = resp.text().await?;
483        match content_type {
484            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
485            ContentType::Text => {
486                return Err(Error::from(serde_json::Error::custom(
487                    "Received `text/plain` content type response that cannot be converted to `models::Settings`",
488                )))
489            }
490            ContentType::Unsupported(unknown_type) => {
491                return Err(Error::from(serde_json::Error::custom(format!(
492                    "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
493                ))))
494            }
495        }
496    } else {
497        let content = resp.text().await?;
498        let entity: Option<AdminSettingsPartialUpdateError> = serde_json::from_str(&content).ok();
499        Err(Error::ResponseError(ResponseContent {
500            status,
501            content,
502            entity,
503        }))
504    }
505}
506
507/// Settings view
508pub async fn admin_settings_retrieve(
509    configuration: &configuration::Configuration,
510) -> Result<models::Settings, Error<AdminSettingsRetrieveError>> {
511    let uri_str = format!("{}/admin/settings/", configuration.base_path);
512    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
513
514    if let Some(ref user_agent) = configuration.user_agent {
515        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
516    }
517    if let Some(ref token) = configuration.bearer_access_token {
518        req_builder = req_builder.bearer_auth(token.to_owned());
519    };
520
521    let req = req_builder.build()?;
522    let resp = configuration.client.execute(req).await?;
523
524    let status = resp.status();
525    let content_type = resp
526        .headers()
527        .get("content-type")
528        .and_then(|v| v.to_str().ok())
529        .unwrap_or("application/octet-stream");
530    let content_type = super::ContentType::from(content_type);
531
532    if !status.is_client_error() && !status.is_server_error() {
533        let content = resp.text().await?;
534        match content_type {
535            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
536            ContentType::Text => {
537                return Err(Error::from(serde_json::Error::custom(
538                    "Received `text/plain` content type response that cannot be converted to `models::Settings`",
539                )))
540            }
541            ContentType::Unsupported(unknown_type) => {
542                return Err(Error::from(serde_json::Error::custom(format!(
543                    "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
544                ))))
545            }
546        }
547    } else {
548        let content = resp.text().await?;
549        let entity: Option<AdminSettingsRetrieveError> = serde_json::from_str(&content).ok();
550        Err(Error::ResponseError(ResponseContent {
551            status,
552            content,
553            entity,
554        }))
555    }
556}
557
558/// Settings view
559pub async fn admin_settings_update(
560    configuration: &configuration::Configuration,
561    settings_request: models::SettingsRequest,
562) -> Result<models::Settings, Error<AdminSettingsUpdateError>> {
563    // add a prefix to parameters to efficiently prevent name collisions
564    let p_body_settings_request = settings_request;
565
566    let uri_str = format!("{}/admin/settings/", configuration.base_path);
567    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
568
569    if let Some(ref user_agent) = configuration.user_agent {
570        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
571    }
572    if let Some(ref token) = configuration.bearer_access_token {
573        req_builder = req_builder.bearer_auth(token.to_owned());
574    };
575    req_builder = req_builder.json(&p_body_settings_request);
576
577    let req = req_builder.build()?;
578    let resp = configuration.client.execute(req).await?;
579
580    let status = resp.status();
581    let content_type = resp
582        .headers()
583        .get("content-type")
584        .and_then(|v| v.to_str().ok())
585        .unwrap_or("application/octet-stream");
586    let content_type = super::ContentType::from(content_type);
587
588    if !status.is_client_error() && !status.is_server_error() {
589        let content = resp.text().await?;
590        match content_type {
591            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
592            ContentType::Text => {
593                return Err(Error::from(serde_json::Error::custom(
594                    "Received `text/plain` content type response that cannot be converted to `models::Settings`",
595                )))
596            }
597            ContentType::Unsupported(unknown_type) => {
598                return Err(Error::from(serde_json::Error::custom(format!(
599                    "Received `{unknown_type}` content type response that cannot be converted to `models::Settings`"
600                ))))
601            }
602        }
603    } else {
604        let content = resp.text().await?;
605        let entity: Option<AdminSettingsUpdateError> = serde_json::from_str(&content).ok();
606        Err(Error::ResponseError(ResponseContent {
607            status,
608            content,
609            entity,
610        }))
611    }
612}
613
614/// Get system information.
615pub async fn admin_system_create(
616    configuration: &configuration::Configuration,
617) -> Result<models::SystemInfo, Error<AdminSystemCreateError>> {
618    let uri_str = format!("{}/admin/system/", configuration.base_path);
619    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
620
621    if let Some(ref user_agent) = configuration.user_agent {
622        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
623    }
624    if let Some(ref token) = configuration.bearer_access_token {
625        req_builder = req_builder.bearer_auth(token.to_owned());
626    };
627
628    let req = req_builder.build()?;
629    let resp = configuration.client.execute(req).await?;
630
631    let status = resp.status();
632    let content_type = resp
633        .headers()
634        .get("content-type")
635        .and_then(|v| v.to_str().ok())
636        .unwrap_or("application/octet-stream");
637    let content_type = super::ContentType::from(content_type);
638
639    if !status.is_client_error() && !status.is_server_error() {
640        let content = resp.text().await?;
641        match content_type {
642            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
643            ContentType::Text => {
644                return Err(Error::from(serde_json::Error::custom(
645                    "Received `text/plain` content type response that cannot be converted to `models::SystemInfo`",
646                )))
647            }
648            ContentType::Unsupported(unknown_type) => {
649                return Err(Error::from(serde_json::Error::custom(format!(
650                    "Received `{unknown_type}` content type response that cannot be converted to `models::SystemInfo`"
651                ))))
652            }
653        }
654    } else {
655        let content = resp.text().await?;
656        let entity: Option<AdminSystemCreateError> = serde_json::from_str(&content).ok();
657        Err(Error::ResponseError(ResponseContent {
658            status,
659            content,
660            entity,
661        }))
662    }
663}
664
665/// Get system information.
666pub async fn admin_system_retrieve(
667    configuration: &configuration::Configuration,
668) -> Result<models::SystemInfo, Error<AdminSystemRetrieveError>> {
669    let uri_str = format!("{}/admin/system/", configuration.base_path);
670    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
671
672    if let Some(ref user_agent) = configuration.user_agent {
673        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
674    }
675    if let Some(ref token) = configuration.bearer_access_token {
676        req_builder = req_builder.bearer_auth(token.to_owned());
677    };
678
679    let req = req_builder.build()?;
680    let resp = configuration.client.execute(req).await?;
681
682    let status = resp.status();
683    let content_type = resp
684        .headers()
685        .get("content-type")
686        .and_then(|v| v.to_str().ok())
687        .unwrap_or("application/octet-stream");
688    let content_type = super::ContentType::from(content_type);
689
690    if !status.is_client_error() && !status.is_server_error() {
691        let content = resp.text().await?;
692        match content_type {
693            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
694            ContentType::Text => {
695                return Err(Error::from(serde_json::Error::custom(
696                    "Received `text/plain` content type response that cannot be converted to `models::SystemInfo`",
697                )))
698            }
699            ContentType::Unsupported(unknown_type) => {
700                return Err(Error::from(serde_json::Error::custom(format!(
701                    "Received `{unknown_type}` content type response that cannot be converted to `models::SystemInfo`"
702                ))))
703            }
704        }
705    } else {
706        let content = resp.text().await?;
707        let entity: Option<AdminSystemRetrieveError> = serde_json::from_str(&content).ok();
708        Err(Error::ResponseError(ResponseContent {
709            status,
710            content,
711            entity,
712        }))
713    }
714}
715
716/// VersionHistory Viewset
717pub async fn admin_version_history_list(
718    configuration: &configuration::Configuration,
719    build: Option<&str>,
720    ordering: Option<&str>,
721    search: Option<&str>,
722    version: Option<&str>,
723) -> Result<Vec<models::VersionHistory>, Error<AdminVersionHistoryListError>> {
724    // add a prefix to parameters to efficiently prevent name collisions
725    let p_query_build = build;
726    let p_query_ordering = ordering;
727    let p_query_search = search;
728    let p_query_version = version;
729
730    let uri_str = format!("{}/admin/version/history/", configuration.base_path);
731    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
732
733    if let Some(ref param_value) = p_query_build {
734        req_builder = req_builder.query(&[("build", &param_value.to_string())]);
735    }
736    if let Some(ref param_value) = p_query_ordering {
737        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
738    }
739    if let Some(ref param_value) = p_query_search {
740        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
741    }
742    if let Some(ref param_value) = p_query_version {
743        req_builder = req_builder.query(&[("version", &param_value.to_string())]);
744    }
745    if let Some(ref user_agent) = configuration.user_agent {
746        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
747    }
748    if let Some(ref token) = configuration.bearer_access_token {
749        req_builder = req_builder.bearer_auth(token.to_owned());
750    };
751
752    let req = req_builder.build()?;
753    let resp = configuration.client.execute(req).await?;
754
755    let status = resp.status();
756    let content_type = resp
757        .headers()
758        .get("content-type")
759        .and_then(|v| v.to_str().ok())
760        .unwrap_or("application/octet-stream");
761    let content_type = super::ContentType::from(content_type);
762
763    if !status.is_client_error() && !status.is_server_error() {
764        let content = resp.text().await?;
765        match content_type {
766            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
767            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::VersionHistory&gt;`"))),
768            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&lt;models::VersionHistory&gt;`")))),
769        }
770    } else {
771        let content = resp.text().await?;
772        let entity: Option<AdminVersionHistoryListError> = serde_json::from_str(&content).ok();
773        Err(Error::ResponseError(ResponseContent {
774            status,
775            content,
776            entity,
777        }))
778    }
779}
780
781/// VersionHistory Viewset
782pub async fn admin_version_history_retrieve(
783    configuration: &configuration::Configuration,
784    id: i32,
785) -> Result<models::VersionHistory, Error<AdminVersionHistoryRetrieveError>> {
786    // add a prefix to parameters to efficiently prevent name collisions
787    let p_path_id = id;
788
789    let uri_str = format!(
790        "{}/admin/version/history/{id}/",
791        configuration.base_path,
792        id = p_path_id
793    );
794    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
795
796    if let Some(ref user_agent) = configuration.user_agent {
797        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
798    }
799    if let Some(ref token) = configuration.bearer_access_token {
800        req_builder = req_builder.bearer_auth(token.to_owned());
801    };
802
803    let req = req_builder.build()?;
804    let resp = configuration.client.execute(req).await?;
805
806    let status = resp.status();
807    let content_type = resp
808        .headers()
809        .get("content-type")
810        .and_then(|v| v.to_str().ok())
811        .unwrap_or("application/octet-stream");
812    let content_type = super::ContentType::from(content_type);
813
814    if !status.is_client_error() && !status.is_server_error() {
815        let content = resp.text().await?;
816        match content_type {
817            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
818            ContentType::Text => {
819                return Err(Error::from(serde_json::Error::custom(
820                    "Received `text/plain` content type response that cannot be converted to `models::VersionHistory`",
821                )))
822            }
823            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!(
824                "Received `{unknown_type}` content type response that cannot be converted to `models::VersionHistory`"
825            )))),
826        }
827    } else {
828        let content = resp.text().await?;
829        let entity: Option<AdminVersionHistoryRetrieveError> = serde_json::from_str(&content).ok();
830        Err(Error::ResponseError(ResponseContent {
831            status,
832            content,
833            entity,
834        }))
835    }
836}
837
838/// Get running and latest version.
839pub async fn admin_version_retrieve(
840    configuration: &configuration::Configuration,
841) -> Result<models::Version, Error<AdminVersionRetrieveError>> {
842    let uri_str = format!("{}/admin/version/", configuration.base_path);
843    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
844
845    if let Some(ref user_agent) = configuration.user_agent {
846        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
847    }
848    if let Some(ref token) = configuration.bearer_access_token {
849        req_builder = req_builder.bearer_auth(token.to_owned());
850    };
851
852    let req = req_builder.build()?;
853    let resp = configuration.client.execute(req).await?;
854
855    let status = resp.status();
856    let content_type = resp
857        .headers()
858        .get("content-type")
859        .and_then(|v| v.to_str().ok())
860        .unwrap_or("application/octet-stream");
861    let content_type = super::ContentType::from(content_type);
862
863    if !status.is_client_error() && !status.is_server_error() {
864        let content = resp.text().await?;
865        match content_type {
866            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
867            ContentType::Text => {
868                return Err(Error::from(serde_json::Error::custom(
869                    "Received `text/plain` content type response that cannot be converted to `models::Version`",
870                )))
871            }
872            ContentType::Unsupported(unknown_type) => {
873                return Err(Error::from(serde_json::Error::custom(format!(
874                    "Received `{unknown_type}` content type response that cannot be converted to `models::Version`"
875                ))))
876            }
877        }
878    } else {
879        let content = resp.text().await?;
880        let entity: Option<AdminVersionRetrieveError> = serde_json::from_str(&content).ok();
881        Err(Error::ResponseError(ResponseContent {
882            status,
883            content,
884            entity,
885        }))
886    }
887}