Skip to main content

orvanta_api/apis/
cmmn_api.rs

1/*
2 * Orvanta API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 6.2.0
7 * Contact: contact@orvanta.cloud
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`archive_cmmn_case_by_path`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum ArchiveCmmnCaseByPathError {
22    Status404(String),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`close_cmmn_case_instance`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CloseCmmnCaseInstanceError {
30    Status400(String),
31    Status404(String),
32    UnknownValue(serde_json::Value),
33}
34
35/// struct for typed errors of method [`create_cmmn_case`]
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(untagged)]
38pub enum CreateCmmnCaseError {
39    Status400(Vec<models::CmmnRefusal>),
40    Status404(String),
41    Status409(),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`delete_cmmn_case_by_path`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum DeleteCmmnCaseByPathError {
49    Status400(String),
50    Status404(String),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`exists_cmmn_case_by_path`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum ExistsCmmnCaseByPathError {
58    Status404(String),
59    UnknownValue(serde_json::Value),
60}
61
62/// struct for typed errors of method [`get_cmmn_case`]
63#[derive(Debug, Clone, Serialize, Deserialize)]
64#[serde(untagged)]
65pub enum GetCmmnCaseError {
66    Status404(String),
67    UnknownValue(serde_json::Value),
68}
69
70/// struct for typed errors of method [`get_cmmn_case_by_path`]
71#[derive(Debug, Clone, Serialize, Deserialize)]
72#[serde(untagged)]
73pub enum GetCmmnCaseByPathError {
74    Status404(String),
75    UnknownValue(serde_json::Value),
76}
77
78/// struct for typed errors of method [`get_cmmn_case_by_path_with_draft`]
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetCmmnCaseByPathWithDraftError {
82    Status404(String),
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`get_cmmn_case_history`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum GetCmmnCaseHistoryError {
90    Status404(String),
91    UnknownValue(serde_json::Value),
92}
93
94/// struct for typed errors of method [`get_cmmn_case_overview`]
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(untagged)]
97pub enum GetCmmnCaseOverviewError {
98    Status400(String),
99    Status404(String),
100    UnknownValue(serde_json::Value),
101}
102
103/// struct for typed errors of method [`get_cmmn_case_status`]
104#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum GetCmmnCaseStatusError {
107    Status404(String),
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method [`list_cmmn_case_instances`]
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum ListCmmnCaseInstancesError {
115    Status404(String),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`list_cmmn_cases`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum ListCmmnCasesError {
123    Status404(String),
124    UnknownValue(serde_json::Value),
125}
126
127/// struct for typed errors of method [`resume_cmmn_case_instance`]
128#[derive(Debug, Clone, Serialize, Deserialize)]
129#[serde(untagged)]
130pub enum ResumeCmmnCaseInstanceError {
131    Status400(String),
132    Status404(String),
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed errors of method [`start_cmmn_case`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum StartCmmnCaseError {
140    Status404(String),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`suspend_cmmn_case_instance`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum SuspendCmmnCaseInstanceError {
148    Status400(String),
149    Status404(String),
150    UnknownValue(serde_json::Value),
151}
152
153/// struct for typed errors of method [`terminate_cmmn_case_instance`]
154#[derive(Debug, Clone, Serialize, Deserialize)]
155#[serde(untagged)]
156pub enum TerminateCmmnCaseInstanceError {
157    Status400(String),
158    Status404(String),
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`trigger_cmmn_plan_item`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum TriggerCmmnPlanItemError {
166    Status400(String),
167    Status401(String),
168    Status404(String),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`update_cmmn_case`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum UpdateCmmnCaseError {
176    Status400(Vec<models::CmmnRefusal>),
177    Status404(String),
178    UnknownValue(serde_json::Value),
179}
180
181
182pub async fn archive_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str, archive_flow_by_path_request: models::ArchiveFlowByPathRequest) -> Result<String, Error<ArchiveCmmnCaseByPathError>> {
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}/cmmn_cases/archive/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
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(&archive_flow_by_path_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/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
206    } else {
207        let local_var_entity: Option<ArchiveCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&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
213/// The CMMN 1.1 case-instance transition out of `completed` or `terminated`. Unlike suspend/resume/terminate this is applied immediately rather than through the control channel: a finished case's queue row has been completed, so no worker would ever read it. 
214pub async fn close_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<CloseCmmnCaseInstanceError>> {
215    let local_var_configuration = configuration;
216
217    let local_var_client = &local_var_configuration.client;
218
219    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/close/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
220    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
221
222    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
223        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
224    }
225    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
226        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
227    };
228
229    let local_var_req = local_var_req_builder.build()?;
230    let local_var_resp = local_var_client.execute(local_var_req).await?;
231
232    let local_var_status = local_var_resp.status();
233    let local_var_content = local_var_resp.text().await?;
234
235    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
236        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
237    } else {
238        let local_var_entity: Option<CloseCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
239        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
240        Err(Error::ResponseError(local_var_error))
241    }
242}
243
244pub async fn create_cmmn_case(configuration: &configuration::Configuration, workspace: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<CreateCmmnCaseError>> {
245    let local_var_configuration = configuration;
246
247    let local_var_client = &local_var_configuration.client;
248
249    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/create", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
250    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
251
252    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
253        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
254    }
255    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
256        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
257    };
258    local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
259
260    let local_var_req = local_var_req_builder.build()?;
261    let local_var_resp = local_var_client.execute(local_var_req).await?;
262
263    let local_var_status = local_var_resp.status();
264    let local_var_content = local_var_resp.text().await?;
265
266    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
267        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
268    } else {
269        let local_var_entity: Option<CreateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
270        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
271        Err(Error::ResponseError(local_var_error))
272    }
273}
274
275pub async fn delete_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<String, Error<DeleteCmmnCaseByPathError>> {
276    let local_var_configuration = configuration;
277
278    let local_var_client = &local_var_configuration.client;
279
280    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/delete/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
281    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
282
283    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
284        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
285    }
286    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
287        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
288    };
289
290    let local_var_req = local_var_req_builder.build()?;
291    let local_var_resp = local_var_client.execute(local_var_req).await?;
292
293    let local_var_status = local_var_resp.status();
294    let local_var_content = local_var_resp.text().await?;
295
296    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
297        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
298    } else {
299        let local_var_entity: Option<DeleteCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
300        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
301        Err(Error::ResponseError(local_var_error))
302    }
303}
304
305pub async fn exists_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<bool, Error<ExistsCmmnCaseByPathError>> {
306    let local_var_configuration = configuration;
307
308    let local_var_client = &local_var_configuration.client;
309
310    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/exists/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
311    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
312
313    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
314        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
315    }
316    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
317        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
318    };
319
320    let local_var_req = local_var_req_builder.build()?;
321    let local_var_resp = local_var_client.execute(local_var_req).await?;
322
323    let local_var_status = local_var_resp.status();
324    let local_var_content = local_var_resp.text().await?;
325
326    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
327        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
328    } else {
329        let local_var_entity: Option<ExistsCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
330        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
331        Err(Error::ResponseError(local_var_error))
332    }
333}
334
335/// The persisted runtime state of one case instance — the engine's own `CaseInstance` (plan-item instances, their lifecycle states, sentry latches, case variables, transition history) plus the job-level lifecycle, incidents, the waiting set and the control channel.  `case_status` is `null` in the window between the job being pushed and its first step committing, so a freshly started case can legitimately return `200` with no engine state yet. 
336pub async fn get_cmmn_case(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseDetail, Error<GetCmmnCaseError>> {
337    let local_var_configuration = configuration;
338
339    let local_var_client = &local_var_configuration.client;
340
341    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/get/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
342    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
343
344    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
345        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
346    }
347    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
348        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
349    };
350
351    let local_var_req = local_var_req_builder.build()?;
352    let local_var_resp = local_var_client.execute(local_var_req).await?;
353
354    let local_var_status = local_var_resp.status();
355    let local_var_content = local_var_resp.text().await?;
356
357    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
358        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
359    } else {
360        let local_var_entity: Option<GetCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
361        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
362        Err(Error::ResponseError(local_var_error))
363    }
364}
365
366pub async fn get_cmmn_case_by_path(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModel, Error<GetCmmnCaseByPathError>> {
367    let local_var_configuration = configuration;
368
369    let local_var_client = &local_var_configuration.client;
370
371    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/get/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
372    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
373
374    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
375        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
376    }
377    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
378        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
379    };
380
381    let local_var_req = local_var_req_builder.build()?;
382    let local_var_resp = local_var_client.execute(local_var_req).await?;
383
384    let local_var_status = local_var_resp.status();
385    let local_var_content = local_var_resp.text().await?;
386
387    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
388        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
389    } else {
390        let local_var_entity: Option<GetCmmnCaseByPathError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
391        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
392        Err(Error::ResponseError(local_var_error))
393    }
394}
395
396pub async fn get_cmmn_case_by_path_with_draft(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<models::CmmnCaseModelWithDraft, Error<GetCmmnCaseByPathWithDraftError>> {
397    let local_var_configuration = configuration;
398
399    let local_var_client = &local_var_configuration.client;
400
401    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/get/draft/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
402    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
403
404    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406    }
407    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
408        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
409    };
410
411    let local_var_req = local_var_req_builder.build()?;
412    let local_var_resp = local_var_client.execute(local_var_req).await?;
413
414    let local_var_status = local_var_resp.status();
415    let local_var_content = local_var_resp.text().await?;
416
417    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
418        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
419    } else {
420        let local_var_entity: Option<GetCmmnCaseByPathWithDraftError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
421        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
422        Err(Error::ResponseError(local_var_error))
423    }
424}
425
426pub async fn get_cmmn_case_history(configuration: &configuration::Configuration, workspace: &str, path: &str) -> Result<Vec<models::CmmnCaseModelVersion>, Error<GetCmmnCaseHistoryError>> {
427    let local_var_configuration = configuration;
428
429    let local_var_client = &local_var_configuration.client;
430
431    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/history/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
432    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
433
434    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
435        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
436    }
437    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
438        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
439    };
440
441    let local_var_req = local_var_req_builder.build()?;
442    let local_var_resp = local_var_client.execute(local_var_req).await?;
443
444    let local_var_status = local_var_resp.status();
445    let local_var_content = local_var_resp.text().await?;
446
447    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
448        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
449    } else {
450        let local_var_entity: Option<GetCmmnCaseHistoryError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
451        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
452        Err(Error::ResponseError(local_var_error))
453    }
454}
455
456/// The stage rail and the case-page list `orvanta_cmmn::stage_overview` and `orvanta_cmmn::case_pages` derive from one deployed document.  **By version, not by path**, and that is half the point. A running case pins a `cmmn_case_model_version.id` and resolves its model from that row on every step, while `GET /cmmn_cases/get/{path}` returns whatever is deployed *now* — a different document the moment anyone redeploys. A Case View reading the latest can only warn that its rail might not match; reading the pinned version makes the warning unnecessary.  The ACL comes from the parent `cmmn_case_model` row: the version table has no RLS and no `extra_perms` of its own, so the read joins the parent and `cmmn_cases:read:<path>` is checked on the path the join returned, not on one the caller supplied. 
457pub async fn get_cmmn_case_overview(configuration: &configuration::Configuration, workspace: &str, version: i64) -> Result<models::CmmnCaseOverview, Error<GetCmmnCaseOverviewError>> {
458    let local_var_configuration = configuration;
459
460    let local_var_client = &local_var_configuration.client;
461
462    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/overview/v/{version}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), version=version);
463    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
464
465    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
466        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
467    }
468    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
469        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
470    };
471
472    let local_var_req = local_var_req_builder.build()?;
473    let local_var_resp = local_var_client.execute(local_var_req).await?;
474
475    let local_var_status = local_var_resp.status();
476    let local_var_content = local_var_resp.text().await?;
477
478    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
479        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
480    } else {
481        let local_var_entity: Option<GetCmmnCaseOverviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
482        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
483        Err(Error::ResponseError(local_var_error))
484    }
485}
486
487/// Everything the Case View re-reads on its 1s poll, and nothing else.  **The trace is absent by construction, not empty.** This response has no `history` field at all rather than an emptied one, because a `[]` a reader could mistake for \"this case has done nothing\" is exactly the silent shape this codebase keeps unwinding. `history_len` says how many events the full document carries, so a client can tell \"no trace here\" from \"no trace yet\" without fetching it — use `GET /cmmn/instances/get/{id}` for the trace itself.  `case_state` / `lifecycle` are `null` in the window between the job being pushed and its first step committing. That is a `200`, not a `404`: the row exists and the poll must keep going. 
488pub async fn get_cmmn_case_status(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<models::CmmnCaseInstanceStatus, Error<GetCmmnCaseStatusError>> {
489    let local_var_configuration = configuration;
490
491    let local_var_client = &local_var_configuration.client;
492
493    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/get/{id}/status", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
494    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
495
496    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
497        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
498    }
499    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
500        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
501    };
502
503    let local_var_req = local_var_req_builder.build()?;
504    let local_var_resp = local_var_client.execute(local_var_req).await?;
505
506    let local_var_status = local_var_resp.status();
507    let local_var_content = local_var_resp.text().await?;
508
509    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
510        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
511    } else {
512        let local_var_entity: Option<GetCmmnCaseStatusError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
513        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
514        Err(Error::ResponseError(local_var_error))
515    }
516}
517
518/// Case instances for the workspace, newest first, as cheap columns only. Root `cmmn_case` jobs (`parent_job IS NULL`) — a case's own child jobs are not case instances.  `business_key` is a **server-side** filter over `cmmn_case_status.business_key` (case-insensitive substring), which is what makes a case on page three findable from page one.  `lifecycle` and `case_state` are read straight out of the JSONB rather than by deserialising the engine blob, so a page of thirty rows costs thirty column reads and not thirty case documents. Both are reported because they can legitimately disagree: an `active` case may carry an `incident`. 
519pub async fn list_cmmn_case_instances(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, business_key: Option<&str>) -> Result<Vec<models::CmmnCaseSummary>, Error<ListCmmnCaseInstancesError>> {
520    let local_var_configuration = configuration;
521
522    let local_var_client = &local_var_configuration.client;
523
524    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
525    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
526
527    if let Some(ref local_var_str) = page {
528        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
529    }
530    if let Some(ref local_var_str) = per_page {
531        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
532    }
533    if let Some(ref local_var_str) = business_key {
534        local_var_req_builder = local_var_req_builder.query(&[("business_key", &local_var_str.to_string())]);
535    }
536    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
537        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
538    }
539    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
540        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
541    };
542
543    let local_var_req = local_var_req_builder.build()?;
544    let local_var_resp = local_var_client.execute(local_var_req).await?;
545
546    let local_var_status = local_var_resp.status();
547    let local_var_content = local_var_resp.text().await?;
548
549    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
550        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
551    } else {
552        let local_var_entity: Option<ListCmmnCaseInstancesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
553        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
554        Err(Error::ResponseError(local_var_error))
555    }
556}
557
558pub async fn list_cmmn_cases(configuration: &configuration::Configuration, workspace: &str, page: Option<i32>, per_page: Option<i32>, path_start: Option<&str>, show_archived: Option<bool>, include_draft_only: Option<bool>, with_cmmn_xml: Option<bool>) -> Result<Vec<models::ListableCmmnCaseModel>, Error<ListCmmnCasesError>> {
559    let local_var_configuration = configuration;
560
561    let local_var_client = &local_var_configuration.client;
562
563    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/list", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
564    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
565
566    if let Some(ref local_var_str) = page {
567        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
568    }
569    if let Some(ref local_var_str) = per_page {
570        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
571    }
572    if let Some(ref local_var_str) = path_start {
573        local_var_req_builder = local_var_req_builder.query(&[("path_start", &local_var_str.to_string())]);
574    }
575    if let Some(ref local_var_str) = show_archived {
576        local_var_req_builder = local_var_req_builder.query(&[("show_archived", &local_var_str.to_string())]);
577    }
578    if let Some(ref local_var_str) = include_draft_only {
579        local_var_req_builder = local_var_req_builder.query(&[("include_draft_only", &local_var_str.to_string())]);
580    }
581    if let Some(ref local_var_str) = with_cmmn_xml {
582        local_var_req_builder = local_var_req_builder.query(&[("with_cmmn_xml", &local_var_str.to_string())]);
583    }
584    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
585        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
586    }
587    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
588        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
589    };
590
591    let local_var_req = local_var_req_builder.build()?;
592    let local_var_resp = local_var_client.execute(local_var_req).await?;
593
594    let local_var_status = local_var_resp.status();
595    let local_var_content = local_var_resp.text().await?;
596
597    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
598        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
599    } else {
600        let local_var_entity: Option<ListCmmnCasesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
601        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
602        Err(Error::ResponseError(local_var_error))
603    }
604}
605
606/// Every suspended plan item takes `parentResume` back to the state it held when the case was suspended — not `available`, which would re-activate a stage and duplicate its children — and the case becomes `active` again. 
607pub async fn resume_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<ResumeCmmnCaseInstanceError>> {
608    let local_var_configuration = configuration;
609
610    let local_var_client = &local_var_configuration.client;
611
612    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/resume/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
613    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
614
615    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
616        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
617    }
618    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
619        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
620    };
621
622    let local_var_req = local_var_req_builder.build()?;
623    let local_var_resp = local_var_client.execute(local_var_req).await?;
624
625    let local_var_status = local_var_resp.status();
626    let local_var_content = local_var_resp.text().await?;
627
628    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
629        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
630    } else {
631        let local_var_entity: Option<ResumeCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
632        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
633        Err(Error::ResponseError(local_var_error))
634    }
635}
636
637/// Pushes a `CmmnCase` job for the latest deployed version at `path` and returns its id, which is also the case-instance id.  Only a **deployed** model can be started: the lookup spells `draft_only IS NOT TRUE`, so a path that exists only as a draft 404s exactly as an absent one does. A draft was never parsed and never admitted, so starting one would hand the worker a model nothing checked. 
638pub async fn start_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, start_cmmn_case: models::StartCmmnCase) -> Result<String, Error<StartCmmnCaseError>> {
639    let local_var_configuration = configuration;
640
641    let local_var_client = &local_var_configuration.client;
642
643    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/run/p/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
644    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
645
646    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
647        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
648    }
649    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
650        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
651    };
652    local_var_req_builder = local_var_req_builder.json(&start_cmmn_case);
653
654    let local_var_req = local_var_req_builder.build()?;
655    let local_var_resp = local_var_client.execute(local_var_req).await?;
656
657    let local_var_status = local_var_resp.status();
658    let local_var_content = local_var_resp.text().await?;
659
660    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
661        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
662    } else {
663        let local_var_entity: Option<StartCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
664        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
665        Err(Error::ResponseError(local_var_error))
666    }
667}
668
669/// Every live plan item takes `parentSuspend` and the case becomes `suspended`: no criteria are evaluated, no completion is decided and plan-item triggers are refused until it is resumed. The request is parked in the case's control channel and applied by the worker on its next step. 
670pub async fn suspend_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<SuspendCmmnCaseInstanceError>> {
671    let local_var_configuration = configuration;
672
673    let local_var_client = &local_var_configuration.client;
674
675    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/suspend/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
676    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
677
678    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
679        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
680    }
681    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
682        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
683    };
684
685    let local_var_req = local_var_req_builder.build()?;
686    let local_var_resp = local_var_client.execute(local_var_req).await?;
687
688    let local_var_status = local_var_resp.status();
689    let local_var_content = local_var_resp.text().await?;
690
691    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
692        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
693    } else {
694        let local_var_entity: Option<SuspendCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
695        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
696        Err(Error::ResponseError(local_var_error))
697    }
698}
699
700/// Every live plan item takes `terminate`, deepest first, and the case becomes `terminated`. Distinct from an exit criterion on the case plan model, which emits `exit` instead — both land in `terminated`, so only the recorded history tells them apart. 
701pub async fn terminate_cmmn_case_instance(configuration: &configuration::Configuration, workspace: &str, id: &str) -> Result<String, Error<TerminateCmmnCaseInstanceError>> {
702    let local_var_configuration = configuration;
703
704    let local_var_client = &local_var_configuration.client;
705
706    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/terminate/{id}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id));
707    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
708
709    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
710        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
711    }
712    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
713        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
714    };
715
716    let local_var_req = local_var_req_builder.build()?;
717    let local_var_resp = local_var_client.execute(local_var_req).await?;
718
719    let local_var_status = local_var_resp.status();
720    let local_var_content = local_var_resp.text().await?;
721
722    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
723        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
724    } else {
725        let local_var_entity: Option<TerminateCmmnCaseInstanceError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
726        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
727        Err(Error::ResponseError(local_var_error))
728    }
729}
730
731/// Completing a human task, firing a user event listener, manually starting an item — one [`CmmnTriggerIntent`] written into the case's control channel and applied by the worker on its next step. The engine decides legality; this route decides who may ask.  ## Which transitions  `Complete`, `Occur`, `ManualStart`, `Disable`, `Reenable` — exactly the set the engine can put into `CmmnWaitingItem.accepts`, so a client passes back verbatim what it was offered. The spelling in the path is the **Rust variant name** (`ManualStart`), which is how `accepts` serialises, not the CMMN `<standardEvent>` spelling (`manualStart`).  Everything else is a `400` naming why. Notably `Fault` is never requestable — a fault is raised by a behaviour and never asked for, and making it requestable would let a caller fabricate a failure the engine never observed. Per-plan-item `Terminate` / `Suspend` / `Resume` are drivable by the engine but are operator authority over one item rather than participation in it; the case-level routes above are the operator surface today.  ## Which instance  `?instance=` names one entry of `CmmnCaseInstance.instances`. Omitting it is the ordinary case and it is resolved server-side. It becomes **required** the moment a plan item has more than one instance parked — a `repetitionRule` produces one per repetition, each separately completable, and picking one arbitrarily is the defect BPMN's #1275 named. The `400` lists the candidates.  ## Who may ask  `cmmn_cases:write:instances`, the instance must be visible under the caller's own row-level ACLs, **and** the plan item's declared audience must admit them. The audience is derived from the model by the same `HumanTaskAudience::permits` predicate BPMN's user tasks use (#1123): admins always; a task that declares nobody falls back to instance visibility; a literal `flowable:assignee` / `owner` / `candidateUsers` / `candidateGroups` is matched on username or group; and a declared identity this build cannot resolve — an `${expression}`, or a `performerRef` / `authorizedRoleRefs` naming a `<caseRoles>` role that `orvanta-cmmn` does not model — falls **open**, because hiding a task nobody can be shown to own is the defect #1104 fixed. 
732pub async fn trigger_cmmn_plan_item(configuration: &configuration::Configuration, workspace: &str, id: &str, plan_item_id: &str, transition: &str, instance: Option<i32>) -> Result<String, Error<TriggerCmmnPlanItemError>> {
733    let local_var_configuration = configuration;
734
735    let local_var_client = &local_var_configuration.client;
736
737    let local_var_uri_str = format!("{}/w/{workspace}/cmmn/instances/{id}/plan-items/{plan_item_id}/{transition}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), id=crate::apis::urlencode(id), plan_item_id=crate::apis::urlencode(plan_item_id), transition=crate::apis::urlencode(transition));
738    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
739
740    if let Some(ref local_var_str) = instance {
741        local_var_req_builder = local_var_req_builder.query(&[("instance", &local_var_str.to_string())]);
742    }
743    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
744        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
745    }
746    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
747        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
748    };
749
750    let local_var_req = local_var_req_builder.build()?;
751    let local_var_resp = local_var_client.execute(local_var_req).await?;
752
753    let local_var_status = local_var_resp.status();
754    let local_var_content = local_var_resp.text().await?;
755
756    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
757        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
758    } else {
759        let local_var_entity: Option<TriggerCmmnPlanItemError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
760        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
761        Err(Error::ResponseError(local_var_error))
762    }
763}
764
765pub async fn update_cmmn_case(configuration: &configuration::Configuration, workspace: &str, path: &str, new_cmmn_case_model: models::NewCmmnCaseModel) -> Result<models::CmmnDeployResult, Error<UpdateCmmnCaseError>> {
766    let local_var_configuration = configuration;
767
768    let local_var_client = &local_var_configuration.client;
769
770    let local_var_uri_str = format!("{}/w/{workspace}/cmmn_cases/update/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
771    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
772
773    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
774        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
775    }
776    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
777        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
778    };
779    local_var_req_builder = local_var_req_builder.json(&new_cmmn_case_model);
780
781    let local_var_req = local_var_req_builder.build()?;
782    let local_var_resp = local_var_client.execute(local_var_req).await?;
783
784    let local_var_status = local_var_resp.status();
785    let local_var_content = local_var_resp.text().await?;
786
787    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
788        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
789    } else {
790        let local_var_entity: Option<UpdateCmmnCaseError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
791        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
792        Err(Error::ResponseError(local_var_error))
793    }
794}
795