authentik_client/apis/
tasks_api.rs

1/*
2 * authentik
3 *
4 * Making authentication simple.
5 *
6 * The version of the OpenAPI document: 2025.10.2
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};
15
16/// struct for typed errors of method [`tasks_schedules_list`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum TasksSchedulesListError {
20    Status400(models::ValidationError),
21    Status403(models::GenericError),
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`tasks_schedules_partial_update`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum TasksSchedulesPartialUpdateError {
29    Status400(models::ValidationError),
30    Status403(models::GenericError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`tasks_schedules_retrieve`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum TasksSchedulesRetrieveError {
38    Status400(models::ValidationError),
39    Status403(models::GenericError),
40    UnknownValue(serde_json::Value),
41}
42
43/// struct for typed errors of method [`tasks_schedules_send_create`]
44#[derive(Debug, Clone, Serialize, Deserialize)]
45#[serde(untagged)]
46pub enum TasksSchedulesSendCreateError {
47    Status404(),
48    Status500(),
49    Status400(models::ValidationError),
50    Status403(models::GenericError),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`tasks_schedules_update`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum TasksSchedulesUpdateError {
58    Status400(models::ValidationError),
59    Status403(models::GenericError),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`tasks_tasks_list`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum TasksTasksListError {
67    Status400(models::ValidationError),
68    Status403(models::GenericError),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`tasks_tasks_retrieve`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum TasksTasksRetrieveError {
76    Status400(models::ValidationError),
77    Status403(models::GenericError),
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`tasks_tasks_retry_create`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum TasksTasksRetryCreateError {
85    Status400(),
86    Status404(),
87    Status403(models::GenericError),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`tasks_tasks_status_retrieve`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum TasksTasksStatusRetrieveError {
95    Status400(models::ValidationError),
96    Status403(models::GenericError),
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`tasks_workers_list`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum TasksWorkersListError {
104    Status400(models::ValidationError),
105    Status403(models::GenericError),
106    UnknownValue(serde_json::Value),
107}
108
109pub async fn tasks_schedules_list(
110    configuration: &configuration::Configuration,
111    actor_name: Option<&str>,
112    ordering: Option<&str>,
113    page: Option<i32>,
114    page_size: Option<i32>,
115    paused: Option<bool>,
116    rel_obj_content_type__app_label: Option<&str>,
117    rel_obj_content_type__model: Option<&str>,
118    rel_obj_id: Option<&str>,
119    rel_obj_id__isnull: Option<bool>,
120    search: Option<&str>,
121) -> Result<models::PaginatedScheduleList, Error<TasksSchedulesListError>> {
122    // add a prefix to parameters to efficiently prevent name collisions
123    let p_query_actor_name = actor_name;
124    let p_query_ordering = ordering;
125    let p_query_page = page;
126    let p_query_page_size = page_size;
127    let p_query_paused = paused;
128    let p_query_rel_obj_content_type__app_label = rel_obj_content_type__app_label;
129    let p_query_rel_obj_content_type__model = rel_obj_content_type__model;
130    let p_query_rel_obj_id = rel_obj_id;
131    let p_query_rel_obj_id__isnull = rel_obj_id__isnull;
132    let p_query_search = search;
133
134    let uri_str = format!("{}/tasks/schedules/", configuration.base_path);
135    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
136
137    if let Some(ref param_value) = p_query_actor_name {
138        req_builder = req_builder.query(&[("actor_name", &param_value.to_string())]);
139    }
140    if let Some(ref param_value) = p_query_ordering {
141        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
142    }
143    if let Some(ref param_value) = p_query_page {
144        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
145    }
146    if let Some(ref param_value) = p_query_page_size {
147        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
148    }
149    if let Some(ref param_value) = p_query_paused {
150        req_builder = req_builder.query(&[("paused", &param_value.to_string())]);
151    }
152    if let Some(ref param_value) = p_query_rel_obj_content_type__app_label {
153        req_builder = req_builder.query(&[("rel_obj_content_type__app_label", &param_value.to_string())]);
154    }
155    if let Some(ref param_value) = p_query_rel_obj_content_type__model {
156        req_builder = req_builder.query(&[("rel_obj_content_type__model", &param_value.to_string())]);
157    }
158    if let Some(ref param_value) = p_query_rel_obj_id {
159        req_builder = req_builder.query(&[("rel_obj_id", &param_value.to_string())]);
160    }
161    if let Some(ref param_value) = p_query_rel_obj_id__isnull {
162        req_builder = req_builder.query(&[("rel_obj_id__isnull", &param_value.to_string())]);
163    }
164    if let Some(ref param_value) = p_query_search {
165        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
166    }
167    if let Some(ref user_agent) = configuration.user_agent {
168        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
169    }
170    if let Some(ref token) = configuration.bearer_access_token {
171        req_builder = req_builder.bearer_auth(token.to_owned());
172    };
173
174    let req = req_builder.build()?;
175    let resp = configuration.client.execute(req).await?;
176
177    let status = resp.status();
178    let content_type = resp
179        .headers()
180        .get("content-type")
181        .and_then(|v| v.to_str().ok())
182        .unwrap_or("application/octet-stream");
183    let content_type = super::ContentType::from(content_type);
184
185    if !status.is_client_error() && !status.is_server_error() {
186        let content = resp.text().await?;
187        match content_type {
188            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
189            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedScheduleList`"))),
190            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::PaginatedScheduleList`")))),
191        }
192    } else {
193        let content = resp.text().await?;
194        let entity: Option<TasksSchedulesListError> = serde_json::from_str(&content).ok();
195        Err(Error::ResponseError(ResponseContent {
196            status,
197            content,
198            entity,
199        }))
200    }
201}
202
203pub async fn tasks_schedules_partial_update(
204    configuration: &configuration::Configuration,
205    id: &str,
206    patched_schedule_request: Option<models::PatchedScheduleRequest>,
207) -> Result<models::Schedule, Error<TasksSchedulesPartialUpdateError>> {
208    // add a prefix to parameters to efficiently prevent name collisions
209    let p_path_id = id;
210    let p_body_patched_schedule_request = patched_schedule_request;
211
212    let uri_str = format!(
213        "{}/tasks/schedules/{id}/",
214        configuration.base_path,
215        id = crate::apis::urlencode(p_path_id)
216    );
217    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
218
219    if let Some(ref user_agent) = configuration.user_agent {
220        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
221    }
222    if let Some(ref token) = configuration.bearer_access_token {
223        req_builder = req_builder.bearer_auth(token.to_owned());
224    };
225    req_builder = req_builder.json(&p_body_patched_schedule_request);
226
227    let req = req_builder.build()?;
228    let resp = configuration.client.execute(req).await?;
229
230    let status = resp.status();
231    let content_type = resp
232        .headers()
233        .get("content-type")
234        .and_then(|v| v.to_str().ok())
235        .unwrap_or("application/octet-stream");
236    let content_type = super::ContentType::from(content_type);
237
238    if !status.is_client_error() && !status.is_server_error() {
239        let content = resp.text().await?;
240        match content_type {
241            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
242            ContentType::Text => {
243                return Err(Error::from(serde_json::Error::custom(
244                    "Received `text/plain` content type response that cannot be converted to `models::Schedule`",
245                )))
246            }
247            ContentType::Unsupported(unknown_type) => {
248                return Err(Error::from(serde_json::Error::custom(format!(
249                    "Received `{unknown_type}` content type response that cannot be converted to `models::Schedule`"
250                ))))
251            }
252        }
253    } else {
254        let content = resp.text().await?;
255        let entity: Option<TasksSchedulesPartialUpdateError> = serde_json::from_str(&content).ok();
256        Err(Error::ResponseError(ResponseContent {
257            status,
258            content,
259            entity,
260        }))
261    }
262}
263
264pub async fn tasks_schedules_retrieve(
265    configuration: &configuration::Configuration,
266    id: &str,
267) -> Result<models::Schedule, Error<TasksSchedulesRetrieveError>> {
268    // add a prefix to parameters to efficiently prevent name collisions
269    let p_path_id = id;
270
271    let uri_str = format!(
272        "{}/tasks/schedules/{id}/",
273        configuration.base_path,
274        id = crate::apis::urlencode(p_path_id)
275    );
276    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
277
278    if let Some(ref user_agent) = configuration.user_agent {
279        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
280    }
281    if let Some(ref token) = configuration.bearer_access_token {
282        req_builder = req_builder.bearer_auth(token.to_owned());
283    };
284
285    let req = req_builder.build()?;
286    let resp = configuration.client.execute(req).await?;
287
288    let status = resp.status();
289    let content_type = resp
290        .headers()
291        .get("content-type")
292        .and_then(|v| v.to_str().ok())
293        .unwrap_or("application/octet-stream");
294    let content_type = super::ContentType::from(content_type);
295
296    if !status.is_client_error() && !status.is_server_error() {
297        let content = resp.text().await?;
298        match content_type {
299            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
300            ContentType::Text => {
301                return Err(Error::from(serde_json::Error::custom(
302                    "Received `text/plain` content type response that cannot be converted to `models::Schedule`",
303                )))
304            }
305            ContentType::Unsupported(unknown_type) => {
306                return Err(Error::from(serde_json::Error::custom(format!(
307                    "Received `{unknown_type}` content type response that cannot be converted to `models::Schedule`"
308                ))))
309            }
310        }
311    } else {
312        let content = resp.text().await?;
313        let entity: Option<TasksSchedulesRetrieveError> = serde_json::from_str(&content).ok();
314        Err(Error::ResponseError(ResponseContent {
315            status,
316            content,
317            entity,
318        }))
319    }
320}
321
322/// Trigger this schedule now
323pub async fn tasks_schedules_send_create(
324    configuration: &configuration::Configuration,
325    id: &str,
326) -> Result<(), Error<TasksSchedulesSendCreateError>> {
327    // add a prefix to parameters to efficiently prevent name collisions
328    let p_path_id = id;
329
330    let uri_str = format!(
331        "{}/tasks/schedules/{id}/send/",
332        configuration.base_path,
333        id = crate::apis::urlencode(p_path_id)
334    );
335    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
336
337    if let Some(ref user_agent) = configuration.user_agent {
338        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339    }
340    if let Some(ref token) = configuration.bearer_access_token {
341        req_builder = req_builder.bearer_auth(token.to_owned());
342    };
343
344    let req = req_builder.build()?;
345    let resp = configuration.client.execute(req).await?;
346
347    let status = resp.status();
348
349    if !status.is_client_error() && !status.is_server_error() {
350        Ok(())
351    } else {
352        let content = resp.text().await?;
353        let entity: Option<TasksSchedulesSendCreateError> = serde_json::from_str(&content).ok();
354        Err(Error::ResponseError(ResponseContent {
355            status,
356            content,
357            entity,
358        }))
359    }
360}
361
362pub async fn tasks_schedules_update(
363    configuration: &configuration::Configuration,
364    id: &str,
365    schedule_request: models::ScheduleRequest,
366) -> Result<models::Schedule, Error<TasksSchedulesUpdateError>> {
367    // add a prefix to parameters to efficiently prevent name collisions
368    let p_path_id = id;
369    let p_body_schedule_request = schedule_request;
370
371    let uri_str = format!(
372        "{}/tasks/schedules/{id}/",
373        configuration.base_path,
374        id = crate::apis::urlencode(p_path_id)
375    );
376    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
377
378    if let Some(ref user_agent) = configuration.user_agent {
379        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
380    }
381    if let Some(ref token) = configuration.bearer_access_token {
382        req_builder = req_builder.bearer_auth(token.to_owned());
383    };
384    req_builder = req_builder.json(&p_body_schedule_request);
385
386    let req = req_builder.build()?;
387    let resp = configuration.client.execute(req).await?;
388
389    let status = resp.status();
390    let content_type = resp
391        .headers()
392        .get("content-type")
393        .and_then(|v| v.to_str().ok())
394        .unwrap_or("application/octet-stream");
395    let content_type = super::ContentType::from(content_type);
396
397    if !status.is_client_error() && !status.is_server_error() {
398        let content = resp.text().await?;
399        match content_type {
400            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
401            ContentType::Text => {
402                return Err(Error::from(serde_json::Error::custom(
403                    "Received `text/plain` content type response that cannot be converted to `models::Schedule`",
404                )))
405            }
406            ContentType::Unsupported(unknown_type) => {
407                return Err(Error::from(serde_json::Error::custom(format!(
408                    "Received `{unknown_type}` content type response that cannot be converted to `models::Schedule`"
409                ))))
410            }
411        }
412    } else {
413        let content = resp.text().await?;
414        let entity: Option<TasksSchedulesUpdateError> = serde_json::from_str(&content).ok();
415        Err(Error::ResponseError(ResponseContent {
416            status,
417            content,
418            entity,
419        }))
420    }
421}
422
423pub async fn tasks_tasks_list(
424    configuration: &configuration::Configuration,
425    actor_name: Option<&str>,
426    aggregated_status: Option<Vec<String>>,
427    ordering: Option<&str>,
428    page: Option<i32>,
429    page_size: Option<i32>,
430    queue_name: Option<&str>,
431    rel_obj_content_type__app_label: Option<&str>,
432    rel_obj_content_type__model: Option<&str>,
433    rel_obj_id: Option<&str>,
434    rel_obj_id__isnull: Option<bool>,
435    search: Option<&str>,
436    state: Option<&str>,
437) -> Result<models::PaginatedTaskList, Error<TasksTasksListError>> {
438    // add a prefix to parameters to efficiently prevent name collisions
439    let p_query_actor_name = actor_name;
440    let p_query_aggregated_status = aggregated_status;
441    let p_query_ordering = ordering;
442    let p_query_page = page;
443    let p_query_page_size = page_size;
444    let p_query_queue_name = queue_name;
445    let p_query_rel_obj_content_type__app_label = rel_obj_content_type__app_label;
446    let p_query_rel_obj_content_type__model = rel_obj_content_type__model;
447    let p_query_rel_obj_id = rel_obj_id;
448    let p_query_rel_obj_id__isnull = rel_obj_id__isnull;
449    let p_query_search = search;
450    let p_query_state = state;
451
452    let uri_str = format!("{}/tasks/tasks/", configuration.base_path);
453    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
454
455    if let Some(ref param_value) = p_query_actor_name {
456        req_builder = req_builder.query(&[("actor_name", &param_value.to_string())]);
457    }
458    if let Some(ref param_value) = p_query_aggregated_status {
459        req_builder = match "multi" {
460            "multi" => req_builder.query(
461                &param_value
462                    .into_iter()
463                    .map(|p| ("aggregated_status".to_owned(), p.to_string()))
464                    .collect::<Vec<(std::string::String, std::string::String)>>(),
465            ),
466            _ => req_builder.query(&[(
467                "aggregated_status",
468                &param_value
469                    .into_iter()
470                    .map(|p| p.to_string())
471                    .collect::<Vec<String>>()
472                    .join(",")
473                    .to_string(),
474            )]),
475        };
476    }
477    if let Some(ref param_value) = p_query_ordering {
478        req_builder = req_builder.query(&[("ordering", &param_value.to_string())]);
479    }
480    if let Some(ref param_value) = p_query_page {
481        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
482    }
483    if let Some(ref param_value) = p_query_page_size {
484        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
485    }
486    if let Some(ref param_value) = p_query_queue_name {
487        req_builder = req_builder.query(&[("queue_name", &param_value.to_string())]);
488    }
489    if let Some(ref param_value) = p_query_rel_obj_content_type__app_label {
490        req_builder = req_builder.query(&[("rel_obj_content_type__app_label", &param_value.to_string())]);
491    }
492    if let Some(ref param_value) = p_query_rel_obj_content_type__model {
493        req_builder = req_builder.query(&[("rel_obj_content_type__model", &param_value.to_string())]);
494    }
495    if let Some(ref param_value) = p_query_rel_obj_id {
496        req_builder = req_builder.query(&[("rel_obj_id", &param_value.to_string())]);
497    }
498    if let Some(ref param_value) = p_query_rel_obj_id__isnull {
499        req_builder = req_builder.query(&[("rel_obj_id__isnull", &param_value.to_string())]);
500    }
501    if let Some(ref param_value) = p_query_search {
502        req_builder = req_builder.query(&[("search", &param_value.to_string())]);
503    }
504    if let Some(ref param_value) = p_query_state {
505        req_builder = req_builder.query(&[("state", &param_value.to_string())]);
506    }
507    if let Some(ref user_agent) = configuration.user_agent {
508        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
509    }
510    if let Some(ref token) = configuration.bearer_access_token {
511        req_builder = req_builder.bearer_auth(token.to_owned());
512    };
513
514    let req = req_builder.build()?;
515    let resp = configuration.client.execute(req).await?;
516
517    let status = resp.status();
518    let content_type = resp
519        .headers()
520        .get("content-type")
521        .and_then(|v| v.to_str().ok())
522        .unwrap_or("application/octet-stream");
523    let content_type = super::ContentType::from(content_type);
524
525    if !status.is_client_error() && !status.is_server_error() {
526        let content = resp.text().await?;
527        match content_type {
528            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
529            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PaginatedTaskList`"))),
530            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::PaginatedTaskList`")))),
531        }
532    } else {
533        let content = resp.text().await?;
534        let entity: Option<TasksTasksListError> = serde_json::from_str(&content).ok();
535        Err(Error::ResponseError(ResponseContent {
536            status,
537            content,
538            entity,
539        }))
540    }
541}
542
543pub async fn tasks_tasks_retrieve(
544    configuration: &configuration::Configuration,
545    message_id: &str,
546) -> Result<models::Task, Error<TasksTasksRetrieveError>> {
547    // add a prefix to parameters to efficiently prevent name collisions
548    let p_path_message_id = message_id;
549
550    let uri_str = format!(
551        "{}/tasks/tasks/{message_id}/",
552        configuration.base_path,
553        message_id = crate::apis::urlencode(p_path_message_id)
554    );
555    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
556
557    if let Some(ref user_agent) = configuration.user_agent {
558        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
559    }
560    if let Some(ref token) = configuration.bearer_access_token {
561        req_builder = req_builder.bearer_auth(token.to_owned());
562    };
563
564    let req = req_builder.build()?;
565    let resp = configuration.client.execute(req).await?;
566
567    let status = resp.status();
568    let content_type = resp
569        .headers()
570        .get("content-type")
571        .and_then(|v| v.to_str().ok())
572        .unwrap_or("application/octet-stream");
573    let content_type = super::ContentType::from(content_type);
574
575    if !status.is_client_error() && !status.is_server_error() {
576        let content = resp.text().await?;
577        match content_type {
578            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
579            ContentType::Text => {
580                return Err(Error::from(serde_json::Error::custom(
581                    "Received `text/plain` content type response that cannot be converted to `models::Task`",
582                )))
583            }
584            ContentType::Unsupported(unknown_type) => {
585                return Err(Error::from(serde_json::Error::custom(format!(
586                    "Received `{unknown_type}` content type response that cannot be converted to `models::Task`"
587                ))))
588            }
589        }
590    } else {
591        let content = resp.text().await?;
592        let entity: Option<TasksTasksRetrieveError> = serde_json::from_str(&content).ok();
593        Err(Error::ResponseError(ResponseContent {
594            status,
595            content,
596            entity,
597        }))
598    }
599}
600
601/// Retry task
602pub async fn tasks_tasks_retry_create(
603    configuration: &configuration::Configuration,
604    message_id: &str,
605) -> Result<(), Error<TasksTasksRetryCreateError>> {
606    // add a prefix to parameters to efficiently prevent name collisions
607    let p_path_message_id = message_id;
608
609    let uri_str = format!(
610        "{}/tasks/tasks/{message_id}/retry/",
611        configuration.base_path,
612        message_id = crate::apis::urlencode(p_path_message_id)
613    );
614    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
615
616    if let Some(ref user_agent) = configuration.user_agent {
617        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
618    }
619    if let Some(ref token) = configuration.bearer_access_token {
620        req_builder = req_builder.bearer_auth(token.to_owned());
621    };
622
623    let req = req_builder.build()?;
624    let resp = configuration.client.execute(req).await?;
625
626    let status = resp.status();
627
628    if !status.is_client_error() && !status.is_server_error() {
629        Ok(())
630    } else {
631        let content = resp.text().await?;
632        let entity: Option<TasksTasksRetryCreateError> = serde_json::from_str(&content).ok();
633        Err(Error::ResponseError(ResponseContent {
634            status,
635            content,
636            entity,
637        }))
638    }
639}
640
641/// Global status summary for all tasks
642pub async fn tasks_tasks_status_retrieve(
643    configuration: &configuration::Configuration,
644) -> Result<models::GlobalTaskStatus, Error<TasksTasksStatusRetrieveError>> {
645    let uri_str = format!("{}/tasks/tasks/status/", configuration.base_path);
646    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
647
648    if let Some(ref user_agent) = configuration.user_agent {
649        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
650    }
651    if let Some(ref token) = configuration.bearer_access_token {
652        req_builder = req_builder.bearer_auth(token.to_owned());
653    };
654
655    let req = req_builder.build()?;
656    let resp = configuration.client.execute(req).await?;
657
658    let status = resp.status();
659    let content_type = resp
660        .headers()
661        .get("content-type")
662        .and_then(|v| v.to_str().ok())
663        .unwrap_or("application/octet-stream");
664    let content_type = super::ContentType::from(content_type);
665
666    if !status.is_client_error() && !status.is_server_error() {
667        let content = resp.text().await?;
668        match content_type {
669            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
670            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GlobalTaskStatus`"))),
671            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::GlobalTaskStatus`")))),
672        }
673    } else {
674        let content = resp.text().await?;
675        let entity: Option<TasksTasksStatusRetrieveError> = serde_json::from_str(&content).ok();
676        Err(Error::ResponseError(ResponseContent {
677            status,
678            content,
679            entity,
680        }))
681    }
682}
683
684/// Get currently connected worker count.
685pub async fn tasks_workers_list(
686    configuration: &configuration::Configuration,
687) -> Result<Vec<models::Worker>, Error<TasksWorkersListError>> {
688    let uri_str = format!("{}/tasks/workers", configuration.base_path);
689    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
690
691    if let Some(ref user_agent) = configuration.user_agent {
692        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
693    }
694    if let Some(ref token) = configuration.bearer_access_token {
695        req_builder = req_builder.bearer_auth(token.to_owned());
696    };
697
698    let req = req_builder.build()?;
699    let resp = configuration.client.execute(req).await?;
700
701    let status = resp.status();
702    let content_type = resp
703        .headers()
704        .get("content-type")
705        .and_then(|v| v.to_str().ok())
706        .unwrap_or("application/octet-stream");
707    let content_type = super::ContentType::from(content_type);
708
709    if !status.is_client_error() && !status.is_server_error() {
710        let content = resp.text().await?;
711        match content_type {
712            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
713            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Worker&gt;`"))),
714            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::Worker&gt;`")))),
715        }
716    } else {
717        let content = resp.text().await?;
718        let entity: Option<TasksWorkersListError> = serde_json::from_str(&content).ok();
719        Err(Error::ResponseError(ResponseContent {
720            status,
721            content,
722            entity,
723        }))
724    }
725}