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.654.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) -> Result<models::Schedule, 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_user_agent) = local_var_configuration.user_agent {
189        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
190    }
191    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
192        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
193    };
194
195    let local_var_req = local_var_req_builder.build()?;
196    let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198    let local_var_status = local_var_resp.status();
199    let local_var_content = local_var_resp.text().await?;
200
201    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
203    } else {
204        let local_var_entity: Option<GetScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
205        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
206        Err(Error::ResponseError(local_var_error))
207    }
208}
209
210pub 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>) -> Result<Vec<models::Schedule>, Error<ListSchedulesError>> {
211    let local_var_configuration = configuration;
212
213    let local_var_client = &local_var_configuration.client;
214
215    let local_var_uri_str = format!("{}/w/{workspace}/schedules/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
216    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
217
218    if let Some(ref local_var_str) = page {
219        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
220    }
221    if let Some(ref local_var_str) = per_page {
222        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
223    }
224    if let Some(ref local_var_str) = args {
225        local_var_req_builder = local_var_req_builder.query(&[("args", &local_var_str.to_string())]);
226    }
227    if let Some(ref local_var_str) = path {
228        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
229    }
230    if let Some(ref local_var_str) = is_flow {
231        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
232    }
233    if let Some(ref local_var_str) = path_start {
234        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
235    }
236    if let Some(ref local_var_str) = schedule_path {
237        local_var_req_builder = local_var_req_builder.query(&[("schedule_path", &local_var_str.to_string())]);
238    }
239    if let Some(ref local_var_str) = description {
240        local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
241    }
242    if let Some(ref local_var_str) = summary {
243        local_var_req_builder = local_var_req_builder.query(&[("summary", &local_var_str.to_string())]);
244    }
245    if let Some(ref local_var_str) = broad_filter {
246        local_var_req_builder = local_var_req_builder.query(&[("broad_filter", &local_var_str.to_string())]);
247    }
248    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
249        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
250    }
251    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
252        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
253    };
254
255    let local_var_req = local_var_req_builder.build()?;
256    let local_var_resp = local_var_client.execute(local_var_req).await?;
257
258    let local_var_status = local_var_resp.status();
259    let local_var_content = local_var_resp.text().await?;
260
261    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
262        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
263    } else {
264        let local_var_entity: Option<ListSchedulesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
265        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
266        Err(Error::ResponseError(local_var_error))
267    }
268}
269
270pub async fn list_schedules_with_jobs(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::ScheduleWJobs>, Error<ListSchedulesWithJobsError>> {
271    let local_var_configuration = configuration;
272
273    let local_var_client = &local_var_configuration.client;
274
275    let local_var_uri_str = format!("{}/w/{workspace}/schedules/list_with_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
276    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
277
278    if let Some(ref local_var_str) = page {
279        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
280    }
281    if let Some(ref local_var_str) = per_page {
282        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
283    }
284    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
285        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
286    }
287    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
288        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
289    };
290
291    let local_var_req = local_var_req_builder.build()?;
292    let local_var_resp = local_var_client.execute(local_var_req).await?;
293
294    let local_var_status = local_var_resp.status();
295    let local_var_content = local_var_resp.text().await?;
296
297    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
298        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
299    } else {
300        let local_var_entity: Option<ListSchedulesWithJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
301        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
302        Err(Error::ResponseError(local_var_error))
303    }
304}
305
306pub async fn preview_schedule(configuration: &configuration::Configuration, preview_schedule_request: models::PreviewScheduleRequest) -> Result<Vec<String>, Error<PreviewScheduleError>> {
307    let local_var_configuration = configuration;
308
309    let local_var_client = &local_var_configuration.client;
310
311    let local_var_uri_str = format!("{}/schedules/preview", local_var_configuration.base_path);
312    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
313
314    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
315        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
316    }
317    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
318        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
319    };
320    local_var_req_builder = local_var_req_builder.json(&preview_schedule_request);
321
322    let local_var_req = local_var_req_builder.build()?;
323    let local_var_resp = local_var_client.execute(local_var_req).await?;
324
325    let local_var_status = local_var_resp.status();
326    let local_var_content = local_var_resp.text().await?;
327
328    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
329        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
330    } else {
331        let local_var_entity: Option<PreviewScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
332        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
333        Err(Error::ResponseError(local_var_error))
334    }
335}
336
337pub 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>> {
338    let local_var_configuration = configuration;
339
340    let local_var_client = &local_var_configuration.client;
341
342    let local_var_uri_str = format!("{}/w/{workspace}/schedules/setdefaulthandler", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
343    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
344
345    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
346        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
347    }
348    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
349        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
350    };
351    local_var_req_builder = local_var_req_builder.json(&set_default_error_or_recovery_handler_request);
352
353    let local_var_req = local_var_req_builder.build()?;
354    let local_var_resp = local_var_client.execute(local_var_req).await?;
355
356    let local_var_status = local_var_resp.status();
357    let local_var_content = local_var_resp.text().await?;
358
359    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
360        Ok(())
361    } else {
362        let local_var_entity: Option<SetDefaultErrorOrRecoveryHandlerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
363        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
364        Err(Error::ResponseError(local_var_error))
365    }
366}
367
368pub async fn set_schedule_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetScheduleEnabledError>> {
369    let local_var_configuration = configuration;
370
371    let local_var_client = &local_var_configuration.client;
372
373    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));
374    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
375
376    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
377        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378    }
379    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
380        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
381    };
382    local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
383
384    let local_var_req = local_var_req_builder.build()?;
385    let local_var_resp = local_var_client.execute(local_var_req).await?;
386
387    let local_var_status = local_var_resp.status();
388    let local_var_content = local_var_resp.text().await?;
389
390    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
391        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
392    } else {
393        let local_var_entity: Option<SetScheduleEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
394        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
395        Err(Error::ResponseError(local_var_error))
396    }
397}
398
399pub async fn update_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_schedule: models::EditSchedule) -> Result<String, Error<UpdateScheduleError>> {
400    let local_var_configuration = configuration;
401
402    let local_var_client = &local_var_configuration.client;
403
404    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));
405    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
406
407    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
408        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
409    }
410    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
411        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
412    };
413    local_var_req_builder = local_var_req_builder.json(&edit_schedule);
414
415    let local_var_req = local_var_req_builder.build()?;
416    let local_var_resp = local_var_client.execute(local_var_req).await?;
417
418    let local_var_status = local_var_resp.status();
419    let local_var_content = local_var_resp.text().await?;
420
421    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
422        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
423    } else {
424        let local_var_entity: Option<UpdateScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
425        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
426        Err(Error::ResponseError(local_var_error))
427    }
428}
429