1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum DeleteFlowWorkflowsByWorkflowError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetFlowRunsError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetFlowStatusError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetFlowWorkflowsError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetFlowWorkflowsByWorkflowError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum PatchFlowWorkflowsByWorkflowError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PostFlowRunsError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostFlowWorkflowsError {
71 UnknownValue(serde_json::Value),
72}
73
74
75pub async fn delete_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str) -> Result<serde_json::Value, Error<DeleteFlowWorkflowsByWorkflowError>> {
77 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
115pub async fn get_flow_runs(configuration: &configuration::Configuration, workflow: Option<&str>) -> Result<serde_json::Value, Error<GetFlowRunsError>> {
117 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", ¶m_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
158pub 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
196pub async fn get_flow_workflows(configuration: &configuration::Configuration, page: Option<&str>, size: Option<&str>) -> Result<serde_json::Value, Error<GetFlowWorkflowsError>> {
198 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", ¶m_value.to_string())]);
207 }
208 if let Some(ref param_value) = p_size {
209 req_builder = req_builder.query(&[("size", ¶m_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
243pub async fn get_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str) -> Result<serde_json::Value, Error<GetFlowWorkflowsByWorkflowError>> {
245 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
283pub async fn patch_flow_workflows_by_workflow(configuration: &configuration::Configuration, workflow: &str, flow_update: models::FlowUpdate) -> Result<serde_json::Value, Error<PatchFlowWorkflowsByWorkflowError>> {
285 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
325pub async fn post_flow_runs(configuration: &configuration::Configuration, flow_run: models::FlowRun) -> Result<serde_json::Value, Error<PostFlowRunsError>> {
327 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
366pub async fn post_flow_workflows(configuration: &configuration::Configuration, flow_create: models::FlowCreate) -> Result<serde_json::Value, Error<PostFlowWorkflowsError>> {
368 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