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.505.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_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 [`update_http_trigger`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum UpdateHttpTriggerError {
71    UnknownValue(serde_json::Value),
72}
73
74
75pub async fn create_http_trigger(configuration: &configuration::Configuration, workspace: &str, new_http_trigger: models::NewHttpTrigger) -> Result<String, Error<CreateHttpTriggerError>> {
76    let local_var_configuration = configuration;
77
78    let local_var_client = &local_var_configuration.client;
79
80    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
81    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
82
83    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
84        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
85    }
86    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
87        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
88    };
89    local_var_req_builder = local_var_req_builder.json(&new_http_trigger);
90
91    let local_var_req = local_var_req_builder.build()?;
92    let local_var_resp = local_var_client.execute(local_var_req).await?;
93
94    let local_var_status = local_var_resp.status();
95    let local_var_content = local_var_resp.text().await?;
96
97    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
98        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
99    } else {
100        let local_var_entity: Option<CreateHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
101        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
102        Err(Error::ResponseError(local_var_error))
103    }
104}
105
106pub async fn create_http_triggers(configuration: &configuration::Configuration, workspace: &str, new_http_trigger: Vec<models::NewHttpTrigger>) -> Result<String, Error<CreateHttpTriggersError>> {
107    let local_var_configuration = configuration;
108
109    let local_var_client = &local_var_configuration.client;
110
111    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/create_many", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
112    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
113
114    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
115        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
116    }
117    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
118        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
119    };
120    local_var_req_builder = local_var_req_builder.json(&new_http_trigger);
121
122    let local_var_req = local_var_req_builder.build()?;
123    let local_var_resp = local_var_client.execute(local_var_req).await?;
124
125    let local_var_status = local_var_resp.status();
126    let local_var_content = local_var_resp.text().await?;
127
128    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
129        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
130    } else {
131        let local_var_entity: Option<CreateHttpTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
132        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
133        Err(Error::ResponseError(local_var_error))
134    }
135}
136
137pub async fn delete_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteHttpTriggerError>> {
138    let local_var_configuration = configuration;
139
140    let local_var_client = &local_var_configuration.client;
141
142    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));
143    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
144
145    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
146        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
147    }
148    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
149        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
150    };
151
152    let local_var_req = local_var_req_builder.build()?;
153    let local_var_resp = local_var_client.execute(local_var_req).await?;
154
155    let local_var_status = local_var_resp.status();
156    let local_var_content = local_var_resp.text().await?;
157
158    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
159        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
160    } else {
161        let local_var_entity: Option<DeleteHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
162        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
163        Err(Error::ResponseError(local_var_error))
164    }
165}
166
167pub async fn exists_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsHttpTriggerError>> {
168    let local_var_configuration = configuration;
169
170    let local_var_client = &local_var_configuration.client;
171
172    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));
173    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
176        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
177    }
178    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
179        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
180    };
181
182    let local_var_req = local_var_req_builder.build()?;
183    let local_var_resp = local_var_client.execute(local_var_req).await?;
184
185    let local_var_status = local_var_resp.status();
186    let local_var_content = local_var_resp.text().await?;
187
188    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
189        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
190    } else {
191        let local_var_entity: Option<ExistsHttpTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
192        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
193        Err(Error::ResponseError(local_var_error))
194    }
195}
196
197pub async fn exists_route(configuration: &configuration::Configuration, workspace: &str, exists_route_request: models::ExistsRouteRequest) -> Result<bool, Error<ExistsRouteError>> {
198    let local_var_configuration = configuration;
199
200    let local_var_client = &local_var_configuration.client;
201
202    let local_var_uri_str = format!("{}/w/{workspace}/http_triggers/route_exists", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
203    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
204
205    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
206        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
207    }
208    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
209        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
210    };
211    local_var_req_builder = local_var_req_builder.json(&exists_route_request);
212
213    let local_var_req = local_var_req_builder.build()?;
214    let local_var_resp = local_var_client.execute(local_var_req).await?;
215
216    let local_var_status = local_var_resp.status();
217    let local_var_content = local_var_resp.text().await?;
218
219    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
220        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
221    } else {
222        let local_var_entity: Option<ExistsRouteError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
223        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
224        Err(Error::ResponseError(local_var_error))
225    }
226}
227
228pub async fn get_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::HttpTrigger, Error<GetHttpTriggerError>> {
229    let local_var_configuration = configuration;
230
231    let local_var_client = &local_var_configuration.client;
232
233    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));
234    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
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<GetHttpTriggerError> = 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_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>> {
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}/http_triggers/list", 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_str) = path {
273        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
274    }
275    if let Some(ref local_var_str) = is_flow {
276        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
277    }
278    if let Some(ref local_var_str) = path_start {
279        local_var_req_builder = local_var_req_builder.query(&[("path_start", &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<ListHttpTriggersError> = 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 update_http_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_http_trigger: models::EditHttpTrigger) -> Result<String, Error<UpdateHttpTriggerError>> {
304    let local_var_configuration = configuration;
305
306    let local_var_client = &local_var_configuration.client;
307
308    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));
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(&edit_http_trigger);
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<UpdateHttpTriggerError> = 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