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 ArchiveBpmnFlowByPathError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CreateBpmnFlowError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum DeleteBpmnFlowByPathError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum ExistsBpmnFlowByPathError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetBpmnFlowByPathError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetBpmnFlowByPathWithDraftError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetBpmnFlowHistoryError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetBpmnFlowVersionError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListBpmnFlowsError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum ListBpmnPathsError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum UpdateBpmnFlowError {
92 UnknownValue(serde_json::Value),
93}
94
95
96pub async fn archive_bpmn_flow_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str, archive_flow_by_path_request: models::ArchiveFlowByPathRequest) -> Result<String, Error<ArchiveBpmnFlowByPathError>> {
97 let local_var_configuration = configuration;
98
99 let local_var_client = &local_var_configuration.client;
100
101 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/archive/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
102 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
103
104 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
105 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
106 }
107 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
108 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
109 };
110 local_var_req_builder = local_var_req_builder.json(&archive_flow_by_path_request);
111
112 let local_var_req = local_var_req_builder.build()?;
113 let local_var_resp = local_var_client.execute(local_var_req).await?;
114
115 let local_var_status = local_var_resp.status();
116 let local_var_content = local_var_resp.text().await?;
117
118 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
119 crate::from_str_patched(&local_var_content).map_err(Error::from)
120 } else {
121 let local_var_entity: Option<ArchiveBpmnFlowByPathError> = crate::from_str_patched(&local_var_content).ok();
122 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
123 Err(Error::ResponseError(local_var_error))
124 }
125}
126
127pub async fn create_bpmn_flow(configuration: &configuration::Configuration, workspace: &str, new_bpmn_flow: models::NewBpmnFlow) -> Result<String, Error<CreateBpmnFlowError>> {
128 let local_var_configuration = configuration;
129
130 let local_var_client = &local_var_configuration.client;
131
132 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
133 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
134
135 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
136 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
137 }
138 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
139 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
140 };
141 local_var_req_builder = local_var_req_builder.json(&new_bpmn_flow);
142
143 let local_var_req = local_var_req_builder.build()?;
144 let local_var_resp = local_var_client.execute(local_var_req).await?;
145
146 let local_var_status = local_var_resp.status();
147 let local_var_content = local_var_resp.text().await?;
148
149 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
150 crate::from_str_patched(&local_var_content).map_err(Error::from)
151 } else {
152 let local_var_entity: Option<CreateBpmnFlowError> = crate::from_str_patched(&local_var_content).ok();
153 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
154 Err(Error::ResponseError(local_var_error))
155 }
156}
157
158pub async fn delete_bpmn_flow_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteBpmnFlowByPathError>> {
159 let local_var_configuration = configuration;
160
161 let local_var_client = &local_var_configuration.client;
162
163 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
164 let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
165
166 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
167 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
168 }
169 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
170 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
171 };
172
173 let local_var_req = local_var_req_builder.build()?;
174 let local_var_resp = local_var_client.execute(local_var_req).await?;
175
176 let local_var_status = local_var_resp.status();
177 let local_var_content = local_var_resp.text().await?;
178
179 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
180 crate::from_str_patched(&local_var_content).map_err(Error::from)
181 } else {
182 let local_var_entity: Option<DeleteBpmnFlowByPathError> = crate::from_str_patched(&local_var_content).ok();
183 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
184 Err(Error::ResponseError(local_var_error))
185 }
186}
187
188pub async fn exists_bpmn_flow_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsBpmnFlowByPathError>> {
189 let local_var_configuration = configuration;
190
191 let local_var_client = &local_var_configuration.client;
192
193 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
194 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
195
196 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
197 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
198 }
199 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
200 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
201 };
202
203 let local_var_req = local_var_req_builder.build()?;
204 let local_var_resp = local_var_client.execute(local_var_req).await?;
205
206 let local_var_status = local_var_resp.status();
207 let local_var_content = local_var_resp.text().await?;
208
209 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
210 crate::from_str_patched(&local_var_content).map_err(Error::from)
211 } else {
212 let local_var_entity: Option<ExistsBpmnFlowByPathError> = crate::from_str_patched(&local_var_content).ok();
213 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
214 Err(Error::ResponseError(local_var_error))
215 }
216}
217
218pub async fn get_bpmn_flow_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::BpmnFlow, Error<GetBpmnFlowByPathError>> {
219 let local_var_configuration = configuration;
220
221 let local_var_client = &local_var_configuration.client;
222
223 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
224 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
225
226 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
227 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
228 }
229 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
230 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
231 };
232
233 let local_var_req = local_var_req_builder.build()?;
234 let local_var_resp = local_var_client.execute(local_var_req).await?;
235
236 let local_var_status = local_var_resp.status();
237 let local_var_content = local_var_resp.text().await?;
238
239 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
240 crate::from_str_patched(&local_var_content).map_err(Error::from)
241 } else {
242 let local_var_entity: Option<GetBpmnFlowByPathError> = crate::from_str_patched(&local_var_content).ok();
243 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
244 Err(Error::ResponseError(local_var_error))
245 }
246}
247
248pub async fn get_bpmn_flow_by_path_with_draft(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::BpmnFlowWithDraft, Error<GetBpmnFlowByPathWithDraftError>> {
249 let local_var_configuration = configuration;
250
251 let local_var_client = &local_var_configuration.client;
252
253 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/get/draft/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
254 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
255
256 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
258 }
259 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
260 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
261 };
262
263 let local_var_req = local_var_req_builder.build()?;
264 let local_var_resp = local_var_client.execute(local_var_req).await?;
265
266 let local_var_status = local_var_resp.status();
267 let local_var_content = local_var_resp.text().await?;
268
269 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
270 crate::from_str_patched(&local_var_content).map_err(Error::from)
271 } else {
272 let local_var_entity: Option<GetBpmnFlowByPathWithDraftError> = crate::from_str_patched(&local_var_content).ok();
273 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
274 Err(Error::ResponseError(local_var_error))
275 }
276}
277
278pub async fn get_bpmn_flow_history(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::BpmnFlowVersion>, Error<GetBpmnFlowHistoryError>> {
279 let local_var_configuration = configuration;
280
281 let local_var_client = &local_var_configuration.client;
282
283 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/history/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
284 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
285
286 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
287 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
288 }
289 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
290 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
291 };
292
293 let local_var_req = local_var_req_builder.build()?;
294 let local_var_resp = local_var_client.execute(local_var_req).await?;
295
296 let local_var_status = local_var_resp.status();
297 let local_var_content = local_var_resp.text().await?;
298
299 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
300 crate::from_str_patched(&local_var_content).map_err(Error::from)
301 } else {
302 let local_var_entity: Option<GetBpmnFlowHistoryError> = crate::from_str_patched(&local_var_content).ok();
303 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
304 Err(Error::ResponseError(local_var_error))
305 }
306}
307
308pub async fn get_bpmn_flow_version(configuration: &configuration::Configuration, workspace: &str, version: i32, path: &str) -> Result<models::BpmnFlow, Error<GetBpmnFlowVersionError>> {
309 let local_var_configuration = configuration;
310
311 let local_var_client = &local_var_configuration.client;
312
313 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/get/v/{version}/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), version=version, path=crate::apis::urlencode(path));
314 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
315
316 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
317 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
318 }
319 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
320 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
321 };
322
323 let local_var_req = local_var_req_builder.build()?;
324 let local_var_resp = local_var_client.execute(local_var_req).await?;
325
326 let local_var_status = local_var_resp.status();
327 let local_var_content = local_var_resp.text().await?;
328
329 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
330 crate::from_str_patched(&local_var_content).map_err(Error::from)
331 } else {
332 let local_var_entity: Option<GetBpmnFlowVersionError> = crate::from_str_patched(&local_var_content).ok();
333 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
334 Err(Error::ResponseError(local_var_error))
335 }
336}
337
338pub async fn list_bpmn_flows(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, order_desc: Option<bool>, path_start: Option<&str>, path_exact: Option<&str>, show_archived: Option<bool>, include_draft_only: Option<bool>, label: Option<&str>, edited_by: Option<&str>, without_description: Option<bool>) -> Result<Vec<models::ListableBpmnFlow>, Error<ListBpmnFlowsError>> {
339 let local_var_configuration = configuration;
340
341 let local_var_client = &local_var_configuration.client;
342
343 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
344 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
345
346 if let Some(ref local_var_str) = page {
347 local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
348 }
349 if let Some(ref local_var_str) = per_page {
350 local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
351 }
352 if let Some(ref local_var_str) = order_desc {
353 local_var_req_builder = local_var_req_builder.query(&[("order_desc", &local_var_str.to_string())]);
354 }
355 if let Some(ref local_var_str) = path_start {
356 local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
357 }
358 if let Some(ref local_var_str) = path_exact {
359 local_var_req_builder = local_var_req_builder.query(&[("path_exact", &local_var_str.to_string())]);
360 }
361 if let Some(ref local_var_str) = show_archived {
362 local_var_req_builder = local_var_req_builder.query(&[("show_archived", &local_var_str.to_string())]);
363 }
364 if let Some(ref local_var_str) = include_draft_only {
365 local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
366 }
367 if let Some(ref local_var_str) = label {
368 local_var_req_builder = local_var_req_builder.query(&[("label", &local_var_str.to_string())]);
369 }
370 if let Some(ref local_var_str) = edited_by {
371 local_var_req_builder = local_var_req_builder.query(&[("edited_by", &local_var_str.to_string())]);
372 }
373 if let Some(ref local_var_str) = without_description {
374 local_var_req_builder = local_var_req_builder.query(&[("without_description", &local_var_str.to_string())]);
375 }
376 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
377 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
378 }
379 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
380 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
381 };
382
383 let local_var_req = local_var_req_builder.build()?;
384 let local_var_resp = local_var_client.execute(local_var_req).await?;
385
386 let local_var_status = local_var_resp.status();
387 let local_var_content = local_var_resp.text().await?;
388
389 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
390 crate::from_str_patched(&local_var_content).map_err(Error::from)
391 } else {
392 let local_var_entity: Option<ListBpmnFlowsError> = crate::from_str_patched(&local_var_content).ok();
393 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
394 Err(Error::ResponseError(local_var_error))
395 }
396}
397
398pub async fn list_bpmn_paths(configuration: &configuration::Configuration, workspace: &str) -> Result<Vec<String>, Error<ListBpmnPathsError>> {
399 let local_var_configuration = configuration;
400
401 let local_var_client = &local_var_configuration.client;
402
403 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/list_paths", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
404 let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
405
406 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
407 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
408 }
409 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
410 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
411 };
412
413 let local_var_req = local_var_req_builder.build()?;
414 let local_var_resp = local_var_client.execute(local_var_req).await?;
415
416 let local_var_status = local_var_resp.status();
417 let local_var_content = local_var_resp.text().await?;
418
419 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
420 crate::from_str_patched(&local_var_content).map_err(Error::from)
421 } else {
422 let local_var_entity: Option<ListBpmnPathsError> = crate::from_str_patched(&local_var_content).ok();
423 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
424 Err(Error::ResponseError(local_var_error))
425 }
426}
427
428pub async fn update_bpmn_flow(configuration: &configuration::Configuration, workspace: &str, path: &str, new_bpmn_flow: models::NewBpmnFlow) -> Result<String, Error<UpdateBpmnFlowError>> {
429 let local_var_configuration = configuration;
430
431 let local_var_client = &local_var_configuration.client;
432
433 let local_var_uri_str = format!("{}/w/{workspace}/bpmn_flows/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
434 let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
435
436 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
437 local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
438 }
439 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
440 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
441 };
442 local_var_req_builder = local_var_req_builder.json(&new_bpmn_flow);
443
444 let local_var_req = local_var_req_builder.build()?;
445 let local_var_resp = local_var_client.execute(local_var_req).await?;
446
447 let local_var_status = local_var_resp.status();
448 let local_var_content = local_var_resp.text().await?;
449
450 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
451 crate::from_str_patched(&local_var_content).map_err(Error::from)
452 } else {
453 let local_var_entity: Option<UpdateBpmnFlowError> = crate::from_str_patched(&local_var_content).ok();
454 let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
455 Err(Error::ResponseError(local_var_error))
456 }
457}
458