1use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateNativeTriggerError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum DeleteNativeTriggerError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum ExistsNativeTriggerError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetNativeTriggerError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum ListGithubReposError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum ListGoogleCalendarsError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum ListGoogleDriveFilesError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum ListGoogleSharedDrivesError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListNativeTriggersError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListNextCloudEventsError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum NativeTriggerWebhookError {
92 UnknownValue(serde_json::Value),
93}
94
95#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum SyncNativeTriggersError {
99 UnknownValue(serde_json::Value),
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum UpdateNativeTriggerError {
106 UnknownValue(serde_json::Value),
107}
108
109
110pub 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(&local_var_content).map_err(Error::from)
135 } else {
136 let local_var_entity: Option<CreateNativeTriggerError> = crate::from_str_patched(&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
142pub 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(&local_var_content).map_err(Error::from)
166 } else {
167 let local_var_entity: Option<DeleteNativeTriggerError> = crate::from_str_patched(&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
173pub 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(&local_var_content).map_err(Error::from)
197 } else {
198 let local_var_entity: Option<ExistsNativeTriggerError> = crate::from_str_patched(&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
204pub 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(&local_var_content).map_err(Error::from)
228 } else {
229 let local_var_entity: Option<GetNativeTriggerError> = crate::from_str_patched(&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(&local_var_content).map_err(Error::from)
258 } else {
259 let local_var_entity: Option<ListGithubReposError> = crate::from_str_patched(&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(&local_var_content).map_err(Error::from)
288 } else {
289 let local_var_entity: Option<ListGoogleCalendarsError> = crate::from_str_patched(&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(&local_var_content).map_err(Error::from)
330 } else {
331 let local_var_entity: Option<ListGoogleDriveFilesError> = crate::from_str_patched(&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(&local_var_content).map_err(Error::from)
360 } else {
361 let local_var_entity: Option<ListGoogleSharedDrivesError> = crate::from_str_patched(&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
367pub 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>> {
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_str) = include_draft_only {
392 local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
393 }
394 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
395 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
396 }
397 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
398 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
399 };
400
401 let local_var_req = local_var_req_builder.build()?;
402 let local_var_resp = local_var_client.execute(local_var_req).await?;
403
404 let local_var_status = local_var_resp.status();
405 let local_var_content = local_var_resp.text().await?;
406
407 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
408 crate::from_str_patched(&local_var_content).map_err(Error::from)
409 } else {
410 let local_var_entity: Option<ListNativeTriggersError> = crate::from_str_patched(&local_var_content).ok();
411 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
412 Err(Error::ResponseError(local_var_error))
413 }
414}
415
416pub async fn list_next_cloud_events(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<models::NextCloudEventType>, Error<ListNextCloudEventsError>> {
417 let local_var_configuration = configuration;
418
419 let local_var_client = &local_var_configuration.client;
420
421 let local_var_uri_str = format!("{}/w/{workspace}/native_triggers/nextcloud/events", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
422 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
423
424 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
425 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
426 }
427 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
428 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
429 };
430
431 let local_var_req = local_var_req_builder.build()?;
432 let local_var_resp = local_var_client.execute(local_var_req).await?;
433
434 let local_var_status = local_var_resp.status();
435 let local_var_content = local_var_resp.text().await?;
436
437 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
438 crate::from_str_patched(&local_var_content).map_err(Error::from)
439 } else {
440 let local_var_entity: Option<ListNextCloudEventsError> = crate::from_str_patched(&local_var_content).ok();
441 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
442 Err(Error::ResponseError(local_var_error))
443 }
444}
445
446pub 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>> {
447 let local_var_configuration = configuration;
448
449 let local_var_client = &local_var_configuration.client;
450
451 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);
452 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
453
454 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
455 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
456 }
457 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
458 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
459 };
460 local_var_req_builder = local_var_req_builder.json(&request_body);
461
462 let local_var_req = local_var_req_builder.build()?;
463 let local_var_resp = local_var_client.execute(local_var_req).await?;
464
465 let local_var_status = local_var_resp.status();
466 let local_var_content = local_var_resp.text().await?;
467
468 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
469 crate::from_str_patched(&local_var_content).map_err(Error::from)
470 } else {
471 let local_var_entity: Option<NativeTriggerWebhookError> = crate::from_str_patched(&local_var_content).ok();
472 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
473 Err(Error::ResponseError(local_var_error))
474 }
475}
476
477pub async fn sync_native_triggers(configuration: &configuration::Configuration, workspace: &str, service_name: models::NativeServiceName) -> Result<(), Error<SyncNativeTriggersError>> {
478 let local_var_configuration = configuration;
479
480 let local_var_client = &local_var_configuration.client;
481
482 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());
483 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
484
485 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
486 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
487 }
488 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
489 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
490 };
491
492 let local_var_req = local_var_req_builder.build()?;
493 let local_var_resp = local_var_client.execute(local_var_req).await?;
494
495 let local_var_status = local_var_resp.status();
496 let local_var_content = local_var_resp.text().await?;
497
498 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
499 Ok(())
500 } else {
501 let local_var_entity: Option<SyncNativeTriggersError> = crate::from_str_patched(&local_var_content).ok();
502 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
503 Err(Error::ResponseError(local_var_error))
504 }
505}
506
507pub 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>> {
509 let local_var_configuration = configuration;
510
511 let local_var_client = &local_var_configuration.client;
512
513 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));
514 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
515
516 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
517 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
518 }
519 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
520 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
521 };
522 local_var_req_builder = local_var_req_builder.json(&native_trigger_data);
523
524 let local_var_req = local_var_req_builder.build()?;
525 let local_var_resp = local_var_client.execute(local_var_req).await?;
526
527 let local_var_status = local_var_resp.status();
528 let local_var_content = local_var_resp.text().await?;
529
530 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
531 crate::from_str_patched(&local_var_content).map_err(Error::from)
532 } else {
533 let local_var_entity: Option<UpdateNativeTriggerError> = crate::from_str_patched(&local_var_content).ok();
534 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
535 Err(Error::ResponseError(local_var_error))
536 }
537}
538