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.644.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>) -> 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_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<ListSchedulesError> = 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
267pub async fn list_schedules_with_jobs(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>) -> Result<Vec<models::ScheduleWJobs>, Error<ListSchedulesWithJobsError>> {
268    let local_var_configuration = configuration;
269
270    let local_var_client = &local_var_configuration.client;
271
272    let local_var_uri_str = format!("{}/w/{workspace}/schedules/list_with_jobs", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
273    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
274
275    if let Some(ref local_var_str) = page {
276        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
277    }
278    if let Some(ref local_var_str) = per_page {
279        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
280    }
281    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
282        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
283    }
284    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
285        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
286    };
287
288    let local_var_req = local_var_req_builder.build()?;
289    let local_var_resp = local_var_client.execute(local_var_req).await?;
290
291    let local_var_status = local_var_resp.status();
292    let local_var_content = local_var_resp.text().await?;
293
294    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
295        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
296    } else {
297        let local_var_entity: Option<ListSchedulesWithJobsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
298        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
299        Err(Error::ResponseError(local_var_error))
300    }
301}
302
303pub async fn preview_schedule(configuration: &configuration::Configuration, preview_schedule_request: models::PreviewScheduleRequest) -> Result<Vec<String>, Error<PreviewScheduleError>> {
304    let local_var_configuration = configuration;
305
306    let local_var_client = &local_var_configuration.client;
307
308    let local_var_uri_str = format!("{}/schedules/preview", local_var_configuration.base_path);
309    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
310
311    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
312        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
313    }
314    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
315        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
316    };
317    local_var_req_builder = local_var_req_builder.json(&preview_schedule_request);
318
319    let local_var_req = local_var_req_builder.build()?;
320    let local_var_resp = local_var_client.execute(local_var_req).await?;
321
322    let local_var_status = local_var_resp.status();
323    let local_var_content = local_var_resp.text().await?;
324
325    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
326        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
327    } else {
328        let local_var_entity: Option<PreviewScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
329        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
330        Err(Error::ResponseError(local_var_error))
331    }
332}
333
334pub 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>> {
335    let local_var_configuration = configuration;
336
337    let local_var_client = &local_var_configuration.client;
338
339    let local_var_uri_str = format!("{}/w/{workspace}/schedules/setdefaulthandler", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
340    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
341
342    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
343        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
344    }
345    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
346        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
347    };
348    local_var_req_builder = local_var_req_builder.json(&set_default_error_or_recovery_handler_request);
349
350    let local_var_req = local_var_req_builder.build()?;
351    let local_var_resp = local_var_client.execute(local_var_req).await?;
352
353    let local_var_status = local_var_resp.status();
354    let local_var_content = local_var_resp.text().await?;
355
356    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
357        Ok(())
358    } else {
359        let local_var_entity: Option<SetDefaultErrorOrRecoveryHandlerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
360        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
361        Err(Error::ResponseError(local_var_error))
362    }
363}
364
365pub async fn set_schedule_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetScheduleEnabledError>> {
366    let local_var_configuration = configuration;
367
368    let local_var_client = &local_var_configuration.client;
369
370    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));
371    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
374        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
375    }
376    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
377        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
378    };
379    local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
380
381    let local_var_req = local_var_req_builder.build()?;
382    let local_var_resp = local_var_client.execute(local_var_req).await?;
383
384    let local_var_status = local_var_resp.status();
385    let local_var_content = local_var_resp.text().await?;
386
387    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
388        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
389    } else {
390        let local_var_entity: Option<SetScheduleEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
391        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
392        Err(Error::ResponseError(local_var_error))
393    }
394}
395
396pub async fn update_schedule(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_schedule: models::EditSchedule) -> Result<String, Error<UpdateScheduleError>> {
397    let local_var_configuration = configuration;
398
399    let local_var_client = &local_var_configuration.client;
400
401    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));
402    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
403
404    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406    }
407    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
408        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
409    };
410    local_var_req_builder = local_var_req_builder.json(&edit_schedule);
411
412    let local_var_req = local_var_req_builder.build()?;
413    let local_var_resp = local_var_client.execute(local_var_req).await?;
414
415    let local_var_status = local_var_resp.status();
416    let local_var_content = local_var_resp.text().await?;
417
418    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
419        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
420    } else {
421        let local_var_entity: Option<UpdateScheduleError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
422        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
423        Err(Error::ResponseError(local_var_error))
424    }
425}
426