Skip to main content

windmill_api/apis/
native_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.848.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_native_trigger`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateNativeTriggerError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`delete_native_trigger`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteNativeTriggerError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`exists_native_trigger`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ExistsNativeTriggerError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_native_trigger`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetNativeTriggerError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`list_github_repos`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListGithubReposError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`list_google_calendars`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListGoogleCalendarsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`list_google_drive_files`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListGoogleDriveFilesError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`list_google_shared_drives`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListGoogleSharedDrivesError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`list_native_triggers`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListNativeTriggersError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`list_next_cloud_events`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListNextCloudEventsError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`native_trigger_webhook`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum NativeTriggerWebhookError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`set_native_trigger_enabled`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SetNativeTriggerEnabledError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`sync_native_triggers`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum SyncNativeTriggersError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`update_native_trigger`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum UpdateNativeTriggerError {
113    UnknownValue(serde_json::Value),
114}
115
116
117/// Creates a new native trigger for the specified service. Requires write access to the script or flow that the trigger will be associated with. 
118pub async fn create_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, native_trigger_data: models::NativeTriggerData) -> Result<models::CreateTriggerResponse, Error<CreateNativeTriggerError>> {
119    let local_var_configuration = configuration;
120
121    let local_var_client = &local_var_configuration.client;
122
123    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
124    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
125
126    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
127        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
128    }
129    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
130        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
131    };
132    local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
133
134    let local_var_req = local_var_req_builder.build()?;
135    let local_var_resp = local_var_client.execute(local_var_req).await?;
136
137    let local_var_status = local_var_resp.status();
138    let local_var_content = local_var_resp.text().await?;
139
140    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
141        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
142    } else {
143        let local_var_entity: Option<CreateNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
144        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
145        Err(Error::ResponseError(local_var_error))
146    }
147}
148
149/// Deletes a native trigger by its external ID. Requires write access to the script or flow that the trigger is associated with. 
150pub async fn delete_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<String, Error<DeleteNativeTriggerError>> {
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}/native_triggers/{service_name}/delete/{external_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), external_id=crate::apis::urlencode(external_id));
156    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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<DeleteNativeTriggerError> = 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
180/// Checks if a native trigger with the given external ID exists.
181pub async fn exists_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<bool, Error<ExistsNativeTriggerError>> {
182    let local_var_configuration = configuration;
183
184    let local_var_client = &local_var_configuration.client;
185
186    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/exists/{external_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), external_id=crate::apis::urlencode(external_id));
187    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
190        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
191    }
192    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
193        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
194    };
195
196    let local_var_req = local_var_req_builder.build()?;
197    let local_var_resp = local_var_client.execute(local_var_req).await?;
198
199    let local_var_status = local_var_resp.status();
200    let local_var_content = local_var_resp.text().await?;
201
202    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
203        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
204    } else {
205        let local_var_entity: Option<ExistsNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
206        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
207        Err(Error::ResponseError(local_var_error))
208    }
209}
210
211/// Retrieves a native trigger by its external ID. Requires write access to the script or flow that the trigger is associated with. 
212pub async fn get_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<models::NativeTriggerWithExternal, Error<GetNativeTriggerError>> {
213    let local_var_configuration = configuration;
214
215    let local_var_client = &local_var_configuration.client;
216
217    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/get/{external_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), external_id=crate::apis::urlencode(external_id));
218    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
219
220    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
221        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
222    }
223    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
224        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
225    };
226
227    let local_var_req = local_var_req_builder.build()?;
228    let local_var_resp = local_var_client.execute(local_var_req).await?;
229
230    let local_var_status = local_var_resp.status();
231    let local_var_content = local_var_resp.text().await?;
232
233    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
234        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
235    } else {
236        let local_var_entity: Option<GetNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
237        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
238        Err(Error::ResponseError(local_var_error))
239    }
240}
241
242pub async fn list_github_repos(configuration: &configuration::Configuration, workspace: &str, connection_path: Option<&str>) -> Result<Vec<models::GithubRepoEntry>, Error<ListGithubReposError>> {
243    let local_var_configuration = configuration;
244
245    let local_var_client = &local_var_configuration.client;
246
247    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/github/repos", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
248    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
249
250    if let Some(ref local_var_str) = connection_path {
251        local_var_req_builder = local_var_req_builder.query(&[("connection_path", &local_var_str.to_string())]);
252    }
253    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
254        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
255    }
256    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
257        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
258    };
259
260    let local_var_req = local_var_req_builder.build()?;
261    let local_var_resp = local_var_client.execute(local_var_req).await?;
262
263    let local_var_status = local_var_resp.status();
264    let local_var_content = local_var_resp.text().await?;
265
266    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
267        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
268    } else {
269        let local_var_entity: Option<ListGithubReposError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
270        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
271        Err(Error::ResponseError(local_var_error))
272    }
273}
274
275pub async fn list_google_calendars(configuration: &configuration::Configuration, workspace: &str, connection_path: Option<&str>) -> Result<Vec<models::GoogleCalendarEntry>, Error<ListGoogleCalendarsError>> {
276    let local_var_configuration = configuration;
277
278    let local_var_client = &local_var_configuration.client;
279
280    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/calendars", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
281    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
282
283    if let Some(ref local_var_str) = connection_path {
284        local_var_req_builder = local_var_req_builder.query(&[("connection_path", &local_var_str.to_string())]);
285    }
286    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
287        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
288    }
289    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
290        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
291    };
292
293    let local_var_req = local_var_req_builder.build()?;
294    let local_var_resp = local_var_client.execute(local_var_req).await?;
295
296    let local_var_status = local_var_resp.status();
297    let local_var_content = local_var_resp.text().await?;
298
299    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
300        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
301    } else {
302        let local_var_entity: Option<ListGoogleCalendarsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
303        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
304        Err(Error::ResponseError(local_var_error))
305    }
306}
307
308pub async fn list_google_drive_files(configuration: &configuration::Configuration, workspace: &str, connection_path: Option<&str>, q: Option<&str>, parent_id: Option<&str>, page_token: Option<&str>, shared_with_me: Option<bool>) -> Result<models::GoogleDriveFilesResponse, Error<ListGoogleDriveFilesError>> {
309    let local_var_configuration = configuration;
310
311    let local_var_client = &local_var_configuration.client;
312
313    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/files", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
314    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
315
316    if let Some(ref local_var_str) = connection_path {
317        local_var_req_builder = local_var_req_builder.query(&[("connection_path", &local_var_str.to_string())]);
318    }
319    if let Some(ref local_var_str) = q {
320        local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
321    }
322    if let Some(ref local_var_str) = parent_id {
323        local_var_req_builder = local_var_req_builder.query(&[("parent_id", &local_var_str.to_string())]);
324    }
325    if let Some(ref local_var_str) = page_token {
326        local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
327    }
328    if let Some(ref local_var_str) = shared_with_me {
329        local_var_req_builder = local_var_req_builder.query(&[("shared_with_me", &local_var_str.to_string())]);
330    }
331    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
332        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
333    }
334    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
335        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
336    };
337
338    let local_var_req = local_var_req_builder.build()?;
339    let local_var_resp = local_var_client.execute(local_var_req).await?;
340
341    let local_var_status = local_var_resp.status();
342    let local_var_content = local_var_resp.text().await?;
343
344    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
345        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
346    } else {
347        let local_var_entity: Option<ListGoogleDriveFilesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
348        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
349        Err(Error::ResponseError(local_var_error))
350    }
351}
352
353pub async fn list_google_shared_drives(configuration: &configuration::Configuration, workspace: &str, connection_path: Option<&str>) -> Result<Vec<models::SharedDriveEntry>, Error<ListGoogleSharedDrivesError>> {
354    let local_var_configuration = configuration;
355
356    let local_var_client = &local_var_configuration.client;
357
358    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/shared_drives", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
359    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
360
361    if let Some(ref local_var_str) = connection_path {
362        local_var_req_builder = local_var_req_builder.query(&[("connection_path", &local_var_str.to_string())]);
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
371    let local_var_req = local_var_req_builder.build()?;
372    let local_var_resp = local_var_client.execute(local_var_req).await?;
373
374    let local_var_status = local_var_resp.status();
375    let local_var_content = local_var_resp.text().await?;
376
377    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
378        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
379    } else {
380        let local_var_entity: Option<ListGoogleSharedDrivesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
381        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
382        Err(Error::ResponseError(local_var_error))
383    }
384}
385
386/// Lists all native triggers for the specified service in the workspace.
387pub async fn list_native_triggers(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, page: Option<i32>, per_page: Option<i32>, path: Option<&str>, is_flow: Option<bool>, label: Option<&str>, include_draft_only: Option<bool>) -> Result<Vec<models::NativeTrigger>, Error<ListNativeTriggersError>> {
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}/native_triggers/{service_name}/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
393    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
394
395    if let Some(ref local_var_str) = page {
396        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
397    }
398    if let Some(ref local_var_str) = per_page {
399        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
400    }
401    if let Some(ref local_var_str) = path {
402        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
403    }
404    if let Some(ref local_var_str) = is_flow {
405        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
406    }
407    if let Some(ref local_var_str) = label {
408        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
409    }
410    if let Some(ref local_var_str) = include_draft_only {
411        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
412    }
413    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
414        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
415    }
416    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
417        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
418    };
419
420    let local_var_req = local_var_req_builder.build()?;
421    let local_var_resp = local_var_client.execute(local_var_req).await?;
422
423    let local_var_status = local_var_resp.status();
424    let local_var_content = local_var_resp.text().await?;
425
426    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
427        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
428    } else {
429        let local_var_entity: Option<ListNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
430        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
431        Err(Error::ResponseError(local_var_error))
432    }
433}
434
435pub async fn list_next_cloud_events(configuration: &configuration::Configuration, workspace: &str, connection_path: Option<&str>) -> Result<Vec<models::NextCloudEventType>, Error<ListNextCloudEventsError>> {
436    let local_var_configuration = configuration;
437
438    let local_var_client = &local_var_configuration.client;
439
440    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/nextcloud/events", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
441    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
442
443    if let Some(ref local_var_str) = connection_path {
444        local_var_req_builder = local_var_req_builder.query(&[("connection_path", &local_var_str.to_string())]);
445    }
446    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
447        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
448    }
449    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
450        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
451    };
452
453    let local_var_req = local_var_req_builder.build()?;
454    let local_var_resp = local_var_client.execute(local_var_req).await?;
455
456    let local_var_status = local_var_resp.status();
457    let local_var_content = local_var_resp.text().await?;
458
459    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
460        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
461    } else {
462        let local_var_entity: Option<ListNextCloudEventsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
463        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
464        Err(Error::ResponseError(local_var_error))
465    }
466}
467
468pub async fn native_trigger_webhook(configuration: &configuration::Configuration, service_name: models::NativeServiceName, workspace_id: &str, internal_id: i64, request_body: Option<std::collections::HashMap<String, serde_json::Value>>) -> Result<String, Error<NativeTriggerWebhookError>> {
469    let local_var_configuration = configuration;
470
471    let local_var_client = &local_var_configuration.client;
472
473    let local_var_uri_str = format!("{}/native_triggers/{service_name}/w/{workspace_id}/webhook/{internal_id}", local_var_configuration.base_path, service_name=service_name.to_string(), workspace_id=crate::apis::urlencode(workspace_id), internal_id=internal_id);
474    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
475
476    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
477        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
478    }
479    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
480        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
481    };
482    local_var_req_builder = local_var_req_builder.json(&request_body);
483
484    let local_var_req = local_var_req_builder.build()?;
485    let local_var_resp = local_var_client.execute(local_var_req).await?;
486
487    let local_var_status = local_var_resp.status();
488    let local_var_content = local_var_resp.text().await?;
489
490    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
491        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
492    } else {
493        let local_var_entity: Option<NativeTriggerWebhookError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
494        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
495        Err(Error::ResponseError(local_var_error))
496    }
497}
498
499/// Enables or disables a native trigger. A disabled trigger stays registered on the external service but starts no job when it fires. Requires write access to the script or flow that the trigger is associated with. 
500pub async fn set_native_trigger_enabled(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str, set_native_trigger_enabled_request: models::SetNativeTriggerEnabledRequest) -> Result<String, Error<SetNativeTriggerEnabledError>> {
501    let local_var_configuration = configuration;
502
503    let local_var_client = &local_var_configuration.client;
504
505    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/setenabled/{external_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), external_id=crate::apis::urlencode(external_id));
506    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
507
508    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
509        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
510    }
511    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
512        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
513    };
514    local_var_req_builder = local_var_req_builder.json(&set_native_trigger_enabled_request);
515
516    let local_var_req = local_var_req_builder.build()?;
517    let local_var_resp = local_var_client.execute(local_var_req).await?;
518
519    let local_var_status = local_var_resp.status();
520    let local_var_content = local_var_resp.text().await?;
521
522    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
523        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
524    } else {
525        let local_var_entity: Option<SetNativeTriggerEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
526        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
527        Err(Error::ResponseError(local_var_error))
528    }
529}
530
531pub async fn sync_native_triggers(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<(), Error<SyncNativeTriggersError>> {
532    let local_var_configuration = configuration;
533
534    let local_var_client = &local_var_configuration.client;
535
536    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/sync", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string());
537    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
538
539    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
540        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
541    }
542    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
543        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
544    };
545
546    let local_var_req = local_var_req_builder.build()?;
547    let local_var_resp = local_var_client.execute(local_var_req).await?;
548
549    let local_var_status = local_var_resp.status();
550    let local_var_content = local_var_resp.text().await?;
551
552    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
553        Ok(())
554    } else {
555        let local_var_entity: Option<SyncNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
556        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
557        Err(Error::ResponseError(local_var_error))
558    }
559}
560
561/// Updates an existing native trigger. Requires write access to the script or flow that the trigger is associated with. 
562pub async fn update_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str, native_trigger_data: models::NativeTriggerData) -> Result<String, Error<UpdateNativeTriggerError>> {
563    let local_var_configuration = configuration;
564
565    let local_var_client = &local_var_configuration.client;
566
567    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/{service_name}/update/{external_id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), service_name=service_name.to_string(), external_id=crate::apis::urlencode(external_id));
568    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
569
570    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
571        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
572    }
573    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
574        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
575    };
576    local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
577
578    let local_var_req = local_var_req_builder.build()?;
579    let local_var_resp = local_var_client.execute(local_var_req).await?;
580
581    let local_var_status = local_var_resp.status();
582    let local_var_content = local_var_resp.text().await?;
583
584    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
585        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
586    } else {
587        let local_var_entity: Option<UpdateNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
588        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
589        Err(Error::ResponseError(local_var_error))
590    }
591}
592