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.792.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 [`list_concurrency_groups`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ListConcurrencyGroupsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`list_extended_jobs`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ListExtendedJobsError {
43    UnknownValue(serde_json::Value),
44}
45
46
47pub async fn delete_concurrency_group(configuration: &configuration::Configuration, concurrency_id: &str) -> Result<serde_json::Value, Error<DeleteConcurrencyGroupError>> {
48    let local_var_configuration = configuration;
49
50    let local_var_client = &local_var_configuration.client;
51
52    let local_var_uri_str = format!("{}/concurrency_groups/prune/{concurrency_id}", local_var_configuration.base_path, concurrency_id=crate::apis::urlencode(concurrency_id));
53    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
54
55    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
56        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
57    }
58    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
59        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
60    };
61
62    let local_var_req = local_var_req_builder.build()?;
63    let local_var_resp = local_var_client.execute(local_var_req).await?;
64
65    let local_var_status = local_var_resp.status();
66    let local_var_content = local_var_resp.text().await?;
67
68    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
69        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
70    } else {
71        let local_var_entity: Option<DeleteConcurrencyGroupError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
72        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
73        Err(Error::ResponseError(local_var_error))
74    }
75}
76
77/// 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.
78pub async fn get_concurrency_key(configuration: &configuration::Configuration, id: &str) -> Result<String, Error<GetConcurrencyKeyError>> {
79    let local_var_configuration = configuration;
80
81    let local_var_client = &local_var_configuration.client;
82
83    let local_var_uri_str = format!("{}/concurrency_groups/{id}/key", local_var_configuration.base_path, id=crate::apis::urlencode(id));
84    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
85
86    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
87        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
88    }
89    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
90        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
91    };
92
93    let local_var_req = local_var_req_builder.build()?;
94    let local_var_resp = local_var_client.execute(local_var_req).await?;
95
96    let local_var_status = local_var_resp.status();
97    let local_var_content = local_var_resp.text().await?;
98
99    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
100        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
101    } else {
102        let local_var_entity: Option<GetConcurrencyKeyError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
103        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
104        Err(Error::ResponseError(local_var_error))
105    }
106}
107
108pub async fn list_concurrency_groups(configuration: &configuration::Configuration, ) -> Result<Vec<models::ConcurrencyGroup>, Error<ListConcurrencyGroupsError>> {
109    let local_var_configuration = configuration;
110
111    let local_var_client = &local_var_configuration.client;
112
113    let local_var_uri_str = format!("{}/concurrency_groups/list", local_var_configuration.base_path);
114    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
115
116    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
117        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
118    }
119    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
120        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
121    };
122
123    let local_var_req = local_var_req_builder.build()?;
124    let local_var_resp = local_var_client.execute(local_var_req).await?;
125
126    let local_var_status = local_var_resp.status();
127    let local_var_content = local_var_resp.text().await?;
128
129    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
130        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
131    } else {
132        let local_var_entity: Option<ListConcurrencyGroupsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
133        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
134        Err(Error::ResponseError(local_var_error))
135    }
136}
137
138pub 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>> {
139    let local_var_configuration = configuration;
140
141    let local_var_client = &local_var_configuration.client;
142
143    let local_var_uri_str = format!("{}/w/{workspace}/concurrency_groups/list_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
144    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
145
146    if let Some(ref local_var_str) = concurrency_key {
147        local_var_req_builder = local_var_req_builder.query(&[("concurrency_key", &local_var_str.to_string())]);
148    }
149    if let Some(ref local_var_str) = row_limit {
150        local_var_req_builder = local_var_req_builder.query(&[("row_limit", &local_var_str.to_string())]);
151    }
152    if let Some(ref local_var_str) = created_by {
153        local_var_req_builder = local_var_req_builder.query(&[("created_by", &local_var_str.to_string())]);
154    }
155    if let Some(ref local_var_str) = label {
156        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
157    }
158    if let Some(ref local_var_str) = parent_job {
159        local_var_req_builder = local_var_req_builder.query(&[("parent_job", &local_var_str.to_string())]);
160    }
161    if let Some(ref local_var_str) = script_path_exact {
162        local_var_req_builder = local_var_req_builder.query(&[("script_path_exact", &local_var_str.to_string())]);
163    }
164    if let Some(ref local_var_str) = script_path_start {
165        local_var_req_builder = local_var_req_builder.query(&[("script_path_start", &local_var_str.to_string())]);
166    }
167    if let Some(ref local_var_str) = schedule_path {
168        local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
169    }
170    if let Some(ref local_var_str) = script_hash {
171        local_var_req_builder = local_var_req_builder.query(&[("script_hash", &local_var_str.to_string())]);
172    }
173    if let Some(ref local_var_str) = started_before {
174        local_var_req_builder = local_var_req_builder.query(&[("started_before", &local_var_str.to_string())]);
175    }
176    if let Some(ref local_var_str) = started_after {
177        local_var_req_builder = local_var_req_builder.query(&[("started_after", &local_var_str.to_string())]);
178    }
179    if let Some(ref local_var_str) = running {
180        local_var_req_builder = local_var_req_builder.query(&[("running", &local_var_str.to_string())]);
181    }
182    if let Some(ref local_var_str) = scheduled_for_before_now {
183        local_var_req_builder = local_var_req_builder.query(&[("scheduled_for_before_now", &local_var_str.to_string())]);
184    }
185    if let Some(ref local_var_str) = completed_before {
186        local_var_req_builder = local_var_req_builder.query(&[("completed_before", &local_var_str.to_string())]);
187    }
188    if let Some(ref local_var_str) = completed_after {
189        local_var_req_builder = local_var_req_builder.query(&[("completed_after", &local_var_str.to_string())]);
190    }
191    if let Some(ref local_var_str) = created_before_queue {
192        local_var_req_builder = local_var_req_builder.query(&[("created_before_queue", &local_var_str.to_string())]);
193    }
194    if let Some(ref local_var_str) = created_after_queue {
195        local_var_req_builder = local_var_req_builder.query(&[("created_after_queue", &local_var_str.to_string())]);
196    }
197    if let Some(ref local_var_str) = job_kinds {
198        local_var_req_builder = local_var_req_builder.query(&[("job_kinds", &local_var_str.to_string())]);
199    }
200    if let Some(ref local_var_str) = args {
201        local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
202    }
203    if let Some(ref local_var_str) = tag {
204        local_var_req_builder = local_var_req_builder.query(&[("tag", &local_var_str.to_string())]);
205    }
206    if let Some(ref local_var_str) = result {
207        local_var_req_builder = local_var_req_builder.query(&[("result", &local_var_str.to_string())]);
208    }
209    if let Some(ref local_var_str) = allow_wildcards {
210        local_var_req_builder = local_var_req_builder.query(&[("allow_wildcards", &local_var_str.to_string())]);
211    }
212    if let Some(ref local_var_str) = page {
213        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
214    }
215    if let Some(ref local_var_str) = per_page {
216        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
217    }
218    if let Some(ref local_var_str) = trigger_kind {
219        local_var_req_builder = local_var_req_builder.query(&[("trigger_kind", &local_var_str.to_string())]);
220    }
221    if let Some(ref local_var_str) = is_skipped {
222        local_var_req_builder = local_var_req_builder.query(&[("is_skipped", &local_var_str.to_string())]);
223    }
224    if let Some(ref local_var_str) = resolved {
225        local_var_req_builder = local_var_req_builder.query(&[("resolved", &local_var_str.to_string())]);
226    }
227    if let Some(ref local_var_str) = is_flow_step {
228        local_var_req_builder = local_var_req_builder.query(&[("is_flow_step", &local_var_str.to_string())]);
229    }
230    if let Some(ref local_var_str) = has_null_parent {
231        local_var_req_builder = local_var_req_builder.query(&[("has_null_parent", &local_var_str.to_string())]);
232    }
233    if let Some(ref local_var_str) = success {
234        local_var_req_builder = local_var_req_builder.query(&[("success", &local_var_str.to_string())]);
235    }
236    if let Some(ref local_var_str) = status {
237        local_var_req_builder = local_var_req_builder.query(&[("status", &local_var_str.to_string())]);
238    }
239    if let Some(ref local_var_str) = all_workspaces {
240        local_var_req_builder = local_var_req_builder.query(&[("all_workspaces", &local_var_str.to_string())]);
241    }
242    if let Some(ref local_var_str) = is_not_schedule {
243        local_var_req_builder = local_var_req_builder.query(&[("is_not_schedule", &local_var_str.to_string())]);
244    }
245    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
246        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
247    }
248    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
249        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
250    };
251
252    let local_var_req = local_var_req_builder.build()?;
253    let local_var_resp = local_var_client.execute(local_var_req).await?;
254
255    let local_var_status = local_var_resp.status();
256    let local_var_content = local_var_resp.text().await?;
257
258    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
259        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
260    } else {
261        let local_var_entity: Option<ListExtendedJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
262        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
263        Err(Error::ResponseError(local_var_error))
264    }
265}
266