Skip to main content

hanzo_client/apis/
auto_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`delete_auto_flows_by_id`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteAutoFlowsByIdError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_auto_connectors`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetAutoConnectorsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_auto_flows`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetAutoFlowsError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_auto_flows_by_id`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetAutoFlowsByIdError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_auto_flows_by_id_versions`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetAutoFlowsByIdVersionsError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_auto_runs`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetAutoRunsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_auto_runs_by_id`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetAutoRunsByIdError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`patch_auto_flows_by_id`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PatchAutoFlowsByIdError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`post_auto_connectors_by_id_run`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostAutoConnectorsByIdRunError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`post_auto_flows`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostAutoFlowsError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`post_auto_flows_by_id_disable`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostAutoFlowsByIdDisableError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`post_auto_flows_by_id_enable`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum PostAutoFlowsByIdEnableError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`post_auto_flows_by_id_operations`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PostAutoFlowsByIdOperationsError {
106    UnknownValue(serde_json::Value),
107}
108
109/// struct for typed errors of method [`post_auto_flows_by_id_run`]
110#[derive(Debug, Clone, Serialize, Deserialize)]
111#[serde(untagged)]
112pub enum PostAutoFlowsByIdRunError {
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`post_auto_flows_by_id_versions`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum PostAutoFlowsByIdVersionsError {
120    UnknownValue(serde_json::Value),
121}
122
123/// struct for typed errors of method [`post_auto_hooks_by_source_by_event`]
124#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum PostAutoHooksBySourceByEventError {
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`post_auto_runs_by_id_resume`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum PostAutoRunsByIdResumeError {
134    UnknownValue(serde_json::Value),
135}
136
137
138/// Deletes one automation, its versions and its run history. It answers no content, and a flow of another org answers not-found.
139pub async fn delete_auto_flows_by_id(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<DeleteAutoFlowsByIdError>> {
140    // add a prefix to parameters to efficiently prevent name collisions
141    let p_id = id;
142
143    let uri_str = format!("{}/v1/auto/flows/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
144    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
145
146    if let Some(ref user_agent) = configuration.user_agent {
147        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
148    }
149    if let Some(ref token) = configuration.bearer_access_token {
150        req_builder = req_builder.bearer_auth(token.to_owned());
151    };
152
153    let req = req_builder.build()?;
154    let resp = configuration.client.execute(req).await?;
155
156    let status = resp.status();
157
158    if !status.is_client_error() && !status.is_server_error() {
159        Ok(())
160    } else {
161        let content = resp.text().await?;
162        let entity: Option<DeleteAutoFlowsByIdError> = serde_json::from_str(&content).ok();
163        Err(Error::ResponseError(ResponseContent { status, content, entity }))
164    }
165}
166
167/// Connectors returns the connector catalogue. Each entry is an external service a flow step can invoke, carrying its auth descriptor and the input properties of its actions and triggers. The catalogue is the same for every tenant, so the gate is a validated principal rather than a per-org view.
168pub async fn get_auto_connectors(configuration: &configuration::Configuration, ) -> Result<models::Catalog, Error<GetAutoConnectorsError>> {
169
170    let uri_str = format!("{}/v1/auto/connectors", configuration.base_path);
171    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
172
173    if let Some(ref user_agent) = configuration.user_agent {
174        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
175    }
176    if let Some(ref token) = configuration.bearer_access_token {
177        req_builder = req_builder.bearer_auth(token.to_owned());
178    };
179
180    let req = req_builder.build()?;
181    let resp = configuration.client.execute(req).await?;
182
183    let status = resp.status();
184    let content_type = resp
185        .headers()
186        .get("content-type")
187        .and_then(|v| v.to_str().ok())
188        .unwrap_or("application/octet-stream");
189    let content_type = super::ContentType::from(content_type);
190
191    if !status.is_client_error() && !status.is_server_error() {
192        let content = resp.text().await?;
193        match content_type {
194            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
195            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Catalog`"))),
196            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Catalog`")))),
197        }
198    } else {
199        let content = resp.text().await?;
200        let entity: Option<GetAutoConnectorsError> = serde_json::from_str(&content).ok();
201        Err(Error::ResponseError(ResponseContent { status, content, entity }))
202    }
203}
204
205/// Returns the caller org's automations, most-recently-updated first. The optional `limit` query bounds the page.
206pub async fn get_auto_flows(configuration: &configuration::Configuration, limit: Option<i32>) -> Result<models::FlowPage, Error<GetAutoFlowsError>> {
207    // add a prefix to parameters to efficiently prevent name collisions
208    let p_limit = limit;
209
210    let uri_str = format!("{}/v1/auto/flows", configuration.base_path);
211    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
212
213    if let Some(ref param_value) = p_limit {
214        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
215    }
216    if let Some(ref user_agent) = configuration.user_agent {
217        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
218    }
219    if let Some(ref token) = configuration.bearer_access_token {
220        req_builder = req_builder.bearer_auth(token.to_owned());
221    };
222
223    let req = req_builder.build()?;
224    let resp = configuration.client.execute(req).await?;
225
226    let status = resp.status();
227    let content_type = resp
228        .headers()
229        .get("content-type")
230        .and_then(|v| v.to_str().ok())
231        .unwrap_or("application/octet-stream");
232    let content_type = super::ContentType::from(content_type);
233
234    if !status.is_client_error() && !status.is_server_error() {
235        let content = resp.text().await?;
236        match content_type {
237            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowPage`"))),
239            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowPage`")))),
240        }
241    } else {
242        let content = resp.text().await?;
243        let entity: Option<GetAutoFlowsError> = serde_json::from_str(&content).ok();
244        Err(Error::ResponseError(ResponseContent { status, content, entity }))
245    }
246}
247
248/// Returns one automation and its latest version. That is the flow record plus the step tree the builder edits; a flow of another org answers not-found.
249pub async fn get_auto_flows_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::PopulatedFlow, Error<GetAutoFlowsByIdError>> {
250    // add a prefix to parameters to efficiently prevent name collisions
251    let p_id = id;
252
253    let uri_str = format!("{}/v1/auto/flows/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
254    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
255
256    if let Some(ref user_agent) = configuration.user_agent {
257        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
258    }
259    if let Some(ref token) = configuration.bearer_access_token {
260        req_builder = req_builder.bearer_auth(token.to_owned());
261    };
262
263    let req = req_builder.build()?;
264    let resp = configuration.client.execute(req).await?;
265
266    let status = resp.status();
267    let content_type = resp
268        .headers()
269        .get("content-type")
270        .and_then(|v| v.to_str().ok())
271        .unwrap_or("application/octet-stream");
272    let content_type = super::ContentType::from(content_type);
273
274    if !status.is_client_error() && !status.is_server_error() {
275        let content = resp.text().await?;
276        match content_type {
277            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
278            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PopulatedFlow`"))),
279            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PopulatedFlow`")))),
280        }
281    } else {
282        let content = resp.text().await?;
283        let entity: Option<GetAutoFlowsByIdError> = serde_json::from_str(&content).ok();
284        Err(Error::ResponseError(ResponseContent { status, content, entity }))
285    }
286}
287
288/// Returns one flow's versions, newest first. The optional `limit` query bounds the page.
289pub async fn get_auto_flows_by_id_versions(configuration: &configuration::Configuration, id: &str, limit: Option<i32>) -> Result<models::VersionPage, Error<GetAutoFlowsByIdVersionsError>> {
290    // add a prefix to parameters to efficiently prevent name collisions
291    let p_id = id;
292    let p_limit = limit;
293
294    let uri_str = format!("{}/v1/auto/flows/{id}/versions", configuration.base_path, id=crate::apis::urlencode(p_id));
295    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
296
297    if let Some(ref param_value) = p_limit {
298        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
299    }
300    if let Some(ref user_agent) = configuration.user_agent {
301        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
302    }
303    if let Some(ref token) = configuration.bearer_access_token {
304        req_builder = req_builder.bearer_auth(token.to_owned());
305    };
306
307    let req = req_builder.build()?;
308    let resp = configuration.client.execute(req).await?;
309
310    let status = resp.status();
311    let content_type = resp
312        .headers()
313        .get("content-type")
314        .and_then(|v| v.to_str().ok())
315        .unwrap_or("application/octet-stream");
316    let content_type = super::ContentType::from(content_type);
317
318    if !status.is_client_error() && !status.is_server_error() {
319        let content = resp.text().await?;
320        match content_type {
321            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
322            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VersionPage`"))),
323            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VersionPage`")))),
324        }
325    } else {
326        let content = resp.text().await?;
327        let entity: Option<GetAutoFlowsByIdVersionsError> = serde_json::from_str(&content).ok();
328        Err(Error::ResponseError(ResponseContent { status, content, entity }))
329    }
330}
331
332/// Returns the caller org's run history, newest first. The optional `flowId` query narrows it to one flow and `limit` bounds the page.
333pub async fn get_auto_runs(configuration: &configuration::Configuration, flow_id: Option<&str>, limit: Option<i32>) -> Result<models::RunPage, Error<GetAutoRunsError>> {
334    // add a prefix to parameters to efficiently prevent name collisions
335    let p_flow_id = flow_id;
336    let p_limit = limit;
337
338    let uri_str = format!("{}/v1/auto/runs", configuration.base_path);
339    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
340
341    if let Some(ref param_value) = p_flow_id {
342        req_builder = req_builder.query(&[("flowId", &param_value.to_string())]);
343    }
344    if let Some(ref param_value) = p_limit {
345        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
346    }
347    if let Some(ref user_agent) = configuration.user_agent {
348        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
349    }
350    if let Some(ref token) = configuration.bearer_access_token {
351        req_builder = req_builder.bearer_auth(token.to_owned());
352    };
353
354    let req = req_builder.build()?;
355    let resp = configuration.client.execute(req).await?;
356
357    let status = resp.status();
358    let content_type = resp
359        .headers()
360        .get("content-type")
361        .and_then(|v| v.to_str().ok())
362        .unwrap_or("application/octet-stream");
363    let content_type = super::ContentType::from(content_type);
364
365    if !status.is_client_error() && !status.is_server_error() {
366        let content = resp.text().await?;
367        match content_type {
368            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
369            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunPage`"))),
370            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunPage`")))),
371        }
372    } else {
373        let content = resp.text().await?;
374        let entity: Option<GetAutoRunsError> = serde_json::from_str(&content).ok();
375        Err(Error::ResponseError(ResponseContent { status, content, entity }))
376    }
377}
378
379/// Returns one run. A run that has not reached a terminal status is refreshed from the durable engine first — scoped to the org's own namespace — so the caller sees live progress rather than the last status that happened to be persisted.
380pub async fn get_auto_runs_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowRun, Error<GetAutoRunsByIdError>> {
381    // add a prefix to parameters to efficiently prevent name collisions
382    let p_id = id;
383
384    let uri_str = format!("{}/v1/auto/runs/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
385    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
386
387    if let Some(ref user_agent) = configuration.user_agent {
388        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
389    }
390    if let Some(ref token) = configuration.bearer_access_token {
391        req_builder = req_builder.bearer_auth(token.to_owned());
392    };
393
394    let req = req_builder.build()?;
395    let resp = configuration.client.execute(req).await?;
396
397    let status = resp.status();
398    let content_type = resp
399        .headers()
400        .get("content-type")
401        .and_then(|v| v.to_str().ok())
402        .unwrap_or("application/octet-stream");
403    let content_type = super::ContentType::from(content_type);
404
405    if !status.is_client_error() && !status.is_server_error() {
406        let content = resp.text().await?;
407        match content_type {
408            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
409            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowRun`"))),
410            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowRun`")))),
411        }
412    } else {
413        let content = resp.text().await?;
414        let entity: Option<GetAutoRunsByIdError> = serde_json::from_str(&content).ok();
415        Err(Error::ResponseError(ResponseContent { status, content, entity }))
416    }
417}
418
419/// Updates one automation's metadata in place. Every field is optional; a field the request omits is left alone. Publishing a version pins which one runs, and is refused unless that version belongs to this flow.
420pub async fn patch_auto_flows_by_id(configuration: &configuration::Configuration, id: &str, patch_flow_in: models::PatchFlowIn) -> Result<models::Flow, Error<PatchAutoFlowsByIdError>> {
421    // add a prefix to parameters to efficiently prevent name collisions
422    let p_id = id;
423    let p_patch_flow_in = patch_flow_in;
424
425    let uri_str = format!("{}/v1/auto/flows/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
426    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
427
428    if let Some(ref user_agent) = configuration.user_agent {
429        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
430    }
431    if let Some(ref token) = configuration.bearer_access_token {
432        req_builder = req_builder.bearer_auth(token.to_owned());
433    };
434    req_builder = req_builder.json(&p_patch_flow_in);
435
436    let req = req_builder.build()?;
437    let resp = configuration.client.execute(req).await?;
438
439    let status = resp.status();
440    let content_type = resp
441        .headers()
442        .get("content-type")
443        .and_then(|v| v.to_str().ok())
444        .unwrap_or("application/octet-stream");
445    let content_type = super::ContentType::from(content_type);
446
447    if !status.is_client_error() && !status.is_server_error() {
448        let content = resp.text().await?;
449        match content_type {
450            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
451            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Flow`"))),
452            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Flow`")))),
453        }
454    } else {
455        let content = resp.text().await?;
456        let entity: Option<PatchAutoFlowsByIdError> = serde_json::from_str(&content).ok();
457        Err(Error::ResponseError(ResponseContent { status, content, entity }))
458    }
459}
460
461/// Run executes one connector action in-process and answers the outcome. The caller's resolved credential travels in `auth`, delivered to the action verbatim — the runtime resolves no credential itself. An action that ran and failed (or an action name the connector does not have) answers ok:false with the failure message, not an HTTP error; an unknown connector is 404 and a missing action 422.
462pub async fn post_auto_connectors_by_id_run(configuration: &configuration::Configuration, id: &str, run_in: models::RunIn) -> Result<models::RunResp, Error<PostAutoConnectorsByIdRunError>> {
463    // add a prefix to parameters to efficiently prevent name collisions
464    let p_id = id;
465    let p_run_in = run_in;
466
467    let uri_str = format!("{}/v1/auto/connectors/{id}/run", configuration.base_path, id=crate::apis::urlencode(p_id));
468    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
469
470    if let Some(ref user_agent) = configuration.user_agent {
471        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
472    }
473    if let Some(ref token) = configuration.bearer_access_token {
474        req_builder = req_builder.bearer_auth(token.to_owned());
475    };
476    req_builder = req_builder.json(&p_run_in);
477
478    let req = req_builder.build()?;
479    let resp = configuration.client.execute(req).await?;
480
481    let status = resp.status();
482    let content_type = resp
483        .headers()
484        .get("content-type")
485        .and_then(|v| v.to_str().ok())
486        .unwrap_or("application/octet-stream");
487    let content_type = super::ContentType::from(content_type);
488
489    if !status.is_client_error() && !status.is_server_error() {
490        let content = resp.text().await?;
491        match content_type {
492            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
493            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RunResp`"))),
494            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RunResp`")))),
495        }
496    } else {
497        let content = resp.text().await?;
498        let entity: Option<PostAutoConnectorsByIdRunError> = serde_json::from_str(&content).ok();
499        Err(Error::ResponseError(ResponseContent { status, content, entity }))
500    }
501}
502
503/// Creates an automation and its initial DRAFT version in one call. The new flow is DISABLED — creating it does not arm its trigger; POST /v1/auto/flows/{id}/enable does that.
504pub async fn post_auto_flows(configuration: &configuration::Configuration, create_flow_req: models::CreateFlowReq) -> Result<models::PopulatedFlow, Error<PostAutoFlowsError>> {
505    // add a prefix to parameters to efficiently prevent name collisions
506    let p_create_flow_req = create_flow_req;
507
508    let uri_str = format!("{}/v1/auto/flows", configuration.base_path);
509    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
510
511    if let Some(ref user_agent) = configuration.user_agent {
512        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
513    }
514    if let Some(ref token) = configuration.bearer_access_token {
515        req_builder = req_builder.bearer_auth(token.to_owned());
516    };
517    req_builder = req_builder.json(&p_create_flow_req);
518
519    let req = req_builder.build()?;
520    let resp = configuration.client.execute(req).await?;
521
522    let status = resp.status();
523    let content_type = resp
524        .headers()
525        .get("content-type")
526        .and_then(|v| v.to_str().ok())
527        .unwrap_or("application/octet-stream");
528    let content_type = super::ContentType::from(content_type);
529
530    if !status.is_client_error() && !status.is_server_error() {
531        let content = resp.text().await?;
532        match content_type {
533            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
534            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PopulatedFlow`"))),
535            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PopulatedFlow`")))),
536        }
537    } else {
538        let content = resp.text().await?;
539        let entity: Option<PostAutoFlowsError> = serde_json::from_str(&content).ok();
540        Err(Error::ResponseError(ResponseContent { status, content, entity }))
541    }
542}
543
544/// Disarms a flow's trigger and marks it DISABLED. Its schedule and its event subscriptions are dropped, so a disabled flow is never a live target; runs already in flight are unaffected, and it can still be started on demand.
545pub async fn post_auto_flows_by_id_disable(configuration: &configuration::Configuration, id: &str) -> Result<models::Flow, Error<PostAutoFlowsByIdDisableError>> {
546    // add a prefix to parameters to efficiently prevent name collisions
547    let p_id = id;
548
549    let uri_str = format!("{}/v1/auto/flows/{id}/disable", configuration.base_path, id=crate::apis::urlencode(p_id));
550    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
551
552    if let Some(ref user_agent) = configuration.user_agent {
553        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
554    }
555    if let Some(ref token) = configuration.bearer_access_token {
556        req_builder = req_builder.bearer_auth(token.to_owned());
557    };
558
559    let req = req_builder.build()?;
560    let resp = configuration.client.execute(req).await?;
561
562    let status = resp.status();
563    let content_type = resp
564        .headers()
565        .get("content-type")
566        .and_then(|v| v.to_str().ok())
567        .unwrap_or("application/octet-stream");
568    let content_type = super::ContentType::from(content_type);
569
570    if !status.is_client_error() && !status.is_server_error() {
571        let content = resp.text().await?;
572        match content_type {
573            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
574            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Flow`"))),
575            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Flow`")))),
576        }
577    } else {
578        let content = resp.text().await?;
579        let entity: Option<PostAutoFlowsByIdDisableError> = serde_json::from_str(&content).ok();
580        Err(Error::ResponseError(ResponseContent { status, content, entity }))
581    }
582}
583
584/// Arms a flow's trigger and marks it ENABLED. A POLLING trigger gets a cron schedule on the durable engine; a WEBHOOK trigger gets a subscription in the routing index, so an inbound event starts it; a MANUAL trigger arms nothing and still runs on demand.
585pub async fn post_auto_flows_by_id_enable(configuration: &configuration::Configuration, id: &str) -> Result<models::Flow, Error<PostAutoFlowsByIdEnableError>> {
586    // add a prefix to parameters to efficiently prevent name collisions
587    let p_id = id;
588
589    let uri_str = format!("{}/v1/auto/flows/{id}/enable", configuration.base_path, id=crate::apis::urlencode(p_id));
590    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
591
592    if let Some(ref user_agent) = configuration.user_agent {
593        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
594    }
595    if let Some(ref token) = configuration.bearer_access_token {
596        req_builder = req_builder.bearer_auth(token.to_owned());
597    };
598
599    let req = req_builder.build()?;
600    let resp = configuration.client.execute(req).await?;
601
602    let status = resp.status();
603    let content_type = resp
604        .headers()
605        .get("content-type")
606        .and_then(|v| v.to_str().ok())
607        .unwrap_or("application/octet-stream");
608    let content_type = super::ContentType::from(content_type);
609
610    if !status.is_client_error() && !status.is_server_error() {
611        let content = resp.text().await?;
612        match content_type {
613            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
614            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Flow`"))),
615            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Flow`")))),
616        }
617    } else {
618        let content = resp.text().await?;
619        let entity: Option<PostAutoFlowsByIdEnableError> = serde_json::from_str(&content).ok();
620        Err(Error::ResponseError(ResponseContent { status, content, entity }))
621    }
622}
623
624/// Applies ONE flow operation and answers the thing it changed. The operation is named by `type`, with its arguments under `request`: `CHANGE_NAME`, `UPDATE_TRIGGER`, `ADD_ACTION`, `UPDATE_ACTION`, `MOVE_ACTION`, `DELETE_ACTION` edit the flow's LATEST version and answer with that version, and `CHANGE_STATUS` instead enables or disables the flow and answers with the FLOW. Two response shapes on one address is the rule a reader would otherwise get wrong, and it is why this route is not a typed op.  Edits land on the latest version only — the published version a run executes is untouched until it is republished — and the whole resulting step tree is re-validated against the step-count and size caps after every operation, so a long sequence of `ADD_ACTION` calls cannot grow a flow past a bound one step at a time (422 when it would). Org-scoped and fails closed: a validated principal is required (403 without one), the flow and its version are read under the caller's OWN org so another tenant's id is a 404, and an operation whose `request` does not decode is a 400.
625pub async fn post_auto_flows_by_id_operations(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<PostAutoFlowsByIdOperationsError>> {
626    // add a prefix to parameters to efficiently prevent name collisions
627    let p_id = id;
628
629    let uri_str = format!("{}/v1/auto/flows/{id}/operations", configuration.base_path, id=crate::apis::urlencode(p_id));
630    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
631
632    if let Some(ref user_agent) = configuration.user_agent {
633        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
634    }
635    if let Some(ref token) = configuration.bearer_access_token {
636        req_builder = req_builder.bearer_auth(token.to_owned());
637    };
638
639    let req = req_builder.build()?;
640    let resp = configuration.client.execute(req).await?;
641
642    let status = resp.status();
643
644    if !status.is_client_error() && !status.is_server_error() {
645        Ok(())
646    } else {
647        let content = resp.text().await?;
648        let entity: Option<PostAutoFlowsByIdOperationsError> = serde_json::from_str(&content).ok();
649        Err(Error::ResponseError(ResponseContent { status, content, entity }))
650    }
651}
652
653/// Starts one durable run of a flow now. It runs the flow's published version if one is pinned, else its latest, and answers the run record it created. The run is bounded by the org's per-minute run-start budget and its in-flight concurrency ceiling; over either, or with the engine not ready, no run is started and no run id is burned.
654pub async fn post_auto_flows_by_id_run(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowRun, Error<PostAutoFlowsByIdRunError>> {
655    // add a prefix to parameters to efficiently prevent name collisions
656    let p_id = id;
657
658    let uri_str = format!("{}/v1/auto/flows/{id}/run", configuration.base_path, id=crate::apis::urlencode(p_id));
659    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
660
661    if let Some(ref user_agent) = configuration.user_agent {
662        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
663    }
664    if let Some(ref token) = configuration.bearer_access_token {
665        req_builder = req_builder.bearer_auth(token.to_owned());
666    };
667
668    let req = req_builder.build()?;
669    let resp = configuration.client.execute(req).await?;
670
671    let status = resp.status();
672    let content_type = resp
673        .headers()
674        .get("content-type")
675        .and_then(|v| v.to_str().ok())
676        .unwrap_or("application/octet-stream");
677    let content_type = super::ContentType::from(content_type);
678
679    if !status.is_client_error() && !status.is_server_error() {
680        let content = resp.text().await?;
681        match content_type {
682            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
683            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowRun`"))),
684            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowRun`")))),
685        }
686    } else {
687        let content = resp.text().await?;
688        let entity: Option<PostAutoFlowsByIdRunError> = serde_json::from_str(&content).ok();
689        Err(Error::ResponseError(ResponseContent { status, content, entity }))
690    }
691}
692
693/// Adds a new DRAFT version to a flow. The version is created invalid unless it carries a trigger, and it does not become the running version until it is published (PATCH the flow's publishedVersionId) or becomes the latest.
694pub async fn post_auto_flows_by_id_versions(configuration: &configuration::Configuration, id: &str, create_version_in: models::CreateVersionIn) -> Result<models::FlowVersion, Error<PostAutoFlowsByIdVersionsError>> {
695    // add a prefix to parameters to efficiently prevent name collisions
696    let p_id = id;
697    let p_create_version_in = create_version_in;
698
699    let uri_str = format!("{}/v1/auto/flows/{id}/versions", configuration.base_path, id=crate::apis::urlencode(p_id));
700    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
701
702    if let Some(ref user_agent) = configuration.user_agent {
703        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
704    }
705    if let Some(ref token) = configuration.bearer_access_token {
706        req_builder = req_builder.bearer_auth(token.to_owned());
707    };
708    req_builder = req_builder.json(&p_create_version_in);
709
710    let req = req_builder.build()?;
711    let resp = configuration.client.execute(req).await?;
712
713    let status = resp.status();
714    let content_type = resp
715        .headers()
716        .get("content-type")
717        .and_then(|v| v.to_str().ok())
718        .unwrap_or("application/octet-stream");
719    let content_type = super::ContentType::from(content_type);
720
721    if !status.is_client_error() && !status.is_server_error() {
722        let content = resp.text().await?;
723        match content_type {
724            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
725            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowVersion`"))),
726            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowVersion`")))),
727        }
728    } else {
729        let content = resp.text().await?;
730        let entity: Option<PostAutoFlowsByIdVersionsError> = serde_json::from_str(&content).ok();
731        Err(Error::ResponseError(ResponseContent { status, content, entity }))
732    }
733}
734
735/// Delivers one event to the org's automation triggers and answers `{matched:n}` — how many enabled flows had a webhook trigger on this `(source, event)` key and were started by it. A zero match is a success, not an error: nothing was subscribed.  The path is the trigger key and the JSON object body is the event payload, threaded into each started run as `{{trigger.*}}` with all of its keys intact — which is why this is not a typed op, since a declared input struct would silently DISCARD every payload key it had no field for. Re-delivery is a no-op: an `X-Idempotency-Key` header dedupes, and with none the body is content-hashed instead, so a hammer of identical posts collapses to ONE run rather than minting a fresh one per post. An in-platform producer may propagate `X-Causation-Depth` so a firing that a flow caused is bounded against a loop; an absent or invalid header reads as depth 0, an external origin.  Authenticated and org-scoped, unlike a provider's public webhook URL: a validated principal is required (403 without one) and the org is that principal's, never the body's, so a producer can only fire into its own tenant's flows. Both path segments are required (400) and a payload over the size limit is a 413.
736pub async fn post_auto_hooks_by_source_by_event(configuration: &configuration::Configuration, source: &str, event: &str) -> Result<(), Error<PostAutoHooksBySourceByEventError>> {
737    // add a prefix to parameters to efficiently prevent name collisions
738    let p_source = source;
739    let p_event = event;
740
741    let uri_str = format!("{}/v1/auto/hooks/{source}/{event}", configuration.base_path, source=crate::apis::urlencode(p_source), event=crate::apis::urlencode(p_event));
742    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
743
744    if let Some(ref user_agent) = configuration.user_agent {
745        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
746    }
747    if let Some(ref token) = configuration.bearer_access_token {
748        req_builder = req_builder.bearer_auth(token.to_owned());
749    };
750
751    let req = req_builder.build()?;
752    let resp = configuration.client.execute(req).await?;
753
754    let status = resp.status();
755
756    if !status.is_client_error() && !status.is_server_error() {
757        Ok(())
758    } else {
759        let content = resp.text().await?;
760        let entity: Option<PostAutoHooksBySourceByEventError> = serde_json::from_str(&content).ok();
761        Err(Error::ResponseError(ResponseContent { status, content, entity }))
762    }
763}
764
765/// Delivers the durable `resume` signal to a run parked on a `wait_for_approval` waitpoint and answers `{resumed:true}` once the engine has taken it.  The body is an ARBITRARY JSON value — object, array, string, number — delivered VERBATIM into the workflow as that waitpoint's output, so it is what the steps after the approval read as their input. An empty body resumes with no payload. That open shape is why this route is not a typed op: an operation's input can carry the payload or the run address, never both.  Org-scoped and fails closed: a validated principal is required (403 without one), the run is read under the caller's OWN org so another tenant's run id is a 404, a body that is not JSON is a 400, and a payload over the size limit is a 413 — it becomes durable engine state, so it is bounded here rather than after it lands. The resume is audited as `automations.run.resume`.
766pub async fn post_auto_runs_by_id_resume(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<PostAutoRunsByIdResumeError>> {
767    // add a prefix to parameters to efficiently prevent name collisions
768    let p_id = id;
769
770    let uri_str = format!("{}/v1/auto/runs/{id}/resume", configuration.base_path, id=crate::apis::urlencode(p_id));
771    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
772
773    if let Some(ref user_agent) = configuration.user_agent {
774        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
775    }
776    if let Some(ref token) = configuration.bearer_access_token {
777        req_builder = req_builder.bearer_auth(token.to_owned());
778    };
779
780    let req = req_builder.build()?;
781    let resp = configuration.client.execute(req).await?;
782
783    let status = resp.status();
784
785    if !status.is_client_error() && !status.is_server_error() {
786        Ok(())
787    } else {
788        let content = resp.text().await?;
789        let entity: Option<PostAutoRunsByIdResumeError> = serde_json::from_str(&content).ok();
790        Err(Error::ResponseError(ResponseContent { status, content, entity }))
791    }
792}
793