Skip to main content

windmill_api/apis/
schedule_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.727.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 [`create_schedule`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateScheduleError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_schedule`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteScheduleError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`exists_schedule`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ExistsScheduleError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_schedule`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetScheduleError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_schedules`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListSchedulesError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_schedules_with_jobs`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListSchedulesWithJobsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`preview_schedule`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PreviewScheduleError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`set_default_error_or_recovery_handler`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum SetDefaultErrorOrRecoveryHandlerError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`set_schedule_enabled`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum SetScheduleEnabledError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`update_schedule`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum UpdateScheduleError {
85    UnknownValue(serde_json::Value),
86}
87
88
89pub async fn create_schedule(configuration: &configuration::Configuration, workspace: &str, new_schedule: models::NewSchedule) -> Result<String, Error<CreateScheduleError>> {
90    let local_var_configuration = configuration;
91
92    let local_var_client = &local_var_configuration.client;
93
94    let local_var_uri_str = format!("{}/w/{workspace}/schedules/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
95    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
96
97    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
98        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
99    }
100    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
101        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
102    };
103    local_var_req_builder = local_var_req_builder.json(&new_schedule);
104
105    let local_var_req = local_var_req_builder.build()?;
106    let local_var_resp = local_var_client.execute(local_var_req).await?;
107
108    let local_var_status = local_var_resp.status();
109    let local_var_content = local_var_resp.text().await?;
110
111    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
112        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
113    } else {
114        let local_var_entity: Option<CreateScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
115        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
116        Err(Error::ResponseError(local_var_error))
117    }
118}
119
120pub async fn delete_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteScheduleError>> {
121    let local_var_configuration = configuration;
122
123    let local_var_client = &local_var_configuration.client;
124
125    let local_var_uri_str = format!("{}/w/{workspace}/schedules/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
126    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
127
128    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
129        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
130    }
131    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
132        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
133    };
134
135    let local_var_req = local_var_req_builder.build()?;
136    let local_var_resp = local_var_client.execute(local_var_req).await?;
137
138    let local_var_status = local_var_resp.status();
139    let local_var_content = local_var_resp.text().await?;
140
141    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
142        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
143    } else {
144        let local_var_entity: Option<DeleteScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
145        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
146        Err(Error::ResponseError(local_var_error))
147    }
148}
149
150pub async fn exists_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsScheduleError>> {
151    let local_var_configuration = configuration;
152
153    let local_var_client = &local_var_configuration.client;
154
155    let local_var_uri_str = format!("{}/w/{workspace}/schedules/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
156    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
157
158    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
159        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
160    }
161    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
162        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
163    };
164
165    let local_var_req = local_var_req_builder.build()?;
166    let local_var_resp = local_var_client.execute(local_var_req).await?;
167
168    let local_var_status = local_var_resp.status();
169    let local_var_content = local_var_resp.text().await?;
170
171    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
172        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
173    } else {
174        let local_var_entity: Option<ExistsScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
175        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
176        Err(Error::ResponseError(local_var_error))
177    }
178}
179
180pub async fn get_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str, get_draft: Option<bool>) -> Result<models::GetSchedule200Response, Error<GetScheduleError>> {
181    let local_var_configuration = configuration;
182
183    let local_var_client = &local_var_configuration.client;
184
185    let local_var_uri_str = format!("{}/w/{workspace}/schedules/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
186    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
187
188    if let Some(ref local_var_str) = get_draft {
189        local_var_req_builder = local_var_req_builder.query(&[("get_draft", &local_var_str.to_string())]);
190    }
191    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
192        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
193    }
194    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
195        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
196    };
197
198    let local_var_req = local_var_req_builder.build()?;
199    let local_var_resp = local_var_client.execute(local_var_req).await?;
200
201    let local_var_status = local_var_resp.status();
202    let local_var_content = local_var_resp.text().await?;
203
204    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
205        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
206    } else {
207        let local_var_entity: Option<GetScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
208        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
209        Err(Error::ResponseError(local_var_error))
210    }
211}
212
213pub async fn list_schedules(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, args: Option<&str>, path: Option<&str>, is_flow: Option<bool>, path_start: Option<&str>, schedule_path: Option<&str>, description: Option<&str>, summary: Option<&str>, broad_filter: Option<&str>, label: Option<&str>, include_draft_only: Option<bool>) -> Result<Vec<models::Schedule>, Error<ListSchedulesError>> {
214    let local_var_configuration = configuration;
215
216    let local_var_client = &local_var_configuration.client;
217
218    let local_var_uri_str = format!("{}/w/{workspace}/schedules/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
219    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
220
221    if let Some(ref local_var_str) = page {
222        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
223    }
224    if let Some(ref local_var_str) = per_page {
225        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
226    }
227    if let Some(ref local_var_str) = args {
228        local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
229    }
230    if let Some(ref local_var_str) = path {
231        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
232    }
233    if let Some(ref local_var_str) = is_flow {
234        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
235    }
236    if let Some(ref local_var_str) = path_start {
237        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
238    }
239    if let Some(ref local_var_str) = schedule_path {
240        local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
241    }
242    if let Some(ref local_var_str) = description {
243        local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
244    }
245    if let Some(ref local_var_str) = summary {
246        local_var_req_builder = local_var_req_builder.query(&[("summary", &local_var_str.to_string())]);
247    }
248    if let Some(ref local_var_str) = broad_filter {
249        local_var_req_builder = local_var_req_builder.query(&[("broad_filter", &local_var_str.to_string())]);
250    }
251    if let Some(ref local_var_str) = label {
252        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
253    }
254    if let Some(ref local_var_str) = include_draft_only {
255        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
256    }
257    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
258        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
259    }
260    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
261        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
262    };
263
264    let local_var_req = local_var_req_builder.build()?;
265    let local_var_resp = local_var_client.execute(local_var_req).await?;
266
267    let local_var_status = local_var_resp.status();
268    let local_var_content = local_var_resp.text().await?;
269
270    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
271        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
272    } else {
273        let local_var_entity: Option<ListSchedulesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
274        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
275        Err(Error::ResponseError(local_var_error))
276    }
277}
278
279pub async fn list_schedules_with_jobs(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::ScheduleWJobs>, Error<ListSchedulesWithJobsError>> {
280    let local_var_configuration = configuration;
281
282    let local_var_client = &local_var_configuration.client;
283
284    let local_var_uri_str = format!("{}/w/{workspace}/schedules/list_with_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
285    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
286
287    if let Some(ref local_var_str) = page {
288        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
289    }
290    if let Some(ref local_var_str) = per_page {
291        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
292    }
293    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
294        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
295    }
296    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
297        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
298    };
299
300    let local_var_req = local_var_req_builder.build()?;
301    let local_var_resp = local_var_client.execute(local_var_req).await?;
302
303    let local_var_status = local_var_resp.status();
304    let local_var_content = local_var_resp.text().await?;
305
306    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
307        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
308    } else {
309        let local_var_entity: Option<ListSchedulesWithJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
310        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
311        Err(Error::ResponseError(local_var_error))
312    }
313}
314
315pub async fn preview_schedule(configuration: &configuration::Configuration, preview_schedule_request: models::PreviewScheduleRequest) -> Result<Vec<String>, Error<PreviewScheduleError>> {
316    let local_var_configuration = configuration;
317
318    let local_var_client = &local_var_configuration.client;
319
320    let local_var_uri_str = format!("{}/schedules/preview", local_var_configuration.base_path);
321    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
322
323    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
324        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
325    }
326    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
327        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
328    };
329    local_var_req_builder = local_var_req_builder.json(&preview_schedule_request);
330
331    let local_var_req = local_var_req_builder.build()?;
332    let local_var_resp = local_var_client.execute(local_var_req).await?;
333
334    let local_var_status = local_var_resp.status();
335    let local_var_content = local_var_resp.text().await?;
336
337    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
338        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
339    } else {
340        let local_var_entity: Option<PreviewScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
341        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
342        Err(Error::ResponseError(local_var_error))
343    }
344}
345
346pub async fn set_default_error_or_recovery_handler(configuration: &configuration::Configuration, workspace: &str, set_default_error_or_recovery_handler_request: models::SetDefaultErrorOrRecoveryHandlerRequest) -> Result<(), Error<SetDefaultErrorOrRecoveryHandlerError>> {
347    let local_var_configuration = configuration;
348
349    let local_var_client = &local_var_configuration.client;
350
351    let local_var_uri_str = format!("{}/w/{workspace}/schedules/setdefaulthandler", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
352    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
353
354    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
355        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
356    }
357    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
358        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
359    };
360    local_var_req_builder = local_var_req_builder.json(&set_default_error_or_recovery_handler_request);
361
362    let local_var_req = local_var_req_builder.build()?;
363    let local_var_resp = local_var_client.execute(local_var_req).await?;
364
365    let local_var_status = local_var_resp.status();
366    let local_var_content = local_var_resp.text().await?;
367
368    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
369        Ok(())
370    } else {
371        let local_var_entity: Option<SetDefaultErrorOrRecoveryHandlerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
372        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
373        Err(Error::ResponseError(local_var_error))
374    }
375}
376
377pub async fn set_schedule_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetScheduleEnabledError>> {
378    let local_var_configuration = configuration;
379
380    let local_var_client = &local_var_configuration.client;
381
382    let local_var_uri_str = format!("{}/w/{workspace}/schedules/setenabled/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
383    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
384
385    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
386        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
387    }
388    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
389        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
390    };
391    local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
392
393    let local_var_req = local_var_req_builder.build()?;
394    let local_var_resp = local_var_client.execute(local_var_req).await?;
395
396    let local_var_status = local_var_resp.status();
397    let local_var_content = local_var_resp.text().await?;
398
399    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
400        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
401    } else {
402        let local_var_entity: Option<SetScheduleEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
403        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
404        Err(Error::ResponseError(local_var_error))
405    }
406}
407
408pub async fn update_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_schedule: models::EditSchedule) -> Result<String, Error<UpdateScheduleError>> {
409    let local_var_configuration = configuration;
410
411    let local_var_client = &local_var_configuration.client;
412
413    let local_var_uri_str = format!("{}/w/{workspace}/schedules/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
414    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
415
416    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
417        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
418    }
419    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
420        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
421    };
422    local_var_req_builder = local_var_req_builder.json(&edit_schedule);
423
424    let local_var_req = local_var_req_builder.build()?;
425    let local_var_resp = local_var_client.execute(local_var_req).await?;
426
427    let local_var_status = local_var_resp.status();
428    let local_var_content = local_var_resp.text().await?;
429
430    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
431        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
432    } else {
433        let local_var_entity: Option<UpdateScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
434        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
435        Err(Error::ResponseError(local_var_error))
436    }
437}
438