Skip to main content

windmill_api/apis/
mqtt_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.727.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_mqtt_trigger`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateMqttTriggerError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_mqtt_trigger`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteMqttTriggerError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`exists_mqtt_trigger`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ExistsMqttTriggerError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_mqtt_trigger`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetMqttTriggerError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_mqtt_triggers`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListMqttTriggersError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`set_mqtt_trigger_mode`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum SetMqttTriggerModeError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`test_mqtt_connection`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum TestMqttConnectionError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`update_mqtt_trigger`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum UpdateMqttTriggerError {
71    UnknownValue(serde_json::Value),
72}
73
74
75pub async fn create_mqtt_trigger(configuration: &configuration::Configuration, workspace: &str, new_mqtt_trigger: models::NewMqttTrigger) -> Result<String, Error<CreateMqttTriggerError>> {
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}/mqtt_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_mqtt_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<CreateMqttTriggerError> = 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 delete_mqtt_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteMqttTriggerError>> {
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}/mqtt_triggers/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
112    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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
121    let local_var_req = local_var_req_builder.build()?;
122    let local_var_resp = local_var_client.execute(local_var_req).await?;
123
124    let local_var_status = local_var_resp.status();
125    let local_var_content = local_var_resp.text().await?;
126
127    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
128        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
129    } else {
130        let local_var_entity: Option<DeleteMqttTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
131        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
132        Err(Error::ResponseError(local_var_error))
133    }
134}
135
136pub async fn exists_mqtt_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsMqttTriggerError>> {
137    let local_var_configuration = configuration;
138
139    let local_var_client = &local_var_configuration.client;
140
141    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
142    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
143
144    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
145        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
146    }
147    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
148        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
149    };
150
151    let local_var_req = local_var_req_builder.build()?;
152    let local_var_resp = local_var_client.execute(local_var_req).await?;
153
154    let local_var_status = local_var_resp.status();
155    let local_var_content = local_var_resp.text().await?;
156
157    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
158        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
159    } else {
160        let local_var_entity: Option<ExistsMqttTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
161        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
162        Err(Error::ResponseError(local_var_error))
163    }
164}
165
166pub async fn get_mqtt_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, get_draft: Option<bool>) -> Result<models::GetMqttTrigger200Response, Error<GetMqttTriggerError>> {
167    let local_var_configuration = configuration;
168
169    let local_var_client = &local_var_configuration.client;
170
171    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
172    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
173
174    if let Some(ref local_var_str) = get_draft {
175        local_var_req_builder = local_var_req_builder.query(&[("get_draft", &local_var_str.to_string())]);
176    }
177    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
178        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
179    }
180    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
181        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
182    };
183
184    let local_var_req = local_var_req_builder.build()?;
185    let local_var_resp = local_var_client.execute(local_var_req).await?;
186
187    let local_var_status = local_var_resp.status();
188    let local_var_content = local_var_resp.text().await?;
189
190    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
191        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
192    } else {
193        let local_var_entity: Option<GetMqttTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
194        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
195        Err(Error::ResponseError(local_var_error))
196    }
197}
198
199pub async fn list_mqtt_triggers(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, path: Option<&str>, is_flow: Option<bool>, path_start: Option<&str>, label: Option<&str>, include_draft_only: Option<bool>) -> Result<Vec<models::MqttTrigger>, Error<ListMqttTriggersError>> {
200    let local_var_configuration = configuration;
201
202    let local_var_client = &local_var_configuration.client;
203
204    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
205    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
206
207    if let Some(ref local_var_str) = page {
208        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
209    }
210    if let Some(ref local_var_str) = per_page {
211        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
212    }
213    if let Some(ref local_var_str) = path {
214        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
215    }
216    if let Some(ref local_var_str) = is_flow {
217        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
218    }
219    if let Some(ref local_var_str) = path_start {
220        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
221    }
222    if let Some(ref local_var_str) = label {
223        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
224    }
225    if let Some(ref local_var_str) = include_draft_only {
226        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
227    }
228    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
229        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
230    }
231    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
232        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
233    };
234
235    let local_var_req = local_var_req_builder.build()?;
236    let local_var_resp = local_var_client.execute(local_var_req).await?;
237
238    let local_var_status = local_var_resp.status();
239    let local_var_content = local_var_resp.text().await?;
240
241    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
242        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
243    } else {
244        let local_var_entity: Option<ListMqttTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
245        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
246        Err(Error::ResponseError(local_var_error))
247    }
248}
249
250pub async fn set_mqtt_trigger_mode(configuration: &configuration::Configuration, workspace: &str, path: &str, set_http_trigger_mode_request: models::SetHttpTriggerModeRequest) -> Result<String, Error<SetMqttTriggerModeError>> {
251    let local_var_configuration = configuration;
252
253    let local_var_client = &local_var_configuration.client;
254
255    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/setmode/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
256    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
257
258    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
259        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
260    }
261    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
262        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
263    };
264    local_var_req_builder = local_var_req_builder.json(&set_http_trigger_mode_request);
265
266    let local_var_req = local_var_req_builder.build()?;
267    let local_var_resp = local_var_client.execute(local_var_req).await?;
268
269    let local_var_status = local_var_resp.status();
270    let local_var_content = local_var_resp.text().await?;
271
272    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
273        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
274    } else {
275        let local_var_entity: Option<SetMqttTriggerModeError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
276        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
277        Err(Error::ResponseError(local_var_error))
278    }
279}
280
281pub async fn test_mqtt_connection(configuration: &configuration::Configuration, workspace: &str, test_kafka_connection_request: models::TestKafkaConnectionRequest) -> Result<String, Error<TestMqttConnectionError>> {
282    let local_var_configuration = configuration;
283
284    let local_var_client = &local_var_configuration.client;
285
286    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/test", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
287    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
288
289    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
290        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
291    }
292    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
293        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
294    };
295    local_var_req_builder = local_var_req_builder.json(&test_kafka_connection_request);
296
297    let local_var_req = local_var_req_builder.build()?;
298    let local_var_resp = local_var_client.execute(local_var_req).await?;
299
300    let local_var_status = local_var_resp.status();
301    let local_var_content = local_var_resp.text().await?;
302
303    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
304        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
305    } else {
306        let local_var_entity: Option<TestMqttConnectionError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
307        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
308        Err(Error::ResponseError(local_var_error))
309    }
310}
311
312pub async fn update_mqtt_trigger(configuration: &configuration::Configuration, workspace: &str, path: &str, edit_mqtt_trigger: models::EditMqttTrigger) -> Result<String, Error<UpdateMqttTriggerError>> {
313    let local_var_configuration = configuration;
314
315    let local_var_client = &local_var_configuration.client;
316
317    let local_var_uri_str = format!("{}/w/{workspace}/mqtt_triggers/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
318    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
319
320    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
321        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
322    }
323    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
324        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
325    };
326    local_var_req_builder = local_var_req_builder.json(&edit_mqtt_trigger);
327
328    let local_var_req = local_var_req_builder.build()?;
329    let local_var_resp = local_var_client.execute(local_var_req).await?;
330
331    let local_var_status = local_var_resp.status();
332    let local_var_content = local_var_resp.text().await?;
333
334    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
335        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
336    } else {
337        let local_var_entity: Option<UpdateMqttTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
338        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
339        Err(Error::ResponseError(local_var_error))
340    }
341}
342