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