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.807.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) -> 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_user_agent) = local_var_configuration.user_agent {
251        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
252    }
253    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
254        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
255    };
256
257    let local_var_req = local_var_req_builder.build()?;
258    let local_var_resp = local_var_client.execute(local_var_req).await?;
259
260    let local_var_status = local_var_resp.status();
261    let local_var_content = local_var_resp.text().await?;
262
263    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
264        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
265    } else {
266        let local_var_entity: Option<ListGithubReposError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
267        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
268        Err(Error::ResponseError(local_var_error))
269    }
270}
271
272pub async fn list_google_calendars(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::GoogleCalendarEntry>, Error<ListGoogleCalendarsError>> {
273    let local_var_configuration = configuration;
274
275    let local_var_client = &local_var_configuration.client;
276
277    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/calendars", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
278    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
279
280    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
281        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
282    }
283    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
284        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
285    };
286
287    let local_var_req = local_var_req_builder.build()?;
288    let local_var_resp = local_var_client.execute(local_var_req).await?;
289
290    let local_var_status = local_var_resp.status();
291    let local_var_content = local_var_resp.text().await?;
292
293    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
294        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
295    } else {
296        let local_var_entity: Option<ListGoogleCalendarsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
297        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
298        Err(Error::ResponseError(local_var_error))
299    }
300}
301
302pub async fn list_google_drive_files(configuration: &configuration::Configuration, workspace: &str, q: Option<&str>, parent_id: Option<&str>, page_token: Option<&str>, shared_with_me: Option<bool>) -> Result<models::GoogleDriveFilesResponse, Error<ListGoogleDriveFilesError>> {
303    let local_var_configuration = configuration;
304
305    let local_var_client = &local_var_configuration.client;
306
307    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/files", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
308    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
309
310    if let Some(ref local_var_str) = q {
311        local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
312    }
313    if let Some(ref local_var_str) = parent_id {
314        local_var_req_builder = local_var_req_builder.query(&[("parent_id", &local_var_str.to_string())]);
315    }
316    if let Some(ref local_var_str) = page_token {
317        local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
318    }
319    if let Some(ref local_var_str) = shared_with_me {
320        local_var_req_builder = local_var_req_builder.query(&[("shared_with_me", &local_var_str.to_string())]);
321    }
322    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
323        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324    }
325    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
326        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
327    };
328
329    let local_var_req = local_var_req_builder.build()?;
330    let local_var_resp = local_var_client.execute(local_var_req).await?;
331
332    let local_var_status = local_var_resp.status();
333    let local_var_content = local_var_resp.text().await?;
334
335    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
336        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
337    } else {
338        let local_var_entity: Option<ListGoogleDriveFilesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
339        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
340        Err(Error::ResponseError(local_var_error))
341    }
342}
343
344pub async fn list_google_shared_drives(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::SharedDriveEntry>, Error<ListGoogleSharedDrivesError>> {
345    let local_var_configuration = configuration;
346
347    let local_var_client = &local_var_configuration.client;
348
349    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/shared_drives", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
350    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
351
352    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
353        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
354    }
355    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
356        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
357    };
358
359    let local_var_req = local_var_req_builder.build()?;
360    let local_var_resp = local_var_client.execute(local_var_req).await?;
361
362    let local_var_status = local_var_resp.status();
363    let local_var_content = local_var_resp.text().await?;
364
365    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
366        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
367    } else {
368        let local_var_entity: Option<ListGoogleSharedDrivesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
369        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
370        Err(Error::ResponseError(local_var_error))
371    }
372}
373
374/// Lists all native triggers for the specified service in the workspace.
375pub 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>> {
376    let local_var_configuration = configuration;
377
378    let local_var_client = &local_var_configuration.client;
379
380    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());
381    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
382
383    if let Some(ref local_var_str) = page {
384        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
385    }
386    if let Some(ref local_var_str) = per_page {
387        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
388    }
389    if let Some(ref local_var_str) = path {
390        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
391    }
392    if let Some(ref local_var_str) = is_flow {
393        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
394    }
395    if let Some(ref local_var_str) = label {
396        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
397    }
398    if let Some(ref local_var_str) = include_draft_only {
399        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
400    }
401    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
402        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
403    }
404    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
405        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
406    };
407
408    let local_var_req = local_var_req_builder.build()?;
409    let local_var_resp = local_var_client.execute(local_var_req).await?;
410
411    let local_var_status = local_var_resp.status();
412    let local_var_content = local_var_resp.text().await?;
413
414    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
415        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
416    } else {
417        let local_var_entity: Option<ListNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
418        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
419        Err(Error::ResponseError(local_var_error))
420    }
421}
422
423pub async fn list_next_cloud_events(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::NextCloudEventType>, Error<ListNextCloudEventsError>> {
424    let local_var_configuration = configuration;
425
426    let local_var_client = &local_var_configuration.client;
427
428    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/nextcloud/events", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
429    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
430
431    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
432        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
433    }
434    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
435        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
436    };
437
438    let local_var_req = local_var_req_builder.build()?;
439    let local_var_resp = local_var_client.execute(local_var_req).await?;
440
441    let local_var_status = local_var_resp.status();
442    let local_var_content = local_var_resp.text().await?;
443
444    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
445        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
446    } else {
447        let local_var_entity: Option<ListNextCloudEventsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
448        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
449        Err(Error::ResponseError(local_var_error))
450    }
451}
452
453pub 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>> {
454    let local_var_configuration = configuration;
455
456    let local_var_client = &local_var_configuration.client;
457
458    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);
459    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
460
461    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
462        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
463    }
464    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
465        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
466    };
467    local_var_req_builder = local_var_req_builder.json(&request_body);
468
469    let local_var_req = local_var_req_builder.build()?;
470    let local_var_resp = local_var_client.execute(local_var_req).await?;
471
472    let local_var_status = local_var_resp.status();
473    let local_var_content = local_var_resp.text().await?;
474
475    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
476        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
477    } else {
478        let local_var_entity: Option<NativeTriggerWebhookError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
479        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
480        Err(Error::ResponseError(local_var_error))
481    }
482}
483
484/// 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. 
485pub 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>> {
486    let local_var_configuration = configuration;
487
488    let local_var_client = &local_var_configuration.client;
489
490    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));
491    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
492
493    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
494        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
495    }
496    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
497        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
498    };
499    local_var_req_builder = local_var_req_builder.json(&set_native_trigger_enabled_request);
500
501    let local_var_req = local_var_req_builder.build()?;
502    let local_var_resp = local_var_client.execute(local_var_req).await?;
503
504    let local_var_status = local_var_resp.status();
505    let local_var_content = local_var_resp.text().await?;
506
507    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
508        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
509    } else {
510        let local_var_entity: Option<SetNativeTriggerEnabledError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
511        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
512        Err(Error::ResponseError(local_var_error))
513    }
514}
515
516pub async fn sync_native_triggers(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<(), Error<SyncNativeTriggersError>> {
517    let local_var_configuration = configuration;
518
519    let local_var_client = &local_var_configuration.client;
520
521    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());
522    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
523
524    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
525        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
526    }
527    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
528        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
529    };
530
531    let local_var_req = local_var_req_builder.build()?;
532    let local_var_resp = local_var_client.execute(local_var_req).await?;
533
534    let local_var_status = local_var_resp.status();
535    let local_var_content = local_var_resp.text().await?;
536
537    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
538        Ok(())
539    } else {
540        let local_var_entity: Option<SyncNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
541        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
542        Err(Error::ResponseError(local_var_error))
543    }
544}
545
546/// Updates an existing native trigger. Requires write access to the script or flow that the trigger is associated with. 
547pub 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>> {
548    let local_var_configuration = configuration;
549
550    let local_var_client = &local_var_configuration.client;
551
552    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));
553    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
554
555    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
556        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
557    }
558    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
559        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
560    };
561    local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
562
563    let local_var_req = local_var_req_builder.build()?;
564    let local_var_resp = local_var_client.execute(local_var_req).await?;
565
566    let local_var_status = local_var_resp.status();
567    let local_var_content = local_var_resp.text().await?;
568
569    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
570        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
571    } else {
572        let local_var_entity: Option<UpdateNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
573        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
574        Err(Error::ResponseError(local_var_error))
575    }
576}
577