Skip to main content

windmill_api/apis/
concurrency_groups_api.rs

1/*
2 * Windmill API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.885.0
7 * Contact: contact@windmill.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`delete_concurrency_group`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteConcurrencyGroupError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_concurrency_key`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetConcurrencyKeyError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_concurrency_key_status`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetConcurrencyKeyStatusError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_concurrency_groups`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListConcurrencyGroupsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_extended_jobs`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListExtendedJobsError {
50    UnknownValue(serde_json::Value),
51}
52
53
54pub async fn delete_concurrency_group(configuration: &configuration::Configuration, concurrency_id: &str) -> Result<serde_json::Value, Error<DeleteConcurrencyGroupError>> {
55    let local_var_configuration = configuration;
56
57    let local_var_client = &local_var_configuration.client;
58
59    let local_var_uri_str = format!("{}/concurrency_groups/prune/{concurrency_id}", local_var_configuration.base_path, concurrency_id=crate::apis::urlencode(concurrency_id));
60    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
61
62    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
63        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
64    }
65    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
66        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
67    };
68
69    let local_var_req = local_var_req_builder.build()?;
70    let local_var_resp = local_var_client.execute(local_var_req).await?;
71
72    let local_var_status = local_var_resp.status();
73    let local_var_content = local_var_resp.text().await?;
74
75    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
76        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
77    } else {
78        let local_var_entity: Option<DeleteConcurrencyGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
79        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
80        Err(Error::ResponseError(local_var_error))
81    }
82}
83
84/// Requires read access to the job, the same as reading the run itself. Returns 403 for a workspace member who cannot see the run, and 404 when the caller is not a member of the job's workspace.
85pub async fn get_concurrency_key(configuration: &configuration::Configuration, id: &str) -> Result<String, Error<GetConcurrencyKeyError>> {
86    let local_var_configuration = configuration;
87
88    let local_var_client = &local_var_configuration.client;
89
90    let local_var_uri_str = format!("{}/concurrency_groups/{id}/key", local_var_configuration.base_path, id=crate::apis::urlencode(id));
91    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
92
93    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
94        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
95    }
96    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
97        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
98    };
99
100    let local_var_req = local_var_req_builder.build()?;
101    let local_var_resp = local_var_client.execute(local_var_req).await?;
102
103    let local_var_status = local_var_resp.status();
104    let local_var_content = local_var_resp.text().await?;
105
106    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
107        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
108    } else {
109        let local_var_entity: Option<GetConcurrencyKeyError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
110        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
111        Err(Error::ResponseError(local_var_error))
112    }
113}
114
115/// Requires read access to the job, the same as reading the run itself. Returns null when the job has no concurrency key.
116pub async fn get_concurrency_key_status(configuration: &configuration::Configuration, id: &str) -> Result<models::GetConcurrencyKeyStatus200Response, Error<GetConcurrencyKeyStatusError>> {
117    let local_var_configuration = configuration;
118
119    let local_var_client = &local_var_configuration.client;
120
121    let local_var_uri_str = format!("{}/concurrency_groups/{id}/key_status", local_var_configuration.base_path, id=crate::apis::urlencode(id));
122    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
123
124    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
125        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
126    }
127    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
128        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
129    };
130
131    let local_var_req = local_var_req_builder.build()?;
132    let local_var_resp = local_var_client.execute(local_var_req).await?;
133
134    let local_var_status = local_var_resp.status();
135    let local_var_content = local_var_resp.text().await?;
136
137    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
138        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
139    } else {
140        let local_var_entity: Option<GetConcurrencyKeyStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
141        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
142        Err(Error::ResponseError(local_var_error))
143    }
144}
145
146pub async fn list_concurrency_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ConcurrencyGroup>, Error<ListConcurrencyGroupsError>> {
147    let local_var_configuration = configuration;
148
149    let local_var_client = &local_var_configuration.client;
150
151    let local_var_uri_str = format!("{}/concurrency_groups/list", local_var_configuration.base_path);
152    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
153
154    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
155        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
156    }
157    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
158        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
159    };
160
161    let local_var_req = local_var_req_builder.build()?;
162    let local_var_resp = local_var_client.execute(local_var_req).await?;
163
164    let local_var_status = local_var_resp.status();
165    let local_var_content = local_var_resp.text().await?;
166
167    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
168        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
169    } else {
170        let local_var_entity: Option<ListConcurrencyGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
171        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
172        Err(Error::ResponseError(local_var_error))
173    }
174}
175
176pub async fn list_extended_jobs(configuration: &configuration::Configuration, workspace: &str, concurrency_key: Option<&str>, row_limit: Option<f64>, created_by: Option<&str>, label: Option<&str>, parent_job: Option<&str>, script_path_exact: Option<&str>, script_path_start: Option<&str>, schedule_path: Option<&str>, script_hash: Option<&str>, started_before: Option<String>, started_after: Option<String>, running: Option<bool>, scheduled_for_before_now: Option<bool>, completed_before: Option<String>, completed_after: Option<String>, created_before_queue: Option<String>, created_after_queue: Option<String>, job_kinds: Option<&str>, args: Option<&str>, tag: Option<&str>, result: Option<&str>, allow_wildcards: Option<bool>, page: Option<i32>, per_page: Option<i32>, trigger_kind: Option<&str>, is_skipped: Option<bool>, resolved: Option<bool>, is_flow_step: Option<bool>, has_null_parent: Option<bool>, success: Option<bool>, status: Option<&str>, all_workspaces: Option<bool>, is_not_schedule: Option<bool>) -> Result<models::ExtendedJobs, Error<ListExtendedJobsError>> {
177    let local_var_configuration = configuration;
178
179    let local_var_client = &local_var_configuration.client;
180
181    let local_var_uri_str = format!("{}/w/{workspace}/concurrency_groups/list_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
182    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
183
184    if let Some(ref local_var_str) = concurrency_key {
185        local_var_req_builder = local_var_req_builder.query(&[("concurrency_key", &local_var_str.to_string())]);
186    }
187    if let Some(ref local_var_str) = row_limit {
188        local_var_req_builder = local_var_req_builder.query(&[("row_limit", &local_var_str.to_string())]);
189    }
190    if let Some(ref local_var_str) = created_by {
191        local_var_req_builder = local_var_req_builder.query(&[("created_by", &local_var_str.to_string())]);
192    }
193    if let Some(ref local_var_str) = label {
194        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
195    }
196    if let Some(ref local_var_str) = parent_job {
197        local_var_req_builder = local_var_req_builder.query(&[("parent_job", &local_var_str.to_string())]);
198    }
199    if let Some(ref local_var_str) = script_path_exact {
200        local_var_req_builder = local_var_req_builder.query(&[("script_path_exact", &local_var_str.to_string())]);
201    }
202    if let Some(ref local_var_str) = script_path_start {
203        local_var_req_builder = local_var_req_builder.query(&[("script_path_start", &local_var_str.to_string())]);
204    }
205    if let Some(ref local_var_str) = schedule_path {
206        local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
207    }
208    if let Some(ref local_var_str) = script_hash {
209        local_var_req_builder = local_var_req_builder.query(&[("script_hash", &local_var_str.to_string())]);
210    }
211    if let Some(ref local_var_str) = started_before {
212        local_var_req_builder = local_var_req_builder.query(&[("started_before", &local_var_str.to_string())]);
213    }
214    if let Some(ref local_var_str) = started_after {
215        local_var_req_builder = local_var_req_builder.query(&[("started_after", &local_var_str.to_string())]);
216    }
217    if let Some(ref local_var_str) = running {
218        local_var_req_builder = local_var_req_builder.query(&[("running", &local_var_str.to_string())]);
219    }
220    if let Some(ref local_var_str) = scheduled_for_before_now {
221        local_var_req_builder = local_var_req_builder.query(&[("scheduled_for_before_now", &local_var_str.to_string())]);
222    }
223    if let Some(ref local_var_str) = completed_before {
224        local_var_req_builder = local_var_req_builder.query(&[("completed_before", &local_var_str.to_string())]);
225    }
226    if let Some(ref local_var_str) = completed_after {
227        local_var_req_builder = local_var_req_builder.query(&[("completed_after", &local_var_str.to_string())]);
228    }
229    if let Some(ref local_var_str) = created_before_queue {
230        local_var_req_builder = local_var_req_builder.query(&[("created_before_queue", &local_var_str.to_string())]);
231    }
232    if let Some(ref local_var_str) = created_after_queue {
233        local_var_req_builder = local_var_req_builder.query(&[("created_after_queue", &local_var_str.to_string())]);
234    }
235    if let Some(ref local_var_str) = job_kinds {
236        local_var_req_builder = local_var_req_builder.query(&[("job_kinds", &local_var_str.to_string())]);
237    }
238    if let Some(ref local_var_str) = args {
239        local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
240    }
241    if let Some(ref local_var_str) = tag {
242        local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
243    }
244    if let Some(ref local_var_str) = result {
245        local_var_req_builder = local_var_req_builder.query(&[("result", &local_var_str.to_string())]);
246    }
247    if let Some(ref local_var_str) = allow_wildcards {
248        local_var_req_builder = local_var_req_builder.query(&[("allow_wildcards", &local_var_str.to_string())]);
249    }
250    if let Some(ref local_var_str) = page {
251        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
252    }
253    if let Some(ref local_var_str) = per_page {
254        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
255    }
256    if let Some(ref local_var_str) = trigger_kind {
257        local_var_req_builder = local_var_req_builder.query(&[("trigger_kind", &local_var_str.to_string())]);
258    }
259    if let Some(ref local_var_str) = is_skipped {
260        local_var_req_builder = local_var_req_builder.query(&[("is_skipped", &local_var_str.to_string())]);
261    }
262    if let Some(ref local_var_str) = resolved {
263        local_var_req_builder = local_var_req_builder.query(&[("resolved", &local_var_str.to_string())]);
264    }
265    if let Some(ref local_var_str) = is_flow_step {
266        local_var_req_builder = local_var_req_builder.query(&[("is_flow_step", &local_var_str.to_string())]);
267    }
268    if let Some(ref local_var_str) = has_null_parent {
269        local_var_req_builder = local_var_req_builder.query(&[("has_null_parent", &local_var_str.to_string())]);
270    }
271    if let Some(ref local_var_str) = success {
272        local_var_req_builder = local_var_req_builder.query(&[("success", &local_var_str.to_string())]);
273    }
274    if let Some(ref local_var_str) = status {
275        local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
276    }
277    if let Some(ref local_var_str) = all_workspaces {
278        local_var_req_builder = local_var_req_builder.query(&[("all_workspaces", &local_var_str.to_string())]);
279    }
280    if let Some(ref local_var_str) = is_not_schedule {
281        local_var_req_builder = local_var_req_builder.query(&[("is_not_schedule", &local_var_str.to_string())]);
282    }
283    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
284        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
285    }
286    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
287        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
288    };
289
290    let local_var_req = local_var_req_builder.build()?;
291    let local_var_resp = local_var_client.execute(local_var_req).await?;
292
293    let local_var_status = local_var_resp.status();
294    let local_var_content = local_var_resp.text().await?;
295
296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
297        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
298    } else {
299        let local_var_entity: Option<ListExtendedJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
300        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
301        Err(Error::ResponseError(local_var_error))
302    }
303}
304