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