Skip to main content

hanzo_client/apis/
flow_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_flow_workflows_by_workflow`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteFlowWorkflowsByWorkflowError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_flow_runs`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetFlowRunsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_flow_status`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetFlowStatusError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_flow_workflows`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetFlowWorkflowsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_flow_workflows_by_workflow`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetFlowWorkflowsByWorkflowError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`patch_flow_workflows_by_workflow`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PatchFlowWorkflowsByWorkflowError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`post_flow_runs`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PostFlowRunsError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`post_flow_workflows`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostFlowWorkflowsError {
71    UnknownValue(serde_json::Value),
72}
73
74
75/// Deletes one of the caller's workflows and its runs. Ownership is verified first; a foreign id answers 404 and deletes nothing.
76pub async fn delete_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str) -> Result<serde_json::Value, Error<DeleteFlowWorkflowsByWorkflowError>> {
77    // add a prefix to parameters to efficiently prevent name collisions
78    let p_workflow = workflow;
79
80    let uri_str = format!("{}/v1/flow/workflows/{workflow}", configuration.base_path, workflow=crate::apis::urlencode(p_workflow));
81    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
82
83    if let Some(ref user_agent) = configuration.user_agent {
84        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
85    }
86    if let Some(ref token) = configuration.bearer_access_token {
87        req_builder = req_builder.bearer_auth(token.to_owned());
88    };
89
90    let req = req_builder.build()?;
91    let resp = configuration.client.execute(req).await?;
92
93    let status = resp.status();
94    let content_type = resp
95        .headers()
96        .get("content-type")
97        .and_then(|v| v.to_str().ok())
98        .unwrap_or("application/octet-stream");
99    let content_type = super::ContentType::from(content_type);
100
101    if !status.is_client_error() && !status.is_server_error() {
102        let content = resp.text().await?;
103        match content_type {
104            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
105            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
106            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
107        }
108    } else {
109        let content = resp.text().await?;
110        let entity: Option<DeleteFlowWorkflowsByWorkflowError> = serde_json::from_str(&content).ok();
111        Err(Error::ResponseError(ResponseContent { status, content, entity }))
112    }
113}
114
115/// Runs reads one workflow's recorded runs: every component build with its result, keyed by component. Ownership is verified first — run records never cross the org boundary.
116pub async fn get_flow_runs(configuration: &configuration::Configuration, workflow: Option<&str>) -> Result<serde_json::Value, Error<GetFlowRunsError>> {
117    // add a prefix to parameters to efficiently prevent name collisions
118    let p_workflow = workflow;
119
120    let uri_str = format!("{}/v1/flow/runs", configuration.base_path);
121    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
122
123    if let Some(ref param_value) = p_workflow {
124        req_builder = req_builder.query(&[("workflow", &param_value.to_string())]);
125    }
126    if let Some(ref user_agent) = configuration.user_agent {
127        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128    }
129    if let Some(ref token) = configuration.bearer_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137    let content_type = resp
138        .headers()
139        .get("content-type")
140        .and_then(|v| v.to_str().ok())
141        .unwrap_or("application/octet-stream");
142    let content_type = super::ContentType::from(content_type);
143
144    if !status.is_client_error() && !status.is_server_error() {
145        let content = resp.text().await?;
146        match content_type {
147            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
149            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
150        }
151    } else {
152        let content = resp.text().await?;
153        let entity: Option<GetFlowRunsError> = serde_json::from_str(&content).ok();
154        Err(Error::ResponseError(ResponseContent { status, content, entity }))
155    }
156}
157
158/// Status reports whether the flow service is reachable and which version it runs. It is the product's own /health and /v1/version composed — an honest lens for \"is the workflow plane up\", never a fabricated ok.
159pub async fn get_flow_status(configuration: &configuration::Configuration, ) -> Result<models::FlowStatus, Error<GetFlowStatusError>> {
160
161    let uri_str = format!("{}/v1/flow/status", configuration.base_path);
162    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
163
164    if let Some(ref user_agent) = configuration.user_agent {
165        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
166    }
167    if let Some(ref token) = configuration.bearer_access_token {
168        req_builder = req_builder.bearer_auth(token.to_owned());
169    };
170
171    let req = req_builder.build()?;
172    let resp = configuration.client.execute(req).await?;
173
174    let status = resp.status();
175    let content_type = resp
176        .headers()
177        .get("content-type")
178        .and_then(|v| v.to_str().ok())
179        .unwrap_or("application/octet-stream");
180    let content_type = super::ContentType::from(content_type);
181
182    if !status.is_client_error() && !status.is_server_error() {
183        let content = resp.text().await?;
184        match content_type {
185            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowStatus`"))),
187            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::FlowStatus`")))),
188        }
189    } else {
190        let content = resp.text().await?;
191        let entity: Option<GetFlowStatusError> = serde_json::from_str(&content).ok();
192        Err(Error::ResponseError(ResponseContent { status, content, entity }))
193    }
194}
195
196/// Workflows lists the caller's workflows, paged. The list is scoped server-side to the org's project — the page can only ever hold the caller's own workflows.
197pub async fn get_flow_workflows(configuration: &configuration::Configuration, page: Option<&str>, size: Option<&str>) -> Result<serde_json::Value, Error<GetFlowWorkflowsError>> {
198    // add a prefix to parameters to efficiently prevent name collisions
199    let p_page = page;
200    let p_size = size;
201
202    let uri_str = format!("{}/v1/flow/workflows", configuration.base_path);
203    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
204
205    if let Some(ref param_value) = p_page {
206        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
207    }
208    if let Some(ref param_value) = p_size {
209        req_builder = req_builder.query(&[("size", &param_value.to_string())]);
210    }
211    if let Some(ref user_agent) = configuration.user_agent {
212        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
213    }
214    if let Some(ref token) = configuration.bearer_access_token {
215        req_builder = req_builder.bearer_auth(token.to_owned());
216    };
217
218    let req = req_builder.build()?;
219    let resp = configuration.client.execute(req).await?;
220
221    let status = resp.status();
222    let content_type = resp
223        .headers()
224        .get("content-type")
225        .and_then(|v| v.to_str().ok())
226        .unwrap_or("application/octet-stream");
227    let content_type = super::ContentType::from(content_type);
228
229    if !status.is_client_error() && !status.is_server_error() {
230        let content = resp.text().await?;
231        match content_type {
232            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
233            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
234            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
235        }
236    } else {
237        let content = resp.text().await?;
238        let entity: Option<GetFlowWorkflowsError> = serde_json::from_str(&content).ok();
239        Err(Error::ResponseError(ResponseContent { status, content, entity }))
240    }
241}
242
243/// Workflow reads one of the caller's workflows — the full record, graph included. A workflow outside the caller's org answers 404, indistinguishable from one that does not exist.
244pub async fn get_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str) -> Result<serde_json::Value, Error<GetFlowWorkflowsByWorkflowError>> {
245    // add a prefix to parameters to efficiently prevent name collisions
246    let p_workflow = workflow;
247
248    let uri_str = format!("{}/v1/flow/workflows/{workflow}", configuration.base_path, workflow=crate::apis::urlencode(p_workflow));
249    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
250
251    if let Some(ref user_agent) = configuration.user_agent {
252        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
253    }
254    if let Some(ref token) = configuration.bearer_access_token {
255        req_builder = req_builder.bearer_auth(token.to_owned());
256    };
257
258    let req = req_builder.build()?;
259    let resp = configuration.client.execute(req).await?;
260
261    let status = resp.status();
262    let content_type = resp
263        .headers()
264        .get("content-type")
265        .and_then(|v| v.to_str().ok())
266        .unwrap_or("application/octet-stream");
267    let content_type = super::ContentType::from(content_type);
268
269    if !status.is_client_error() && !status.is_server_error() {
270        let content = resp.text().await?;
271        match content_type {
272            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
273            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
274            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
275        }
276    } else {
277        let content = resp.text().await?;
278        let entity: Option<GetFlowWorkflowsByWorkflowError> = serde_json::from_str(&content).ok();
279        Err(Error::ResponseError(ResponseContent { status, content, entity }))
280    }
281}
282
283/// Patches one of the caller's workflows: name, description, graph, or the locked flag — only the stated fields move. Ownership is verified before the patch reaches the product.
284pub async fn patch_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str, flow_update: models::FlowUpdate) -> Result<serde_json::Value, Error<PatchFlowWorkflowsByWorkflowError>> {
285    // add a prefix to parameters to efficiently prevent name collisions
286    let p_workflow = workflow;
287    let p_flow_update = flow_update;
288
289    let uri_str = format!("{}/v1/flow/workflows/{workflow}", configuration.base_path, workflow=crate::apis::urlencode(p_workflow));
290    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
291
292    if let Some(ref user_agent) = configuration.user_agent {
293        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
294    }
295    if let Some(ref token) = configuration.bearer_access_token {
296        req_builder = req_builder.bearer_auth(token.to_owned());
297    };
298    req_builder = req_builder.json(&p_flow_update);
299
300    let req = req_builder.build()?;
301    let resp = configuration.client.execute(req).await?;
302
303    let status = resp.status();
304    let content_type = resp
305        .headers()
306        .get("content-type")
307        .and_then(|v| v.to_str().ok())
308        .unwrap_or("application/octet-stream");
309    let content_type = super::ContentType::from(content_type);
310
311    if !status.is_client_error() && !status.is_server_error() {
312        let content = resp.text().await?;
313        match content_type {
314            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
315            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
316            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
317        }
318    } else {
319        let content = resp.text().await?;
320        let entity: Option<PatchFlowWorkflowsByWorkflowError> = serde_json::from_str(&content).ok();
321        Err(Error::ResponseError(ResponseContent { status, content, entity }))
322    }
323}
324
325/// Run executes one of the caller's workflows synchronously: the graph runs in the flow service and the response carries the run's session and outputs. A graph whose components fail reports the product's own error. Runs are bounded by the product's five-minute sync ceiling.
326pub async fn post_flow_runs(configuration: &configuration::Configuration, flow_run: models::FlowRun) -> Result<serde_json::Value, Error<PostFlowRunsError>> {
327    // add a prefix to parameters to efficiently prevent name collisions
328    let p_flow_run = flow_run;
329
330    let uri_str = format!("{}/v1/flow/runs", configuration.base_path);
331    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
332
333    if let Some(ref user_agent) = configuration.user_agent {
334        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
335    }
336    if let Some(ref token) = configuration.bearer_access_token {
337        req_builder = req_builder.bearer_auth(token.to_owned());
338    };
339    req_builder = req_builder.json(&p_flow_run);
340
341    let req = req_builder.build()?;
342    let resp = configuration.client.execute(req).await?;
343
344    let status = resp.status();
345    let content_type = resp
346        .headers()
347        .get("content-type")
348        .and_then(|v| v.to_str().ok())
349        .unwrap_or("application/octet-stream");
350    let content_type = super::ContentType::from(content_type);
351
352    if !status.is_client_error() && !status.is_server_error() {
353        let content = resp.text().await?;
354        match content_type {
355            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
356            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
357            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
358        }
359    } else {
360        let content = resp.text().await?;
361        let entity: Option<PostFlowRunsError> = serde_json::from_str(&content).ok();
362        Err(Error::ResponseError(ResponseContent { status, content, entity }))
363    }
364}
365
366/// Creates a workflow in the caller's org. The org's project id is pinned server-side from the validated principal — there is no field by which a caller could place a workflow in another org.
367pub async fn post_flow_workflows(configuration: &configuration::Configuration, flow_create: models::FlowCreate) -> Result<serde_json::Value, Error<PostFlowWorkflowsError>> {
368    // add a prefix to parameters to efficiently prevent name collisions
369    let p_flow_create = flow_create;
370
371    let uri_str = format!("{}/v1/flow/workflows", configuration.base_path);
372    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
373
374    if let Some(ref user_agent) = configuration.user_agent {
375        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
376    }
377    if let Some(ref token) = configuration.bearer_access_token {
378        req_builder = req_builder.bearer_auth(token.to_owned());
379    };
380    req_builder = req_builder.json(&p_flow_create);
381
382    let req = req_builder.build()?;
383    let resp = configuration.client.execute(req).await?;
384
385    let status = resp.status();
386    let content_type = resp
387        .headers()
388        .get("content-type")
389        .and_then(|v| v.to_str().ok())
390        .unwrap_or("application/octet-stream");
391    let content_type = super::ContentType::from(content_type);
392
393    if !status.is_client_error() && !status.is_server_error() {
394        let content = resp.text().await?;
395        match content_type {
396            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
397            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
398            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
399        }
400    } else {
401        let content = resp.text().await?;
402        let entity: Option<PostFlowWorkflowsError> = serde_json::from_str(&content).ok();
403        Err(Error::ResponseError(ResponseContent { status, content, entity }))
404    }
405}
406