windmill_api/apis/
http_trigger_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.579.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_http_trigger`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateHttpTriggerError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`create_http_triggers`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateHttpTriggersError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`delete_http_trigger`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteHttpTriggerError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`exists_http_trigger`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ExistsHttpTriggerError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`exists_route`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ExistsRouteError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_http_trigger`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetHttpTriggerError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_http_triggers`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListHttpTriggersError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`set_http_trigger_enabled`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum SetHttpTriggerEnabledError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`update_http_trigger`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum UpdateHttpTriggerError {
78    UnknownValue(serde_json::Value),
79}
80
81
82pub async fn create_http_trigger(configuration: &configuration::Configuration, workspace: &str, new_http_trigger: models::NewHttpTrigger) -> Result<String, Error<CreateHttpTriggerError>> {
83    let local_var_configuration = configuration;
84
85    let local_var_client = &local_var_configuration.client;
86
87    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
88    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
89
90    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
91        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
92    }
93    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
94        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
95    };
96    local_var_req_builder = local_var_req_builder.json(&new_http_trigger);
97
98    let local_var_req = local_var_req_builder.build()?;
99    let local_var_resp = local_var_client.execute(local_var_req).await?;
100
101    let local_var_status = local_var_resp.status();
102    let local_var_content = local_var_resp.text().await?;
103
104    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
105        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
106    } else {
107        let local_var_entity: Option<CreateHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
108        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
109        Err(Error::ResponseError(local_var_error))
110    }
111}
112
113pub async fn create_http_triggers(configuration: &configuration::Configuration, workspace: &str, new_http_trigger: Vec<models::NewHttpTrigger>) -> Result<String, Error<CreateHttpTriggersError>> {
114    let local_var_configuration = configuration;
115
116    let local_var_client = &local_var_configuration.client;
117
118    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/create_many", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
119    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
122        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
123    }
124    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
125        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
126    };
127    local_var_req_builder = local_var_req_builder.json(&new_http_trigger);
128
129    let local_var_req = local_var_req_builder.build()?;
130    let local_var_resp = local_var_client.execute(local_var_req).await?;
131
132    let local_var_status = local_var_resp.status();
133    let local_var_content = local_var_resp.text().await?;
134
135    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
136        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
137    } else {
138        let local_var_entity: Option<CreateHttpTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
139        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
140        Err(Error::ResponseError(local_var_error))
141    }
142}
143
144pub async fn delete_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteHttpTriggerError>> {
145    let local_var_configuration = configuration;
146
147    let local_var_client = &local_var_configuration.client;
148
149    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
150    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
151
152    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
153        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
154    }
155    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
156        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
157    };
158
159    let local_var_req = local_var_req_builder.build()?;
160    let local_var_resp = local_var_client.execute(local_var_req).await?;
161
162    let local_var_status = local_var_resp.status();
163    let local_var_content = local_var_resp.text().await?;
164
165    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
166        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
167    } else {
168        let local_var_entity: Option<DeleteHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
169        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
170        Err(Error::ResponseError(local_var_error))
171    }
172}
173
174pub async fn exists_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsHttpTriggerError>> {
175    let local_var_configuration = configuration;
176
177    let local_var_client = &local_var_configuration.client;
178
179    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
180    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
181
182    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
184    }
185    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
186        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
187    };
188
189    let local_var_req = local_var_req_builder.build()?;
190    let local_var_resp = local_var_client.execute(local_var_req).await?;
191
192    let local_var_status = local_var_resp.status();
193    let local_var_content = local_var_resp.text().await?;
194
195    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
196        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
197    } else {
198        let local_var_entity: Option<ExistsHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
199        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
200        Err(Error::ResponseError(local_var_error))
201    }
202}
203
204pub async fn exists_route(configuration: &configuration::Configuration, workspace: &str, exists_route_request: models::ExistsRouteRequest) -> Result<bool, Error<ExistsRouteError>> {
205    let local_var_configuration = configuration;
206
207    let local_var_client = &local_var_configuration.client;
208
209    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/route_exists", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
210    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
211
212    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
213        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
214    }
215    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
216        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
217    };
218    local_var_req_builder = local_var_req_builder.json(&exists_route_request);
219
220    let local_var_req = local_var_req_builder.build()?;
221    let local_var_resp = local_var_client.execute(local_var_req).await?;
222
223    let local_var_status = local_var_resp.status();
224    let local_var_content = local_var_resp.text().await?;
225
226    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
227        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
228    } else {
229        let local_var_entity: Option<ExistsRouteError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
230        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
231        Err(Error::ResponseError(local_var_error))
232    }
233}
234
235pub async fn get_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::HttpTrigger, Error<GetHttpTriggerError>> {
236    let local_var_configuration = configuration;
237
238    let local_var_client = &local_var_configuration.client;
239
240    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
241    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
242
243    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
244        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
245    }
246    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
247        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
248    };
249
250    let local_var_req = local_var_req_builder.build()?;
251    let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253    let local_var_status = local_var_resp.status();
254    let local_var_content = local_var_resp.text().await?;
255
256    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
258    } else {
259        let local_var_entity: Option<GetHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
260        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
261        Err(Error::ResponseError(local_var_error))
262    }
263}
264
265pub async fn list_http_triggers(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, path: Option<&str>, is_flow: Option<bool>, path_start: Option<&str>) -> Result<Vec<models::HttpTrigger>, Error<ListHttpTriggersError>> {
266    let local_var_configuration = configuration;
267
268    let local_var_client = &local_var_configuration.client;
269
270    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
271    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
272
273    if let Some(ref local_var_str) = page {
274        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
275    }
276    if let Some(ref local_var_str) = per_page {
277        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
278    }
279    if let Some(ref local_var_str) = path {
280        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
281    }
282    if let Some(ref local_var_str) = is_flow {
283        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
284    }
285    if let Some(ref local_var_str) = path_start {
286        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
287    }
288    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
289        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
290    }
291    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
292        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
293    };
294
295    let local_var_req = local_var_req_builder.build()?;
296    let local_var_resp = local_var_client.execute(local_var_req).await?;
297
298    let local_var_status = local_var_resp.status();
299    let local_var_content = local_var_resp.text().await?;
300
301    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
302        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
303    } else {
304        let local_var_entity: Option<ListHttpTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
305        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
306        Err(Error::ResponseError(local_var_error))
307    }
308}
309
310pub async fn set_http_trigger_enabled(configuration: &configuration::Configuration, workspace: &str, path: &str, set_schedule_enabled_request: models::SetScheduleEnabledRequest) -> Result<String, Error<SetHttpTriggerEnabledError>> {
311    let local_var_configuration = configuration;
312
313    let local_var_client = &local_var_configuration.client;
314
315    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/setenabled/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
316    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
317
318    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
319        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
320    }
321    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
322        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
323    };
324    local_var_req_builder = local_var_req_builder.json(&set_schedule_enabled_request);
325
326    let local_var_req = local_var_req_builder.build()?;
327    let local_var_resp = local_var_client.execute(local_var_req).await?;
328
329    let local_var_status = local_var_resp.status();
330    let local_var_content = local_var_resp.text().await?;
331
332    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
333        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
334    } else {
335        let local_var_entity: Option<SetHttpTriggerEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
336        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
337        Err(Error::ResponseError(local_var_error))
338    }
339}
340
341pub async fn update_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_http_trigger: models::EditHttpTrigger) -> Result<String, Error<UpdateHttpTriggerError>> {
342    let local_var_configuration = configuration;
343
344    let local_var_client = &local_var_configuration.client;
345
346    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
347    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
348
349    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
350        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
351    }
352    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
353        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
354    };
355    local_var_req_builder = local_var_req_builder.json(&edit_http_trigger);
356
357    let local_var_req = local_var_req_builder.build()?;
358    let local_var_resp = local_var_client.execute(local_var_req).await?;
359
360    let local_var_status = local_var_resp.status();
361    let local_var_content = local_var_resp.text().await?;
362
363    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
364        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
365    } else {
366        let local_var_entity: Option<UpdateHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
367        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
368        Err(Error::ResponseError(local_var_error))
369    }
370}
371