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.687.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 [`sync_native_triggers`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SyncNativeTriggersError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`update_native_trigger`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum UpdateNativeTriggerError {
106    UnknownValue(serde_json::Value),
107}
108
109
110/// Creates a new native trigger for the specified service. Requires write access to the script or flow that the trigger will be associated with. 
111pub async fn create_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, native_trigger_data: models::NativeTriggerData) -> Result<models::CreateTriggerResponse, Error<CreateNativeTriggerError>> {
112    let local_var_configuration = configuration;
113
114    let local_var_client = &local_var_configuration.client;
115
116    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());
117    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
118
119    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
120        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
121    }
122    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
123        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
124    };
125    local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
126
127    let local_var_req = local_var_req_builder.build()?;
128    let local_var_resp = local_var_client.execute(local_var_req).await?;
129
130    let local_var_status = local_var_resp.status();
131    let local_var_content = local_var_resp.text().await?;
132
133    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
134        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
135    } else {
136        let local_var_entity: Option<CreateNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
137        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
138        Err(Error::ResponseError(local_var_error))
139    }
140}
141
142/// Deletes a native trigger by its external ID. Requires write access to the script or flow that the trigger is associated with. 
143pub async fn delete_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<String, Error<DeleteNativeTriggerError>> {
144    let local_var_configuration = configuration;
145
146    let local_var_client = &local_var_configuration.client;
147
148    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));
149    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
150
151    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
152        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
153    }
154    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
155        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
156    };
157
158    let local_var_req = local_var_req_builder.build()?;
159    let local_var_resp = local_var_client.execute(local_var_req).await?;
160
161    let local_var_status = local_var_resp.status();
162    let local_var_content = local_var_resp.text().await?;
163
164    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
165        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
166    } else {
167        let local_var_entity: Option<DeleteNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
168        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
169        Err(Error::ResponseError(local_var_error))
170    }
171}
172
173/// Checks if a native trigger with the given external ID exists.
174pub async fn exists_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<bool, Error<ExistsNativeTriggerError>> {
175    let local_var_configuration = configuration;
176
177    let local_var_client = &local_var_configuration.client;
178
179    let local_var_uri_str = format!("{}/w/{workspace}/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));
180    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
181
182    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
183        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
184    }
185    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
186        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
187    };
188
189    let local_var_req = local_var_req_builder.build()?;
190    let local_var_resp = local_var_client.execute(local_var_req).await?;
191
192    let local_var_status = local_var_resp.status();
193    let local_var_content = local_var_resp.text().await?;
194
195    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
196        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
197    } else {
198        let local_var_entity: Option<ExistsNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
199        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
200        Err(Error::ResponseError(local_var_error))
201    }
202}
203
204/// Retrieves a native trigger by its external ID. Requires write access to the script or flow that the trigger is associated with. 
205pub async fn get_native_trigger(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName, external_id: &str) -> Result<models::NativeTriggerWithExternal, Error<GetNativeTriggerError>> {
206    let local_var_configuration = configuration;
207
208    let local_var_client = &local_var_configuration.client;
209
210    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));
211    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
212
213    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
214        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
215    }
216    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
217        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
218    };
219
220    let local_var_req = local_var_req_builder.build()?;
221    let local_var_resp = local_var_client.execute(local_var_req).await?;
222
223    let local_var_status = local_var_resp.status();
224    let local_var_content = local_var_resp.text().await?;
225
226    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
227        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
228    } else {
229        let local_var_entity: Option<GetNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
230        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
231        Err(Error::ResponseError(local_var_error))
232    }
233}
234
235pub async fn list_github_repos(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::GithubRepoEntry>, Error<ListGithubReposError>> {
236    let local_var_configuration = configuration;
237
238    let local_var_client = &local_var_configuration.client;
239
240    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/github/repos", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
241    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
242
243    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
244        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
245    }
246    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
247        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
248    };
249
250    let local_var_req = local_var_req_builder.build()?;
251    let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253    let local_var_status = local_var_resp.status();
254    let local_var_content = local_var_resp.text().await?;
255
256    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
258    } else {
259        let local_var_entity: Option<ListGithubReposError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
260        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
261        Err(Error::ResponseError(local_var_error))
262    }
263}
264
265pub async fn list_google_calendars(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::GoogleCalendarEntry>, Error<ListGoogleCalendarsError>> {
266    let local_var_configuration = configuration;
267
268    let local_var_client = &local_var_configuration.client;
269
270    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/calendars", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
271    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
272
273    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
274        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
275    }
276    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
277        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
278    };
279
280    let local_var_req = local_var_req_builder.build()?;
281    let local_var_resp = local_var_client.execute(local_var_req).await?;
282
283    let local_var_status = local_var_resp.status();
284    let local_var_content = local_var_resp.text().await?;
285
286    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
288    } else {
289        let local_var_entity: Option<ListGoogleCalendarsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
290        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294
295pub 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>> {
296    let local_var_configuration = configuration;
297
298    let local_var_client = &local_var_configuration.client;
299
300    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/files", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
301    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
302
303    if let Some(ref local_var_str) = q {
304        local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
305    }
306    if let Some(ref local_var_str) = parent_id {
307        local_var_req_builder = local_var_req_builder.query(&[("parent_id", &local_var_str.to_string())]);
308    }
309    if let Some(ref local_var_str) = page_token {
310        local_var_req_builder = local_var_req_builder.query(&[("page_token", &local_var_str.to_string())]);
311    }
312    if let Some(ref local_var_str) = shared_with_me {
313        local_var_req_builder = local_var_req_builder.query(&[("shared_with_me", &local_var_str.to_string())]);
314    }
315    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
316        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
317    }
318    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
319        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
320    };
321
322    let local_var_req = local_var_req_builder.build()?;
323    let local_var_resp = local_var_client.execute(local_var_req).await?;
324
325    let local_var_status = local_var_resp.status();
326    let local_var_content = local_var_resp.text().await?;
327
328    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
329        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
330    } else {
331        let local_var_entity: Option<ListGoogleDriveFilesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
332        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
333        Err(Error::ResponseError(local_var_error))
334    }
335}
336
337pub async fn list_google_shared_drives(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::SharedDriveEntry>, Error<ListGoogleSharedDrivesError>> {
338    let local_var_configuration = configuration;
339
340    let local_var_client = &local_var_configuration.client;
341
342    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/google/drive/shared_drives", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
343    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
344
345    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
346        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
347    }
348    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
349        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
350    };
351
352    let local_var_req = local_var_req_builder.build()?;
353    let local_var_resp = local_var_client.execute(local_var_req).await?;
354
355    let local_var_status = local_var_resp.status();
356    let local_var_content = local_var_resp.text().await?;
357
358    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
359        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
360    } else {
361        let local_var_entity: Option<ListGoogleSharedDrivesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
362        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
363        Err(Error::ResponseError(local_var_error))
364    }
365}
366
367/// Lists all native triggers for the specified service in the workspace.
368pub 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>) -> Result<Vec<models::NativeTrigger>, Error<ListNativeTriggersError>> {
369    let local_var_configuration = configuration;
370
371    let local_var_client = &local_var_configuration.client;
372
373    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());
374    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
375
376    if let Some(ref local_var_str) = page {
377        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
378    }
379    if let Some(ref local_var_str) = per_page {
380        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
381    }
382    if let Some(ref local_var_str) = path {
383        local_var_req_builder = local_var_req_builder.query(&[("path", &local_var_str.to_string())]);
384    }
385    if let Some(ref local_var_str) = is_flow {
386        local_var_req_builder = local_var_req_builder.query(&[("is_flow", &local_var_str.to_string())]);
387    }
388    if let Some(ref local_var_str) = label {
389        local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
390    }
391    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
392        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
393    }
394    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
395        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
396    };
397
398    let local_var_req = local_var_req_builder.build()?;
399    let local_var_resp = local_var_client.execute(local_var_req).await?;
400
401    let local_var_status = local_var_resp.status();
402    let local_var_content = local_var_resp.text().await?;
403
404    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
405        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
406    } else {
407        let local_var_entity: Option<ListNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
408        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
409        Err(Error::ResponseError(local_var_error))
410    }
411}
412
413pub async fn list_next_cloud_events(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::NextCloudEventType>, Error<ListNextCloudEventsError>> {
414    let local_var_configuration = configuration;
415
416    let local_var_client = &local_var_configuration.client;
417
418    let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/nextcloud/events", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
419    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
420
421    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
422        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
423    }
424    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
425        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
426    };
427
428    let local_var_req = local_var_req_builder.build()?;
429    let local_var_resp = local_var_client.execute(local_var_req).await?;
430
431    let local_var_status = local_var_resp.status();
432    let local_var_content = local_var_resp.text().await?;
433
434    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
436    } else {
437        let local_var_entity: Option<ListNextCloudEventsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
438        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
439        Err(Error::ResponseError(local_var_error))
440    }
441}
442
443pub 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>> {
444    let local_var_configuration = configuration;
445
446    let local_var_client = &local_var_configuration.client;
447
448    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);
449    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
450
451    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
452        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
453    }
454    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
455        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
456    };
457    local_var_req_builder = local_var_req_builder.json(&request_body);
458
459    let local_var_req = local_var_req_builder.build()?;
460    let local_var_resp = local_var_client.execute(local_var_req).await?;
461
462    let local_var_status = local_var_resp.status();
463    let local_var_content = local_var_resp.text().await?;
464
465    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
466        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
467    } else {
468        let local_var_entity: Option<NativeTriggerWebhookError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
469        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
470        Err(Error::ResponseError(local_var_error))
471    }
472}
473
474pub async fn sync_native_triggers(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<(), Error<SyncNativeTriggersError>> {
475    let local_var_configuration = configuration;
476
477    let local_var_client = &local_var_configuration.client;
478
479    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());
480    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
481
482    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
483        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
484    }
485    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
486        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
487    };
488
489    let local_var_req = local_var_req_builder.build()?;
490    let local_var_resp = local_var_client.execute(local_var_req).await?;
491
492    let local_var_status = local_var_resp.status();
493    let local_var_content = local_var_resp.text().await?;
494
495    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
496        Ok(())
497    } else {
498        let local_var_entity: Option<SyncNativeTriggersError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
499        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
500        Err(Error::ResponseError(local_var_error))
501    }
502}
503
504/// Updates an existing native trigger. Requires write access to the script or flow that the trigger is associated with. 
505pub 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>> {
506    let local_var_configuration = configuration;
507
508    let local_var_client = &local_var_configuration.client;
509
510    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));
511    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
512
513    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
514        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
515    }
516    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
517        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
518    };
519    local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
520
521    let local_var_req = local_var_req_builder.build()?;
522    let local_var_resp = local_var_client.execute(local_var_req).await?;
523
524    let local_var_status = local_var_resp.status();
525    let local_var_content = local_var_resp.text().await?;
526
527    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
528        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
529    } else {
530        let local_var_entity: Option<UpdateNativeTriggerError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
531        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
532        Err(Error::ResponseError(local_var_error))
533    }
534}
535